/* ==========================================================================
   WeighIn — design tokens
   Palette: validated categorical set (8 slots), light and dark stepped
   separately against their own surfaces. Both modes pass every check —
   lightness band, chroma floor, CVD separation, normal-vision floor and
   3:1 contrast. Re-run scripts/validate_palette.js before changing any
   of these hexes; softening one slot can break its neighbour's CVD gap.
   ========================================================================== */

:root {
  color-scheme: light;

  --plane:          #f7f5f1;
  --surface-1:      #fbfaf7;
  --surface-2:      #f1efe9;
  --text-primary:   #14120f;
  --text-secondary: #57544e;
  --text-muted:     #8c8880;
  --grid:           #e4e1d8;
  --axis:           #c6c2b6;
  --border:         rgba(20, 18, 15, 0.10);
  --border-strong:  rgba(20, 18, 15, 0.18);

  /* Categorical slots 1-8. Softer than a saturated set but still inside the
     validator's chroma floor — every check passes in both modes, contrast
     included, which the harder palette this replaced did not manage. */
  --series-1: #4a80c8;
  --series-2: #cc6437;
  --series-3: #2f9376;
  --series-4: #a87a1f;
  --series-5: #c25c7e;
  --series-6: #357f45;
  --series-7: #7568c4;
  --series-8: #cf5c5c;

  /* sequential blue — bars use accent + track from the same ramp */
  --seq-track:  #d7e4f5;
  --seq-fill:   #4a80c8;
  --seq-strong: #2c5a94;

  /* status — fixed, never themed, always shipped with an icon + label */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;

  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 12px rgba(11, 11, 11, 0.04);
  --radius: 16px;
  --radius-sm: 11px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Only applies when the viewer has made no explicit choice — otherwise an
   explicitly picked theme below would be fighting this block. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --plane:          #100f0d;
    --surface-1:      #1b1a18;
    --surface-2:      #262421;
    --text-primary:   #faf8f4;
    --text-secondary: #c8c3b8;
    --text-muted:     #8f8b82;
    --grid:           #2e2c28;
    --axis:           #3b3833;
    --border:         rgba(250, 248, 244, 0.10);
    --border-strong:  rgba(250, 248, 244, 0.20);

    --series-1: #5b93dd;
    --series-2: #d67243;
    --series-3: #3da88a;
    --series-4: #b88727;
    --series-5: #d06e8e;
    --series-6: #3f9150;
    --series-7: #8b7fd4;
    --series-8: #dd6f6f;

    --seq-track:  #2b4a75;
    --seq-fill:   #5b93dd;
    --seq-strong: #9dbcea;

    --good-text: #0ca30c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:          #100f0d;
  --surface-1:      #1b1a18;
  --surface-2:      #262421;
  --text-primary:   #faf8f4;
  --text-secondary: #c8c3b8;
  --text-muted:     #8f8b82;
  --grid:           #2e2c28;
  --axis:           #3b3833;
  --border:         rgba(250, 248, 244, 0.10);
  --border-strong:  rgba(250, 248, 244, 0.20);

  --series-1: #5b93dd;
  --series-2: #d67243;
  --series-3: #3da88a;
  --series-4: #b88727;
  --series-5: #d06e8e;
  --series-6: #3f9150;
  --series-7: #8b7fd4;
  --series-8: #dd6f6f;

  --seq-track:  #2b4a75;
  --seq-fill:   #5b93dd;
  --seq-strong: #9dbcea;

  --good-text: #0ca30c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* --------------------------------------------------------------------------
   "Fae" — a third theme: dusk-plum ground, parchment ink, jewel-toned series.
   The hues are the dark palette shifted toward periwinkle / copper-rose /
   verdigris / antique gold / orchid / moss / amethyst / garnet, then validated
   as a set against this surface. All six checks pass, worst adjacent CVD
   ΔE 8.3 — clear of the warn band, not scraping it.
   -------------------------------------------------------------------------- */
:root[data-theme="fae"] {
  color-scheme: dark;
  --plane:          #14101c;
  --surface-1:      #1e1829;
  --surface-2:      #2a2138;
  --text-primary:   #f4ecdf;
  --text-secondary: #c9bcd4;
  --text-muted:     #948aa3;
  --grid:           #2e2540;
  --axis:           #3d3150;
  --border:         rgba(244, 236, 223, 0.11);
  --border-strong:  rgba(244, 236, 223, 0.22);

  --series-1: #6f92e2;   /* periwinkle   */
  --series-2: #d2755a;   /* copper rose  */
  --series-3: #3fa992;   /* verdigris    */
  --series-4: #b98b35;   /* antique gold */
  --series-5: #cd6f9d;   /* orchid       */
  --series-6: #4a8f57;   /* moss         */
  --series-7: #9280da;   /* amethyst     */
  --series-8: #d76a74;   /* garnet       */

  --seq-track:  #33294a;
  --seq-fill:   #9280da;
  --seq-strong: #b9aae8;

  --good-text: #4ec07a;
  --shadow: 0 1px 2px rgba(8, 4, 16, 0.5), 0 6px 20px rgba(8, 4, 16, 0.38);
}

/* A barely-there wash of moonlight and moss over the dusk ground. Fixed so it
   reads as ambient light rather than as content that scrolls. */
:root[data-theme="fae"] body {
  background-image:
    radial-gradient(1100px 620px at 12% -12%, rgba(146, 128, 218, 0.13), transparent 62%),
    radial-gradient(900px 520px at 102% 2%, rgba(63, 169, 146, 0.08), transparent 58%);
  background-attachment: fixed;
}

/* ========================== base ========================== */

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }
p { margin: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: inherit; }
a { color: var(--series-1); }

.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ========================== shell ========================== */

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 72px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .week { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.topbar-spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.tab:hover { background: var(--surface-2); color: var(--text-primary); }
.tab[aria-selected="true"] {
  background: var(--text-primary);
  color: var(--plane);
}
.tab .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--critical);
  margin-left: 6px;
  vertical-align: 2px;
}

/* ========================== cards ========================== */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.card-head h2 { flex: 1; min-width: 0; }
.card-sub { font-size: 12.5px; color: var(--text-muted); margin-top: -8px; margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }

/* ========================== figures ========================== */

.hero {
  font-size: 52px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}
.hero-unit { font-size: 22px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0; }
.hero-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tile { background: var(--surface-1); padding: 13px 14px; }
.tile-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: none;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tile-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.tile-value small { font-size: 13px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0; }
.tile-note { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.tile-note.pos { color: var(--good-text); }
.tile-note.neg { color: var(--critical); }

/* ========================== status pill ========================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 550;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pill svg { flex: none; }
.pill.good     { color: var(--good-text); }
.pill.behind   { color: var(--critical); }
.pill.waiting  { color: var(--text-muted); }

/* ========================== forms ========================== */

.field { display: block; margin-bottom: 13px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-weight: 500;
}
.field .hint { font-size: 11.5px; color: var(--text-muted); font-weight: 400; margin-top: 4px; display: block; }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus {
  border-color: var(--series-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-1) 18%, transparent);
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  border: 1px solid transparent;
  background: var(--text-primary);
  color: var(--plane);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 550;
  transition: opacity 0.12s;
}
.btn:hover { opacity: 0.86; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.ghost {
  background: var(--surface-1);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-2); opacity: 1; }
.btn.accent { background: var(--seq-fill); color: #fff; }
.btn.danger { background: transparent; color: var(--critical); border-color: var(--border-strong); }

.err {
  color: var(--critical);
  font-size: 13px;
  margin-top: 10px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.ok { color: var(--good-text); font-size: 13px; margin-top: 10px; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: 0;
  background: var(--surface-1);
  color: var(--text-secondary);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--text-primary); color: var(--plane); }

/* ========================== avatar ========================== */

.av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  color: #fff;
  flex: none;
  letter-spacing: -0.01em;
}
.av.sm { width: 22px; height: 22px; font-size: 10px; }
.av.lg { width: 40px; height: 40px; font-size: 15px; }
.av.neutral { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

/* Photo sits over the initials, which stay as the fallback if it fails to load. */
.av.has-photo { position: relative; overflow: hidden; }
.av.has-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ========================== ranked rows / race ========================== */

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

.rrow {
  display: grid;
  grid-template-columns: 26px 30px minmax(84px, 1fr) 2.4fr auto;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  color: inherit;
  transition: background 0.12s;
}
button.rrow:hover { background: var(--surface-2); }
.rrow[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); }
.rrow .rank {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rrow .rank.lead { color: var(--text-primary); }
/* Name over detail, not beside it — the detail is smaller and muted, so it reads
   as a subtitle. Both were inline spans, which ran them together. */
.rrow .who {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.rrow .who .nm {
  display: block;
  font-weight: 550;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rrow .who .sub {
  display: block;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rrow .who .sub svg { vertical-align: -1px; margin-right: 1px; }
.rrow .val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.rrow .val small { font-weight: 500; color: var(--text-muted); font-size: 11.5px; }

@media (max-width: 700px) {
  .rrow { grid-template-columns: 22px 26px 1fr auto; gap: 9px; }
  .rrow .bar-cell { grid-column: 1 / -1; }
}

/* the meter: fill carries progress, track is a lighter step of the same ramp */
.meter {
  position: relative;
  height: 20px;
  background: var(--seq-track);
  border-radius: 4px;
  overflow: hidden;
}
.meter .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--seq-fill);
  border-radius: 0 4px 4px 0;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.meter .fill.done { background: var(--good); }
.meter .fill.zero { background: var(--axis); }
.meter .goalmark {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--text-primary);
  opacity: 0.55;
}
.meter.tall { height: 26px; }
.meter.thin { height: 8px; border-radius: 3px; }
.meter.thin .fill { border-radius: 0 3px 3px 0; }

.detail {
  padding: 4px 8px 16px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ========================== charts ========================== */

.chartbox { position: relative; }
.chartbox svg { display: block; width: 100%; height: auto; overflow: visible; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.legend .key.dot { width: 9px; height: 9px; border-radius: 50%; }
.legend .item.off { opacity: 0.4; }
button.legend-btn { border: 0; background: none; padding: 2px 0; color: inherit; font: inherit; }

.tip {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 9px 11px;
  font-size: 12.5px;
  min-width: 132px;
  opacity: 0;
  transition: opacity 0.1s;
}
.tip.on { opacity: 1; }
.tip .th { font-weight: 600; margin-bottom: 5px; font-size: 12px; }
.tip .tr { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tip .tr .k { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tip .tr .n { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.tip .tr .v { font-variant-numeric: tabular-nums; font-weight: 600; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  text-align: right;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
  border-bottom: 1px solid var(--axis);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.name { display: flex; align-items: center; gap: 7px; font-weight: 550; }
.tablewrap { overflow-x: auto; }

/* ========================== day grid (steps) ========================== */

.daygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  background: var(--surface-1);
}
.day.today { border-color: var(--series-1); box-shadow: 0 0 0 2px color-mix(in srgb, var(--series-1) 15%, transparent); }
.day.future { opacity: 0.45; }
.day .dow { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.day .num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 3px; }
.day .num.empty { color: var(--text-muted); font-weight: 400; }
.day .spark { height: 26px; display: flex; align-items: flex-end; justify-content: center; margin-top: 5px; }
.day .spark i {
  display: block;
  width: 60%;
  min-height: 2px;
  background: var(--seq-fill);
  border-radius: 3px 3px 0 0;
}
.day .spark i.none { background: var(--grid); }
button.day { cursor: pointer; transition: border-color 0.12s; }
button.day:hover { border-color: var(--border-strong); }

/* The official weigh-in day, set apart from the extra readings around it. */
.day.weighin {
  border-color: var(--seq-fill);
  border-width: 2px;
  background: color-mix(in srgb, var(--seq-fill) 9%, var(--surface-1));
}
.day.weighin .num { font-weight: 700; }
.day.weighin.today { box-shadow: 0 0 0 3px color-mix(in srgb, var(--seq-fill) 20%, transparent); }
.wi-dot {
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--seq-fill);
  margin-left: 3px;
  vertical-align: 1px;
}
.wi-tag {
  font-size: 9.5px;
  letter-spacing: 0.02em;
  margin-top: 3px;
  color: var(--seq-fill);
  font-weight: 650;
  text-transform: uppercase;
}
.wi-tag.ghost { color: var(--text-muted); font-weight: 500; text-transform: none; }

/* The two readings that bound a week: where you started it and where you ended it. */
.anchors {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 10px;
}
.anchor {
  text-align: left;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  padding: 12px 14px;
  color: inherit;
  font: inherit;
  transition: border-color 0.12s, background 0.12s;
}
button.anchor:hover { border-color: var(--seq-fill); background: var(--surface-2); }
.anchor.filled { background: var(--surface-2); }
.anchor.future { opacity: 0.5; }
.anchor-role {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 650;
  color: var(--seq-fill);
}
.anchor-future .anchor-role { color: var(--text-muted); }
.anchor-when { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.anchor-val {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 6px;
}
.anchor-val small { font-size: 13px; font-weight: 500; color: var(--text-secondary); letter-spacing: 0; }
.anchor-val.empty { font-size: 15px; font-weight: 500; color: var(--text-muted); }

.anchor-gap {
  display: grid;
  place-items: center;
  min-width: 74px;
  font-size: 12px;
  color: var(--text-muted);
}
.anchor-change {
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.anchor-change.down { color: var(--good-text); }
.anchor-change.up { color: var(--critical); }

@media (max-width: 560px) {
  .anchors { grid-template-columns: 1fr; }
  .anchor-gap { min-width: 0; padding: 2px 0; }
}

.daygrid.six { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 480px) { .daygrid.six { grid-template-columns: repeat(3, 1fr); } }

/* Explanatory strip inside a modal. */
.note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  margin-bottom: 16px;
}
.note svg { flex: none; margin-top: 1px; color: var(--text-muted); }
.note.official { border-color: color-mix(in srgb, var(--seq-fill) 45%, var(--border)); }
.note.official svg { color: var(--seq-fill); }

/* ========================== gate / setup ========================== */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
}
.gate-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.gate-card .mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--seq-fill);
  display: grid; place-items: center;
  margin-bottom: 18px;
}
.gate-card h1 { font-size: 22px; margin-bottom: 6px; }
.gate-card .lede { color: var(--text-secondary); font-size: 14px; margin-bottom: 22px; }

/* Shown only after the password: the first look at what you have joined. */
.reveal {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  margin-bottom: 20px;
}
.reveal-name {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 3px;
}
.reveal-line { font-size: 13.5px; color: var(--text-secondary); }
.reveal-line strong { color: var(--text-primary); font-weight: 600; }
.reveal .chips { margin-top: 11px; }

.whoami { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.whoami button {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  text-align: left;
  font-weight: 550;
  transition: background 0.12s, border-color 0.12s;
}
.whoami button:hover { background: var(--surface-2); border-color: var(--series-1); }
.whoami button .arrow { margin-left: auto; color: var(--text-muted); }

.sep {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-muted); font-size: 12px;
  margin: 18px 0;
}
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ========================== banner ========================== */

.banner {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.banner.nudge { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); }
.banner .txt { flex: 1; min-width: 0; }
.banner .txt strong { display: block; font-size: 14.5px; }
.banner .txt span { font-size: 12.5px; color: var(--text-secondary); }
@media (max-width: 600px) {
  .banner { flex-wrap: wrap; }
  .banner .btn { width: 100%; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ========================== game moments ========================== */

/* rank movement beside a position number */
.move {
  font-size: 10.5px;
  font-weight: 650;
  margin-left: 4px;
  letter-spacing: -0.02em;
  vertical-align: 1px;
}
.move.up { color: var(--good-text); }
.move.down { color: var(--text-muted); }

.chip.win {
  color: var(--good-text);
  border-color: color-mix(in srgb, var(--good) 40%, var(--border));
}

/* who you are chasing */
.chase {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}
.chase svg { flex: none; color: var(--text-muted); }
.chase strong { color: var(--text-primary); font-weight: 650; }

/* week-in-review titles */
.award {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.award:last-of-type { border-bottom: 0; }
.award-label { color: var(--text-muted); font-size: 12px; width: 104px; flex: none; }
.award-name { font-weight: 600; flex: 1; min-width: 0; }
.award-val { font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 520px) {
  .award { flex-wrap: wrap; }
  .award-label { width: 100%; }
}

/* the weigh-in reveal */
.reveal-fig { text-align: center; padding: 6px 0 18px; }
.reveal-delta {
  font-size: 46px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}
.reveal-delta.down { color: var(--good-text); }
.reveal-delta.up { color: var(--critical); }

.milestone {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--seq-fill) 40%, var(--border));
  background: color-mix(in srgb, var(--seq-fill) 8%, var(--surface-2));
}
.milestone svg { color: var(--seq-fill); flex: none; }
.milestone strong { font-size: 14px; }

/* ========================== modal ========================== */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  max-height: 88dvh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 4px; }
.modal .lede { color: var(--text-secondary); font-size: 13px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 9px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ========================== texture / forced colors ========================== */

@media (forced-colors: active) {
  .meter .fill { forced-color-adjust: none; background: CanvasText; }
  .meter { border: 1px solid CanvasText; }
  .card, .tile { border: 1px solid CanvasText; }
}

@media print {
  .topbar, .tabs, .btn, .icon-btn { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
