:root {
  color-scheme: dark;
  /* Ink: neutral near-black. Sky = information, white = text/hierarchy, hot pink = what's live right now. */
  --bg: #0a0a0d;
  --panel: #131318;
  --panel2: #1b1b22;
  --line: #26262f;
  --text: #f5f8ff;
  --muted: #8b8b9a;
  --faint: #55556a;
  --sky: #38bdf8;
  --sky-soft: rgba(56,189,248,.14);
  --sky-line: rgba(56,189,248,.38);
  --sky-ink: #04222f;
  --pink: #ff2d95;
  --pink-soft: rgba(255,45,149,.16);
  --pink-line: rgba(255,45,149,.5);
  --danger: #ff6b7a;
  --radius: 16px;
  --nav-h: 64px;
  --top-h: 60px;
  --side-w: 210px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.4; }
body { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
body.has-timer { padding-bottom: calc(var(--nav-h) + 130px + env(safe-area-inset-bottom)); }
body.locked .tabs, body.locked .topbar .btn { display: none; }
body.locked { padding-bottom: 24px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="date"] { min-height: 44px; color-scheme: dark; }
select { color-scheme: dark; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-soft); }
button:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
textarea { resize: vertical; min-height: 70px; }
h2, h3 { margin: 0; }
.hidden { display: none !important; }
.mi { width: 1.3em; height: 1.3em; fill: currentColor; flex: none; display: inline-block; vertical-align: middle; }
.mi.inl { width: 1.15em; height: 1.15em; vertical-align: -0.22em; }
.mi.mk { width: 12px; height: 12px; margin-right: 2px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.up { color: var(--sky); }
.down { color: var(--pink); }

/* Top bar: plain dark, sky-to-pink hairline, glowing pink dot on the wordmark */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--top-h); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: rgba(10,10,13,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, var(--sky), #fff 55%, var(--pink)); opacity: .9; }
.topbar .btn { background: var(--panel2); }
.brand { min-width: 0; }
.brand-title { font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 10px var(--pink); }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sky); }
.sync svg { width: 20px; height: 20px; }
.sync.saving { color: var(--muted); }
.sync.offline { color: var(--pink); }
.sync.saving svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }
.sync span { display: none; }

.shell { max-width: 820px; margin: 0 auto; }
#view { padding: 14px 14px 0; min-width: 0; }

/* Tabs: active = soft white pill with a glowing sky icon */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(10,10,13,.94); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; min-width: 0; background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--muted); position: relative; }
.tabs button .ico { display: flex; line-height: 1; }
.tabs button .ico svg { width: 26px; height: 26px; }
.tabs button.active { color: #fff; font-weight: 700; }
.tabs button.active .ico svg { color: var(--sky); filter: drop-shadow(0 0 8px rgba(56,189,248,.55)); }
.tabs button.active::after { content: ""; position: absolute; inset: 7px 8px; border-radius: 14px; background: rgba(255,255,255,.07); z-index: -1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; min-width: 0; }
.card-title { font-weight: 700; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; font-weight: 700; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: #fff; border-color: #fff; color: var(--bg); }
.btn.danger { color: var(--danger); border-color: rgba(255,107,122,.4); background: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 14px; min-height: 34px; }
.btn.block { width: 100%; }
.btn.big { padding: 14px; font-size: 17px; min-height: 52px; }
.btn svg { width: 1.15em; height: 1.15em; }

.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.accent { color: var(--sky); border-color: var(--sky-line); background: var(--sky-soft); }
.chip.warn { color: var(--muted); border-color: var(--line); background: var(--panel2); }

.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.daynav .mid { flex: 1; text-align: center; min-width: 0; }
.daynav .date { font-weight: 800; font-size: 18px; }
.daynav .sub { font-size: 13px; color: var(--muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.icon-btn svg { width: 26px; height: 26px; }

/* Workout header card: sky stripe + glow; NEXT UP tag when it is the next workout */
.wo-head { border-left: 4px solid var(--sky); background: linear-gradient(135deg, rgba(56,189,248,.10), transparent 55%), var(--panel); }
.wo-title { font-size: 21px; font-weight: 800; margin: 2px 0 8px; }
.pill-next { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .7px; color: var(--pink); background: var(--pink-soft); border: 1px solid var(--pink-line); border-radius: 99px; padding: 2px 10px; margin-bottom: 8px; }
.pill-next::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }
.progress { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--sky); border-radius: 99px; transition: width .25s; }
.tech-box { margin-top: 12px; background: var(--panel2); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; color: var(--muted); }
.tech-box b { color: var(--text); }

.su-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.su-row:last-child { border-bottom: 0; }
.su-name { font-weight: 600; font-size: 14px; min-width: 0; }
.su-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 16px; }
.su-name .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--sky); }
.su-row input { width: 160px; flex: none; }

.ex-grid { display: block; }
.ex { padding: 12px 12px 8px; }
.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ex-name { font-weight: 800; font-size: 17px; min-width: 0; }
.ex-target { font-weight: 800; color: var(--sky); white-space: nowrap; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ex-meta:empty { display: none; }
.ex-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.ex-last { font-size: 13px; color: var(--muted); margin-top: 6px; }
.ex-note { font-size: 13px; color: var(--muted); margin-top: 4px; }
.sets { margin-top: 8px; }
.set, .set-labels { display: grid; grid-template-columns: 26px 1fr 14px 1fr 48px; gap: 8px; align-items: center; }
.set.timed, .set-labels.timed { grid-template-columns: 26px 1fr 48px; }
.set { padding: 4px 0; }
.set .n { text-align: center; color: var(--muted); font-weight: 700; }
.set .x { text-align: center; color: var(--muted); }
.set input { text-align: center; padding: 10px 6px; font-weight: 700; min-height: 44px; }
.set.done input { color: var(--muted); }
.set .check { width: 48px; height: 44px; border-radius: 11px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; }
.set .check svg { width: 24px; height: 24px; }
.set.done .check { background: var(--sky); border-color: var(--sky); color: var(--sky-ink); }
/* the set you're about to do */
.set.cur .n { color: var(--pink); }
.set.cur input { border-color: var(--pink-line); box-shadow: 0 0 0 3px var(--pink-soft); }
.set.cur .check { border-color: var(--pink-line); color: var(--pink); }
.set-tag { margin: 4px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.set-tag .btn { margin-left: 4px; }
.set-labels { font-size: 11px; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .6px; }

/* Rest timer: live, so it glows pink */
.timer { position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 40; max-width: 740px; margin: 0 auto; background: #101015; border: 1px solid var(--pink-line); color: var(--text); border-radius: 18px; padding: 12px 14px; box-shadow: 0 0 0 1px rgba(255,45,149,.2), 0 12px 40px rgba(255,45,149,.25); }
.timer.done { background: #1b0f17; border-color: var(--pink); animation: pulse 1s infinite; }
.timer .t-time { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; color: var(--pink); }
.timer.done .t-time { color: #fff; }
.timer .t-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer .t-bar { height: 5px; border-radius: 99px; background: var(--panel2); margin-top: 10px; overflow: hidden; }
.timer .t-bar > i { display: block; height: 100%; background: var(--pink); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255,45,149,.3), 0 12px 40px rgba(255,45,149,.4); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 92px); background: #fff; color: var(--bg); padding: 10px 16px; border-radius: 99px; z-index: 60; font-size: 14px; font-weight: 700; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

.login { max-width: 420px; margin: 8vh auto 0; }
.err { color: var(--danger); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* Calendar: colour = status, letters = workout type */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head .title { flex: 1; text-align: center; font-weight: 800; font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.cell { position: relative; min-height: 62px; padding: 5px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); text-align: left; display: flex; flex-direction: column; gap: 4px; overflow: hidden; min-width: 0; }
.cell.rest { background: transparent; border-color: var(--line); cursor: default; }
.cell.has { background: var(--sky-soft); border-color: var(--sky-line); }
.cell.today { border: 2px solid var(--pink); background: var(--pink-soft); padding: 4px; }
.cell .dn { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.cell.has .dn, .cell.today .dn { color: var(--text); }
.cell .lab { display: flex; align-items: center; justify-content: space-between; gap: 2px; font-size: 11px; font-weight: 800; border-radius: 6px; padding: 2px 5px; max-width: 100%; white-space: nowrap; overflow: hidden; width: fit-content; }
.cell .lab.done { background: var(--sky); color: var(--sky-ink); }
.cell .lab.open { background: transparent; color: var(--sky); border: 1.5px solid var(--sky); padding: 1px 4px; }
.cell .lab small { font-size: 9.5px; font-weight: 700; opacity: .75; display: none; }
.cell .lab .full { display: none; }
.cell .lab .mk { display: none; }
.cell .bw { position: absolute; bottom: 3px; right: 4px; font-size: 10px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; }
.legend i.sky { background: var(--sky); }
.legend i.ring { border: 1.5px solid var(--sky); }
.legend i.now { background: var(--pink-soft); border: 2px solid var(--pink); }
.cols > .card:last-child { margin-bottom: 12px; }

.weeks { width: 100%; border-collapse: collapse; font-size: 14px; }
.weeks th, .weeks td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.weeks th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.weeks tr.cur td { background: var(--sky-soft); }
.weeks tr[data-act] { cursor: pointer; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stat { background: var(--panel2); border-radius: 12px; padding: 10px; min-width: 0; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--sky); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--sky-soft); }
.chart .pt { fill: var(--bg); stroke: var(--sky); stroke-width: 2; }
.chart .now { fill: var(--pink); stroke: var(--bg); stroke-width: 2.5; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.pr { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; color: #fff; background: var(--pink); border-radius: 6px; padding: 2px 6px; margin-left: 8px; vertical-align: 2px; }
.pr svg { width: 12px; height: 12px; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); font-weight: 700; min-height: 36px; }
.seg button.on { background: var(--sky); color: var(--sky-ink); }
.wrapseg { display: flex; flex-wrap: wrap; }
.wrapseg button { flex: 1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--sky); }

/* Very small phones */
@media (max-width: 359px) {
  .set, .set-labels { grid-template-columns: 22px 1fr 10px 1fr 42px; gap: 5px; }
  .set .check { width: 42px; }
  .grid2 { grid-template-columns: 1fr; }
  .ex-name { font-size: 16px; }
}

/* Large phones / small tablets */
@media (min-width: 560px) {
  #view { padding: 18px 18px 0; }
  .cell { min-height: 84px; padding: 6px; }
  .cell .lab { flex-direction: column; align-items: flex-start; gap: 0; font-size: 10.5px; line-height: 1.25; letter-spacing: -.1px; padding: 3px 6px; }
  .cell .lab .abbr { display: none; }
  .cell .lab .full { display: inline; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .cell .lab small { display: block; }
  .sync span { display: inline; }
}

/* Tablets */
@media (min-width: 760px) {
  .ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .ex-grid .card { margin-bottom: 0; }
  .cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .cards2 .card { margin-bottom: 0; }
  .cards2 .card:nth-child(3) { grid-column: 1 / -1; }
  .ex-grid + .card, .ex-grid ~ .card { margin-top: 12px; }
  .cell { min-height: 92px; }
}

/* Desktop: sidebar nav */
@media (min-width: 1024px) {
  body { padding-bottom: 40px; }
  body.has-timer { padding-bottom: 140px; }
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); max-width: 1200px; gap: 0; align-items: start; }
  .tabs { position: sticky; top: var(--top-h); left: auto; right: auto; bottom: auto; z-index: 10; flex-direction: column; height: auto; padding: 14px 10px; margin: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; border: 0; gap: 4px; }
  .tabs button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; }
  .tabs button:hover { background: var(--panel); }
  .tabs button.active::after { inset: 0; z-index: -1; }
  .tabs button .ico { width: 24px; justify-content: center; }
  .timer { left: calc(50% - 380px + var(--side-w) / 2); right: auto; width: 760px; bottom: 20px; }
  .toast { bottom: 24px; }
  .cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 12px; align-items: start; }
  .cols .card { margin-bottom: 0; }
  .cell { min-height: 100px; }
  .brand-sub { font-size: 13px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  body.locked .shell { display: block; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .timer { max-width: 560px; }
  .timer .t-time { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .timer.done { animation: none; }
  .progress > i { transition: none; }
  .sync.saving svg { animation: none; }
}
