/* The Big Squeeze — one stylesheet, no build step.
   Fraunces (self-hosted, static/fonts/) carries the display voice; body text
   stays on the system stack. Data-series colours (--series-1) are the validated
   pair: #008300 on the light card surface (#fffdf6), #3fae3f on the dark one
   (#171b12) — re-validated against these surfaces with the dataviz palette
   checker. Chrome greens are a different role from the series colour. */

@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page:           #f5f0e1;
  --surface-1:      #fffdf6;
  --surface-2:      #f4eeda;
  --line:           #e7dfc6;
  --line-strong:    #cfc5a3;
  --text-primary:   #201f12;
  --text-secondary: #565645;
  --text-muted:     #7f7d64;
  --brand:          #4d7c0f;
  --brand-deep:     #3b620a;
  --brand-ink:      #ffffff;
  --brand-soft:     #eaf3cf;
  --lime-bright:    #a3e635;
  --logo-rind:      #3f6212;
  --logo-pith:      #f5fbdd;
  --series-1:       #008300;
  --series-neg:     #b3541e;
  --good:           #146c2e;
  --danger:         #a8332f;
  --danger-soft:    #fbeceb;
  --ok-soft:        #e9f3e2;
  --glow-a:         rgb(163 230 53 / 20%);
  --glow-b:         rgb(132 204 22 / 12%);
  --radius:         16px;
  --shadow:         0 1px 2px rgb(59 51 15 / 6%), 0 10px 30px rgb(59 51 15 / 7%);
  --shadow-pop:     0 2px 6px rgb(59 51 15 / 8%), 0 18px 50px rgb(59 51 15 / 12%);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0e120a;
    --surface-1:      #171b12;
    --surface-2:      #202617;
    --line:           #2c331f;
    --line-strong:    #454f31;
    --text-primary:   #f4f6e9;
    --text-secondary: #c1c7a9;
    --text-muted:     #8f957a;
    --brand:          #a3e635;
    --brand-deep:     #8bc926;
    --brand-ink:      #1a2405;
    --brand-soft:     #26301a;
    --lime-bright:    #a3e635;
    --logo-rind:      #547d18;
    --logo-pith:      #ecf7c9;
    --series-1:       #3fae3f;
    --series-neg:     #e08a5a;
    --good:           #6cc487;
    --danger:         #f08a86;
    --danger-soft:    #2c1a19;
    --ok-soft:        #1a2716;
    --glow-a:         rgb(163 230 53 / 7%);
    --glow-b:         rgb(132 204 22 / 5%);
    --shadow:         0 1px 2px rgb(0 0 0 / 45%), 0 10px 30px rgb(0 0 0 / 35%);
    --shadow-pop:     0 2px 6px rgb(0 0 0 / 50%), 0 18px 50px rgb(0 0 0 / 45%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e120a; --surface-1: #171b12; --surface-2: #202617;
  --line: #2c331f; --line-strong: #454f31;
  --text-primary: #f4f6e9; --text-secondary: #c1c7a9; --text-muted: #8f957a;
  --brand: #a3e635; --brand-deep: #8bc926; --brand-ink: #1a2405; --brand-soft: #26301a;
  --lime-bright: #a3e635; --logo-rind: #547d18; --logo-pith: #ecf7c9;
  --series-1: #3fae3f; --series-neg: #e08a5a;
  --good: #6cc487; --danger: #f08a86; --danger-soft: #2c1a19; --ok-soft: #1a2716;
  --glow-a: rgb(163 230 53 / 7%); --glow-b: rgb(132 204 22 / 5%);
  --shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 10px 30px rgb(0 0 0 / 35%);
  --shadow-pop: 0 2px 6px rgb(0 0 0 / 50%), 0 18px 50px rgb(0 0 0 / 45%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 88% -12%, var(--glow-a), transparent 62%),
    radial-gradient(900px 460px at -12% 4%, var(--glow-b), transparent 58%),
    var(--page);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

::selection { background: var(--lime-bright); color: #1a2405; }

a { color: var(--text-primary); text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }

h1, h2, h3, .tile-value, .big-code {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---------- top bar ---------- */

.topbar {
  background: color-mix(in srgb, var(--surface-1) 84%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .55rem 0; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; }
.brand strong {
  display: block; font-family: var(--display); font-weight: 640;
  font-size: 1.1rem; letter-spacing: -.01em; line-height: 1.15;
}
.brand small { display: block; color: var(--text-muted); font-size: .72rem; letter-spacing: .02em; }
.lime-mark { display: block; flex: none; filter: drop-shadow(0 1px 2px rgb(40 50 10 / 25%)); }
.lime-rind { fill: var(--logo-rind); }
.lime-pith { fill: var(--logo-pith); }

.topbar nav { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.topbar nav a, .linkish {
  padding: .38rem .65rem; border-radius: 999px; font-size: .875rem;
  color: var(--text-secondary); text-decoration: none; white-space: nowrap;
}
.topbar nav a:hover, .linkish:hover { background: var(--surface-2); color: var(--text-primary); }
.topbar nav a[aria-current] { background: var(--brand-soft); color: var(--text-primary); font-weight: 600; }
.linkish { background: none; border: 0; font: inherit; cursor: pointer; }
.inline { display: inline; }

/* ---------- bottom tab bar (mobile app shell) ---------- */

.tabbar { display: none; }

@media (max-width: 768px) {
  .topbar nav { display: none; }
  .topbar-inner { padding: .5rem 0; }
  .tabbar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 30;
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: .35rem .35rem calc(.35rem + env(safe-area-inset-bottom));
    gap: .15rem;
  }
  .tab {
    /* min-width: 0 lets tabs shrink below their content, so large system
       font sizes can't push the last tab off the edge of the bar. */
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: .1rem;
    padding: .15rem 0; min-height: 48px; text-decoration: none;
    color: var(--text-muted); font-size: .64rem; font-weight: 600; letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-label {
    /* A long label may bleed a touch into a short neighbour's slack before
       it truncates; the bleed stays under the bar's own side padding, so it
       can never push past the viewport edge. */
    max-width: calc(100% + .5rem);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .tab-ico {
    display: grid; place-items: center; width: min(3.4rem, 100%); height: 1.8rem;
    border-radius: 999px; transition: background .15s ease;
  }
  .tab-ico svg {
    width: 22px; height: 22px; fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  }
  .tab[aria-current] { color: var(--text-primary); }
  .tab[aria-current] .tab-ico { background: var(--brand-soft); }
}

/* ---------- layout ---------- */

main.wrap { padding: 1.75rem 0 2rem; }
.page-head { margin-bottom: 1.4rem; }
.page-head-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem 1rem; flex-wrap: wrap;
}
.page-head-row .track-btn { margin-top: .35rem; flex: none; }
.page-head h1 { margin: 0; font-size: 2.05rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.thin { font-weight: 420; color: var(--text-muted); }
.sub { margin: .3rem 0 0; color: var(--text-secondary); }
.strapline { color: var(--text-muted); font-size: .875rem; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.35rem;
  margin-bottom: 1.35rem;
}
.card.narrow { max-width: 560px; }
.card.center { text-align: center; }
.card-title { margin: 0 0 .2rem; font-size: 1.12rem; font-weight: 600; letter-spacing: -.01em; }
.card-note { margin: .35rem 0 0; color: var(--text-muted); font-size: .82rem; }

.footnote {
  padding-bottom: 2.5rem; color: var(--text-muted); font-size: .8rem;
  max-width: 62ch; text-align: center;
}
.footnote p { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

/* ---------- podium ---------- */

.podium {
  display: grid; grid-template-columns: 1fr 1.15fr 1fr;
  grid-template-areas: "second first third";
  gap: .8rem; align-items: end; margin-bottom: 1.35rem;
}
.podium-step {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: .15rem; text-align: center; text-decoration: none;
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem .9rem 1rem; border-top: 4px solid var(--line-strong);
  transition: transform .15s ease, box-shadow .15s ease;
}
@media (hover: hover) {
  .podium-step:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
}
.podium-step.pos-1 { grid-area: first; min-height: 200px; }
.podium-step.pos-2 { grid-area: second; min-height: 168px; }
.podium-step.pos-3 { grid-area: third; min-height: 150px; }
.podium-step.medal-1 { border-top-color: #e0a92e; }
.podium-step.medal-2 { border-top-color: #b7bdc6; }
.podium-step.medal-3 { border-top-color: #c07c42; }
.podium-step.pos-1.medal-1 {
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, #e0a92e 14%, transparent), transparent 70%),
    var(--surface-1);
}
.podium-medal { width: 2.1rem; height: 2.1rem; font-size: .95rem; margin-bottom: .35rem; }
.podium-name { font-family: var(--display); font-weight: 640; font-size: 1.15rem; letter-spacing: -.01em; }
.podium-step.pos-1 .podium-name { font-size: 1.3rem; }
.podium-score {
  font-family: var(--display); font-variant-numeric: lining-nums tabular-nums;
  font-weight: 560; font-size: 1.7rem; letter-spacing: -.02em; line-height: 1.15;
  color: var(--good);
}
.podium-step.pos-1 .podium-score { font-size: 2.15rem; }
.podium-sub { font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.podium-step.is-you { box-shadow: var(--shadow), 0 0 0 2px color-mix(in oklab, var(--brand) 55%, transparent); }

@media (max-width: 640px) {
  .podium { gap: .45rem; }
  .podium-step { padding: .8rem .4rem .75rem; }
  .podium-step.pos-1 { min-height: 160px; }
  .podium-step.pos-2 { min-height: 134px; }
  .podium-step.pos-3 { min-height: 120px; }
  .podium-name { font-size: .95rem; }
  .podium-step.pos-1 .podium-name { font-size: 1.05rem; }
  .podium-score { font-size: 1.25rem; }
  .podium-step.pos-1 .podium-score { font-size: 1.55rem; }
  .podium-sub { font-size: .7rem; }
}

/* ---------- tiles ---------- */

.tiles {
  display: grid; gap: .8rem; margin-bottom: 1.35rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.tile {
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .95rem 1.05rem; box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
@media (hover: hover) {
  .tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
}
.tile-accent {
  border-color: transparent;
  background: linear-gradient(135deg, #b8ec50, #76b917);
  box-shadow: var(--shadow), inset 0 1px 0 rgb(255 255 255 / 35%);
}
.tile-accent .tile-label { color: #2c4208; }
.tile-accent .tile-value { color: #16260a; }
.tile-accent .tile-unit, .tile-accent .tile-foot { color: #33500b; }
.tile-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-muted); font-weight: 600; }
.tile-value { display: block; font-size: 2rem; font-weight: 560; line-height: 1.2; letter-spacing: -.02em; }
.tile-unit { font-size: .8rem; font-weight: 500; color: var(--text-secondary); margin-left: .3rem; letter-spacing: 0; font-family: var(--sans); }
.tile-foot { display: block; margin-top: .2rem; font-size: .78rem; color: var(--text-muted); }

/* ---------- tables ---------- */

.table-scroll, .chart-scroll { overflow-x: auto; margin-top: .75rem; }
.grid { width: 100%; border-collapse: collapse; font-size: .875rem; }
.grid th, .grid td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--line); }
.grid thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 650; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
.grid tbody tr:last-child th, .grid tbody tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tbody th { font-weight: 600; white-space: nowrap; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.good { color: var(--good); }
.score { font-weight: 700; }
.derived { color: var(--text-secondary); background: var(--surface-2); }

.leaderboard tbody tr, .admin-table tbody tr { transition: background .1s ease; }
.leaderboard tbody tr:hover, .admin-table tbody tr:hover { background: var(--surface-2); }
.leaderboard .rank { width: 2.6rem; }
.leaderboard tr.is-you, .leaderboard tbody tr.is-you:hover {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
.rank-badge {
  display: inline-grid; place-items: center;
  min-width: 1.75rem; height: 1.75rem; padding-inline: .2rem;
  border-radius: 999px; font-weight: 700; font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.rank-badge.rank-1 {
  background: linear-gradient(150deg, #fbe38b, #e0a92e);
  color: #573d06; box-shadow: inset 0 1px 0 rgb(255 255 255 / 55%), 0 1px 3px rgb(87 61 6 / 30%);
}
.rank-badge.rank-2 {
  background: linear-gradient(150deg, #eef0f3, #b7bdc6);
  color: #3d434b; box-shadow: inset 0 1px 0 rgb(255 255 255 / 65%), 0 1px 3px rgb(61 67 75 / 25%);
}
.rank-badge.rank-3 {
  background: linear-gradient(150deg, #eec49e, #c07c42);
  color: #48280e; box-shadow: inset 0 1px 0 rgb(255 255 255 / 45%), 0 1px 3px rgb(72 40 14 / 30%);
}

.leaderboard .move { font-size: .78rem; white-space: nowrap; }
.move-up { color: var(--good); font-weight: 700; }
.move-down { color: var(--danger); font-weight: 700; }
.move-flat { color: var(--text-muted); }
.move-new {
  display: inline-block; font-size: .62rem; text-transform: uppercase; letter-spacing: .07em;
  font-weight: 700; color: var(--text-secondary);
  background: var(--surface-2); border-radius: 999px; padding: .1rem .4rem;
}

.leaderboard .trend { line-height: 0; }
.spark { display: inline-block; vertical-align: middle; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--series-1); }

.scorecell { min-width: 7rem; }
.scorebar {
  display: block; height: 5px; margin-top: .3rem; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.scorebar-fill {
  display: block; height: 100%; border-radius: 999px;
  background: var(--series-1); min-width: 3px;
}
.scorebar-fill.neg { background: var(--series-neg); margin-left: auto; }

.week-track {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  margin: .45rem 0 .3rem; overflow: hidden;
}
.week-fill {
  display: block; height: 100%; border-radius: 999px; min-width: 4px;
  background: linear-gradient(90deg, #b8ec50, #76b917);
}

.wins-list { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: .75rem 0 0; }
.win {
  display: inline-flex; align-items: baseline; gap: .5rem; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .85rem; font-size: .85rem;
}
.win-note { font-style: italic; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-name { font-weight: 650; font-size: .78rem; white-space: nowrap; }

.tracker .baseline-row { background: var(--surface-2); }
.tracker .future-row th, .tracker .future-row td:first-of-type { color: var(--text-muted); }
/* The week column stays put while the rest of the row scrolls on phones. */
.tracker thead th:first-child, .tracker tbody th {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface-1);
  box-shadow: 1px 0 0 var(--line);
}
.tracker .baseline-row th { background: var(--surface-2); }
.tracker input[type="number"] { width: 4.9rem; }
.tracker .notes { min-width: 11rem; }
.tracker .notes input { width: 100%; }
.formula th { width: 12rem; }
.admin-table code { font-family: var(--mono); font-size: .9em; letter-spacing: .04em; }
.admin-table .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.admin-table tr.inactive { opacity: .55; }

.pill {
  display: inline-block; font-size: .64rem; text-transform: uppercase; letter-spacing: .07em;
  padding: .12rem .4rem; border-radius: 999px;
  background: var(--brand-soft); border: 1px solid color-mix(in oklab, var(--brand) 30%, var(--line));
  color: var(--text-secondary); vertical-align: middle; margin-left: .3rem; font-weight: 650;
}

/* ---------- forms ---------- */

input, select, button, textarea { font: inherit; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  padding: .42rem .55rem; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface-1); color: var(--text-primary); max-width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover { border-color: var(--text-muted); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .bar-group:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
input[type="number"] { text-align: right; }
.pin-input {
  text-align: center; letter-spacing: .45em; font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.pin-input::placeholder { letter-spacing: .2em; }

button.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 82%, #d9f99d), var(--brand-deep));
  color: var(--brand-ink); border: 0;
  padding: .55rem 1.15rem; border-radius: 999px; font-weight: 680; cursor: pointer;
  box-shadow: 0 1px 2px rgb(30 40 8 / 25%), inset 0 1px 0 rgb(255 255 255 / 30%);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
button.primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 3px 8px rgb(30 40 8 / 25%), inset 0 1px 0 rgb(255 255 255 / 30%); }
button.primary:active { transform: translateY(0); }
button.small {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--line-strong);
  padding: .3rem .65rem; border-radius: 999px; font-size: .8rem; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
button.small:hover { border-color: var(--text-muted); background: var(--surface-2); }
button.small.quiet { color: var(--text-secondary); }

.stack {
  /* minmax(0, 1fr) caps the column at the container: an input's intrinsic
     width (size attr × letter-spacing, inflated by large device font
     settings) would otherwise force the column past the card edge. */
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .35rem; margin-top: 1rem;
}
.stack input, .stack select { width: 100%; }
.stack label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-top: .5rem; }
.stack button { margin-top: 1rem; }
.row-form { display: flex; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.form-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.hint { color: var(--text-muted); font-size: .8rem; }

.switcher { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .85rem; }
.chip {
  display: inline-block; padding: .28rem .7rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-1);
  font-size: .8rem; text-decoration: none; color: var(--text-secondary);
  transition: transform .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--text-muted); color: var(--text-primary); transform: translateY(-1px); }
.chip-on {
  background: var(--brand-soft); border-color: color-mix(in oklab, var(--brand) 45%, var(--line));
  color: var(--text-primary); font-weight: 650;
}

/* ---------- check-in sheet ----------
   A plain fixed overlay rather than <dialog>: identical behaviour on every
   mobile browser, and the interactive-widget viewport meta keeps it above the
   on-screen keyboard. Bottom sheet on phones, centred card on wider screens. */

.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-scrim {
  position: absolute; inset: 0;
  background: rgb(14 18 10 / 45%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sheet-panel {
  position: relative; width: 100%; max-height: calc(100dvh - 2.5rem);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-1); color: var(--text-primary);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-pop);
  animation: sheet-up .22s ease-out;
}
.sheet-grip {
  width: 2.4rem; height: 4px; border-radius: 999px;
  background: var(--line-strong); margin: .55rem auto 0;
}
.sheet-form { padding: .75rem 1.15rem calc(1.1rem + env(safe-area-inset-bottom)); }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem .8rem; margin-top: .9rem; }
.field { display: grid; gap: .25rem; min-width: 0; }
.field > span { font-size: .78rem; font-weight: 600; color: var(--text-secondary); }
.field input { width: 100%; }
.span-2 { grid-column: 1 / -1; }
.sheet-actions { display: flex; justify-content: flex-end; align-items: center; gap: .6rem; margin-top: 1.15rem; }
body.no-scroll { overflow: hidden; }

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 769px) {
  .sheet { align-items: center; padding: 1rem; }
  .sheet-panel {
    width: min(440px, 100%); border: 1px solid var(--line);
    border-radius: var(--radius); max-height: calc(100vh - 4rem);
  }
  .sheet-grip { display: none; }
  .sheet-form { padding: 1.2rem 1.35rem 1.3rem; }
}

/* ---------- mobile week list (tracker) ---------- */

.week-list { display: none; list-style: none; margin: .75rem 0 0; padding: 0; }
.week-item {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-1); padding: .75rem .9rem;
}
.week-item.is-baseline { background: var(--surface-2); }
.week-item.is-future { opacity: .62; }
.week-item.edit-week { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.week-item.edit-week:active { background: var(--surface-2); }
.week-item-top { display: flex; align-items: center; gap: .5rem; }
.week-item-title { font-weight: 650; }
.week-item-date { color: var(--text-muted); font-size: .8rem; margin-left: auto; }
.week-item-chevron {
  width: 16px; height: 16px; flex: none; fill: none;
  stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.week-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .55rem; }
.ws { display: grid; gap: .05rem; min-width: 0; }
.ws-label {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); font-weight: 650;
}
.ws-value { font-size: .92rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ws-value small { font-size: .68rem; font-weight: 500; color: var(--text-muted); }
.week-note { margin: .5rem 0 0; font-size: .82rem; font-style: italic; color: var(--text-secondary); }
.week-empty { margin: .45rem 0 0; font-size: .82rem; color: var(--text-muted); }

/* ---------- mobile standings list (leaderboard) ---------- */

.board-list { display: none; list-style: none; margin: .75rem 0 0; padding: 0; }
.board-item {
  display: flex; align-items: center; gap: .7rem;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-1); padding: .7rem .8rem;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.board-item:active { background: var(--surface-2); }
.board-item.is-you { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.board-main { flex: 1; min-width: 0; display: grid; gap: .18rem; }
.board-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-sub {
  color: var(--text-muted); font-size: .78rem; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-end { display: grid; gap: .15rem; justify-items: end; flex: none; }
.board-end .score { font-variant-numeric: tabular-nums; }
.board-end .spark { width: 72px; height: 24px; }

/* ---------- mobile admin list ---------- */

.admin-list { display: none; list-style: none; margin: .75rem 0 0; padding: 0; }
.admin-item {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-1); padding: .75rem .9rem;
  display: grid; gap: .55rem;
}
.admin-item.inactive { opacity: .55; }
.admin-item-info { display: grid; gap: .15rem; }
.admin-item-name { font-weight: 650; }
.admin-item-meta { color: var(--text-secondary); font-size: .82rem; }
.admin-item-meta code { font-family: var(--mono); letter-spacing: .06em; }

/* ---------- flashes ---------- */

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.flash { padding: .6rem .85rem; border-radius: 12px; font-size: .875rem; border: 1px solid var(--line); }
.flash-ok { background: var(--ok-soft); border-color: color-mix(in oklab, var(--good) 30%, var(--line)); }
.flash-error { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, var(--line)); color: var(--danger); }

/* ---------- login ---------- */

.login-page {
  display: grid; place-items: center; min-height: 88vh;
  position: relative; isolation: isolate;
}
.login-page::before, .login-page::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  filter: blur(70px); pointer-events: none;
}
.login-page::before {
  width: 420px; height: 420px; top: -4%; right: -6%;
  background: color-mix(in srgb, var(--lime-bright) 26%, transparent);
}
.login-page::after {
  width: 360px; height: 360px; bottom: -6%; left: -8%;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
}
.login-card {
  width: min(410px, 100%); background: var(--surface-1); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-pop); padding: 2rem 1.9rem; text-align: center;
}
.login-card .lime-mark { margin-inline: auto; }
.login-card h1 { margin: .85rem 0 0; font-size: 1.9rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.login-card .sub, .login-card .strapline { margin: .2rem 0 0; }
.login-card .stack { text-align: left; }
.login-card select, .login-card input { width: 100%; }
.login-card .hint { margin-top: 1.1rem; }

/* ---------- steps & lists ---------- */

.steps { margin: .75rem 0 0; padding-left: 1.1rem; display: grid; gap: .5rem; }
.steps::marker, .steps li::marker { color: var(--brand); font-weight: 700; }
.steps strong { display: block; }
.steps span { color: var(--text-secondary); font-size: .9rem; }
.plain { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--text-secondary); }
.plain li::marker { color: var(--brand); }
.big-code { font-size: 3.4rem; font-weight: 700; margin: 0; letter-spacing: -.03em; }
.empty { color: var(--text-muted); font-size: .875rem; padding: 2rem 0; text-align: center; }

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

.charts-row { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-block { min-width: 0; }
.chart-title { margin: 0 0 .25rem; font-size: 1rem; font-weight: 600; }
.chart-note { margin: .35rem 0 0; font-size: .78rem; color: var(--text-muted); }
.chart-holder { position: relative; }
.viz { width: 100%; height: auto; display: block; overflow: visible; }
.bar-viz { min-width: 420px; }

.gridline { stroke: var(--line); stroke-width: 1; }
.axis-zero { stroke: var(--line-strong); stroke-width: 1; }
.tick { fill: var(--text-muted); font-size: 11px; font-family: var(--sans); }
.series-line { fill: none; stroke: var(--series-1); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.dot.is-active { r: 6; }
.crosshair { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; transition: opacity .1s; }
.point-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; font-family: var(--sans); }

.bar { fill: var(--series-1); }
.bar-down { fill: var(--series-neg); }
.bar-group:hover .bar { filter: brightness(1.12); }
.bar-name { fill: var(--text-primary); font-size: 12px; font-family: var(--sans); }
.bar-value { fill: var(--text-secondary); font-size: 11.5px; font-family: var(--sans); font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: .35rem .6rem; font-size: .78rem;
  box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -125%);
}
.tooltip strong { font-variant-numeric: tabular-nums; }

@media (max-width: 768px) {
  /* 16px inputs stop iOS Safari zooming the page on focus. */
  input[type="text"], input[type="password"], input[type="number"],
  input[type="date"], select { font-size: 16px; }

  /* Wide tables swap for vertically stacked lists. */
  .grid-form, .grid-note, .board-table, .admin-table-wrap { display: none; }
  .week-list, .admin-list { display: grid; gap: .55rem; }
  .board-list { display: grid; gap: .5rem; }

  /* SVG text sizes are in viewBox units; bumping them here keeps tick
     labels legible once a 640-unit chart scales down to a phone column. */
  .tick, .point-label { font-size: 16px; }

  .chip { padding: .42rem .85rem; }
  .charts-row { grid-template-columns: 1fr; }

  /* Clear the fixed tab bar: generous, so the last line stays visible even
     when large system font sizes make the bar taller. (This must live after
     the base .footnote rule in the cascade.) */
  .footnote { padding-bottom: calc(7.5rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .page-head h1 { font-size: 1.65rem; }
  .page-head-row .track-btn { width: 100%; margin-top: 0; }
  /* minmax(0, …): don't let a tile's min-content width (big numbers at
     large device font sizes) push the grid past the screen edge. */
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: .8rem .85rem; }
  .tile-value { font-size: 1.6rem; }
  .formula th { width: 8rem; }
  .form-actions .primary, .sheet-actions .primary { flex: 1; }
  .login-page::before, .login-page::after { width: 260px; height: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .tile:hover, .chip:hover, button.primary:hover { transform: none; }
}
