:root {
  --bg: #ffffff;
  --surface: #f5f5f3;
  --border: #e2e2dc;
  --fg: #111111;
  --muted: #6b6b66;
  --accent: #65704a;
  --accent-fg: #ffffff;
  --accent-text: #56603e;
  --accent-soft: #eef0e6;
  --danger: #b3261e;
  --warn-bg: #fff6e0;
  --warn-fg: #6b4e00;
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --surface: #181817;
    --border: #2c2c29;
    --fg: #f2f2ef;
    --muted: #a0a097;
    --accent-text: #b5c193;
    --accent-soft: #23271a;
    --danger: #f2817a;
    --warn-bg: #2e2610;
    --warn-fg: #f3d58a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px 140px; }
[hidden] { display: none !important; }

/* Header + logo: the SVG is a mask, so it takes the text color (black/white). */
header { text-align: center; padding: 24px 16px 8px; }
.logo {
  display: block;
  width: 132px;
  aspect-ratio: 1800 / 550;
  margin: 0 auto 10px;
  background: var(--fg);
  -webkit-mask: url(logo.svg) center / contain no-repeat;
  mask: url(logo.svg) center / contain no-repeat;
}
h1 { margin: 0; font-size: 15px; letter-spacing: .16em; font-weight: 700; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
h2 { font-size: 20px; margin: 24px 0 12px; }
h3 { font-size: 17px; margin: 0 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.muted { color: var(--muted); font-size: 14px; }
.note { background: var(--accent-soft); color: var(--accent-text); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.warn { background: var(--warn-bg); color: var(--warn-fg); border-radius: 12px; padding: 12px; font-size: 15px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

button, .btn {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.danger { color: var(--danger); }
button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.full { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

input[type=text], input[type=password], input[type=number] {
  font: inherit;
  min-height: 48px;
  width: 100%;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}
input.code { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 700; }

/* Artist tabs */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; overflow-x: auto;
  padding: 10px 16px; margin: 0 -16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; min-height: 44px; border-radius: 999px; white-space: nowrap; }
.tab[aria-selected=true] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tab .check { color: var(--accent-text); margin-left: 4px; }
.tab[aria-selected=true] .check { color: inherit; }

/* Criterion card */
.rubric { list-style: none; margin: 0 0 12px; padding: 0; font-size: 14px; color: var(--muted); }
.rubric li { display: flex; gap: 8px; padding: 2px 0; }
.rubric b { color: var(--fg); min-width: 1.2em; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { min-height: 56px; font-size: 20px; padding: 0; }
.scale button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* Sticky submit bar */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.bar > div { max-width: 720px; margin: 0 auto; }
.bar p { margin: 6px 0 0; text-align: center; }

/* Tables scroll inside their container */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
th { font-weight: 600; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: 0; }
tr.first td { background: var(--accent-soft); font-weight: 700; }
td.total { font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 4px 4px 14px; background: var(--bg); }
.chip button { min-height: 36px; width: 36px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper output { font-size: 22px; font-weight: 700; min-width: 2ch; text-align: center; }
.weights { display: grid; grid-template-columns: 1fr 96px; gap: 8px 12px; align-items: center; }
.big { font-size: 28px; font-weight: 700; }
.footer-note { text-align: center; margin-top: 24px; }
.footer-note button { margin-top: 8px; }
.sum-bad { color: var(--danger); }

/* ---- v2: guided flows ---------------------------------------------------- */
a { color: var(--accent-text); }
.center { text-align: center; }
.stack { display: grid; gap: 8px; margin-top: 12px; }
.spaced { margin-top: 12px; }
.lead { font-size: 18px; margin: 0 0 12px; }
.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.big-btn { min-height: 60px; font-size: 18px; margin-top: 8px; }
details { margin-top: 16px; text-align: left; }
summary { cursor: pointer; color: var(--accent-text); font-weight: 600; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.steps { padding-left: 22px; margin: 0 0 16px; }
.steps li { margin: 0 0 10px; }

.station { display: flex; flex-direction: column; align-items: center; padding: 16px 0 8px; }
.station-label { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.station-number { font-size: 88px; line-height: 1; font-weight: 800; color: var(--accent-text); }

.criterion.is-done { border-color: var(--accent); }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.pill.progress { color: var(--accent-text); border-color: var(--accent); }
.scale button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; }
.scale .num { font-size: 22px; line-height: 1; }
.scale .hint { font-size: 11px; font-weight: 500; min-height: 13px; color: var(--muted); }
.scale button[aria-pressed=true] .hint { color: inherit; }

.bar-progress { height: 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; margin-bottom: 10px; }
.bar-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.done-mark { width: 88px; height: 88px; margin: 8px auto 4px; border-radius: 50%; display: grid; place-items: center; font-size: 48px; font-weight: 800; background: var(--accent); color: var(--accent-fg); }
.review-scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; font-size: 13px; }
.review-scores div { display: flex; flex-direction: column; gap: 2px; }
.review-scores b { font-size: 20px; }

/* Organizer */
.segmented { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 8px 0 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.segmented button { min-height: 44px; border: 0; background: transparent; font-size: 14px; padding: 0 6px; }
.segmented button[aria-selected=true] { background: var(--fg); color: var(--bg); }
.judge h3 { margin: 0; }
.judge-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.judge-actions .btn { grid-column: 1 / -1; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.link { border: 0; background: transparent; padding: 0; min-height: 36px; }
.weights { grid-template-columns: 1fr auto; }
.pct { display: inline-flex; align-items: center; gap: 4px; }
.pct input { width: 76px; text-align: right; }
.huge { font-size: 44px; font-weight: 800; line-height: 1.1; margin: 4px 0 12px; }
.warn-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.warn-list li { background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
#test-banner { margin: 12px 0; }

.podium { display: grid; gap: 8px; margin: 12px 0; }
.podium-item { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.podium-item.p1 { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); padding: 22px 16px; }
.podium-item .place { font-size: 22px; font-weight: 800; }
.podium-item .who { font-size: 18px; font-weight: 700; }
.podium-item .score { font-size: 22px; font-weight: 800; }
.podium-item.p1 .who, .podium-item.p1 .score { font-size: 26px; }

dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(92vw, 420px); background: var(--bg); color: var(--fg); text-align: center; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
.qr { background: #fff; border-radius: 12px; padding: 8px; margin: 12px 0 16px; }
.qr svg { display: block; width: 100%; height: auto; }

/* Station sheets */
.print-toolbar { max-width: 720px; margin: 0 auto; padding: 16px; text-align: center; }
.sheet { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 90vh; border: 1px dashed var(--border); border-radius: var(--radius); margin: 16px; text-align: center; }
.sheet .logo { width: 220px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet-label { font-size: 32px; letter-spacing: .3em; font-weight: 700; }
.sheet-number { font-size: min(50vh, 55vw); line-height: 1; font-weight: 800; }
.sheet-foot { font-size: 16px; letter-spacing: .16em; color: var(--muted); }
@media print {
  :root { --bg: #fff; --fg: #000; --muted: #444; --border: #fff; }
  .no-print { display: none; }
  .sheet { min-height: 0; height: 100vh; margin: 0; border: 0; break-after: page; }
  .sheet-number { font-size: min(60vh, 55vw); }
}
.list.card { padding: 4px 16px; }
