:root {
  --ink: #16181D; --ink-2: #5B6170; --ink-3: #9AA0AE; --line: #DDE0E6; --line-2: #EEF0F3;
  --paper: #F3F4F6; --card: #FFFFFF; --card-2: #F8F9FB;
  --orange: #E8590C; --orange-ink: #B35300; --orange-soft: #FFE9D6; --orange-tint: #FFF8F3;
  --blue: #2F6FED; --blue-soft: #EEF3FF; --purple: #7A49D6; --purple-soft: #EFE6FF;
  --bg: #0B1220; --panel: #121C33; --rule: #1E2C4D; --rule2: #2A3A5C; --text: #F2F6FF; --muted: #9FB0CC; --accent: #38D6F5; --accent-text: #38D6F5; --accent-ink: #0B1220; --done: #9EF0C3; --warn: #FFC857;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Archivo, system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.35; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#notice { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: 720px; padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; box-shadow: 0 12px 32px rgba(0,0,0,0.35); white-space: pre-line; }
#notice.error { background: #B3261E; }
.view[hidden] { display: none; }

/* ---------- Builder ---------- */
.builder { min-height: 100vh; display: flex; flex-direction: column; }
.b-header { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: var(--topnav-h, 0px); z-index: 9; }
.b-header .brand { margin: 0; font-size: 13px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.b-header .wname { flex: 1 1 220px; min-width: 0; font-size: 18px; font-weight: 700; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card-2); }
.estimate { display: flex; align-items: baseline; gap: 8px; }
.estimate .big { font-size: 20px; font-weight: 900; }
.estimate .small, .estimate .label { font-size: 12px; color: var(--ink-2); }
.badge { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; }
.badge.draft { color: var(--orange-ink); background: var(--orange-soft); }
.badge.saved { color: #166534; background: #DCFCE7; }
.btn { min-height: 44px; padding: 0 18px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--card); font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.quiet { border-color: var(--line); color: var(--ink-2); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 12px; border-color: var(--line); }
.btn.icon { width: 36px; height: 36px; min-height: 0; padding: 0; justify-content: center; border: 0; background: transparent; font-size: 16px; font-weight: 900; color: var(--ink-2); }
.btn.icon:hover { background: var(--line-2); color: var(--ink); }
.b-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 24px; font-size: 13px; color: var(--ink-2); background: var(--card); border-bottom: 1px solid var(--line); }
.b-sub select { min-height: 36px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card-2); font-weight: 700; }
.b-sub .spacer { flex: 1; }
.b-sub label.btn { cursor: pointer; }
.b-sub #wlist { max-width: 100%; }
.b-body { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px; flex: 1; align-items: flex-start; }

.library { flex: 1 1 280px; max-width: 320px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 118px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--ink-2); }
.hint b { color: var(--orange-ink); }
.search { font-size: 15px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-size: 12px; font-weight: 700; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cards { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; padding-right: 2px; }
.card { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; cursor: grab; text-align: left; width: 100%; }
.card:hover { border-color: var(--ink-3); }
.card:active { cursor: grabbing; }
.card.dragging { background: var(--orange-tint); border-color: var(--orange); box-shadow: 0 8px 24px rgba(22,24,29,0.18); }
.card .t { font-size: 15px; font-weight: 700; }
.card .s { font-size: 12px; color: var(--ink-2); }
.card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.handle { color: var(--ink-3); flex: none; display: inline-flex; }
.dashed { min-height: 44px; border: 1.5px dashed var(--ink-3); border-radius: 10px; background: transparent; font-size: 14px; font-weight: 700; color: var(--ink-2); width: 100%; }
.dashed:hover { border-color: var(--ink); color: var(--ink); }
.newex { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; }
.newex input { font-size: 14px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px; }
.newex .row { display: flex; gap: 8px; }
.newex textarea { display: block; width: 100%; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.tag-picker { border: 0; border-top: 1px solid var(--line); padding: 10px 0; margin: 8px 0 0; }
.tag-picker legend { font-size: 12px; font-weight: 700; }
.tag-picker label { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.library-item { display: flex; align-items: stretch; gap: 4px; }
.library-item .card { flex: 1; min-width: 0; }
.view-exercise { align-self: center; }
.exercise-detail { padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--card); overflow: auto; }
.exercise-detail::backdrop { background: rgb(11 18 32 / 65%); }
.exercise-detail header, .exercise-detail footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; background: var(--card); }
.exercise-detail header { position: sticky; top: 0; border-bottom: 1px solid var(--line); }
.exercise-detail h2 { margin: 5px 0 0; font-size: 24px; }
.detail-body { padding: 4px 24px 16px; }
.detail-body section { border-top: 1px solid var(--line-2); margin-top: 18px; padding-top: 12px; }
.detail-body h3 { font-size: 16px; margin: 0 0 8px; }
.detail-body p { margin: 8px 0; }
.detail-body li { margin-bottom: 8px; }
.detail-prose { white-space: pre-line; }
.detail-tag { font-size: 12px; padding: 5px 9px; background: var(--paper); border-radius: 20px; }
.detail-body a { color: var(--blue); overflow-wrap: anywhere; }
.savedblocks { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }

.sections { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section.drag-over { outline: 2px dashed var(--orange); outline-offset: 6px; border-radius: 14px; }
.s-head { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.s-head .n { font-size: 11px; font-weight: 900; color: var(--ink-2); letter-spacing: 0.12em; }
.s-head .sname { flex: 1 1 160px; min-width: 0; font-size: 22px; font-weight: 900; padding: 4px 8px; border: 1.5px solid transparent; border-radius: 8px; background: transparent; }
.s-head .sname:hover, .s-head .sname:focus { border-color: var(--line); background: var(--card); }
.s-head .meta { font-size: 13px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.block { background: var(--card); border-radius: 14px; border: 1.5px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.block.active { border-color: var(--ink); }
.block.amrap.active { border: 2px solid var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.block.drop { background: var(--orange-tint); }
.bk-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); background: var(--card-2); }
.block.amrap .bk-head { background: var(--orange-tint); }
.tag { font-size: 12px; font-weight: 900; color: #fff; background: var(--blue); padding: 4px 10px; border-radius: 6px; letter-spacing: 0.08em; }
.block.amrap .tag { background: var(--orange); }
.block.circuit .tag { background: var(--purple); }
.bk-head .lbl { font-size: 13px; color: var(--ink-2); }
.bk-head select, .bk-head input { min-height: 36px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; font-weight: 700; }
.bk-head select.rule { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.block.amrap .bk-head select.rule { border-color: var(--orange); color: var(--orange-ink); background: var(--orange-soft); }
.block.circuit .bk-head select.rule { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.bk-head input.short { width: 72px; text-align: center; font-weight: 900; font-size: 15px; }
.bk-head .spacer { flex: 1; }
.bk-head .meta { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.steps { display: flex; flex-direction: column; }
.step { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--line-2); background: var(--card); }
.step:last-child { border-bottom: 0; }
.step.dragging { opacity: 0.4; }
.step.before { box-shadow: inset 0 3px 0 var(--orange); }
.step.after { box-shadow: inset 0 -3px 0 var(--orange); }
.step .i { width: 22px; font-size: 13px; font-weight: 700; color: var(--ink-3); }
.step .name { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .name.rest { color: var(--ink-2); font-style: italic; }
.amount { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.amount input { width: 56px; font-size: 15px; font-weight: 700; text-align: center; border: 0; padding: 8px 4px; }
.amount select { border: 0; border-left: 1.5px solid var(--line); background: var(--card-2); padding: 0 8px; font-size: 12px; font-weight: 700; }
.step select.side { min-height: 36px; padding: 0 8px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); font-size: 12px; font-weight: 700; }
.step select.side.both { background: var(--ink); color: #fff; border-color: var(--ink); }
.empty { padding: 22px 16px; text-align: center; font-size: 14px; color: var(--ink-2); border: 2px dashed var(--line); margin: 10px 16px; border-radius: 10px; }
.block.drop .empty { border-color: var(--orange); color: var(--orange-ink); }
.bk-foot { display: flex; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line-2); background: var(--card-2); }
.addblock { min-height: 40px; font-size: 13px; }
.addsection { min-height: 56px; border-width: 2px; border-radius: 14px; font-size: 15px; }
.b-foot { padding: 14px 24px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

/* ---------- Runner (Arctic) ---------- */
/* One header bar across the top, two columns under it. The stage column is the wide one for timed lists;
 * for AMRAP and fixed-round blocks (data-block="loop") the exercise list takes the wide side instead. */
.runner { height: 100dvh; box-sizing: border-box; overflow: auto; background: var(--bg); color: var(--text); padding: clamp(10px, 1.6vh, 14px) clamp(16px, 2vw, 28px) clamp(12px, 2vh, 20px); display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); grid-template-rows: auto minmax(0, 1fr); column-gap: clamp(14px, 1.7vw, 24px); row-gap: clamp(8px, 1.6vh, 14px); }
.runner[data-block="loop"] { grid-template-columns: minmax(400px, 0.85fr) minmax(0, 1.65fr); }
.runner .col-main, .runner .col-side { display: contents; }
/* Header: back · workout title · remaining section pills · clocks · sound. The title truncates and the pill row
 * slides under a fade at its edge, so a long title or many sections never push the clocks around. */
.r-top { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: auto minmax(120px, max-content) minmax(0, 1fr) auto auto; align-items: center; gap: 16px; }
.r-top .pills { grid-column: 3; justify-content: flex-start; flex-wrap: nowrap; overflow: hidden; min-width: 0; mask-image: linear-gradient(90deg, black 85%, transparent); -webkit-mask-image: linear-gradient(90deg, black 85%, transparent); }
.r-top .pill { white-space: nowrap; flex: none; }
.r-top .clocks { gap: 28px; padding: 0; align-items: flex-end; }
.r-top .clock { align-items: flex-end; }
.r-top .clock .v { font-size: clamp(22px, min(3.4vh, 2.2vw), 30px); line-height: 1; }
.main-body { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; gap: clamp(8px, 1.6vh, 14px); min-height: 0; }
.side-body { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; gap: clamp(6px, 1.2vh, 10px); min-height: 0; }
.side-body .list-title { flex: none; padding: 2px 4px 0; }
/* Only the exercise list gives way; the +1 button, up-next and strip always stay on screen. */
.side-body .list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: clamp(6px, 1.2vh, 10px); padding: 0 2px; }
.side-body .bigbtn, .side-body .upnext, .side-body .strip { flex: none; }
.side-body .upnext { margin-top: 0; }
.finish { grid-column: 1 / -1; grid-row: 1 / -1; }
.r-top .wtitle { min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; font-size: clamp(18px, 2vw, 24px); font-weight: 700; color: var(--text); }
.r-top .back { min-height: 36px; padding: 0 12px; border: 1.5px solid var(--rule2); border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; }
.r-top .back:hover { color: var(--text); border-color: var(--muted); }
.r-top .back.icon, .r-top .back.sound { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; justify-content: center; display: inline-flex; align-items: center; }
.r-top .back.sound[aria-pressed="true"] { color: var(--accent-text); border-color: var(--accent); }
.pills { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pill { font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--rule2); color: var(--muted); }
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 900; }
.pill.done { color: var(--done); border-color: var(--rule); }
.hero { flex: 1; min-height: 0; background: var(--panel); border-radius: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 1.6vh, 16px); padding: clamp(10px, 2vh, 20px) clamp(14px, 2vw, 24px); text-align: center; }
.hero .dial { width: min(320px, 40vh, 30vw); height: auto; }
/* Timed lists: the step name sits at the top of the stage and the ring takes all the room under it. */
.runner[data-block="list"] .hero { justify-content: flex-start; gap: clamp(8px, 1.6vh, 14px); padding: clamp(10px, 2vh, 18px) clamp(14px, 2vw, 24px) clamp(10px, 1.8vh, 16px); }
.runner[data-block="list"] .hero .title { font-size: clamp(28px, min(6.6vh, 4.4vw), 62px); }
.runner[data-block="list"] .hero .title.long { font-size: clamp(20px, min(3.8vh, 2.6vw), 42px); }
.runner[data-block="list"] .hero > #r-dial { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.runner[data-block="list"] .hero .dial { width: auto; height: 100%; max-height: min(520px, 58vh); aspect-ratio: 1; }
.hero .score { display: flex; align-items: center; justify-content: center; gap: clamp(24px, 4vw, 64px); }
.hero .rounds { background: transparent; padding: 0; align-items: flex-start; text-align: left; gap: 4px; }
.hero .rounds .big { font-size: clamp(56px, 14vh, 140px); }
.hero .rounds .pips { justify-content: flex-start; }
.hero .state { font-size: 14px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-text); }
.hero .state.paused { color: var(--warn); }
.hero .state.rest { color: var(--done); }
.hero .title { flex: none; font-size: clamp(26px, min(5.6vh, 3.6vw), 60px); font-weight: 900; line-height: 1.05; text-wrap: balance; max-width: 18ch; }
/* Long step titles (authored instructions) drop a size and cap at three lines so the dial keeps its room. */
.hero .title.long { font-size: clamp(20px, min(3.8vh, 2.6vw), 42px); max-width: 30ch; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.hero .sub { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 16px; font-weight: 700; color: var(--muted); }
.spill { font-size: 16px; font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--rule2); color: var(--muted); }
.spill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 900; }
.dial { display: block; }
.dial text { font-family: Archivo, system-ui, sans-serif; font-weight: 900; fill: var(--text); font-variant-numeric: tabular-nums; }
/* One row of equal buttons: Pause is the widest, the rest share the remaining width. */
.controls { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: 14px; }
.controls .rbtn { flex: 1 1 0; min-width: max-content; padding: 0 12px; justify-content: center; white-space: nowrap; }
.controls .rbtn.primary { flex: 1.2 1 0; padding: 0 20px; }
.rbtn { min-height: clamp(48px, 8vh, 60px); padding: 0 28px; border: 2px solid var(--rule2); border-radius: 16px; background: transparent; color: var(--text); font-size: clamp(15px, 2.4vh, 18px); font-weight: 700; display: inline-flex; align-items: center; gap: 12px; }
.rbtn:hover:not(:disabled) { border-color: var(--muted); }
.rbtn.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-size: clamp(18px, 3vh, 22px); font-weight: 900; padding: 0 40px; }
/* Secondary buttons: the verb on top, what it acts on underneath. */
.rbtn .lbl { display: flex; flex-direction: column; align-items: center; gap: 3px; line-height: 1.1; }
.rbtn .what { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; }
.rbtn.danger { color: var(--muted); }
.rbtn.danger:hover { color: #FF6B6B; border-color: #FF6B6B; }
.rbtn.danger:hover .what { color: inherit; }
.kbd { font-size: 11px; font-weight: 900; padding: 3px 8px; border-radius: 5px; border: 1.5px solid currentColor; letter-spacing: 0.1em; opacity: 0.75; }
.clocks { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 4px; }
.clock { display: flex; flex-direction: column; }
.clock.right { align-items: flex-end; }
.clock .l { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.clock .v { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }
.clock .v.accent { color: var(--accent-text); }
.list-title { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.row { display: flex; align-items: center; gap: 14px; padding: clamp(5px, 1.2vh, 12px) 16px; border-radius: 14px; background: var(--panel); border: 2px solid transparent; }
.row.done { opacity: 0.55; }
.row.done .n { text-decoration: line-through; color: var(--muted); }
.row.now { border-color: var(--accent); }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .n { font-size: clamp(15px, 2.4vh, 18px); font-weight: 700; }
.row.now .n { font-weight: 900; }
.row .s { font-size: 13px; color: var(--muted); }
.row.now .s { color: var(--accent-text); font-weight: 700; }
.row .a { font-size: 15px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.row.now .a { color: var(--text); }
/* AMRAP rows stay one line tall so a five-exercise round fits above the +1 button on a laptop. */
.row.amrap .grow { flex-direction: row; align-items: baseline; flex-wrap: wrap; column-gap: 10px; }
.row .reps { width: 64px; line-height: 1; font-size: clamp(24px, 4vh, 32px); font-weight: 900; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.row.amrap .n { font-size: 22px; font-weight: 900; }
/* Loop blocks (AMRAP, rounds): compact timer column on the left, the round's list fills the wide right column. */
.runner[data-block="loop"] .hero { gap: clamp(4px, 1vh, 6px); padding: clamp(8px, 1.6vh, 16px) clamp(12px, 1.6vw, 20px); }
.runner[data-block="loop"] .hero .title { font-size: clamp(22px, min(4vh, 2.6vw), 36px); }
.runner[data-block="loop"] .hero .dial { width: min(240px, 26vh, 20vw); }
.runner[data-block="loop"] .hero .score { gap: clamp(12px, 2vw, 20px); }
.runner[data-block="loop"] .hero .rounds .big { font-size: clamp(44px, min(11vh, 6vw), 92px); }
.runner[data-block="loop"] .main-body .bigbtn { margin: 0; min-height: clamp(72px, 15vh, 140px); }
.runner[data-block="loop"] .bigbtn .plus { font-size: clamp(30px, 6vh, 52px); }
.runner[data-block="loop"] .bigbtn .word { font-size: clamp(16px, 2.6vh, 22px); }
.runner[data-block="loop"] .controls .rbtn { padding: 0 10px; font-size: clamp(14px, 2.2vh, 16px); }
.runner[data-block="loop"] .side-body .list { gap: clamp(6px, 1.2vh, 10px); padding: 0; }
.runner[data-block="loop"] .side-body .list .row { flex: 1 0 auto; padding: clamp(3px, 1vh, 6px) clamp(14px, 2.2vw, 24px); gap: clamp(12px, 2vw, 20px); }
.runner[data-block="loop"] .row .reps { width: clamp(56px, 8vw, 90px); font-size: clamp(26px, min(7vh, 3.6vw), 64px); }
.runner[data-block="loop"] .row.amrap .n { font-size: clamp(18px, min(4.6vh, 2.2vw), 42px); }
.runner[data-block="loop"] .row .s, .runner[data-block="loop"] .row .a { font-size: clamp(15px, min(3vh, 1.8vw), 22px); }
.runner[data-block="loop"] .row .workout-note { flex-basis: 100%; margin: 0; font-size: 17px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.runner[data-block="loop"] .upnext { padding: clamp(6px, 1.4vh, 10px) 20px; gap: 2px; }
.runner[data-block="loop"] .upnext .v { font-size: clamp(16px, 2.6vh, 20px); }
/* Queue rows (timed lists): Now and Next cards carry a small label and larger names; rest is a dashed card; a transition is a thin line. */
.runner[data-block="list"] .side-body .list { gap: 8px; padding: 0; }
.runner[data-block="list"] .row { padding: clamp(6px, 1.4vh, 10px) clamp(14px, 1.8vw, 20px); gap: clamp(10px, 1.4vw, 16px); }
.row .l { font-size: 12px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.row.now .l { color: var(--accent-text); }
.runner[data-block="list"] .row .n { font-size: clamp(18px, min(3.2vh, 2vw), 28px); font-weight: 800; line-height: 1.1; }
.runner[data-block="list"] .row.now .n { font-size: clamp(22px, min(4vh, 2.6vw), 36px); font-weight: 900; }
.runner[data-block="list"] .row.next .n { font-size: clamp(20px, min(3.8vh, 2.4vw), 34px); font-weight: 900; }
.runner[data-block="list"] .row .s { font-size: clamp(14px, 2.4vh, 18px); }
.runner[data-block="list"] .row .a { font-size: clamp(16px, 2.8vh, 22px); }
.runner[data-block="list"] .row.now .a { font-size: clamp(18px, 3.2vh, 26px); color: var(--text); }
.row.rest { border-style: dashed; border-color: var(--rule2); background: transparent; }
.row.next.rest { border-color: var(--done); }
.row.transition { padding: 2px 20px; background: transparent; border: 0; gap: 10px; }
.row.transition .n { flex: 1; font-size: 16px; font-weight: 700; color: var(--muted); }
.row.transition .n::before { content: ''; display: inline-block; width: 18px; height: 2px; background: var(--rule2); vertical-align: middle; margin-right: 10px; }
.row.transition .a { font-size: 15px; }
.upnext { margin-top: clamp(4px, 1.4vh, 14px); padding: clamp(8px, 1.6vh, 16px) 18px; border-radius: 14px; border: 1.5px dashed var(--rule2); display: flex; flex-direction: column; gap: 6px; }
.upnext .l { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.upnext .v { font-size: 16px; font-weight: 700; line-height: 1.35; }
.strip { height: 10px; border-radius: 5px; background: var(--rule); overflow: hidden; display: flex; gap: 3px; margin-top: auto; }
.strip .seg { background: var(--rule); display: flex; min-width: 6px; }
.strip .seg > div { background: var(--accent); }
.strip .seg.done > div { background: var(--done); }
.rounds { background: var(--panel); border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: clamp(8px, 1.6vh, 16px) 20px; }
.rounds .l { font-size: 13px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.rounds .big { font-size: clamp(44px, 10vh, 110px); font-weight: 900; line-height: 1; letter-spacing: -0.04em; color: var(--accent-text); }
.pips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--rule2); }
.pip.on { background: var(--accent); border-color: var(--accent); }
.rounds .last { font-size: 13px; font-weight: 700; color: var(--muted); }
/* Fixed-round circuits: one numbered stop per round; finished rounds turn green with their split underneath. */
.track { display: flex; align-items: flex-start; justify-content: center; flex-wrap: wrap; gap: clamp(10px, 2vw, 22px); }
.track .r { display: flex; flex-direction: column; align-items: center; gap: 8px; width: clamp(44px, 4.5vw, 64px); }
.track .c { width: clamp(38px, min(7vh, 4vw), 56px); height: clamp(38px, min(7vh, 4vw), 56px); border-radius: 50%; border: 3px solid var(--rule2); display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 3vh, 22px); font-weight: 900; color: var(--muted); }
.track .r.done .c { background: var(--done); border-color: var(--done); color: var(--accent-ink); }
.track .r.skip .c { border-style: dashed; }
.track .r.now .c { border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 18%, transparent); }
.track .t { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.track .r.done .t { color: var(--done); }
.track .r.now .t { color: var(--accent-text); }
.clockrow { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.clockrow .l { font-size: 13px; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.clockrow .v { font-size: clamp(30px, 6vh, 44px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.bigbtn { min-height: clamp(104px, 20vh, 220px); margin: 8px 0 6px; border: 0; border-radius: 24px; background: var(--accent); color: var(--accent-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 0 0 6px var(--bg), 0 0 0 10px var(--accent), 0 18px 48px color-mix(in srgb, var(--accent) 35%, transparent); width: 100%; }
.bigbtn:active { transform: scale(0.985); }
.bigbtn .plus { font-size: clamp(44px, 8vh, 72px); font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.bigbtn .word { font-size: 26px; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.bigbtn .hint { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: inherit; opacity: 0.85; margin-top: 6px; }
.bigbtn .kbd { font-size: 13px; padding: 4px 14px; border-width: 2px; opacity: 1; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 700; box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
.toast button { min-height: 32px; padding: 0 12px; border: 1.5px solid var(--bg); border-radius: 8px; background: transparent; font-weight: 900; }
.finish { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.finish h2 { margin: 0; font-size: 48px; font-weight: 900; }
.finish p { margin: 0; font-size: 18px; color: var(--muted); }
.finish .stats { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.finish .stat { display: flex; flex-direction: column; align-items: center; }
.finish .stat .v { font-size: 44px; font-weight: 900; color: var(--accent-text); }
.finish .stat .l { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 900px) {
  .runner { display: flex; flex-direction: column; height: auto; min-height: 100dvh; padding: 16px; gap: 14px; }
  .runner .col-main, .runner .col-side { display: flex; flex-direction: column; gap: 14px; }
  .r-top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
  .r-top .wtitle { max-width: none; font-size: 18px; }
  .r-top .pills { grid-column: 1 / -1; grid-row: 2; }
  .r-top .clocks { grid-column: 1 / -1; grid-row: 3; justify-content: space-between; }
  .r-top .clock:first-child { align-items: flex-start; }
  .hero { min-height: 380px; }
  .hero .title { font-size: 30px; }
  .track { gap: 8px; }
  .track .r { width: 48px; }
  .track .c { width: 44px; height: 44px; font-size: 18px; }
  .clockrow .v { font-size: 36px; }
  .library { position: static; max-width: none; }
  .cards { max-height: none; }
}

/* ---------- primitives: focus, selects, icons, dialogs ---------- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.runner :focus-visible { outline-color: var(--accent); }
.ic { display: block; flex: none; }
.btn.icon svg { width: 16px; height: 16px; }
.btn.icon:focus-visible { background: var(--line-2); color: var(--ink); }
/* Selects: same box as the inputs, our own chevron with breathing room, colour follows the control. */
.builder select, .builder .b-sub select, .builder .bk-head select, .builder .step select.side { appearance: none; -webkit-appearance: none; padding-right: 32px; background-repeat: no-repeat; background-position: right 10px center; background-size: 14px 14px; cursor: pointer; line-height: 1.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6170' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.builder select:hover { border-color: var(--ink-3); }
.builder .amount select { appearance: none; -webkit-appearance: none; padding-right: 26px; background-repeat: no-repeat; background-position: right 7px center; background-size: 12px 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6170' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.builder .bk-head select.rule { background: var(--blue-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232F6FED' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px 14px; }
.builder .block.amrap .bk-head select.rule { background: var(--orange-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B35300' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px 14px; }
.builder .block.circuit .bk-head select.rule { background: var(--purple-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A49D6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px 14px; }
.builder .step select.side.both { background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px 14px; }
/* Buttons: one danger variant for both palettes. */
.btn.primary.danger { background: #C92A2A; border-color: #C92A2A; color: #fff; }
.rbtn.primary.danger { background: #FF6B6B; color: #2A0A0A; }
.btn:hover:not(:disabled):not(.icon) { border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #000; }
.btn.primary.danger:hover:not(:disabled) { background: #A61E1E; border-color: #A61E1E; }
/* Confirm dialog: one card, a question, a short line, then Cancel and the action. */
.dlg { border: 0; padding: 0; width: min(420px, calc(100vw - 32px)); border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: 0 28px 80px rgba(11,18,32,0.35); animation: dlg-in 160ms ease-out; }
.dlg::backdrop { background: rgba(11,18,32,0.55); backdrop-filter: blur(2px); }
.dlg-body { padding: 26px 26px 10px; }
.dlg.settings { width: min(680px, calc(100vw - 32px)); }
.dlg.settings .theme-grid + h3 { margin-top: 8px; }
.dlg h2 { margin: 0 0 6px; font-size: 20px; font-weight: 900; line-height: 1.2; }
.dlg p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.dlg label { display: block; margin: 18px 0 6px; font-size: 14px; font-weight: 700; }
.dlg input { width: 100%; padding: 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card-2); color: var(--ink); }
.dlg p[role="alert"]:not(:empty) { margin-top: 10px; color: var(--orange-ink); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 22px; }
.dlg.dark { background: var(--panel); color: var(--text); box-shadow: 0 28px 80px rgba(0,0,0,0.6), 0 0 0 1.5px var(--rule2); }
.dlg.dark p { color: var(--muted); }
.dlg.dark .rbtn { min-height: 52px; font-size: 16px; }
.dlg.dark .rbtn.primary { font-size: 17px; padding: 0 24px; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
/* Notice and toast share one voice. */
#notice, .toast { font-size: 14px; border-radius: 14px; padding: 13px 20px; }
.dlg.dark :focus-visible { outline-color: var(--accent); }

/* Settings dialog: sound is its first section. */
.sound-tests { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 16px; }
.dlg h3 { margin: 18px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
/* Player theme cards: each is a tiny player drawn in that theme's variables, set inline from the registry. */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 16px; }
.theme-card { display: flex; flex-direction: column; gap: 6px; padding: 0 0 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; }
.theme-card:hover { border-color: var(--ink-3); }
.theme-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.theme-card .mini { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; padding: 8px; border-radius: 10px 10px 0 0; background: var(--bg); color: var(--text); font-family: Archivo, system-ui, sans-serif; }
.theme-card .mini .hero { padding: 8px 6px; border-radius: 8px; gap: 4px; }
.theme-card .mini .state { font-size: 7px; letter-spacing: 0.12em; font-weight: 900; text-transform: uppercase; color: var(--accent-text); }
.theme-card .mini .ring { width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--rule); border-top-color: var(--accent); border-right-color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; color: var(--text); }
.theme-card .mini .side { display: flex; flex-direction: column; gap: 4px; }
.theme-card .mini .row { padding: 3px 6px; border-radius: 6px; gap: 5px; font-size: 8px; font-weight: 700; white-space: nowrap; }
.theme-card .mini .row b { color: var(--accent-text); font-weight: 900; }
.theme-card .mini .row span { color: var(--muted); }
.theme-card .mini .plus { margin-top: auto; padding: 5px 0; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 9px; font-weight: 900; text-align: center; letter-spacing: 0.08em; }
.theme-card .name { padding: 0 10px; font-size: 14px; font-weight: 800; color: var(--ink); }
.theme-card .blurb { padding: 0 10px; font-size: 12px; line-height: 1.35; color: var(--ink-2); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 14px; font-weight: 700; }

/* Section recovery is a compact boundary row, not a numbered exercise block. */
.section-group { display: flex; flex-direction: column; gap: 12px; }
.section-rest { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
.section-rest label { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-weight: 600; }
.section-rest input { flex: 0 0 88px; width: 88px; min-width: 0; min-height: 36px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); font-size: 15px; font-weight: 700; text-align: center; }
.section-rest .hint { flex: 1; }
.addrest { min-height: 38px; align-self: flex-start; padding: 8px 14px; font-size: 13px; }

/* Notes stay attached to a workout step, including its copied/snapshotted forms. */
.step-content { flex: 1; min-width: 130px; }
.step-content .name { display: block; }
.step-note-editor { margin-top: 4px; font-size: 13px; font-weight: 400; }
.step-note-editor summary { cursor: pointer; color: var(--ink-2); }
.step-note-editor textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical; }
.workout-note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; margin: 8px 0; }
.runner .hero > .workout-note { max-width: 620px; margin: 12px auto; text-align: left; }
.runner .row .workout-note { font-size: 14px; }
