/* =========================================================================
   Two Directions — visual system

   The premise of the app is that two people are pulling in opposite
   directions on the same schedule. Each profile slot owns a colour so you
   always know whose screen you are on; direction is carried separately, by
   the trend arrows. Everything accented reads from --accent, which is
   re-pointed by [data-who] on <html>.
   ========================================================================= */

:root {
  /* Neutrals carry a faint violet bias so they sit with either accent
     rather than reading as generic grey. */
  --ground: #F1F0F5;
  --surface: #FFFFFF;
  --surface-2: #E8E7EF;
  --surface-3: #DEDCE7;
  --line: #D8D6E2;
  --line-strong: #C2BFD1;
  --text: #15161E;
  --text-muted: #585A6B;
  --text-faint: #85879A;

  /* One accent per profile slot. Darker here to hold contrast on light. */
  --p1: #3A62D4;
  --p2: #A9660D;

  /* Semantic state, deliberately separate from the slot accents. */
  --good: #26855A;
  --over: #C4443C;
  --good-tint: #26855A22;
  --over-tint: #C4443C22;

  --shadow: 0 1px 2px rgba(20, 20, 35, .06), 0 8px 24px rgba(20, 20, 35, .05);
  --shadow-lift: 0 2px 4px rgba(20, 20, 35, .08), 0 16px 40px rgba(20, 20, 35, .12);

  --r-card: 14px;
  --r-ctl: 9px;

  --font-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #111219;
    --surface: #191A23;
    --surface-2: #22232F;
    --surface-3: #2C2D3B;
    --line: #2C2D3B;
    --line-strong: #3E4052;
    --text: #E8E8F1;
    --text-muted: #9A9CB0;
    --text-faint: #6C6E83;

    --p1: #7CA0FF;
    --p2: #F0A93B;

    --good: #45BE87;
    --over: #F0736A;
    --good-tint: #45BE8722;
    --over-tint: #F0736A22;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .45), 0 16px 40px rgba(0, 0, 0, .45);
  }
}

:root[data-theme="dark"] {
  --ground: #111219;
  --surface: #191A23;
  --surface-2: #22232F;
  --surface-3: #2C2D3B;
  --line: #2C2D3B;
  --line-strong: #3E4052;
  --text: #E8E8F1;
  --text-muted: #9A9CB0;
  --text-faint: #6C6E83;

  --p1: #7CA0FF;
  --p2: #F0A93B;

  --good: #45BE87;
  --over: #F0736A;
  --good-tint: #45BE8722;
  --over-tint: #F0736A22;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .45), 0 16px 40px rgba(0, 0, 0, .45);
}

/* Whose app is it right now. */
:root { --accent: var(--p1); }
:root[data-who="p1"] { --accent: var(--p1); }
:root[data-who="p2"] { --accent: var(--p2); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.02em;
  text-wrap: balance;
  margin: 0;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

:where(a) { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ app shell */

.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  flex: none;
}
:root[data-theme="dark"] .brand-mark,
:root[data-who="p2"] .brand-mark { color: #14151C; }

.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: -.03em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-faint); line-height: 1.2; }

/* Profile switcher — the two of you, always both visible. */
.who { display: flex; flex-direction: column; gap: 4px; }

.who-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  background: none;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.who-btn:hover { background: var(--surface-2); }
.who-btn[aria-pressed="true"] { background: var(--surface-2); border-color: var(--line-strong); }

.who-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.who-dot[data-p="p1"] { background: var(--p1); }
.who-dot[data-p="p2"] { background: var(--p2); }

.who-name { font-weight: 600; font-size: 13.5px; }
.who-meta { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-ctl);
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.nav-btn svg { flex: none; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.main { min-width: 0; padding: 26px 30px 60px; }

.page-head { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; }
.page-head p { margin: 3px 0 0; color: var(--text-muted); font-size: 14px; max-width: 62ch; }

/* --------------------------------------------------------------- pieces */

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 17px;
  box-shadow: var(--shadow);
}
.card > .eyebrow { display: block; margin-bottom: 10px; }
.card h3 { font-size: 16px; margin-bottom: 3px; }

.stat-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat-unit { font-size: 13px; color: var(--text-faint); font-weight: 400; }
.stat-note { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }

/* Direction chip. The same fall in weight is good news for one of you and
   bad news for the other, so the colour comes from intent, not sign. */
.trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  padding: 2px 7px; border-radius: 999px;
}
.trend[data-dir="good"] { background: var(--good-tint); color: var(--good); }
.trend[data-dir="bad"] { background: var(--over-tint); color: var(--over); }
.trend[data-dir="flat"] { background: var(--surface-2); color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--text);
  font-weight: 600; font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-who="p2"] .btn.primary { color: #14151C; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn.ghost { border-color: transparent; background: none; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }

.input, .select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl);
  background: var(--ground);
  color: var(--text);
}
.input:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
}
.chip.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.rowline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* --------------------------------------------------- calorie ring + bars */

.ring-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; max-width: 620px; }
.ring { position: relative; width: 152px; height: 152px; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.3, 1, .4, 1); }
.ring-fill.over { stroke: var(--over); }
.ring-mid {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
}
.ring-num { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -.04em; line-height: 1; }
.ring-of { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.ring-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); font-family: var(--font-mono); margin-top: 3px; }

.macros { display: flex; flex-direction: column; gap: 11px; flex: 1; min-width: 190px; }
.macro-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.macro-head b { font-weight: 600; }
.macro-head span { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }
.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s ease; }
.bar i[data-m="p"] { background: var(--accent); }
.bar i[data-m="c"] { background: color-mix(in srgb, var(--accent) 55%, var(--text-faint)); }
.bar i[data-m="f"] { background: color-mix(in srgb, var(--accent) 30%, var(--text-faint)); }

/* ------------------------------------------------------------- training */

.week { display: grid; gap: 8px; }

.day {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.day:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.day:active { transform: translateY(1px); }
.day[data-today="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day[data-kind="rest"] { background: var(--ground); cursor: default; }
.day[data-kind="rest"]:hover { border-color: var(--line); box-shadow: none; }

.day-dow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.day-date { font-family: var(--font-mono); font-size: 17px; font-weight: 600; line-height: 1.1; }
.day-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.day-focus { font-size: 12.5px; color: var(--text-muted); }
.day-tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--good); color: #fff; flex: none; }

/* Session player */
.session { display: grid; gap: 12px; }

.ex-row {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}
.ex-row[data-done="true"] { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }

.ex-top { display: flex; align-items: center; gap: 13px; padding: 13px 15px; }
.ex-idx {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--text-muted);
}
.ex-row[data-done="true"] .ex-idx { background: var(--good); color: #fff; }
.ex-name { font-weight: 600; font-size: 14.5px; }
.ex-scheme { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.ex-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.sets { display: flex; gap: 6px; padding: 0 15px 13px; flex-wrap: wrap; }
.set-btn {
  min-width: 42px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--ground);
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.set-btn:hover { border-color: var(--accent); }
.set-btn[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }

.weight-in {
  width: 74px; padding: 5px 8px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--ground);
  font-family: var(--font-mono); font-size: 12px;
  text-align: right;
}

/* Rest timer */
.timer {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift);
}
.timer[hidden] { display: none; }
.timer-num { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: -.02em; min-width: 62px; text-align: center; }
.timer-ring { width: 34px; height: 34px; flex: none; }
.timer-ring circle { fill: none; stroke-width: 4; }
.timer-ring .t-track { stroke: var(--surface-3); }
.timer-ring .t-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }

/* ------------------------------------------------- exercise detail sheet */

.sheet-bg {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 10, 18, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.sheet-bg[hidden] { display: none; }

.sheet {
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
}
.sheet-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 22px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 21px; }
.sheet-body { padding: 20px 22px 26px; display: grid; gap: 22px; }
.sheet-close { margin-left: auto; }

.ex-layout { display: grid; grid-template-columns: 222px minmax(0, 1fr); gap: 26px; align-items: start; }

.howto { display: grid; gap: 18px; }
.howto h4 { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); font-family: var(--font-mono); font-weight: 500; margin-bottom: 8px; }
.howto ol { margin: 0; padding-left: 0; list-style: none; counter-reset: step; display: grid; gap: 9px; }
.howto ol li {
  counter-increment: step;
  display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 11px;
  font-size: 14px;
}
.howto ol li::before {
  content: counter(step);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.howto ul { margin: 0; padding-left: 17px; display: grid; gap: 6px; font-size: 13.5px; }
.howto ul li::marker { color: var(--accent); }
.howto .warn li::marker { color: var(--over); }

.muscle-key { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-muted); margin-top: 10px; justify-content: center; flex-wrap: wrap; }
.muscle-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: -1px; }

/* Body map */
.bodymap { display: flex; gap: 8px; justify-content: center; }
.bodymap svg { width: 100%; height: auto; max-width: 106px; }
.bm-base { fill: var(--surface-3); }
.bm-on { fill: var(--accent); }
.bm-sec { fill: color-mix(in srgb, var(--accent) 42%, var(--surface-3)); }
.bm-outline { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.bm-cap { font-family: var(--font-mono); font-size: 9px; fill: var(--text-faint); text-anchor: middle; letter-spacing: .08em; }

/* -------------------------------------------------------------- eat tab */

.searchbar { position: relative; }
.searchbar .input { padding-left: 34px; }
.searchbar svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }

.results { display: grid; gap: 4px; max-height: 340px; overflow-y: auto; margin-top: 10px; }

.food-opt {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  background: var(--ground);
  cursor: pointer; text-align: left; width: 100%;
}
.food-opt:hover { border-color: var(--accent); background: var(--surface-2); }
.food-opt b { font-weight: 600; font-size: 13.5px; display: block; }
.food-opt small { color: var(--text-faint); font-size: 11.5px; font-family: var(--font-mono); }
.food-kcal { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.meal { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.meal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 15px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.meal-head h4 { font-family: var(--font-display); font-size: 13.5px; font-weight: 700; }
.meal-kcal { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }
.meal-list { display: grid; }
.meal-empty { padding: 13px 15px; color: var(--text-faint); font-size: 13px; }

.entry { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 9px 15px; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-name { font-size: 13.5px; }
.entry-sub { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.entry-kcal { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.icon-btn {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: none; color: var(--text-faint); cursor: pointer;
}
.icon-btn:hover { background: var(--over-tint); color: var(--over); }

.datenav { display: flex; align-items: center; gap: 8px; }
.datenav b { font-family: var(--font-display); font-size: 15px; min-width: 116px; text-align: center; }

.tips { display: grid; gap: 8px; }
.tips li { font-size: 13.5px; color: var(--text-muted); display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; }
.tips li::before { content: '→'; color: var(--accent); font-family: var(--font-mono); }
.tips { list-style: none; margin: 0; padding: 0; }

/* -------------------------------------------------------------- charts */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-txt { font-family: var(--font-mono); font-size: 9px; fill: var(--text-faint); }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.chart .goal-line { stroke: var(--good); stroke-width: 1.4; stroke-dasharray: 4 4; }
.chart .cap { fill: var(--accent); }
.chart .cap-ring { fill: var(--surface); stroke: var(--accent); stroke-width: 2.2; }

.chart-empty { display: grid; place-items: center; min-height: 130px; color: var(--text-faint); font-size: 13px; text-align: center; padding: 16px; }

/* ------------------------------------------------------------- us board */

.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }
.versus-mid { display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--text-faint); }

/* Each side reads in its own person's colour, not the active accent —
   this is the one place both identities appear at once. */
.side[data-p="p1"] { --accent: var(--p1); }
.side[data-p="p2"] { --accent: var(--p2); }
.side { display: grid; gap: 12px; }
.side h3 { color: var(--accent); }

.mini-stat { display: flex; align-items: baseline; gap: 7px; }
.mini-stat b { font-family: var(--font-mono); font-size: 19px; font-weight: 600; }
.mini-stat span { font-size: 12px; color: var(--text-muted); }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.badge {
  display: grid; place-items: center; gap: 5px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: var(--ground);
  text-align: center;
}
.badge[data-earned="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.badge-icon { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .4; }
.badge[data-earned="true"] .badge-icon { filter: none; opacity: 1; }
.badge b { font-size: 11.5px; font-weight: 600; }
.badge small { font-size: 10.5px; color: var(--text-faint); line-height: 1.3; }

/* ----------------------------------------------------------- week strip */

.weekstrip { display: grid; gap: 8px; }

/* Each row reads in its own person's colour so the two schedules stay
   distinguishable while sitting on the same grid. */
.ws-row { display: grid; grid-template-columns: 82px repeat(7, minmax(0, 1fr)); gap: 6px; align-items: center; }
.ws-row[data-p="p1"] { --accent: var(--p1); }
.ws-row[data-p="p2"] { --accent: var(--p2); }

.ws-who { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }

.ws-cell {
  display: grid; place-items: center; gap: 2px;
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ground);
  min-width: 0;
}
.ws-cell[data-state="done"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ws-row[data-p="p2"] .ws-cell[data-state="done"] { color: #14151C; }
.ws-cell[data-state="rest"] { opacity: .5; }
.ws-cell[data-today="true"] { box-shadow: 0 0 0 1px var(--accent); }

.ws-d { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.ws-cell[data-state="done"] .ws-d { color: inherit; opacity: .8; }
.ws-n { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (max-width: 560px) {
  .ws-row { grid-template-columns: 58px repeat(7, minmax(0, 1fr)); gap: 4px; }
  .ws-who { font-size: 11.5px; }
  .ws-cell { padding: 7px 1px; }
  .ws-n { font-size: 9.5px; }
}

/* On a wide screen the food search follows you down the meal list. */
@media (min-width: 861px) {
  .sticky-col { position: sticky; top: 20px; }
}

/* --------------------------------------------------------------- toasts */

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: grid; gap: 8px; }
.toast {
  padding: 11px 15px;
  border-radius: var(--r-ctl);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift);
  font-size: 13.5px; font-weight: 500;
  animation: toast-in .25s cubic-bezier(.2, 1, .3, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------- mobile nav */

.tabbar { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  .rail {
    position: static; height: auto;
    flex-direction: row; align-items: center; gap: 14px;
    padding: 12px 16px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .rail .nav, .rail .rail-foot { display: none; }
  .who { flex-direction: row; margin-left: auto; gap: 6px; }
  .who-meta { display: none; }

  .main { padding: 18px 16px 96px; }
  .page-head h1 { font-size: 23px; }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-btn {
    display: grid; place-items: center; gap: 2px;
    padding: 6px 2px;
    border: 0; background: none; cursor: pointer;
    color: var(--text-faint);
    font-size: 10.5px; font-weight: 600;
    border-radius: var(--r-ctl);
  }
  .tab-btn[aria-current="page"] { color: var(--accent); }

  .timer { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toasts { right: 12px; left: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); }

  .ex-layout { grid-template-columns: 1fr; }
  .versus { grid-template-columns: 1fr; }
  .versus-mid { display: none; }
  .ring-wrap { gap: 16px; }
}

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


/* ------------------------------------------------------------ first run */

.setup {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 60px;
  background: var(--ground);
}
.setup-inner { width: min(900px, 100%); display: grid; gap: 20px; }

.setup-head { text-align: center; display: grid; gap: 8px; justify-items: center; }
.setup-head .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.setup-head h1 { font-size: 30px; }
.setup-head p { margin: 0; color: var(--text-muted); max-width: 56ch; font-size: 14.5px; }

.setup-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 14px; }

/* Each side previews the colour that person will carry through the app. */
.setup-card[data-p="p1"] { --accent: var(--p1); }
.setup-card[data-p="p2"] { --accent: var(--p2); }
.setup-card { border-top: 3px solid var(--accent); }
.setup-card h3 { color: var(--accent); margin-bottom: 12px; }

.setup-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setup-fields .wide { grid-column: 1 / -1; }

.setup-foot { display: grid; gap: 10px; justify-items: center; text-align: center; }
.setup-foot .btn { min-width: 240px; }
.setup-note { font-size: 12.5px; color: var(--text-faint); max-width: 60ch; }

/* ---------------------------------------------------------------- cloud */

.cloud-state {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
}
.cloud-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.cloud-dot[data-on="true"] { background: var(--good); }
.cloud-dot[data-on="error"] { background: var(--over); }
