/* ==========================================================================
   San Francisco Proof Open 2026 — Contest Portal
   --------------------------------------------------------------------------
   Visual idiom: a printed examination paper.

   The rules that hold the look together, so later edits don't drift:
     1. HAIRLINES, NOT BOXES. Structure comes from 1px rules and whitespace.
        Shadows appear only on things that genuinely float (modal, chat, toast).
     2. THREE TYPEFACES, THREE JOBS. Serif = anything a competitor reads as
        prose (headings, problem statements). Sans = interface chrome. Mono =
        anything a machine produced: IDs, clocks, scores, labels, state.
     3. CRISP CORNERS. 3px. Nothing is a pill except the live indicator.
     4. THE RAIL. Problem numbers hang in a left margin against a vertical
        rule, the way they do on a printed paper. This is the signature.
     5. COLOUR IS PUNCTUATION. A near-neutral paper ground; green marks what
        is live or yours; blue marks the secondary path; red marks a stop.
        Never a gradient behind text.
     6. NO EMOJI. Icons are inline SVG or typographic marks.
   ========================================================================== */

:root {
  /* Ink & paper ---------------------------------------------------------
     A warm cream ground with white sheets floating on it. Committed light
     theme: no dark variant, no toggle. A contest runs in daylight on eighty
     different screens, and one predictable look beats two half-tuned ones. */
  --paper:      #fbf8f0;   /* page ground, warm cream */
  --sheet:      #ffffff;   /* raised sheet */
  --sheet-2:    #f5f1e6;   /* recessed panel */
  --ink:        #1b1c18;
  --ink-2:      #5c5f52;
  --ink-3:      #8d9080;

  --rule:       #e6e1d2;   /* hairline */
  --rule-2:     #d2ccb8;   /* emphasised hairline */

  /* Accents — green leads, blue is the secondary path, yellow marks the
     things that need a human's eye. */
  --green:      #2f6b4f;
  --green-deep: #1f4a36;
  --green-lift: #e8f2ea;
  --green-line: #b9d6c4;
  --green-live: #3d9169;

  --blue:       #2a5f8f;
  --blue-lift:  #e7eff7;
  --blue-line:  #bcd2e6;

  --yellow:      #8a6a12;
  --yellow-lift: #fbf1d4;
  --yellow-line: #e8d49a;
  --yellow-pure: #e3b53f;

  --red:        #a33a2c;
  --red-lift:   #f9e8e4;

  /* Spacing (4px base) --------------------------------------------------- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  --r:  3px;
  --r2: 2px;

  --sh-pop:  0 10px 28px -12px rgba(40, 36, 20, .22), 0 2px 5px rgba(40, 36, 20, .06);
  --sh-lift: 0 18px 44px -16px rgba(40, 36, 20, .28);

  /* Type ----------------------------------------------------------------- */
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
           Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
           "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, "DejaVu Sans Mono",
           Consolas, monospace;

  --measure: 66ch;
  --maxw: 1080px;
}

/* Legacy aliases, so any stray reference still resolves to something sane. */
:root { --amber: var(--yellow); --amber-lift: var(--yellow-lift); }

/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}
img, svg, video, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.16; letter-spacing: -.012em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 1.9vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.7rem); }
h3 { font-size: 1.12rem; }
h4 { font-family: var(--sans); font-size: .95rem; font-weight: 650; }

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: var(--r2); }
::selection { background: var(--green-lift); color: var(--ink); }

code, kbd { font-family: var(--mono); font-size: .88em; }
kbd {
  padding: 1px 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px;
  border-radius: var(--r2); background: var(--sheet-2);
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s5); }
.wrap-wide { max-width: 1400px; }
.wrap-tight { max-width: 620px; }
@media (max-width: 620px) { .wrap { padding-inline: var(--s4); } }

.stack    { display: grid; gap: var(--s4); }
.stack-sm { display: grid; gap: var(--s2); }
.stack-lg { display: grid; gap: var(--s5); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s4); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid   { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

.center { text-align: center; }
.spacer { flex: 1 1 auto; }
.hide   { display: none !important; }
.muted  { color: var(--ink-2); }
.faint  { color: var(--ink-3); }
.small  { font-size: .875rem; }
.tiny   { font-size: .78rem; line-height: 1.5; }
.serif  { font-family: var(--serif); }
.prose  { max-width: var(--measure); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }

/* ── Signature type detail: machine-set metadata ─────────────────────── */
/* Anything a machine produced — IDs, states, labels, counts — is set in
   mono, uppercase, letterspaced. It is the thread that ties every screen
   together and is doing the job a pill badge would otherwise do. */
.meta {
  font-family: var(--mono);
  font-size: .69rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.meta-strong { color: var(--ink-2); font-weight: 600; }

/* ── Rule head: a label with a hairline running to the end ───────────── */
.rulehead {
  display: flex; align-items: center; gap: var(--s3);
  margin-bottom: var(--s4);
}
.rulehead::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--rule);
}
.rulehead > .meta { flex: none; }

/* ── Tags (replacing pill badges) ────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 7px; border-radius: var(--r2);
  border: 1px solid var(--rule-2); background: transparent;
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
  white-space: nowrap;
}
.tag-live  { border-color: var(--green-line); background: var(--green-lift); color: var(--green); }
.tag-blue  { border-color: var(--blue-line);  background: var(--blue-lift);  color: var(--blue); }
.tag-amber { border-color: color-mix(in srgb, var(--amber) 42%, transparent); background: var(--amber-lift); color: var(--amber); }
.tag-red   { border-color: color-mix(in srgb, var(--red) 42%, transparent);   background: var(--red-lift);   color: var(--red); }

.dot {
  display: inline-block; width: 6px; height: 6px; flex: none;
  border-radius: 50%; background: currentColor;
}
.dot-live {
  background: var(--green-live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--green-live) 60%, transparent);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ── Masthead ────────────────────────────────────────────────────────── */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s5); max-width: 1400px; margin-inline: auto;
  flex-wrap: wrap;
}
@media (max-width: 620px) { .masthead-inner { padding: var(--s2) var(--s4); gap: var(--s3); } }

.mark {
  display: flex; align-items: center; gap: var(--s3);
  color: var(--ink); text-decoration: none;
}
.mark:hover { text-decoration: none; }
/* The halmos — the square that closes a proof. Used as the mark and the
   favicon. The explicit stroke-width matters: the global `svg` rule sets 1.6
   and a CSS declaration beats the SVG's own stroke-width attribute. */
.mark-glyph {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center; color: var(--green);
}
.mark-glyph svg { width: 26px; height: 26px; stroke-width: 5; }

.mark-text { display: grid; line-height: 1.25; }
.mark-title { font-family: var(--serif); font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.mark-sub   { font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
              text-transform: uppercase; color: var(--ink-3); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  --bg: transparent; --fg: var(--ink); --bd: var(--rule-2);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 9px 16px; min-height: 38px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
  border-radius: var(--r);
  font-family: var(--sans); font-size: .9rem; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .42; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-solid { --bg: var(--green); --fg: #fff; --bd: var(--green); }
.btn-solid:hover:not(:disabled) { --bg: var(--green-deep); --bd: var(--green-deep); }

.btn-outline:hover:not(:disabled) { --bg: var(--sheet-2); --bd: var(--ink-3); }
.btn-quiet { --bd: transparent; --fg: var(--ink-2); }
.btn-quiet:hover:not(:disabled) { --bg: var(--sheet-2); --fg: var(--ink); }
.btn-danger { --fg: var(--red); --bd: color-mix(in srgb, var(--red) 45%, transparent); }
.btn-danger:hover:not(:disabled) { --bg: var(--red-lift); }

.btn-sm { padding: 5px 11px; min-height: 30px; font-size: .82rem; }
.btn-lg { padding: 12px 22px; min-height: 46px; font-size: .98rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; flex: none; border-radius: var(--r);
  display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
  transition: background .13s, color .13s, border-color .13s;
}
.icon-btn:hover { background: var(--sheet-2); color: var(--ink); border-color: var(--rule); }
.icon-btn svg { width: 17px; height: 17px; }

/* ── Sheets ──────────────────────────────────────────────────────────── */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: var(--s5);
}
.sheet-lg { padding: clamp(var(--s5), 3vw, var(--s6)); }
.sheet-flat { background: var(--sheet-2); border-color: transparent; }
.sheet-mark { border-left: 2px solid var(--green); }

/* ── The rail: hanging problem numbers ───────────────────────────────
   The signature layout. The number sits in a left margin against a vertical
   hairline, the way it does on a printed exam. Below 720px the rail folds
   into a horizontal header instead of stealing width from the statement. */
.paper-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
  padding-block: var(--s6);
}
.paper-item:first-of-type { border-top: 1px solid var(--rule-2); }
.paper-item:last-of-type { border-bottom: 1px solid var(--rule); }

.rail {
  border-right: 1px solid var(--rule);
  padding-right: var(--s4);
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.rail-num {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 600;
  line-height: 1; letter-spacing: -.03em; color: var(--green);
  font-variant-numeric: tabular-nums;
}
.rail-label { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em;
              text-transform: uppercase; color: var(--ink-3); }

.paper-body { padding-left: var(--s5); min-width: 0; }

@media (max-width: 720px) {
  .paper-item { grid-template-columns: minmax(0, 1fr); padding-block: var(--s5); }
  .rail {
    flex-direction: row; align-items: baseline; justify-content: flex-start;
    gap: var(--s3); border-right: 0; padding-right: 0; text-align: left;
    border-bottom: 1px solid var(--rule); padding-bottom: var(--s2); margin-bottom: var(--s4);
  }
  .rail-num { font-size: 1.15rem; }
  .paper-body { padding-left: 0; }
}

/* ── Statement typography ────────────────────────────────────────────── */
.statement {
  font-family: var(--serif);
  font-size: 1.09rem;
  line-height: 1.75;
  max-width: var(--measure);
  color: var(--ink);
}
.statement > p { margin-bottom: .8em; }
.statement > p:last-child, .statement > ul:last-child, .statement > ol:last-child { margin-bottom: 0; }
.statement ul, .statement ol { margin: 0 0 .8em 1.35em; }
.statement li { margin-bottom: .28em; }
.statement strong { font-weight: 700; }
.statement em { font-style: italic; }
.statement .katex-display { margin: .85em 0; overflow-x: auto; overflow-y: hidden; padding-block: 2px; }
.statement .katex { font-size: 1.05em; }
.math-error {
  font-family: var(--mono); font-size: .84em;
  background: var(--red-lift); color: var(--red);
  padding: 1px 4px; border-radius: var(--r2);
}

/* ── Forms ───────────────────────────────────────────────────────────── */
.field { display: grid; gap: 5px; min-width: 0; }
.label {
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase; color: var(--ink-2);
}
.hint { font-size: .78rem; color: var(--ink-3); line-height: 1.45; }

.input, .select, .textarea {
  width: 100%; padding: 9px 11px; min-height: 40px;
  font-size: .95rem; color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--rule-2); border-radius: var(--r);
  transition: border-color .13s, box-shadow .13s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 22%, transparent);
}
.input:disabled, .textarea:disabled { background: var(--sheet-2); color: var(--ink-3); cursor: not-allowed; }
.input-mono { font-family: var(--mono); letter-spacing: .04em; }
.textarea { resize: vertical; min-height: 92px; font-family: var(--mono); font-size: .85rem; line-height: 1.55; }
.select {
  appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath d='M1 1.5 5.5 6 10 1.5' fill='none' stroke='%2383998d' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.checkbox { display: inline-flex; align-items: center; gap: var(--s2); font-size: .89rem; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--green); cursor: pointer; flex: none; }

/* ── Notes (alerts) ──────────────────────────────────────────────────── */
/* A left rule rather than a filled box — quieter, and consistent with the
   hairline language. */
.note {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4);
  border-left: 2px solid var(--rule-2);
  background: var(--sheet-2);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: .89rem; line-height: 1.55; color: var(--ink-2);
}
.note strong { color: var(--ink); font-weight: 650; }
.note-ok    { border-left-color: var(--green); background: var(--green-lift); color: var(--ink); }
.note-info  { border-left-color: var(--blue);  background: var(--blue-lift);  color: var(--ink); }
.note-warn  { border-left-color: var(--amber); background: var(--amber-lift); color: var(--ink); }
.note-error { border-left-color: var(--red);   background: var(--red-lift);   color: var(--ink); }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto; border: 1px solid var(--rule);
  border-radius: var(--r); background: var(--sheet);
  -webkit-overflow-scrolling: touch;
}
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
table.tbl th {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 12px; text-align: left; white-space: nowrap;
  font-family: var(--mono); font-size: .66rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  background: var(--sheet-2); border-bottom: 1px solid var(--rule-2);
}
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--sheet-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Clock ───────────────────────────────────────────────────────────── */
.clock {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; letter-spacing: -.02em; font-size: 1.2rem;
  font-feature-settings: "zero";
}
.clock-lg {
  font-size: clamp(2.4rem, 1.8rem + 3vw, 3.6rem);
  letter-spacing: -.04em; line-height: 1;
}
.clock-warn   { color: var(--amber); }
.clock-danger { color: var(--red); }

/* ── The seal: content withheld ──────────────────────────────────────
   Used for locked rounds and sealed standings. Diagonal hatching reads as
   "not yet opened" without needing an emoji padlock. */
.seal {
  position: relative; border: 1px solid var(--rule-2); border-radius: var(--r);
  padding: var(--s7) var(--s5); text-align: center; overflow: hidden;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0 9px,
    color-mix(in srgb, var(--ink-3) 8%, transparent) 9px 10px);
}
.seal-inner {
  display: inline-block; background: var(--paper);
  padding: var(--s4) var(--s5); border: 1px solid var(--rule-2); border-radius: var(--r2);
}

/* ── Connection banner ───────────────────────────────────────────────── */
.netbar {
  position: fixed; inset-inline: 0; top: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 6px var(--s4);
  font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  background: var(--amber); color: #fff;
  transform: translateY(-100%); transition: transform .22s ease;
}
.netbar.show { transform: translateY(0); }
.netbar.offline { background: var(--red); }
.netbar .spin {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ──────────────────────────────────────────────────────────── */
#sfpo-toasts {
  position: fixed; top: var(--s4); left: 50%; transform: translateX(-50%);
  z-index: 250; display: flex; flex-direction: column; gap: var(--s2);
  align-items: center; width: min(520px, calc(100vw - 32px)); pointer-events: none;
}
#sfpo-toasts .note {
  width: 100%; pointer-events: auto; box-shadow: var(--sh-pop);
  background-color: var(--sheet); animation: rise .2s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(-6px); } }

/* ── Screens (waiting / locked / closed) ─────────────────────────────── */
.screen { min-height: 72vh; display: grid; place-items: center; padding: var(--s7) var(--s5); }
.screen > div { max-width: 560px; width: 100%; text-align: center; }
.screen-glyph { display: grid; place-items: center; margin: 0 auto var(--s5); color: var(--ink-3); }
.screen-glyph svg { width: 52px; height: 52px; stroke-width: 1.2; }

/* A slow sweep, not a spinner — the round has not started, nothing is loading */
.sweep { width: 100%; height: 1px; background: var(--rule); overflow: hidden; margin-bottom: var(--s6); }
.sweep::after {
  content: ""; display: block; height: 1px; width: 34%;
  background: var(--green); animation: sweep 2.8s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(330%); } }

/* ── Skeleton ────────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--sheet-2) 25%, var(--rule) 50%, var(--sheet-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite linear;
  border-radius: var(--r2);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-line { height: 12px; margin-bottom: 10px; }
.skel-line:last-child { width: 58%; margin-bottom: 0; }

/* ── Chat ────────────────────────────────────────────────────────────── */
.chat-panel {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 60;
  width: min(370px, calc(100vw - 32px)); max-height: min(530px, 78vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sheet); border: 1px solid var(--rule-2);
  border-radius: var(--r); box-shadow: var(--sh-lift);
  animation: rise .16s ease-out;
}
.chat-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); background: var(--sheet-2);
  border-bottom: 1px solid var(--rule);
}
.chat-log {
  flex: 1; min-height: 150px; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3);
}
.chat-msg { max-width: 86%; font-size: .875rem; line-height: 1.5; }
.chat-msg .who {
  display: block; font-family: var(--mono); font-size: .63rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px;
}
.chat-msg .body { padding: 7px 11px; border-radius: var(--r); display: inline-block; }
.chat-msg.me   { align-self: flex-end; text-align: right; }
.chat-msg.me .body   { background: var(--green); color: #fff; text-align: left; }
.chat-msg.them .body { background: var(--sheet-2); border: 1px solid var(--rule); }
.chat-form { display: flex; gap: var(--s2); padding: var(--s3); border-top: 1px solid var(--rule); }

.chat-fab {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 59;
  height: 40px; padding: 0 var(--s4); border-radius: var(--r);
  border: 1px solid var(--rule-2); background: var(--sheet); color: var(--ink);
  cursor: pointer; box-shadow: var(--sh-pop);
  display: flex; align-items: center; gap: var(--s2);
  font-family: var(--mono); font-size: .7rem; letter-spacing: .11em; text-transform: uppercase;
}
.chat-fab:hover { background: var(--sheet-2); }
.chat-fab svg { width: 15px; height: 15px; }
.chat-fab .unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r2);
  background: var(--red); color: #fff; font-size: .66rem; font-weight: 700;
  display: grid; place-items: center; letter-spacing: 0;
}

/* ── Guts ────────────────────────────────────────────────────────────── */
.set-track { display: flex; gap: 3px; flex-wrap: wrap; }
.set-chip {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: var(--r2);
  background: transparent; color: var(--ink-3);
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
}
.set-chip.done    { border-color: var(--green-line); background: var(--green-lift); color: var(--green); }
.set-chip.current { border-color: var(--green); background: var(--green); color: #fff; }
@media (max-width: 620px) { .set-chip { width: 22px; height: 22px; font-size: .66rem; } }

.answer-input { font-family: var(--mono); font-size: 1rem; letter-spacing: .03em; max-width: 320px; }
.answer-input.synced {
  border-color: var(--green);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 22%, transparent);
  transition: border-color .5s ease, box-shadow .5s ease;
}

/* Standings: a ruled results table, not a card list */
.standing {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: var(--s3); align-items: baseline;
  padding: 9px var(--s4); border-bottom: 1px solid var(--rule);
}
.standing:last-child { border-bottom: 0; }
.standing.me { background: var(--green-lift); }
.standing.bump { animation: bump 1.3s ease-out; }
@keyframes bump { 0% { background: color-mix(in srgb, var(--green-live) 26%, transparent); } }
.standing.me.bump { animation: bumpme 1.3s ease-out; }
@keyframes bumpme { 0% { background: color-mix(in srgb, var(--green-live) 36%, transparent); } 100% { background: var(--green-lift); } }
.standing-rank {
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums;
}
.standing-name { font-family: var(--serif); font-size: 1rem; font-weight: 600;
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing-score { font-family: var(--mono); font-size: 1.02rem; font-weight: 700;
                  font-variant-numeric: tabular-nums; }

/* ── Upload ──────────────────────────────────────────────────────────── */
.drop {
  display: block; cursor: pointer; text-align: center;
  padding: var(--s6) var(--s5);
  border: 1px dashed var(--rule-2); border-radius: var(--r);
  background: var(--sheet-2);
  transition: border-color .14s, background .14s;
}
.drop:hover, .drop.over { border-color: var(--green); background: var(--green-lift); }
.drop svg { width: 26px; height: 26px; margin: 0 auto var(--s3); color: var(--ink-3); }
.drop:hover svg, .drop.over svg { color: var(--green); }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.page-chip {
  position: relative; aspect-ratio: 3 / 4; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: var(--r2); background: var(--sheet-2);
  text-align: center; padding: var(--s2);
}
.page-chip button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border: 1px solid var(--rule-2); border-radius: var(--r2);
  background: var(--sheet); color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; font-size: .7rem; line-height: 1;
}
.page-chip button:hover { color: var(--red); border-color: var(--red); }

.progress { height: 3px; background: var(--rule); overflow: hidden; border-radius: var(--r2); }
.progress > div { height: 100%; background: var(--green); transition: width .2s ease; }

/* ── Staff ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: var(--s5); overflow-x: auto;
  border-bottom: 1px solid var(--rule); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 0; border: 0; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--green); border-bottom-color: var(--green); }

/* Figures: numbers separated by rules, no boxes */
.figures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet);
  overflow: hidden;
}
.figure { padding: var(--s3) var(--s4); border-left: 1px solid var(--rule); }
.figure:first-child { border-left: 0; }
.figure-value { font-family: var(--mono); font-size: 1.5rem; font-weight: 600;
                line-height: 1.1; font-variant-numeric: tabular-nums; }
.figure-label { font-family: var(--mono); font-size: .64rem; letter-spacing: .12em;
                text-transform: uppercase; color: var(--ink-3); margin-top: 2px; }

.list-item { padding: 9px var(--s4); border-bottom: 1px solid var(--rule); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--sheet-2); }
.list-item.active { background: var(--green-lift); box-shadow: inset 2px 0 0 var(--green); }

.split { display: grid; gap: var(--s5); align-items: start; }
@media (min-width: 1001px) {
  .split-grade { grid-template-columns: 320px minmax(0, 1fr); }
  .split-chat  { grid-template-columns: 270px minmax(0, 1fr); }
}
@media (min-width: 961px) { .split-guts { grid-template-columns: minmax(0, 1fr) 300px; } }

.grade-media { width: 100%; border: 1px solid var(--rule); border-radius: var(--r2); background: var(--sheet-2); }
.sticky-side { position: sticky; top: 76px; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: var(--s5);
  background: color-mix(in srgb, #071410 60%, transparent);
  backdrop-filter: blur(2px); animation: fade .13s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(660px, 100%); max-height: 88vh; overflow-y: auto; padding: var(--s6);
  background: var(--sheet); border: 1px solid var(--rule-2);
  border-radius: var(--r); box-shadow: var(--sh-lift); animation: rise .16s ease-out;
}

/* ── Colophon ────────────────────────────────────────────────────────── */
.colophon {
  border-top: 1px solid var(--rule); margin-top: var(--s8);
  padding-block: var(--s5);
}
.colophon-inner {
  display: flex; gap: var(--s5); align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}

/* ── Utilities ───────────────────────────────────────────────────────── */
.no-select .statement, .no-select .rail-num { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.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;
}

/* ── Print ───────────────────────────────────────────────────────────── */
@media print {
  .masthead, .colophon, .chat-fab, .chat-panel, .netbar, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .sheet, .paper-item { border-color: #bbb; box-shadow: none; break-inside: avoid; }
  .statement { font-size: 11pt; }
}

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