﻿/* Layout: una colonna a tutta altezza, contenuto che scorre, timer, Spotify e menu fissi in basso */
/* Palette: rest days blue, training days bordeaux. Each one in a light (white) and a dark (black) version.
   The mode comes from data-mode on <html> (set by app.js from the training days in Calendar), the light/dark choice from data-theme or the phone. */
:root {
  /* rest day, light: white + blue */
  --bg: #f4f7fe; --surf: #ffffff; --surf2: #e9f0fd; --fg: #0f1f3d; --mut: #55647f;
  --line: #d9e3f5; --acc: #1c4fd6; --acc-fg: #ffffff; --brand: #1c4fd6; --brand-fg: #ffffff; --ok: #1f9d55; --bad: #c4283c;
  --shadow: 0 1px 2px rgba(28,79,214,.10);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-mode="train"] {
  /* training day, light: white + bordeaux */
  --bg: #fbf4f6; --surf: #ffffff; --surf2: #f6e8ec; --fg: #2b1018; --mut: #7b5560;
  --line: #ecd6dc; --acc: #7a1230; --acc-fg: #ffffff; --brand: #7a1230; --brand-fg: #ffffff;
  --shadow: 0 1px 2px rgba(122,18,48,.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* rest day, dark: black + blue */
    --bg: #06080e; --surf: #0e1320; --surf2: #161d2f; --fg: #e8eefc; --mut: #9fb0d2;
    --line: #232d45; --acc: #6fa1ff; --acc-fg: #04122e; --brand: #15409f; --brand-fg: #eaf1ff; --ok: #3ccf7a; --bad: #ff7b8a;
    --shadow: none; color-scheme: dark;
  }
  :root[data-mode="train"]:not([data-theme="light"]) {
    /* training day, dark: black + bordeaux */
    --bg: #0a0607; --surf: #150c0f; --surf2: #1f1217; --fg: #f7e9ed; --mut: #c8a3ae;
    --line: #35202a; --acc: #e8738f; --acc-fg: #2b0713; --brand: #7a1230; --brand-fg: #fbe9ee;
  }
}
:root[data-theme="dark"] {
  --bg: #06080e; --surf: #0e1320; --surf2: #161d2f; --fg: #e8eefc; --mut: #9fb0d2;
  --line: #232d45; --acc: #6fa1ff; --acc-fg: #04122e; --brand: #15409f; --brand-fg: #eaf1ff; --ok: #3ccf7a; --bad: #ff7b8a;
  --shadow: none; color-scheme: dark;
}
:root[data-mode="train"][data-theme="dark"] {
  --bg: #0a0607; --surf: #150c0f; --surf2: #1f1217; --fg: #f7e9ed; --mut: #c8a3ae;
  --line: #35202a; --acc: #e8738f; --acc-fg: #2b0713; --brand: #7a1230; --brand-fg: #fbe9ee;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.4 var(--font); overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

#app { height: 100%; display: flex; flex-direction: column; }
#view {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
#view > * { flex-shrink: 0; width: 100%; max-width: 640px; margin-inline: auto; }

#tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surf); border-bottom: 1px solid var(--line); order: -1;
  padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}
#tabs button { padding: 12px 2px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--mut); border-bottom: 3px solid transparent; }
#tabs button[aria-current="page"] { color: var(--fg); border-bottom-color: var(--acc); }

#timerbar {
  display: flex; align-items: center; gap: 12px; background: var(--brand); color: var(--brand-fg);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
#timerbar .t { font-size: 28px; font-weight: 800; letter-spacing: .02em; }
#timerbar .l { flex: 1; min-width: 0; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#timerbar button { background: rgba(255,255,255,.16); color: var(--brand-fg); border-radius: 10px; padding: 8px 12px; font-weight: 700; }

.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.card { background: var(--surf); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mut { color: var(--mut); font-size: 14px; }
.title { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }

.btn { background: var(--surf2); border-radius: 12px; padding: 12px 16px; font-weight: 700; text-align: center; }
.btn.pri { background: var(--acc); color: var(--acc-fg); }
.btn.bad { color: var(--bad); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; }
.link { color: var(--acc); font-weight: 700; padding: 6px 0; }

input[type="text"], input[type="number"], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { min-height: 150px; resize: vertical; font-size: 15px; }

/* riepilogo serie */
.hero { display: flex; flex-direction: column; gap: 10px; }
.streak { display: flex; align-items: baseline; gap: 10px; }
.streak b { font-size: 52px; line-height: 1; font-weight: 800; color: var(--acc); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week div { text-align: center; font-size: 12px; font-weight: 700; color: var(--mut); padding: 6px 0; border-radius: 9px; border: 1px solid var(--line); }
.week div.sched { color: var(--fg); border-color: var(--fg); }
.week div.done { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.week div.today { box-shadow: 0 0 0 2px var(--acc); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex-shrink: 0; padding: 9px 14px; border-radius: 999px; background: var(--surf); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-fg); border-color: var(--acc); }

/* esercizi */
.ex h3 { font-size: 18px; line-height: 1.2; }
.ex .scheme { font-weight: 800; white-space: nowrap; }
.ex .note { font-size: 14px; color: var(--mut); }
.stepper { display: flex; align-items: stretch; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 44px; font-size: 22px; font-weight: 700; background: var(--surf2); }
.stepper input { width: 76px; border: 0; border-radius: 0; text-align: center; font-size: 22px; font-weight: 800; background: transparent; padding: 8px 4px; }
.stepper span { align-self: center; padding-right: 10px; color: var(--mut); font-weight: 700; }
.warm { background: var(--bg); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.warm .chip { background: var(--surf); display: flex; flex-direction: column; align-items: center; min-width: 74px; border-radius: 12px; padding: 8px 10px; line-height: 1.15; }
.warm .chips { flex-wrap: wrap; overflow: visible; }
.warm .chip small { color: var(--mut); font-weight: 600; font-size: 12px; }
.warm .chip b { font-size: 18px; }
.warm .chip[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.warm .chip[aria-pressed="true"] small { color: var(--acc-fg); }
.sets { display: flex; gap: 8px; flex-wrap: wrap; }
.setb { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); font-weight: 800; font-size: 17px; background: var(--surf); }
.setb.done { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }

/* timer */
.bigtime { font-size: 84px; line-height: 1; font-weight: 800; text-align: center; padding: 18px 0 8px; letter-spacing: -.02em; }
.bar { height: 10px; background: var(--surf2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--acc); width: 0; transition: width .25s linear; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* calendario */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surf); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 26px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--mut); }
.wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd button { padding: 12px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surf); font-weight: 700; font-size: 14px; }
.wd button[aria-pressed="true"] { background: var(--brand); color: var(--brand-fg); border-color: var(--acc); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .h { text-align: center; font-size: 12px; color: var(--mut); font-weight: 700; padding-bottom: 2px; }
.cal button { aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent; background: var(--surf); font-weight: 700; font-size: 15px; position: relative; padding: 0; }
.cal button.out { visibility: hidden; }
.cal button.sched { border-color: var(--fg); }
.cal button.done { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); }
.cal button.miss { border-color: var(--bad); color: var(--bad); }
.cal button.today { box-shadow: 0 0 0 2px var(--acc); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--mut); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; border: 1.5px solid var(--fg); }
.legend i.d { background: var(--acc); border-color: var(--acc); }
.legend i.m { border-color: var(--bad); }

/* editor scheda */
.day-ed { display: flex; flex-direction: column; gap: 10px; }
.ex-ed { display: grid; grid-template-columns: 1fr 46px 56px 56px 34px 30px; gap: 5px; align-items: center; }
.ex-ed .play { height: 38px; border-radius: 10px; background: var(--acc); color: var(--acc-fg); font-size: 14px; font-weight: 700; }
.ex-ed .lab { font-size: 11px; color: var(--mut); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.ex-ed input { padding: 9px 8px; }
.ex-ed .x { color: var(--bad); font-size: 20px; font-weight: 700; height: 38px; }
.dayhead { display: flex; gap: 8px; }

#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
#sheet .panel {
  background: var(--surf); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px; max-height: 85%; overflow-y: auto;
}
#toast {
  position: fixed; left: 50%; top: calc(96px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 30;
  background: var(--brand); color: var(--brand-fg); border: 1px solid var(--acc); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; max-width: 88%; text-align: center;
}
.empty { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
@media (max-width: 380px) { .ex-ed { grid-template-columns: 1fr 40px 50px 50px 32px 26px; } .bigtime { font-size: 68px; } }

/* set rows */
.setrows { display: flex; flex-direction: column; gap: 8px; }
.srow { display: grid; grid-template-columns: 24px 1fr 1fr 48px; gap: 8px; align-items: center; }
.srow .sn { font-weight: 800; color: var(--mut); text-align: center; }
.sfield { position: relative; display: block; }
.sfield input { padding: 11px 42px 11px 10px; text-align: right; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.sfield small { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--mut); font-size: 12px; pointer-events: none; }
.sdone { height: 46px; border-radius: 12px; border: 2px solid var(--line); background: var(--surf); font-weight: 800; font-size: 19px; color: var(--mut); }
.sdone[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.lastbox { display: flex; flex-direction: column; gap: 2px; background: var(--surf2); border-radius: 10px; padding: 8px 10px; font-weight: 700; }

/* progress */
.pstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pstats div { background: var(--surf2); border-radius: 10px; padding: 8px; text-align: center; }
.pstats b { display: block; font-size: 20px; }
.pstats span { font-size: 12px; color: var(--mut); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--mut); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .vl { fill: var(--fg); font-weight: 700; }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart .cbar { fill: var(--acc); opacity: .3; }
.chart .ln { fill: none; stroke: var(--acc); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dt { fill: var(--surf); stroke: var(--acc); stroke-width: 2; }
.legend i.ln2 { height: 0; width: 16px; border: 0; border-top: 2.5px solid var(--acc); border-radius: 0; vertical-align: 3px; }
.legend i.d { opacity: .45; }
.plist { display: flex; flex-direction: column; gap: 4px; }
.plist div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }

/* spotify */
.cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
a.btn { display: block; text-decoration: none; color: inherit; }

/* ai coach */
#aireport { min-height: 260px; font-size: 12px; line-height: 1.45; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.chk { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.chk input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--acc); }

/* song position */
.seek { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--mut); font-variant-numeric: tabular-nums; }
.seek input[type="range"] { flex: 1; min-width: 0; accent-color: var(--acc); height: 28px; padding: 0; background: none; border: 0; }

/* header with the language switch */
#top { order: -2; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surf);
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px)); }
#top .brand { font-weight: 800; letter-spacing: .01em; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang button { padding: 6px 13px; font-size: 12px; font-weight: 800; color: var(--mut); }
.lang button[aria-pressed="true"] { background: var(--brand); color: var(--brand-fg); }

/* v12: bigger touch targets, compact workout, icon buttons, undo toast */
.btn { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
a.btn { display: flex; }
.btn.sm { min-height: 44px; min-width: 44px; }
.btn.block { display: flex; }
.chip { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; }
.ibtn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--surf2); color: var(--fg); display: inline-grid; place-items: center; padding: 0; }
.ibtn svg { width: 22px; height: 22px; fill: currentColor; }
.ibtn.pri, .ibtn[aria-expanded="true"], .ibtn[aria-pressed="true"] { background: var(--acc); color: var(--acc-fg); }
.ibtn.del { color: var(--bad); }
.row.nw { flex-wrap: nowrap; }
.min0 { min-width: 0; }
.ell { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero { gap: 8px; padding: 12px 14px; }
.streak { align-items: center; gap: 12px; }
.streak b { font-size: 36px; }
.week div { padding: 4px 0; }
#tabs button { min-height: 44px; font-size: 12px; letter-spacing: -.01em; }
#top { padding-bottom: 4px; }
.hright { display: flex; align-items: center; gap: 8px; }
.lang button { min-height: 44px; min-width: 44px; padding: 0 12px; }
.stepper input { min-height: 44px; width: 64px; }
.lastbox { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; padding: 8px 12px; border-radius: 12px; }
.card { border-radius: 16px; }
input[type="text"], input[type="number"], input[type="search"], select, textarea { border-radius: 12px; }
.pstats div, .stat, .wd button, .cal button { border-radius: 12px; }
input::placeholder, textarea::placeholder { color: var(--mut); opacity: .7; font-style: italic; font-weight: 500; }
.chart .cbar { opacity: .55; }
.chart text { font-size: 12px; }
.cal button.miss::after { content: "×"; position: absolute; right: 5px; bottom: 1px; font-size: 14px; line-height: 1; }
.chk { min-height: 44px; }
#timerbar button { min-height: 44px; min-width: 44px; }
/* plan editor */
.ex-ed2 { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ex-top { display: grid; grid-template-columns: 1fr 44px 44px; gap: 8px; align-items: center; }
.ex-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ex-fields label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 700; color: var(--mut); text-transform: uppercase; letter-spacing: .05em; }
.ex-fields input { min-height: 44px; text-transform: none; letter-spacing: 0; font-size: 16px; font-weight: 500; color: var(--fg); }
/* toast at the bottom, above the timer bar */
#toast { top: auto; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 12px; }
body:has(#timerbar:not([hidden])) #toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
#toast button { color: var(--brand-fg); font-weight: 800; text-decoration: underline; padding: 8px 4px; min-height: 44px; }
input[type="password"] { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; }
.chart text { font-size: 12.5px; }

/* form check */
input[type="search"] { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; -webkit-appearance: none; appearance: none; }
:root { --warn: #f0b43c; }
.vwrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; }
.vwrap video { display: block; width: 100%; max-height: 62vh; background: #000; }
.vwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.repband { fill: var(--acc); opacity: .12; cursor: pointer; }
.repband.b { opacity: .22; }
.fnd { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.fnd i { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 14px; margin-top: 1px; }
.sev-bad i { background: var(--bad); color: #fff; }
.sev-warn i { background: var(--warn); color: #2b2433; }
.sev-info i { background: var(--surf2); color: var(--fg); border: 1px solid var(--line); }
.sev-ok i { background: var(--ok); color: #0b2a17; }
.rrow { display: flex; justify-content: space-between; gap: 12px; min-height: 44px; align-items: center; padding: 0 4px; font-size: 15px; text-align: left; border-bottom: 1px solid var(--line); }

.chips.wrapc { flex-wrap: wrap; overflow: visible; }

/* mascot */
.mascotwrap { flex: none; display: flex; align-items: center; margin: -6px -2px -6px 0; }
.mascot { display: block; height: auto; }
.mascotbig { display: flex; justify-content: center; }

/* background pattern: the mascot in every pose, faint, behind everything */
body::before { content: ""; position: fixed; inset: 0; background-image: var(--pattern, none); background-size: 460px 460px; background-position: center top; opacity: .10; pointer-events: none; z-index: 0; }
#app { position: relative; z-index: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { opacity: .08; } }
:root[data-theme="dark"] body::before { opacity: .08; }

/* bottom dock: the timer on top, Spotify under it (its song list opens above the player).
   The strip under the controls keeps them clear of the hosting badge in the bottom-right corner. */
#dock { display: flex; flex-direction: column; background: var(--surf); border-top: 1px solid var(--line); padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -6px 18px rgba(0,0,0,.12); }
#dock > * { margin-inline: auto; width: 100%; max-width: 640px; }
#timerbar { margin-top: 8px; width: calc(100% - 24px); border-radius: 14px; padding: 6px 8px 6px 14px; gap: 10px; }
#timerbar .t { font-size: 26px; }
#timerbar.warn, .card.warn { background: var(--warn); color: #2b2433; border-color: var(--warn); animation: warnpulse .7s ease-in-out infinite alternate; }
#timerbar.warn .l, #timerbar.warn button { color: #2b2433; }
#timerbar.warn button { background: rgba(0,0,0,.14); }
.card.warn .bigtime { color: #2b2433; }
@keyframes warnpulse { from { filter: brightness(1); } to { filter: brightness(1.18); } }
@media (prefers-reduced-motion: reduce) { #timerbar.warn, .card.warn { animation: none; } }
#spbar { display: flex; flex-direction: column; gap: 2px; padding: 8px max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px)); }
#spbar .ibtn { width: 40px; height: 40px; }
#spbar .seek { height: 28px; }
#view { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
body:has(#dock:not([hidden])) #view { padding-bottom: 16px; }
#toast, body:has(#timerbar:not([hidden])) #toast { bottom: calc(max(var(--dockh, 0px), 48px) + 24px); }

/* song list */
#splist { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 0; }
#splist .tracks { display: flex; flex-direction: column; max-height: min(30vh, 250px); overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); border-radius: 12px; }
.trk { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 12px; text-align: left; border-bottom: 1px solid var(--line); width: 100%; }
.trk:last-child { border-bottom: 0; }
.trk .n { width: 22px; text-align: right; color: var(--mut); font-size: 13px; flex: none; }
.trk b { font-weight: 700; font-size: 15px; }
.trk .mut { font-size: 13px; }
.trk.cur { background: var(--surf2); box-shadow: inset 3px 0 0 var(--acc); }
.trk.cur b { color: var(--acc); }

/* exercises: finished badge, folded sets, lit flame */
.okbadge { flex: none; background: var(--ok); color: #0b2a17; font-weight: 800; font-size: 12px; padding: 4px 9px; border-radius: 999px; }
.ex.complete { border-color: var(--ok); }
.fold { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--surf2); font-weight: 700; width: 100%; }
.fold i { width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.fold svg { width: 22px; height: 22px; fill: currentColor; }
.ibtn.lit svg { fill: #ff9a1f; filter: drop-shadow(0 0 5px rgba(255,150,30,.75)); }
.ibtn.lit { box-shadow: inset 0 0 0 2px #ff9a1f; }
.wout { display: grid; place-items: center; min-width: 76px; font-size: 20px; font-weight: 800; padding: 0 8px; }
.ex-top { grid-template-columns: 1fr 44px 44px 44px; }

/* leg day: "good luck" with infernal icons */
#luck { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.74); }
.luckbox { width: min(100%, 360px); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 20px 18px 18px; border-radius: 22px; color: #fff4f2;
  background: radial-gradient(120% 90% at 50% 0%, #8a1233 0%, #3a0a17 55%, #0b0406 100%); border: 2px solid #ff5a3c; box-shadow: 0 0 0 4px rgba(255,90,60,.18), 0 0 44px rgba(255,70,40,.55); animation: luckin .35s ease-out; }
.luckbox .btn.pri { background: #ff5a3c; color: #2b0508; }
.lrow { display: flex; gap: 14px; justify-content: center; }
.lrow svg { width: 32px; height: 32px; color: #ff7a2e; filter: drop-shadow(0 0 6px rgba(255,100,30,.85)); transform-origin: 50% 85%; }
.lrow svg:nth-child(even) { color: #ffd9d2; }
.lrow svg:nth-child(odd) { animation: flick .7s ease-in-out infinite alternate; }
.ltitle { font-size: 40px; line-height: 1.05; font-weight: 900; text-shadow: 0 0 18px rgba(255,80,40,.95); }
.lsub { color: #ffb9a8; font-weight: 700; }
@keyframes flick { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.14) rotate(4deg); } }
@keyframes luckin { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lrow svg, .luckbox { animation: none; } }

/* v26: the menu sits at the very bottom (icon + label), the timer and Spotify dock right above it */
#tabs { order: 0; border-bottom: 0; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
#tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 7px 2px 6px; min-height: 58px; font-size: 11px; border-bottom: 0; box-shadow: inset 0 3px 0 transparent; }
#tabs button svg { width: 24px; height: 24px; fill: currentColor; }
#tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#tabs button[aria-current="page"] { color: var(--acc); box-shadow: inset 0 3px 0 var(--acc); }
#dock { padding-bottom: 0; box-shadow: none; }
#view { padding-bottom: 20px; }
body:has(#dock:not([hidden])) #view { padding-bottom: 16px; }
#toast, body:has(#timerbar:not([hidden])) #toast { bottom: calc(var(--dockh, 0px) + var(--tabsh, 60px) + 16px); }

/* v27: workout clock in the dock, Start card, heart rate analysis */
#wkbar { margin-top: 8px; width: calc(100% - 24px); }
#wkbar button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 4px 14px; border-radius: 14px; background: var(--surf2); border: 1px solid var(--line); text-align: left; }
#wkbar .t { font-size: 20px; font-weight: 800; letter-spacing: .02em; color: var(--acc); }
#wkbar .l { flex: 1; min-width: 0; font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#wkbar .rec { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; animation: recblink 1.4s ease-in-out infinite; }
@keyframes recblink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { #wkbar .rec { animation: none; } }
.startcard { flex-direction: row; align-items: center; gap: 12px; }
.startcard > .grow { display: flex; flex-direction: column; gap: 2px; }
.startcard .btn.pri { min-width: 96px; }
.startcard.on { border-color: var(--acc); }
.hrchart .hrband { fill: var(--acc); opacity: .10; }
.hrchart .hrband.b { opacity: .20; }
.zrow { display: grid; grid-template-columns: 64px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; color: var(--mut); }
.zrow b { text-align: right; color: var(--fg); }
.zbar { height: 12px; background: var(--surf2); border-radius: 999px; overflow: hidden; }
.zbar i { display: block; height: 100%; border-radius: 999px; background: var(--acc); }
.zbar i.z0 { opacity: .35; } .zbar i.z1 { opacity: .5; } .zbar i.z2 { opacity: .7; } .zbar i.z3 { opacity: .88; } .zbar i.z4 { background: var(--bad); }
.hrex { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hrex .n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--acc); color: var(--acc-fg); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.hrex b { display: block; }
.hrex .mut { display: block; font-size: 13px; }
.tips { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
#sheet .panel > * { flex-shrink: 0; }
.hrchart { aspect-ratio: 320 / 150; }

/* v28: coach page */
.bigstat { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 76px; padding: 8px 10px; border-radius: 12px; background: var(--surf2); flex: none; }
.bigstat b { font-size: 26px; font-weight: 800; color: var(--acc); line-height: 1.1; }
.bigstat span { font-size: 12px; color: var(--mut); }
.kcal { font-size: 15px; color: var(--mut); }
.kcal b { font-size: 34px; font-weight: 800; color: var(--fg); letter-spacing: -.01em; }
.warnline { color: var(--bad); font-weight: 700; font-size: 14px; }
.wtable { display: flex; flex-direction: column; }
.wtable > div { display: grid; grid-template-columns: 1fr 70px 80px 40px; gap: 8px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); font-size: 15px; }
.wtable .wh { min-height: 28px; font-size: 12px; color: var(--mut); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.wtable .num { text-align: right; }
.wtable .up { color: var(--ok); } .wtable .down { color: var(--bad); }
.ibtn.sm { width: 40px; height: 40px; }
.ibtn.sm svg { width: 18px; height: 18px; }
input[type="date"] { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 44px; min-width: 0; color: var(--fg); }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 92%; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-fg); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surf2); border-bottom-left-radius: 4px; }
#aiq { min-height: 48px; font-size: 15px; resize: vertical; }
details.card > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; margin-left: auto; color: var(--mut); }
details.card[open] > summary::after { content: "▴"; }
.chip[disabled] { opacity: .45; }
