:root {
  color-scheme: light;
  --cond: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F3F4F8;
  --ink: #12151C;
  --muted: rgba(18, 21, 28, .58);
  --line: rgba(18, 21, 28, .08);
  --line-strong: rgba(18, 21, 28, .2);
  --shadow: 0 1px 2px rgba(18, 21, 28, .05), 0 12px 32px -14px rgba(18, 21, 28, .2);
  --dock-bg: #12151C;
  --c-work: #2F4BF0;
  --c-side2: #7A3BE6;
  --c-rest: #22B573;
  --c-prep: #FFC93C;
  --c-cool: #3B97DD;
  --cta: #FFD54A;
  --cta-hover: #FFE17C;
  --cta-ink: #231B00;
  --warn: #C2361E;
  --warn-bg: rgba(194, 54, 30, .09);
  --glow-1: rgba(47, 75, 240, .17);
  --glow-2: rgba(255, 201, 60, .26);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0D0F14;
    --surface: #171A22;
    --surface-2: #20242E;
    --ink: #ECEEF4;
    --muted: rgba(236, 238, 244, .6);
    --line: rgba(255, 255, 255, .07);
    --line-strong: rgba(255, 255, 255, .18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -18px rgba(0, 0, 0, .7);
    --dock-bg: #242938;
    --c-work: #5570FF;
    --c-side2: #9663F6;
    --c-rest: #34C77B;
    --c-prep: #FFD54A;
    --c-cool: #5AB0F0;
    --warn: #FF907B;
    --warn-bg: rgba(255, 144, 123, .12);
    --glow-1: rgba(85, 112, 255, .2);
    --glow-2: rgba(150, 99, 246, .16);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 440px at -12% -10%, var(--glow-1), transparent 70%),
    radial-gradient(720px 400px at 112% -6%, var(--glow-2), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-work); outline-offset: 2px; }

.app { max-width: 760px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 0; }

.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--cond); font-weight: 800; font-size: 1.05rem; letter-spacing: .16em; text-transform: uppercase; }
.brand svg { color: var(--c-work); }

.hero { padding: 36px 0 4px; }
.eyebrow { display: block; margin-bottom: 4px; font-family: var(--cond); font-weight: 700; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.title-input {
  display: block;
  width: 100%;
  padding: 2px 0 10px;
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  line-height: 1;
  letter-spacing: -.01em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 3px solid var(--line-strong);
  border-radius: 0;
  outline: none;
  transition: border-color .2s;
}
.title-input::placeholder { color: var(--ink); opacity: .2; }
.title-input:focus { border-color: var(--c-work); }
.lede { margin: 16px 0 0; max-width: 48ch; font-size: 1.08rem; line-height: 1.45; color: var(--muted); }

.section { margin-top: 44px; }
.section-head .note { margin-left: auto; font-size: .92rem; color: var(--muted); }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-family: var(--cond); font-weight: 800; font-size: 1.75rem; letter-spacing: .01em; text-transform: uppercase; }
.badge { min-width: 28px; height: 28px; padding: 0 9px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--ink); color: var(--bg); font-family: var(--cond); font-weight: 700; font-size: 1rem; }
.help { margin: 14px 2px 0; font-size: .95rem; line-height: 1.45; color: var(--muted); }

.rows { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 12px; counter-reset: row; }
.row {
  counter-increment: row;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.row.is-new { animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.thumb { position: relative; width: 60px; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb::after { content: counter(row); position: absolute; left: 6px; top: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-family: var(--cond); font-weight: 700; font-size: .9rem; }
.has-media .thumb::after { background: rgba(0, 0, 0, .62); color: #FFFFFF; }

.row-fields { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
.row-fields .name-input,
.row-fields .link-input {
  width: 100%;
  min-width: 0;
  color: inherit;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, background-color .15s;
}
.row-fields .name-input:hover,
.row-fields .link-input:hover { background: var(--surface-2); }
.row-fields .name-input:focus,
.row-fields .link-input:focus { color: var(--ink); background: var(--surface); border-color: var(--c-work); }
.row-fields .name-input { padding: 4px 10px; font-family: var(--cond); font-weight: 700; font-size: 1.5rem; line-height: 1.15; }
.row-fields .name-input:placeholder-shown { background: var(--surface-2); }
.name-input::placeholder { color: inherit; opacity: .4; }

.link-field { position: relative; display: flex; align-items: center; }
.link-field svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.row-fields .link-input { min-height: 40px; padding: 0 12px 0 36px; font-size: 1rem; color: var(--muted); }
.row-fields .link-input:placeholder-shown { border: 2px dashed var(--line-strong); }
.row-fields .link-input::placeholder { color: var(--muted); }

.row-times { display: flex; flex-wrap: wrap; gap: 6px; }
.time-chip {
  --tone: var(--c-work);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--cond);
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: text;
  transition: border-color .15s, background-color .15s;
}
.time-chip[data-kind="rest"] { --tone: var(--c-rest); }
.time-chip::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--tone); }
.time-chip input {
  width: 3.2ch;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0;
  text-align: right;
  color: var(--ink);
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}
.time-chip input::placeholder { color: var(--muted); opacity: 1; }
.time-chip input::-webkit-outer-spin-button,
.time-chip input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-chip:focus-within { border-color: var(--tone); background: var(--surface); }
.time-chip.is-custom { background: color-mix(in srgb, var(--tone) 16%, transparent); color: var(--ink); }

.hint { margin: 4px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; font-weight: 500; line-height: 1.35; }

.row-tools { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.sides { display: inline-flex; gap: 2px; padding: 3px; margin-right: auto; border-radius: 999px; background: var(--surface-2); }
.sides button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-family: var(--cond); font-weight: 700; font-size: 1.02rem; letter-spacing: .02em; cursor: pointer; transition: background-color .15s, color .15s; }
.sides button:hover { color: var(--ink); }
.sides button[data-sides="1"][aria-pressed="true"] { background: var(--c-work); color: #FFFFFF; }
.sides button[data-sides="2"][aria-pressed="true"] { background: var(--c-side2); color: #FFFFFF; }
.icon { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background-color .15s, color .15s; }
.icon:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon[data-remove]:hover { background: var(--warn-bg); color: var(--warn); }
.icon:disabled { opacity: .25; cursor: default; }

.add {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  text-align: left;
  border: 2px dashed var(--line-strong);
  border-radius: 22px;
  background: transparent;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.add:hover:not(:disabled) { border-color: var(--c-work); background: color-mix(in srgb, var(--c-work) 7%, transparent); }
.add:disabled { opacity: .4; cursor: default; }
.add-icon { flex: none; width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center; background: var(--c-work); color: #FFFFFF; box-shadow: 0 8px 18px -8px var(--c-work); }
.add-text { display: grid; gap: 2px; }
.add-text strong { font-family: var(--cond); font-weight: 700; font-size: 1.3rem; }
.add-text span { font-size: .95rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.tile {
  --tone: var(--ink);
  --tone-ink: var(--bg);
  position: relative;
  display: grid;
  gap: 8px;
  padding: 16px 12px 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tone); }
.tile[data-setting="work"] { --tone: var(--c-work); --tone-ink: #FFFFFF; }
.tile[data-setting="rest"] { --tone: var(--c-rest); --tone-ink: #FFFFFF; }
.tile[data-setting="warmup"] { --tone: var(--c-prep); --tone-ink: #231B00; }
.tile[data-setting="cooldown"] { --tone: var(--c-cool); --tone-ink: #FFFFFF; }
.tile-label { display: flex; align-items: center; gap: 8px; padding-left: 4px; font-family: var(--cond); font-weight: 700; font-size: .95rem; line-height: 1.15; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tile-label::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 999px; background: var(--tone); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 10px;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { background: var(--surface-2); }
.step { flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: background-color .15s, color .15s, transform .1s; }
.step:hover:not(:disabled) { background: var(--tone); color: var(--tone-ink); }
.step:active:not(:disabled) { transform: scale(.9); }
.step:disabled { opacity: .3; cursor: default; }
.tile-unit { text-align: center; font-size: .88rem; color: var(--muted); }

.round-bar { display: grid; gap: 12px; margin-bottom: 12px; }
@media (min-width: 560px) {
  .round-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.inline-setting {
  --tone: var(--ink);
  --tone-ink: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  transition: opacity .2s;
}
.inline-setting[data-setting="roundRest"] { --tone: var(--c-rest); --tone-ink: #FFFFFF; }
.inline-setting.is-idle { opacity: .45; }
.inline-label { display: grid; gap: 2px; margin-right: auto; }
.inline-label label { font-family: var(--cond); font-weight: 700; font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase; }
.inline-label span { font-size: .88rem; color: var(--muted); }
.inline-setting .stepper { flex: none; width: 150px; }

.preview { margin-top: 12px; padding: 16px 16px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.timeline { display: flex; align-items: flex-end; height: 72px; border-bottom: 2px solid var(--line-strong); }
.block { flex: 1 1 0; min-width: 0; height: 100%; border-radius: 5px 5px 0 0; box-shadow: inset -2px 0 0 var(--surface); }
.timeline.is-dense .block { border-radius: 0; box-shadow: none; }
.block[data-kind="work"], .block[data-kind="side1"] { background: var(--c-work); }
.block[data-kind="side2"] { background: var(--c-side2); }
.block[data-kind="rest"], .block[data-kind="roundRest"] { height: 30%; background: var(--c-rest); }
.block[data-kind="warmup"] { height: 55%; background: var(--c-prep); }
.block[data-kind="cooldown"] { height: 55%; background: var(--c-cool); }
.block[data-kind="prep"] { height: 16%; background: var(--line-strong); }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .92rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend li::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }
.legend [data-kind="work"] { --tone: var(--c-work); }
.legend [data-kind="side2"] { --tone: var(--c-side2); }
.legend [data-kind="rest"] { --tone: var(--c-rest); }
.legend [data-kind="warmup"] { --tone: var(--c-prep); }
.legend [data-kind="cooldown"] { --tone: var(--c-cool); }

.dock { position: sticky; bottom: 0; z-index: 5; margin-top: 40px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.dock::before { content: ""; position: absolute; inset: -32px -20px 0; z-index: -1; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg) 50%); }
.dock-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 12px 12px 22px;
  border-radius: 26px;
  background: var(--dock-bg);
  color: #FFFFFF;
  box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .55);
}
.dock-total { display: grid; margin-right: auto; }
.dock-time { font-family: var(--cond); font-weight: 800; font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; }
.dock-meta { font-size: .92rem; opacity: .7; }
.dock-total:has(.dock-time[hidden]) .dock-meta { opacity: .85; font-size: 1rem; padding: 10px 0; }
.actions { display: flex; gap: 8px; }
.btn {
  min-height: 48px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: #FFFFFF;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s, transform .1s;
}
.btn:hover { background: rgba(255, 255, 255, .18); }
.btn:active { transform: scale(.96); }
.btn.cta { background: var(--cta); color: var(--cta-ink); }
.btn.cta:hover { background: var(--cta-hover); }
.btn.is-done, .btn.is-done:hover { background: var(--c-rest); color: #FFFFFF; }
.share-link { flex-basis: 100%; min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1); color: #FFFFFF; font: inherit; font-size: 1rem; }
.status { flex-basis: 100%; margin: 0; font-size: .92rem; opacity: .8; }
.status:empty { display: none; }

@media (max-width: 520px) {
  .actions { width: 100%; }
  .btn { flex: 1; padding: 0 10px; }
}
@media (max-width: 380px) {
  .btn:not(.cta) svg { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .row.is-new { animation: none; }
  .title-input, .btn, .step, .add, .row-fields input { transition: none; }
}
