/* zenbook design system (redesign 2026-11-07): a native-feeling iOS web app.
   White / neutral surfaces, near-black text, one purple accent; status colours only for status.
   Light and dark (prefers-color-scheme). One column, max 640 px, 16 px gutter, 4/8 px grid.
   Visuals are compact; every control still has a 44 px touch target.
   WCAG AA: every text/background pair is checked in both themes by tests/test_contrast.py. */
:root {
  --bg: #FFFFFF;
  --bg-2: #F2F2F7;            /* grouped cells, selected strip day off-state, inputs */
  --fill: #EDEDF2;            /* neutral button fill (Book) */
  --sep: #E2E2E7;             /* hairlines */

  --text: #111114;
  --text-2: #66666D;          /* secondary text: meta lines, end times, headers */

  --accent: #5440D8;          /* accent text and icons */
  --accent-fill: #5440D8;     /* solid accent (selected day, primary button) */
  --on-accent: #FFFFFF;
  --accent-soft: rgba(84, 64, 216, 0.10);

  --ok: #13773A;              /* Booked */
  --ok-soft: rgba(52, 199, 89, 0.15);
  --wait: #935300;            /* Waitlist */
  --wait-soft: rgba(255, 149, 0, 0.16);
  --bad: #C0261B;             /* Failed, Full, danger */
  --bad-soft: rgba(255, 59, 48, 0.11);

  /* Class families: the row's left rail only, never text (3:1 on --bg, tests/test_contrast.py). */
  --fam-strength: #D2685C;
  --fam-engine: #5B8FD6;
  --fam-gymnastics: #BF7A20;
  --fam-mobility: #48975A;
  --fam-wod: #7C5CF6;
  --fam-named: #D86598;
  --fam-open: #8E8E96;
  --fam-other: #8E8E96;

  --r: 10px;                  /* buttons, cells, notices */
  --r-sm: 8px;                /* row buttons, pills */
  --g: 16px;                  /* side gutter */
  --row-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #1C1C1E;
    --fill: #26262A;
    --sep: #2A2A2E;

    --text: #F4F4F6;
    --text-2: #9C9CA3;

    --accent: #A497FF;
    --accent-fill: #5B49E0;
    --on-accent: #FFFFFF;
    --accent-soft: rgba(140, 125, 255, 0.18);

    --ok: #5BD27C;
    --ok-soft: rgba(48, 209, 88, 0.16);
    --wait: #FFB340;
    --wait-soft: rgba(255, 159, 10, 0.16);
    --bad: #FF6961;
    --bad-soft: rgba(255, 69, 58, 0.16);

    --fam-strength: #E07A6E;
    --fam-engine: #6E9FE6;
    --fam-gymnastics: #D9952E;
    --fam-mobility: #5FB872;
    --fam-wod: #8C74FF;
    --fam-named: #E278A8;
    --fam-open: #7C7C85;
    --fam-other: #7C7C85;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.i { display: inline-block; flex: 0 0 auto; width: 20px; height: 20px; vertical-align: middle; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- type scale */
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
/* Section header: one style for days, Weekly, Settings groups. */
.sec {
  margin: 0; padding: 20px var(--g) 6px; font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2);
}
.empty { margin: 0; padding: 12px var(--g); color: var(--text-2); }

/* ---------------------------------------------------------------- frame */
main { max-width: 640px; margin: 0 auto; padding: 0 0 24px; }
body.has-tabs main { padding-bottom: calc(50px + env(safe-area-inset-bottom) + 24px); }
/* Pages without tabs (sign in, setup, messages) keep a small brand bar. */
.top { display: flex; align-items: center; min-height: 44px; padding: 0 var(--g); max-width: 640px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.page-head {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px var(--g) 0;
}
.page-head h1 { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  height: calc(50px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 0.5px solid var(--sep);
}
.tab {
  flex: 0 1 160px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; min-height: 44px; font-size: 10px; font-weight: 500; color: var(--text-2);
}
.tab .i { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------------------------------------------------------------- banner and notices */
.banner {
  max-width: 640px; margin: 0 auto; padding: 8px var(--g);
  font-size: 13px; font-weight: 500; line-height: 1.35;
}
.banner a { color: inherit; text-decoration: underline; }
.banner-danger { background: var(--bad-soft); color: var(--bad); }
.banner-callout { background: var(--wait-soft); color: var(--wait); }
.banner-muted { background: var(--bg-2); color: var(--text); }
.notice {
  margin: 8px var(--g); padding: 10px 12px; border-radius: var(--r);
  font-size: 14px; font-weight: 500; background: var(--bg-2); color: var(--text);
}
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-callout { background: var(--wait-soft); color: var(--wait); }
.notice-danger { background: var(--bad-soft); color: var(--bad); }
.notice a { color: inherit; text-decoration: underline; }
.error { color: var(--bad); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.line { margin: 0 0 6px; font-size: 14px; }
.line-ok { color: var(--ok); }
.line-danger { color: var(--bad); }
.line-muted { color: var(--text-2); }

/* ---------------------------------------------------------------- buttons */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r); border: 0;
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  color: var(--on-accent); background: var(--accent-fill);
}
button:active, .button:active { opacity: 0.6; }
button.ghost, .button.ghost, button.secondary, .button.secondary { background: var(--fill); color: var(--accent); }
button.danger, .button.danger { background: var(--bad-soft); color: var(--bad); }
button.link, .button.link { background: none; color: var(--accent); padding: 0 4px; }
button.link.danger { background: none; color: var(--bad); }
button.compact, .button.compact { min-height: 36px; padding: 0 12px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.actions > * { flex: 1 1 auto; }

/* ---------------------------------------------------------------- status pills (word + tint) */
.pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg-2); color: var(--text-2);
}
.pill-booked { background: var(--ok-soft); color: var(--ok); }
.pill-waitlisted { background: var(--wait-soft); color: var(--wait); }
.pill-scheduled { background: var(--accent-soft); color: var(--accent); }
.pill-failed { background: var(--bad-soft); color: var(--bad); }
.pill-muted, .pill-dry { background: var(--bg-2); color: var(--text-2); }
.st-ok { color: var(--ok); }
.st-auto { color: var(--accent); }
.st-wait { color: var(--wait); }
.st-bad { color: var(--bad); }

/* ---------------------------------------------------------------- forms */
label { display: block; margin: 0; font-weight: 500; }
input[type=email], input[type=password], input[type=number], select {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 0; border-radius: var(--r); min-height: 44px; padding: 0 12px;
}
input[type=email], input[type=password] { display: block; width: 100%; margin-top: 6px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent-fill); }
fieldset { border: 0; margin: 0; padding: 0; }
form { margin: 0; }
label.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400; }

/* ---------------------------------------------------------------- lists: the one row component */
.list { list-style: none; margin: 0; padding: 0; }
.row { position: relative; scroll-margin-top: 140px; }
.row + .row::after {
  content: ""; position: absolute; top: 0; left: calc(var(--g) + 52px); right: 0;
  border-top: 0.5px solid var(--sep);
}
.row-d > summary { list-style: none; }
.row-d > summary::-webkit-details-marker { display: none; }
.row-sum {
  display: flex; align-items: center; gap: 12px; min-height: var(--row-h);
  padding: 6px var(--g); cursor: pointer;
}
.row.has-act .row-sum { padding-right: calc(var(--g) + 84px); }
.row-d[open] > .row-sum { background: var(--bg-2); }
/* Left rail by class family (scan a day by type). */
.row-sum::before {
  content: ""; position: absolute; left: 6px; top: 14px; height: 28px; width: 3px;
  border-radius: 2px; background: var(--fam-other);
}
.fam-strength .row-sum::before { background: var(--fam-strength); }
.fam-engine .row-sum::before { background: var(--fam-engine); }
.fam-gymnastics .row-sum::before { background: var(--fam-gymnastics); }
.fam-mobility .row-sum::before { background: var(--fam-mobility); }
.fam-wod .row-sum::before { background: var(--fam-wod); }
.fam-named .row-sum::before { background: var(--fam-named); }
.fam-open .row-sum::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fam-open); }
.canceled .row-sum::before { background: var(--fam-other); box-shadow: none; }
.time {
  flex: 0 0 40px; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25;
}
.t-end { display: block; font-size: 12px; font-weight: 400; color: var(--text-2); }
.row-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.name-line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-line .i { width: 14px; height: 14px; color: var(--accent); }
.meta { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta > span + span::before { content: " · "; color: var(--text-2); }
.state { flex: 0 0 auto; }
.canceled .name { text-decoration: line-through; color: var(--text-2); }
/* The row's one direct action (Book / Waitlist), over the summary's right side. */
.row-act { position: absolute; top: calc((var(--row-h) - 44px) / 2); right: var(--g); }
.btn-book {
  min-height: 44px; min-width: 76px; padding: 0; background: none; color: var(--accent);
  font-size: 14px; font-weight: 600;
}
.btn-book > span {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  height: 30px; padding: 0 12px; border-radius: var(--r-sm); background: var(--fill);
}
.btn-book[disabled] { opacity: 0.6; }
/* The row's panel: what this class needs, nothing general (that lives in Settings). */
.row-panel { padding: 4px var(--g) 12px calc(var(--g) + 52px); background: var(--bg-2); }
.p-info { margin: 0 0 8px; font-size: 13px; color: var(--text-2); }
.p-act { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.p-act .p-info { flex: 1 1 9rem; margin: 0; }
.p-act button { min-height: 36px; padding: 0 14px; font-size: 14px; }
.p-act button.danger { background: var(--bg); }
.p-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; border-top: 0.5px solid var(--sep); }
.p-line > span { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.p-line .sub { color: var(--text-2); font-size: 13px; }
.p-line .i { width: 16px; height: 16px; color: var(--accent); }
/* iOS-style switch (a submit button: one tap turns Weekly on or off). */
.switch {
  position: relative; flex: 0 0 auto; width: 51px; min-height: 31px; height: 31px; padding: 0;
  border-radius: 16px; background: var(--fill); box-shadow: inset 0 0 0 1px var(--sep);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: left .15s;
}
.switch[aria-checked="true"] { background: var(--ok); box-shadow: none; }
.switch[aria-checked="true"]::after { left: 22px; }
/* Segmented control (Book at: opening / +1 min). */
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-sm); background: var(--fill); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 5px 10px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.seg input:checked + span { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
/* Options (rare): a text disclosure. */
.opts > summary {
  display: inline-flex; align-items: center; min-height: 44px; list-style: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--accent);
}
.opts > summary::-webkit-details-marker { display: none; }
.opts-body { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-bottom: 4px; }
.opts-body label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; font-weight: 400; }
.opts-body input[type=number] { width: 4.5rem; min-height: 36px; }
.opts-body button { min-height: 36px; font-size: 14px; }
/* Workout text. */
.wod { margin: 4px 0 4px; border-top: 0.5px solid var(--sep); padding-top: 8px; }
.wod-part { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.wod-part strong { display: block; font-weight: 600; }
.wod-text { white-space: pre-line; overflow-wrap: break-word; }
.wod .muted, .no-wod { font-size: 13px; color: var(--text-2); margin: 0 0 4px; }
/* One-line feedback under a row after an action. */
.row-notice { margin: 0; padding: 0 var(--g) 10px calc(var(--g) + 52px); font-size: 13px; font-weight: 500; background: none; border-radius: 0; }
.row-notice.notice-ok { color: var(--ok); }
.row-notice.notice-callout { color: var(--wait); }
.row-notice.notice-danger { color: var(--bad); }
.row-over { display: flex; align-items: center; gap: 8px; padding: 0 var(--g) 10px calc(var(--g) + 52px); }
.row-over .row-notice { flex: 1; padding: 0; }
.row-over button { min-height: 36px; font-size: 14px; }

/* ---------------------------------------------------------------- Week: header, day strip, day */
.wk-top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding-top: env(safe-area-inset-top); margin-top: calc(-1 * env(safe-area-inset-top));
  border-bottom: 0.5px solid var(--sep);
}
.wk-head { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 8px 0 var(--g); }
.wk-head h1 { flex: 0 1 auto; }
.wk-range { flex: 1; font-size: 15px; color: var(--text-2); white-space: nowrap; }
.wk-nav { display: flex; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  color: var(--accent); border-radius: var(--r);
}
.icon-btn.off { color: var(--text-2); opacity: 0.3; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 6px 12px 10px; }
.sd {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px;
  border-radius: var(--r); color: var(--text);
}
.sd-w { font-size: 12px; font-weight: 500; color: var(--text-2); }
.sd-n { font-size: 17px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.sd-dots { display: flex; gap: 3px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-2); }
.dot-ok { background: var(--ok); }
.dot-wait { background: var(--wait); }
.dot-auto { background: var(--accent); }
.dot-bad { background: var(--bad); }
.sd.today .sd-n { color: var(--accent); }
.sd.past { opacity: 0.45; }
.sd[aria-current="true"] { background: var(--accent-fill); }
.sd[aria-current="true"] .sd-w, .sd[aria-current="true"] .sd-n { color: var(--on-accent); }
.sd[aria-current="true"] .dot { box-shadow: 0 0 0 1.5px var(--on-accent); }
.sd[aria-current="true"].past { opacity: 1; }
.day-head { display: flex; align-items: center; justify-content: space-between; }
.day-head .sec { flex: 1; }
.day-head form { padding: 12px var(--g) 0 0; }
.day-head button { min-height: 32px; font-size: 14px; }

/* ---------------------------------------------------------------- Classes: filter, weekly list */
.filter { position: relative; flex: 0 0 auto; }
.filter select {
  -webkit-appearance: none; appearance: none; min-height: 32px; max-width: 11rem;
  padding: 0 28px 0 12px; border-radius: var(--r-sm); background: var(--fill);
  font-size: 14px; font-weight: 600; color: var(--accent); text-overflow: ellipsis;
}
.filter .i { position: absolute; right: 8px; top: 50%; width: 14px; height: 14px; margin-top: -7px; color: var(--accent); pointer-events: none; }
.sec.sticky { position: sticky; top: 0; z-index: 4; background: var(--bg); }
.rule .row-sum::before { display: none; }
.rule .row-sum { gap: 12px; }
.rule-ic { flex: 0 0 40px; display: flex; color: var(--accent); }
.p-act form { display: contents; }

/* ---------------------------------------------------------------- cards (sign in, setup, messages, Settings groups) */
.card { margin: 0 var(--g) 8px; padding: 4px 16px; border-radius: 12px; background: var(--bg-2); }
.card > h1, .card > h2 { margin: 12px 0 8px; }
.card > p { margin: 8px 0; }
.card.narrow { max-width: 26rem; margin: 24px auto; padding: 16px; }
.card.narrow label { margin: 12px 0; }
.card.narrow button { width: 100%; margin-top: 8px; }
.card.warn { background: var(--wait-soft); }
.card input[type=email], .card input[type=password], .card input[type=number] { background: var(--bg); }
.qr { background: #fff; display: inline-block; padding: 8px; border-radius: var(--r); }
.qr svg { display: block; width: 200px; height: auto; }
code.topic { word-break: break-all; }

/* ---------------------------------------------------------------- Settings: grouped cells */
.cell {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 6px 0; border-top: 0.5px solid var(--sep); font-weight: 400;
}
.card > .cell:first-child, .card > form:first-child > .cell:first-child { border-top: 0; }
.cell input[type=number] { width: 6rem; text-align: right; }
.cell .seg span { padding: 5px 12px; }
.cell-note { margin: 0; padding: 4px 0 8px; font-size: 13px; color: var(--text-2); }
.card details > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; list-style: none; cursor: pointer; }
.card details > summary::-webkit-details-marker { display: none; }
.save-bar { padding: 8px var(--g) 0; }
.save-bar button { width: 100%; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { padding: 10px 0; border-top: 0.5px solid var(--sep); }
.facts li:first-child { border-top: 0; }

/* ---------------------------------------------------------------- wide screens: centred column */
@media (min-width: 700px) {
  .tab { flex-direction: row; gap: 6px; font-size: 13px; }
}
.card label.stack { padding: 10px 0 4px; font-size: 13px; color: var(--text-2); font-weight: 400; }
.p-info.line-danger { color: var(--bad); }
/* Settings on/off cells: checkboxes drawn as iOS switches (still real checkboxes). */
.cell input[type=checkbox] {
  -webkit-appearance: none; appearance: none; position: relative; flex: 0 0 auto;
  width: 51px; height: 31px; border-radius: 16px; background: var(--fill); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--sep); transition: background .15s;
}
.cell input[type=checkbox]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: left .15s;
}
.cell input[type=checkbox]:checked { background: var(--ok); box-shadow: none; }
.cell input[type=checkbox]:checked::after { left: 22px; }
