/* Barlow and Barlow Condensed (SIL Open Font License), self-hosted, latin subset */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('fonts/Barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('fonts/Barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('fonts/Barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url('fonts/BarlowCondensed-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url('fonts/BarlowCondensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('fonts/BarlowCondensed-700.woff2') format('woff2'); }

:root {
  /* midnight enamel ground, porcelain type, four line inks */
  --ground: #0b1230;
  --panel: #111a3e;
  --panel-2: #18234f;
  --hair: rgb(244 241 232 / 0.14);
  --hair-2: rgb(244 241 232 / 0.28);
  --porcelain: #f4f1e8;
  --muted: #aab1c9;
  --cobalt: #1e88e5;
  --amber: #f2b531;
  --green: #22b14c;
  --scarlet: #e21d2d;
  --ink: var(--cobalt); /* the line colour of whatever is on screen */

  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --text: 'Barlow', system-ui, sans-serif;
  --u: 8px; /* one spacing module */
  --r: 10px;
  --tabs: calc(64px + env(safe-area-inset-bottom));
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--ground); scrollbar-color: var(--hair-2) transparent; }
body { margin: 0; min-height: 100dvh; background: var(--ground); color: var(--porcelain); font: 400 16px/1.45 var(--text); font-variant-numeric: tabular-nums; caret-color: var(--cobalt); }
::selection { background: var(--cobalt); color: #fff; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--porcelain); outline-offset: 3px; border-radius: 6px; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--tabs) + 32px); }
.muted { color: var(--muted); }
.pad { padding: 32px 0; }

/* type: condensed transit sans for names and numbers, Barlow for reading */
.label { font: 600 13px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
h1 { font: 700 30px/1 var(--display); letter-spacing: 0.01em; text-transform: uppercase; margin: 0; }
h2 { font: 700 15px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; margin: 40px 0 16px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ""; width: 24px; height: 6px; border-radius: 3px; background: var(--ink); }
.num { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; margin: 0 -16px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgb(11 18 48 / 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.top h1 { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 26px; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; border: 1px solid var(--hair-2); flex: none; transition: background 0.2s; }
.iconbtn:active { background: var(--panel-2); }

/* bottom tabs */
#tabs { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: var(--tabs); padding: 0 max(8px, calc(50% - 280px)) env(safe-area-inset-bottom); display: flex; background: var(--ground); border-top: 1px solid var(--hair); }
#tabs a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: 600 11px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
#tabs a.on { color: var(--porcelain); }
#tabs a.on::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--cobalt); }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--r); padding: 16px; box-shadow: 0 8px 20px -6px rgb(0 0 0 / 0.55); }
.panel + .panel { margin-top: 12px; }

/* ---------- the route: vertical line with stations ---------- */
.route { list-style: none; margin: 0; padding: 0; }
.stop { position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 0 8px 48px; }
.stop::before { content: ""; position: absolute; left: 17px; top: 0; bottom: 0; width: 6px; background: var(--ink); }
.route > :first-child::before { top: 50%; }
.route > :last-child::before { bottom: 50%; }
.route > :only-child::before { display: none; }
.stop .dot { position: absolute; left: 10px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; background: var(--ground); border: 4px solid var(--ink); }
.stop.done .dot { background: var(--ink); border-color: var(--ink); }
.stop.today .dot { left: 4px; width: 32px; height: 32px; margin-top: -16px; background: var(--ground); border: 6px solid var(--porcelain); box-shadow: 0 0 0 2px var(--ground); }
.stop.xing { min-height: 36px; }
.stop.xing .dot { display: none; }
.stop.xing span { font: 600 12px/1 var(--display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.stop > a, .stop > .body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit; }
.stop .name { display: block; font: 600 20px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.stop.today .name { font-size: 30px; }
.stop small { display: block; font: 500 14px/1.3 var(--text); color: var(--muted); }
.stop .t { font: 600 18px/1 var(--display); color: var(--porcelain); }
.stop img, .stop .noimg { flex: none; width: 72px; height: 48px; border-radius: 6px; object-fit: cover; background: #fff; }
.stop .noimg { background: var(--panel-2); }
.stop .chev { color: var(--muted); }
.stop .txt { flex: 1; min-width: 0; }
.stop .tools { display: flex; gap: 4px; }
.stop .tools button { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; color: var(--muted); }
.stop .tools button:active { background: var(--panel-2); color: var(--porcelain); }

/* horizontal line with stations: week, weekdays, badges */
.hline { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); padding-top: 4px; }
.hline::before { content: ""; position: absolute; left: calc(50% / var(--n)); right: calc(50% / var(--n)); top: 15px; height: 6px; background: var(--ink); border-radius: 3px; }
.hline > * { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-height: 64px; }
.hline .dot { width: 20px; height: 20px; margin-top: 3px; border-radius: 50%; background: var(--ground); border: 4px solid var(--ink); }
.hline .on .dot { background: var(--porcelain); }
.hline .now .dot { width: 30px; height: 30px; margin-top: -2px; background: var(--ground); border: 6px solid var(--porcelain); }
.hline b { font: 600 13px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; }
.hline small { font: 500 12px/1 var(--text); color: var(--muted); margin-top: -2px; }
.hline.scroll { display: flex; overflow-x: auto; margin: 0 -16px; padding: 4px 16px; scrollbar-width: none; }
.hline.scroll::before { left: 46px; right: auto; width: calc(var(--n) * 64px - 64px); }
.hline.scroll > * { flex: none; width: 64px; }
.hline.scroll::-webkit-scrollbar { display: none; }

/* ---------- workouts home ---------- */
.yourline { padding: 16px 16px 8px; }
.yourline header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--ink); color: var(--ground); font: 700 13px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.pill.amber, .pill.green { color: var(--ground); }
.pill.cobalt, .pill.scarlet { color: #fff; }
.totals { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font: 500 14px/1.3 var(--text); color: var(--muted); }
.totals b { color: var(--porcelain); font: 600 17px/1 var(--display); margin-right: 3px; }

/* program rows in the network */
.prog img { width: 88px; height: 56px; }

/* buttons */
.go { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; border-radius: 28px; background: var(--porcelain); color: var(--ground); font: 700 20px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; transition: transform 0.15s var(--ease); }
.go:active { transform: scale(0.98); }
.go:disabled { opacity: 0.35; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--hair-2); font: 600 15px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; }
.btn:active { background: var(--panel-2); }
.btn.danger { background: var(--scarlet); border-color: var(--scarlet); color: #fff; }
.sticky { position: sticky; bottom: calc(var(--tabs) + 12px); margin-top: 20px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.45); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.actions .go { flex: 1; width: auto; min-width: 150px; }

/* hero banner on a program */
.banner { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; background: var(--panel-2) center / cover; margin-bottom: 16px; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgb(11 18 48 / 0.85)); }
.banner .meta { position: absolute; z-index: 1; left: 16px; right: 16px; bottom: 14px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.progress { height: 6px; border-radius: 3px; background: var(--hair); overflow: hidden; margin: 8px 0 4px; }
.progress div { height: 100%; background: var(--ink); }

/* inputs */
.filters { display: flex; gap: 8px; margin: 4px 0 16px; }
.field { position: relative; display: block; }
input[type=search], input[type=text], input[type=number], select { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--hair-2); border-radius: var(--r); background: var(--panel); font: 500 16px var(--text); color: var(--porcelain); appearance: none; -webkit-appearance: none; }
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgb(30 136 229 / 0.35); }
select { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23aab1c9' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.filters select { width: 44%; }
input[type=range] { width: 100%; accent-color: var(--cobalt); height: 32px; }
.row-field { display: grid; gap: 8px; margin-bottom: 16px; }
.row-field > span { display: flex; justify-content: space-between; align-items: baseline; }
.row-field output { font: 700 22px/1 var(--display); }

/* segmented control */
.seg { display: flex; border: 1px solid var(--hair-2); border-radius: 24px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 40px; border-radius: 20px; font: 600 14px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.seg button.on { background: var(--porcelain); color: var(--ground); }

/* exercise detail */
.media { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--r); background: #fff; }
.facts { display: grid; grid-template-columns: auto 1fr; margin: 16px 0; border-top: 1px solid var(--hair); }
.facts dt, .facts dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.facts dt { font: 600 13px/1.6 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding-right: 16px; }
.tip { font-size: 16px; line-height: 1.55; max-width: 62ch; }

/* meals */
.daymeal header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.daymeal header b { font: 700 20px/1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; }
.daymeal header span { font: 700 20px/1 var(--display); }
.daymeal label { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.daymeal select { min-height: 44px; font-size: 15px; }
.recipes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hair); }
.recipes li { display: flex; gap: 12px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--hair); }
.recipes li div { flex: 1; min-width: 0; }
.recipes b { display: block; font: 600 17px/1.2 var(--text); }
.recipes small { color: var(--muted); font-size: 14px; }
.recipes .k { font: 700 22px/1 var(--display); text-align: right; white-space: nowrap; }
.recipes .k small { display: block; font: 600 11px/1.4 var(--display); letter-spacing: 0.12em; text-transform: uppercase; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--hair-2); font: 600 14px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.chip.on { background: var(--porcelain); border-color: var(--porcelain); color: var(--ground); }

/* report */
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { padding: 12px 0; border-bottom: 1px solid var(--hair); text-align: left; }
.board th { font: 600 13px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.board td { text-align: right; font: 700 22px/1 var(--display); }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 168px; }
.bars div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font: 600 12px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bars i { display: block; width: 100%; max-width: 28px; border-radius: 4px 4px 0 0; background: var(--hair); min-height: 4px; }
.bars .on i { background: var(--cobalt); }
.bars .on span { color: var(--porcelain); }
.bmi { display: flex; align-items: baseline; gap: 12px; }
.bmi .num { font-size: 48px; line-height: 1; }
.scale { position: relative; height: 8px; border-radius: 4px; margin: 20px 0 10px; background: linear-gradient(90deg, var(--cobalt) 0 13.6%, var(--green) 13.6% 40%, var(--amber) 40% 60%, var(--scarlet) 60%); }
.scale i { position: absolute; top: -8px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: var(--ground); border: 5px solid var(--porcelain); }
.hist { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--hair); }
.hist > div { flex: 1; min-width: 0; }
.hist b { display: block; font: 600 18px/1.2 var(--display); text-transform: uppercase; letter-spacing: 0.02em; }

/* sheet (exercise picker) */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--ground); display: flex; flex-direction: column; animation: rise 0.35s var(--ease); }
.sheet header { display: flex; gap: 8px; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--hair); }
.sheet .list { flex: 1; overflow-y: auto; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
.addbtn { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--porcelain); color: var(--ground); flex: none; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

/* ---------- player ---------- */
#player { position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: var(--ground); padding: calc(8px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
#player .wrap { max-width: 560px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; }
#player .bar { display: flex; align-items: center; gap: 12px; height: 52px; }
#player .bar .label { flex: 1; text-align: center; color: var(--porcelain); font-size: 15px; }
.phase { font: 700 14px/1 var(--display); letter-spacing: 0.16em; text-transform: uppercase; padding: 6px 10px; border-radius: 4px; background: var(--ph); color: var(--ground); min-width: 44px; text-align: center; }
/* the signature: the session as a line, a train dot riding it */
.ride { position: relative; height: 36px; margin: 8px 6px 16px; }
.ride::before { content: ""; position: absolute; left: 0; right: 0; top: 15px; height: 6px; border-radius: 3px; background: var(--hair-2); }
.ride .done-line { position: absolute; left: 0; top: 15px; height: 6px; border-radius: 3px; background: var(--ink); }
.ride .st { position: absolute; top: 12px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--ground); border: 3px solid var(--hair-2); }
.ride .st.on { border-color: var(--ink); background: var(--ink); }
.ride .train { position: absolute; top: 4px; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: var(--ground); border: 6px solid var(--porcelain); box-shadow: 0 2px 10px rgb(0 0 0 / 0.5); }
#player .media { flex: 1 1 200px; min-height: 180px; max-height: 56vh; aspect-ratio: auto; object-fit: contain; box-shadow: 0 10px 30px rgb(0 0 0 / 0.4); }
#player .now { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 20px; }
#player .now h2 { margin: 0; font: 700 32px/1.05 var(--display); letter-spacing: 0.01em; text-transform: uppercase; display: block; }
#player .now h2::before { display: none; }
.clock { font: 700 clamp(104px, 34vw, 168px)/0.9 var(--display); letter-spacing: 0.01em; font-variant-numeric: tabular-nums; text-align: center; margin: 20px 0 4px; }
.clock.paused { color: var(--muted); }
.next { text-align: center; font: 500 16px/1.3 var(--text); color: var(--muted); min-height: 21px; }
.next b { color: var(--porcelain); font-weight: 600; }
.controls { display: flex; gap: 24px; justify-content: center; align-items: center; margin-top: auto; padding-top: 24px; }
.controls button { width: 64px; height: 64px; border-radius: 32px; display: grid; place-items: center; border: 1px solid var(--hair-2); }
.controls button svg { width: 28px; height: 28px; }
.controls .main { width: 88px; height: 88px; border-radius: 44px; background: var(--porcelain); color: var(--ground); border: 0; }
.controls .main svg { width: 36px; height: 36px; stroke-width: 2.6; }
.confirm { margin-top: auto; padding: 20px 16px; border: 1px solid var(--hair-2); border-radius: var(--r); text-align: center; background: var(--panel); }
.confirm p { margin: 0 0 16px; font: 600 20px/1.2 var(--display); text-transform: uppercase; letter-spacing: 0.04em; }
.confirm .actions { justify-content: center; margin: 0; }
.arrived { margin: auto 0; text-align: center; }
.arrived h1 { font-size: 56px; }
.arrived .board { margin: 28px 0; }

#toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs) + 16px); background: var(--porcelain); color: var(--ground); padding: 12px 20px; border-radius: 24px; font: 600 15px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; box-shadow: 0 8px 24px rgb(0 0 0 / 0.4); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
