:root {
  --bg: #f3f5f9;
  --bg-2: #ffffff;
  --ink: #17202a;
  --ink-2: #5b6675;
  --line: #dfe4ec;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px rgba(20, 30, 50, .10);
  --radius: 14px;
  --stage-bg: radial-gradient(circle at 50% 40%, #ffffff, #e9edf5 70%);
}

[data-theme="dark"] {
  --bg: #0f141b;
  --bg-2: #171e28;
  --ink: #eef2f7;
  --ink-2: #97a3b4;
  --line: #27313e;
  --accent: #7c74ff;
  --accent-ink: #0f141b;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --stage-bg: radial-gradient(circle at 50% 40%, #1c2532, #0f141b 70%);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

kbd {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font: inherit;
  font-size: 12px;
}

code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 4px;
  font-size: 12px;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; }

.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background:
    conic-gradient(#e74c3c 0 25%, #f4d03f 0 50%, #2ecc71 0 75%, #3498db 0);
  box-shadow: inset 0 0 0 3px var(--bg-2), 0 0 0 1px var(--line);
}

.wheel-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  padding: 6px 10px;
}
.wheel-title:hover { border-color: var(--line); }
.wheel-title:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.topbar-actions { display: flex; gap: 6px; flex: none; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { padding: 8px 10px; line-height: 1; }
.btn.danger { color: #e0464a; }

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

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 360px;
}

.stage {
  background: var(--stage-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  padding: 20px;
  position: relative;
}

.wheel-wrap {
  position: relative;
  width: min(74vh, 100%);
  aspect-ratio: 1;
  max-width: 720px;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .22));
  touch-action: manipulation;
}

.pointer {
  position: absolute;
  top: 50%;
  right: -6px;
  width: 52px;
  height: 40px;
  transform: translateY(-50%);
  transform-origin: 86% 50%;
  background: var(--bg-2);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
  filter: drop-shadow(-3px 2px 3px rgba(0, 0, 0, .3));
  pointer-events: none;
  will-change: transform;
}

.spin-hint {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 19%; height: 19%;
  border-radius: 50%;
  border: none;
  background: var(--bg-2);
  color: var(--ink);
  font: 700 clamp(11px, 1.6vw, 17px)/1 inherit;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  display: grid;
  place-items: center;
  padding: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spin-hint:hover { filter: brightness(1.05); }
.spin-hint:disabled { cursor: default; opacity: .8; }

.stage-note { margin: 0; color: var(--ink-2); font-size: 13px; }

/* ---------- side panel ---------- */

.panel {
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }

.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 13px 8px;
  font: inherit;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.pill {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-2);
}

.tabpane { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 12px; gap: 10px; }
.tabpane.active { display: flex; }

.panel-tools { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }

.chip {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }

/* The textarea itself is transparent — see .editor-wrap, which layers it over
   the highlighted copy. Styling it by id here would outrank those rules. */

.hint { margin: 0; font-size: 12px; color: var(--ink-2); flex: none; }

.results {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0 0 0 4px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.results li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.results li .idx { color: var(--ink-2); font-size: 12px; min-width: 22px; }
.results li .who { font-weight: 600; flex: 1; word-break: break-word; }
.results li .when { color: var(--ink-2); font-size: 11.5px; }

.row-cert {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: .45;
  transition: opacity .12s, background .12s;
}
.results li:hover .row-cert, .row-cert:focus-visible { opacity: 1; background: var(--bg-2); }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, .55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 80;
}

.winner-card {
  position: relative;
  background: var(--bg-2);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 40px;
  text-align: center;
  max-width: min(640px, 92vw);
  animation: pop .28s cubic-bezier(.2, 1.4, .5, 1);
}

@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.winner-label { margin: 0 0 6px; color: var(--ink-2); font-size: 13px; text-transform: uppercase; letter-spacing: .14em; }

.winner-name {
  margin: 0 0 22px;
  font-size: clamp(30px, 6vw, 60px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  word-break: break-word;
}

.winner-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.sheet {
  background: var(--bg-2);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(520px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.sheet-head, .sheet-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  flex: none;
}
.sheet-head { border-bottom: 1px solid var(--line); }
.sheet-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.sheet-head h2 { margin: 0; font-size: 17px; flex: 1; }

.sheet-body { padding: 8px 18px 16px; overflow-y: auto; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row > span { color: var(--ink); }
.row input[type="range"] { width: 160px; }
.row output { color: var(--ink-2); font-size: 13px; min-width: 34px; text-align: right; }
.row input[type="range"] + output { grid-column: 3; }
.row:has(input[type="range"]) { grid-template-columns: 1fr auto auto; }

.row select, .row input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  min-width: 170px;
}
.row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.saved-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  background: var(--bg);
}
.saved-list .meta { flex: 1; min-width: 0; }
.saved-list .name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-list .sub { color: var(--ink-2); font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg-2);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 90;
  animation: rise .2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}
.toast[hidden] { display: none; }

.toast-undo {
  font: inherit;
  font-weight: 700;
  color: var(--bg-2);
  background: none;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, .25);
  padding: 0 0 0 12px;
  cursor: pointer;
  text-decoration: underline;
}
[data-theme="dark"] .toast-undo { border-left-color: rgba(0, 0, 0, .25); }
.toast-undo[hidden] { display: none; }

/* ---------- new surfaces ---------- */

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

.group-title {
  margin: 18px 0 2px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-2);
}
.group-title:first-child { margin-top: 4px; }

.row > span small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
  margin-top: 2px;
}

.row input[type="number"] {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  width: 90px;
}

.row[hidden] { display: none; }

.winner-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
}
.winner-list[hidden] { display: none; }

.winner-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: clamp(17px, 2.6vw, 24px);
  font-weight: 700;
}
.winner-list li span { color: var(--ink-2); font-size: 13px; font-weight: 600; min-width: 26px; }

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.team {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 12px 14px;
}
.team h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 7px;
}
.team h4::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--team-color, var(--accent));
}
.team ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.team li { font-weight: 600; word-break: break-word; }

.fairness {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  padding: 0 12px;
}
.fairness[hidden] { display: none; }
.fairness summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 13px; }
.fairness > div { padding-bottom: 10px; }

.fair-row {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
}
.fair-row .bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}
.fair-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.fair-row .bar b {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 9px;
  background: var(--ink-2);
  border-radius: 1px;
}
.fair-row .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fair-row .n { text-align: right; color: var(--ink-2); }
.fair-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-2); }

.qr-panel {
  position: absolute;
  right: 26px;
  bottom: 26px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 12px 8px;
  box-shadow: var(--shadow);
  text-align: center;
}
.qr-panel[hidden] { display: none; }
.qr-panel canvas { display: block; image-rendering: pixelated; width: 180px; height: 180px; }
.qr-panel p { margin: 6px 0 0; font-size: 11px; font-weight: 600; color: #444; }

body:not(.presenting) .qr-panel { display: none; }

@media (prefers-reduced-motion: reduce) {
  .winner-card { animation: none; }
  .toast { animation: none; }
  .pointer { transition: none; }
}

/* ---------- proof ---------- */

.proof-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.proof-chip[hidden] { display: none; }
.proof-chip:hover { border-color: var(--accent); color: var(--ink); }
.proof-chip code { border: none; background: none; padding: 0; font-size: 12px; color: var(--ink); }
.proof-chip .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}

.proof-reveal {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 0 14px;
  margin: 0 0 20px;
}
.proof-reveal[hidden] { display: none; }
.proof-reveal summary { cursor: pointer; padding: 11px 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.proof-reveal .hint { margin: 8px 0 12px; }

.proof-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  align-items: baseline;
  padding-top: 4px;
}
.proof-grid span { font-size: 12px; color: var(--ink-2); }
.proof-grid code {
  font-size: 11.5px;
  word-break: break-all;
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
}

.verify-out {
  margin: 10px 0 12px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 9px;
}
.verify-out[hidden] { display: none; }
.verify-out.ok { color: #14804a; background: rgba(34, 197, 94, .14); }
.verify-out.bad { color: #b42318; background: rgba(239, 68, 68, .14); }
[data-theme="dark"] .verify-out.ok { color: #6ee7a8; }
[data-theme="dark"] .verify-out.bad { color: #fda29b; }

.entropy-add { display: flex; gap: 8px; }
.entropy-add input {
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
}

.entropy-list { display: flex; flex-wrap: wrap; gap: 6px; }
.entropy-list:empty { display: none; }
.entropy-list .seedchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}
.entropy-list .seedchip button {
  border: none; background: none; cursor: pointer;
  color: var(--ink-2); font: inherit; padding: 0; line-height: 1;
}

/* ---------- tags ---------- */

.tag-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }
.tag-filter[hidden] { display: none; }
.tag-label { font-size: 12px; color: var(--ink-2); }

.tag-chip {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.tag-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- rows, sheets, certificates ---------- */

.row.stack {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 8px;
}
.row.stack input[type="text"] { min-width: 0; width: 100%; }

.sheet.wide { width: min(860px, 96vw); }

.cert-preview { text-align: center; }
.cert-preview canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.winner-path {
  margin: -10px 0 20px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
}
.winner-path[hidden] { display: none; }

.chain-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.chain-line code { font-size: 11px; border: none; background: none; padding: 0; color: var(--ink-2); }

@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- fullscreen presentation ---------- */

body.presenting .panel,
body.presenting .topbar { display: none; }
body.presenting .wheel-wrap { width: min(88vh, 96vw); max-width: none; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel { border-left: none; border-top: 1px solid var(--line); min-height: 46vh; }
  .wheel-wrap { width: min(92vw, 520px); }
  .topbar { flex-wrap: wrap; }
  .wheel-title { order: 3; flex-basis: 100%; }
  .topbar-actions { margin-left: auto; }
}

/* ================= UI pass: menus, modes, editor, tour ================= */

.visually-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- overflow menu ---------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu[hidden] { display: none; }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

.menu button {
  font: inherit;
  font-size: 14px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  cursor: pointer;
}
.menu button:hover { background: var(--bg); }

/* ---------- mode bar ---------- */

.mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.mode-select {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.mode-select:hover { border-color: var(--accent); }

.mode-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px 5px 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.mode-count[hidden] { display: none; }
.mode-count input {
  width: 52px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  text-align: center;
}

/* ---------- slice tooltip ---------- */

.slice-tip {
  position: absolute;
  transform: translate(-50%, -140%);
  background: var(--ink);
  color: var(--bg-2);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slice-tip[hidden] { display: none; }

/* ---------- in-place result ---------- */

.result-card {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 18px;
  max-width: min(680px, 96%);
  animation: rise .18s ease;
}
.result-card[hidden] { display: none; }

.result-main { min-width: 0; text-align: center; }
.result-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.result-name {
  margin: 2px 0 0;
  font-size: clamp(22px, 3.4vw, 34px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.15;
  word-break: break-word;
}
.result-path { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.result-path[hidden] { display: none; }

.result-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-height: 22vh;
  overflow-y: auto;
}
.result-list[hidden] { display: none; }
.result-list li {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 14px;
}

.result-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }

/* ---------- segmented control ---------- */

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }

.seg-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: none;
  border: none;
  border-radius: 999px;
  padding: 4px 13px;
  cursor: pointer;
}
.seg-btn.active { background: var(--bg-2); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- add popover ---------- */

.add-pop {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: none;
}
.add-pop[hidden] { display: none; }

.add-grid { display: grid; grid-template-columns: 1fr 76px; gap: 8px; }
.add-grid label:last-child { grid-column: 1 / -1; }
.add-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.add-grid input {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  min-width: 0;
}
.add-actions { display: flex; justify-content: flex-end; gap: 7px; }
#addPreview { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- text editor with highlighting ---------- */

.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.editor-wrap[hidden] { display: none; }
.editor-wrap:focus-within { border-color: var(--accent); }

.editor-hl, .editor-wrap textarea {
  margin: 0;
  padding: 12px;
  border: none;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.editor-hl {
  position: absolute;
  inset: 0;
  overflow: auto;
  pointer-events: none;
  color: var(--ink);
}

.editor-wrap textarea {
  position: relative;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  outline: none;
  overflow: auto;
}
.editor-wrap textarea::selection { background: rgba(79, 70, 229, .28); }

.tok-weight { color: #c2410c; font-weight: 700; }
.tok-tag    { color: #7c3aed; font-weight: 700; }
.tok-chain  { color: #0369a1; font-weight: 700; }
.tok-rule   { color: #b91c1c; font-weight: 700; }
.tok-note   { color: var(--ink-2); font-style: italic; }

[data-theme="dark"] .tok-weight { color: #fb923c; }
[data-theme="dark"] .tok-tag    { color: #c4b5fd; }
[data-theme="dark"] .tok-chain  { color: #7dd3fc; }
[data-theme="dark"] .tok-rule   { color: #fca5a5; }

/* ---------- structured entry list ---------- */

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.entry-list[hidden] { display: none; }

/* Past the point where syntax colouring is affordable, the textarea shows its
   own text instead of hiding behind the highlight layer. */
#entries.plain { color: var(--ink); -webkit-text-fill-color: var(--ink); }

/* Windowed mode: rows are placed by index, a spacer carries the full height. */
.entry-list.virtual { display: block; position: relative; gap: 0; }
.entry-list.virtual .entry-row {
  position: absolute; left: 0; right: 6px; height: 34px; padding: 0 8px;
}
.entry-list.virtual .tags { display: none; }
.v-pad { width: 1px; pointer-events: none; }

.entry-row {
  display: grid;
  grid-template-columns: 18px 1fr auto auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.entry-row.dragging { opacity: .4; }
.entry-row.away { opacity: .5; }
.entry-row.away .name { text-decoration: line-through; }
.entry-row .pic {
  border: 0; background: none; cursor: pointer; font-size: 13px;
  padding: 2px 4px; border-radius: 6px; line-height: 1; opacity: .55;
}
.entry-row .pic:hover { background: var(--bg-2); opacity: 1; }
.entry-row .pic.has { opacity: 1; }

.entry-row .here {
  border: 0; background: none; cursor: pointer; font-size: 14px;
  padding: 2px 4px; border-radius: 6px; line-height: 1;
}
.entry-row .here:hover { background: var(--bg-2); }

.combo-wrap { margin-bottom: 8px; }
.combo-wrap[hidden] { display: none; }
.combo-wrap label {
  display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px;
}
.combo-wrap textarea {
  width: 100%; resize: vertical; min-height: 66px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 13px;
}

.fair-note.verdict { margin-top: 2px; font-style: italic; }
.fair-note.verdict.flag { color: var(--warn, #d97706); font-style: normal; font-weight: 600; }

/* Bracket: one column per round, ties stacked and centred against the next. */
.bracket { margin-bottom: 10px; }
.bracket[hidden] { display: none; }
.bracket-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; font-size: 12px; color: var(--ink-2);
}
.bracket-rounds { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.bracket-round { display: flex; flex-direction: column; min-width: 116px; }
.bracket-ties { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 6px; }
.bracket-round > h4 {
  margin: 0 0 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-2); font-weight: 700;
}
.tie {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--bg); font-size: 12px;
}
.tie span { display: block; padding: 3px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tie span + span { border-top: 1px solid var(--line); }
.tie span.won { font-weight: 700; background: var(--bg-2); }
.tie span.out { opacity: .45; text-decoration: line-through; }
.tie span.tbd { opacity: .4; font-style: italic; }
.tie.next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }

.versions { flex-basis: 100%; margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 6px; }
.versions[hidden] { display: none; }
.version {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 3px 0; font-size: 12px; color: var(--ink-2);
}

#diagBody h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-2); margin: 16px 0 8px; }
#diagBody h3:first-child { margin-top: 4px; }
.diag-row {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 8px;
  align-items: baseline; padding: 3px 0; font-size: 13px;
}
.diag-row i { font-style: normal; font-weight: 700; }
.diag-row i.yes { color: #14804a; }
.diag-row i.no { color: #b42318; }
.diag-row.problem { grid-template-columns: 62px 1fr; color: var(--ink-2); font-size: 12px; }
.diag-row small { color: var(--ink-2); font-size: 11px; }

.store-list { display: flex; flex-direction: column; gap: 7px; margin: 12px 0; }
.store-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  align-items: baseline; font-size: 13px;
}
.store-row.sub { padding-left: 12px; color: var(--ink-2); font-size: 12px; }
.store-row i {
  grid-column: 1 / -1; height: 4px; border-radius: 2px;
  background: var(--accent); opacity: .8; min-width: 2px;
}
.store-row.sub i { opacity: .35; }

.result-filter {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px;
}
.result-filter input[type="search"] {
  flex: 1 1 130px; min-width: 0; padding: 5px 9px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink);
}
.result-filter select {
  padding: 5px 7px; font: inherit; font-size: 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink);
}
.result-filter .only-proof {
  display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2);
}

.away-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; margin-bottom: 6px;
  border: 1px dashed var(--line); border-radius: 10px;
  font-size: 12px; color: var(--ink-2);
}
.away-bar[hidden] { display: none; }
.entry-row.drop-target { border-color: var(--accent); border-style: dashed; }

.entry-row .grab { cursor: grab; color: var(--ink-2); font-size: 13px; text-align: center; user-select: none; }
.entry-row .grab:active { cursor: grabbing; }

.entry-row .name {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 5px;
  min-width: 0;
}
.entry-row .name:focus { outline: none; border-color: var(--accent); background: var(--bg-2); }

.entry-row .weight { display: inline-flex; align-items: center; gap: 1px; }
.entry-row .weight button {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-2);
  width: 22px; height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0;
}
.entry-row .weight button:hover { color: var(--ink); border-color: var(--accent); }
.entry-row .weight span { min-width: 22px; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.entry-row .kill {
  border: none; background: none; cursor: pointer;
  color: var(--ink-2); font-size: 14px; padding: 2px 4px; border-radius: 6px;
}
.entry-row .kill:hover { color: #e0464a; background: var(--bg-2); }

.entry-row .tags { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.entry-row .tags b {
  font-size: 10.5px; font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ---------- examples / empty state ---------- */

.examples { flex: none; text-align: center; padding: 10px 0; }
.examples[hidden] { display: none; }
.examples p { margin: 0 0 9px; font-size: 13px; color: var(--ink-2); }
.examples div { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ---------- customize sub-header ---------- */

.sheet-sub {
  padding: 10px 18px 0;
  border-bottom: 1px solid var(--line);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.preset-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }

.cust-search {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  width: 100%;
}
.cust-search:focus { outline: none; border-color: var(--accent); }

.cust-tabs { display: flex; gap: 2px; }

.cust-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  cursor: pointer;
}
.cust-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- shortcuts ---------- */

.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; padding: 4px 0; }
.keys > div { display: flex; gap: 4px; justify-content: flex-end; }
.keys span { font-size: 13.5px; color: var(--ink-2); }

/* ---------- tour ---------- */

.tour { position: fixed; inset: 0; z-index: 95; }
.tour[hidden] { display: none; }

.tour-spot {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(8, 12, 20, .62);
  border: 2px solid var(--accent);
  transition: all .22s ease;
  pointer-events: none;
}

.tour-box {
  position: absolute;
  background: var(--bg-2);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  max-width: 320px;
  transition: all .22s ease;
}
.tour-box p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.tour-actions { display: flex; justify-content: flex-end; gap: 7px; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .panel { min-height: 52vh; }
  .topbar-actions .btn.ghost { padding: 8px 10px; font-size: 13.5px; }
  .result-card { flex-direction: column; gap: 12px; }
  .add-grid { grid-template-columns: 1fr 70px; }
}

@media (max-width: 620px) {
  #btnCustomize, #btnSave { display: none; }   /* reachable from the ⋯ menu */
  .brand-name { display: none; }
  .mode-bar { flex-wrap: wrap; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .result-card, .tour-spot, .tour-box { animation: none; transition: none; }
}

/* ---------- keep the result card on screen ----------
   The stage is a fixed-height flex column with no scrolling, so a full-size
   wheel plus a result card can push the card below the fold — where it is
   both invisible and unclickable. Give the wheel less room while a result
   is showing, and less again on short viewports. */

.stage { overflow: hidden; }

body.has-result .wheel-wrap { width: min(54vh, 100%); }

@media (max-height: 820px) {
  .wheel-wrap { width: min(64vh, 100%); }
  body.has-result .wheel-wrap { width: min(46vh, 100%); }
}

@media (max-height: 640px) {
  .wheel-wrap { width: min(56vh, 100%); }
  body.has-result .wheel-wrap { width: min(38vh, 100%); }
  .result-card { padding: 10px 14px; }
  .result-name { font-size: clamp(18px, 2.6vw, 24px); }
}

/* ---------- odds strip ---------- */

.odds { width: min(560px, 92%); flex: none; }
.odds[hidden] { display: none; }

.odds-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.odds-bar i { display: block; height: 100%; min-width: 2px; }
.odds-note { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-2); text-align: center; }

/* ---------- season heatmap + ledger ---------- */

.season { display: flex; flex-direction: column; gap: 4px; flex: none; overflow-x: auto; }
.season:empty { display: none; }

.season-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 8px; }
.season-row .who {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.season-row .cells { display: flex; gap: 3px; }
.season-row .n { font-size: 11px; color: var(--ink-2); min-width: 16px; text-align: right; }

.season-cell {
  width: 15px; height: 15px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.season-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 28%, transparent); border-color: transparent; }
.season-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 55%, transparent); border-color: transparent; }
.season-cell[data-level="3"] { background: var(--accent); border-color: transparent; }

.season-head { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; font-size: 10.5px; color: var(--ink-2); }
.season-overdue { color: #b45309; font-weight: 700; }
[data-theme="dark"] .season-overdue { color: #fbbf24; }

.ledger { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: none; }
.ledger:empty { display: none; }

.ledger li {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); padding: 8px 12px;
  font-size: 13.5px;
}
.ledger li.done { opacity: .5; text-decoration: line-through; }
.ledger li span { flex: 1; word-break: break-word; }
.ledger li button {
  border: 1px solid var(--line); background: var(--bg-2);
  border-radius: 8px; padding: 3px 9px; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.ledger li button:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- ticker (very long lists) ---------- */

.ticker {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}
body.ticker-mode .ticker { display: flex; }
body.ticker-mode #wheel { visibility: hidden; }

.ticker-item {
  font-size: clamp(15px, 2.4vw, 26px);
  font-weight: 700;
  padding: 5px 0;
  color: var(--ink-2);
  white-space: nowrap;
}
.ticker-item.mid { color: var(--ink); font-size: clamp(20px, 3.2vw, 36px); }

/* ---------- misc ---------- */

.entropy-add input[type="file"] { font-size: 12px; color: var(--ink-2); flex: 1; min-width: 0; }

.chip.listening { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[hidden] { display: none; }

/* ---------- embed mode ---------- */
body.embed .topbar, body.embed .panel { display: none; }
body.embed .layout { grid-template-columns: 1fr; }

/* ---------- custom palette ---------- */

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }

.swatches label { position: relative; display: block; }

.swatches input[type="color"] {
  width: 38px; height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.swatches input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
.swatches input[type="color"]:hover { border-color: var(--accent); }

.swatch-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.swatch-count {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2); font-weight: 600;
}
.swatch-count input {
  width: 58px;
  font: inherit; font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 7px;
  text-align: center;
}

/* ---------- proof words, templates, overlay ---------- */

.proof-words {
  font-size: 13.5px;
  letter-spacing: .01em;
  color: var(--ink);
  word-spacing: .25em;
}
#proofChipWords { color: var(--ink); font-weight: 700; margin-right: 6px; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }

.template-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.template-card:hover { border-color: var(--accent); }
.template-card b { display: block; font-size: 14px; margin-bottom: 3px; }
.template-card span { font-size: 12px; color: var(--ink-2); }

/* Stream overlay: just the wheel, on transparency */
body.overlay { background: transparent; }
body.overlay .topbar, body.overlay .panel, body.overlay .mode-bar,
body.overlay .stage-note, body.overlay .odds, body.overlay .proof-chip { display: none; }
body.overlay .layout { grid-template-columns: 1fr; }
body.overlay .stage { background: transparent; }

/* Streaming: a flat key colour a compositor can remove cleanly. */
body.chroma, body.chroma .stage, body.chroma .layout { background: var(--chroma, #00b140); }
body.chroma .wheel-wrap { filter: none; }
body.chroma .stage-note, body.chroma .thumb-spin { display: none; }

@media print {
  body { overflow: visible; height: auto; display: block; }
  .topbar, .stage, .panel-tools, .tabs, .modal-backdrop, .toast, .tour { display: none !important; }
  .layout { display: block; }
  .tabpane { display: block !important; }
  .results li, .ledger li, .season-row { break-inside: avoid; }
  /* On screen a wide bracket scrolls; on paper it has to fit the page. */
  .bracket-rounds { overflow: visible; flex-wrap: wrap; }
  .bracket-round { break-inside: avoid; }
  .bracket, .tie { break-inside: avoid; }
}

/* ---------- controls that live next to what they affect ---------- */

.stage-sound { background: var(--bg-2); }

.inline-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.inline-setting label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.inline-setting small { font-size: 11.5px; color: var(--ink-2); flex-basis: 100%; }

.mini-select {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
}
.mini-select:hover { border-color: var(--accent); }

/* ---------- intent chooser ---------- */

.intent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }

.intent-card {
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
}
.intent-card:hover { border-color: var(--accent); }
.intent-card b { display: block; font-size: 15px; margin-bottom: 4px; }
.intent-card span { font-size: 12px; color: var(--ink-2); line-height: 1.45; }

/* ---------- why this? ---------- */

.why-line {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.why-line:last-child { border-bottom: none; }
.why-line i { font-style: normal; opacity: .8; }
.why-line b { display: block; font-weight: 700; }
.why-line span { color: var(--ink-2); font-size: 12.5px; }
.why-line code { word-break: break-all; }

/* ---------- timeline ---------- */

.timeline { flex: none; display: flex; flex-direction: column; gap: 8px; }
.timeline[hidden] { display: none; }
.timeline input[type="range"] { width: 100%; accent-color: var(--accent); }

.timeline-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  padding: 10px 12px;
}
.timeline-card b { display: block; font-size: 15px; }
.timeline-card small { color: var(--ink-2); font-size: 11.5px; }
.timeline-card .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- customize depth ---------- */

.cust-depth { display: flex; align-items: center; gap: 8px; }
.cust-depth .cust-search { flex: 1; }

/* ---------- room mode ---------- */

body.room .topbar, body.room .panel, body.room .odds,
body.room .stage-note, body.room .mode-bar { display: none; }
body.room .layout { grid-template-columns: 1fr; }
body.room .stage { padding: 2vh 2vw; gap: 2vh; }
body.room .wheel-wrap { width: min(62vh, 92vw); }
body.room.has-result .wheel-wrap { width: min(46vh, 80vw); }

body.room .result-card {
  padding: 2vh 3vw;
  border-width: 2px;
  max-width: 92vw;
}
body.room .result-label { font-size: clamp(13px, 1.4vw, 20px); letter-spacing: .2em; }
body.room .result-name { font-size: clamp(40px, 9vw, 140px); }
body.room .result-actions .btn { font-size: clamp(14px, 1.4vw, 20px); padding: 12px 20px; }
body.room .proof-chip { font-size: clamp(12px, 1.2vw, 18px); padding: 10px 20px; }
body.room #proofChipWords { font-size: 1.1em; }

/* ---------- editing on the wheel ---------- */

body.editing #wheel { cursor: pointer; }
body.editing .spin-hint { opacity: .45; pointer-events: none; }
#btnEdit[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.slice-rename {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: 168px;
  font: 700 14px/1.2 inherit;
  text-align: center;
  color: var(--ink);
  background: var(--bg-2);
  border: 2px solid var(--accent);
  border-radius: 9px;
  padding: 7px 9px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.slice-rename[hidden] { display: none; }
.slice-rename:focus { outline: none; }

/* ---------- command palette ---------- */

.palette-backdrop { align-items: start; padding-top: 12vh; }

.palette {
  width: min(620px, 94vw);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.palette input {
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}
.palette input:focus { outline: none; }

.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 46vh;
  overflow-y: auto;
}

.palette-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
}
.palette-list li.on { background: var(--accent); color: #fff; }
.palette-list li.on small { color: rgba(255, 255, 255, .8); }
.palette-list li i { font-style: normal; opacity: .85; width: 18px; text-align: center; }
.palette-list li b { font-weight: 600; }
.palette-list li small { color: var(--ink-2); font-size: 12px; margin-left: auto; }
.palette-list:empty::after {
  content: 'Nothing matches that.';
  display: block; padding: 16px 12px; color: var(--ink-2); font-size: 13.5px;
}

.palette-foot {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-2);
}
.palette-foot kbd { margin-right: 3px; }

/* ================= rollout: mobile, drawers, density, motion ================= */

/* ---------- display size ---------- */

:root { --scale: 1; }
[data-density="compact"]     { --scale: .88; }
[data-density="large"]       { --scale: 1.16; }

body { font-size: calc(15px * var(--scale)); }
.btn, .chip, .tab, .mode-select, .seg-btn { font-size: calc(13px * var(--scale)); }
.stage-note { font-size: calc(13px * var(--scale)); }
.result-name { font-size: calc(clamp(22px, 3.4vw, 34px) * var(--scale)); }

/* ---------- the sheets become an inspector on the right ---------- */

@media (min-width: 901px) {
  .modal-backdrop.as-drawer { place-items: stretch; justify-items: end; padding: 0; background: rgba(10, 14, 22, .38); }
  .modal-backdrop.as-drawer .sheet {
    height: 100%;
    max-height: none;
    width: min(520px, 92vw);
    border-radius: 16px 0 0 16px;
    animation: slide-in .2s cubic-bezier(.2, .8, .3, 1);
  }
  .modal-backdrop.as-drawer .sheet.wide { width: min(760px, 96vw); }
}

@keyframes slide-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- notices ---------- */

.notices { display: flex; flex-direction: column; gap: 6px; flex: none; }
.notices:empty { display: none; }

.notice {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
}
.notice b { color: var(--ink); font-weight: 600; }
.notice button {
  margin-left: auto;
  font: inherit; font-size: 12px; font-weight: 700;
  color: var(--accent); background: none; border: none; cursor: pointer; white-space: nowrap;
}
.notice.warn { border-color: color-mix(in srgb, #d97706 40%, var(--line)); }

/* ---------- motion ---------- */

.result-card { transform-origin: 85% 0; }
@keyframes from-pointer {
  from { transform: translate(18px, -14px) scale(.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.result-card:not([hidden]) { animation: from-pointer .22s cubic-bezier(.2, .9, .3, 1); }

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

.sheet-grip { display: none; }
.thumb-spin { display: none; }

@media (max-width: 900px) {
  body { overflow: hidden; }
  .layout { display: block; height: 100%; position: relative; }

  .stage {
    height: 100%;
    padding: 8px 12px calc(34vh + env(safe-area-inset-bottom, 0px));
    justify-content: flex-start;
    gap: 10px;
  }
  .wheel-wrap { width: min(92vw, 52vh); }
  body.has-result .wheel-wrap { width: min(74vw, 40vh); }

  /* the panel is a bottom sheet with three resting places */
  .panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 88vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .28);
    z-index: 40;
    transform: translateY(calc(88vh - var(--sheet-open, 30vh)));
    transition: transform .24s cubic-bezier(.2, .8, .3, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.sheet-half .panel { --sheet-open: 55vh; }
  body.sheet-full .panel { --sheet-open: 88vh; }
  body.sheet-dragging .panel { transition: none; }

  .sheet-grip {
    display: block;
    width: 100%;
    height: 26px;
    border: none;
    background: none;
    cursor: grab;
    position: relative;
    flex: none;
    touch-action: none;
  }
  .sheet-grip::before {
    content: '';
    position: absolute;
    left: 50%; top: 10px;
    width: 42px; height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: var(--line);
  }

  /* spin where a thumb actually reaches */
  .thumb-spin {
    display: block;
    position: fixed;
    left: 50%;
    bottom: calc(32vh + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 30;
    border: none;
    border-radius: 999px;
    padding: 16px 42px;
    font: 800 17px/1 inherit;
    letter-spacing: .08em;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  }
  .thumb-spin:disabled { opacity: .5; }
  body.sheet-full .thumb-spin { display: none; }
  .spin-hint { font-size: clamp(10px, 3vw, 14px); }

  /* the thumb button owns the lower third, so the status line moves up */
  .mode-bar { order: -2; }
  .stage-note { order: -1; text-align: center; }
  .result-card { max-width: 94vw; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .modal-backdrop.as-drawer .sheet { width: 100%; max-height: 92vh; }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}

/* ---------- spreadsheet import ---------- */

.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 4px; align-items: end; }
.map-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.map-grid small { font-weight: 400; text-transform: none; }
.map-grid select {
  font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }

.preview { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.preview td, .preview th { padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
.preview th { background: var(--bg); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); }
.preview tr:last-child td { border-bottom: none; }
.preview td.picked { color: var(--ink); font-weight: 700; }
.preview td { color: var(--ink-2); }

.drop-veil {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(10, 14, 22, .72);
  display: grid; place-items: center;
  border: 3px dashed var(--accent);
  pointer-events: none;
}
.drop-veil[hidden] { display: none; }
.drop-veil div { font-size: 22px; font-weight: 700; color: #fff; }

/* ---------- a wheel linked to a file ---------- */

.linked-file {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.linked-file[hidden] { display: none; }
.linked-file b { color: var(--ink); font-weight: 600; }
.linked-file .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
  flex: none;
}
.linked-file .chip { margin-left: auto; }
.linked-file .chip + .chip { margin-left: 0; }


/* Reading it as a list: the wheel steps aside, the names take its place. */
.text-wheel {
  position: absolute; inset: 6%; margin: 0; padding: 14px; overflow: auto;
  list-style: none; counter-reset: pick;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
}
.text-wheel[hidden] { display: none; }
.text-wheel li {
  counter-increment: pick;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 9px; font-size: 15px;
}
.text-wheel li::before {
  content: counter(pick) '.'; color: var(--ink-2); font-size: 12px;
  min-width: 2.2em; text-align: right; margin-right: 6px;
}
.text-wheel li span { flex: 1; }
.text-wheel li b { color: var(--ink-2); font-weight: 600; font-size: 12px; }
.text-wheel li.won { background: var(--accent); color: #fff; font-weight: 700; }
.text-wheel li.won b { color: rgba(255,255,255,.85); }
body.text-only #wheel,
body.text-only .pointer,
body.text-only .spin-hint { visibility: hidden; }
body.text-only .wheel-wrap::before,
body.text-only .wheel-wrap::after { display: none; }

/* Second screen: a mirror, so nothing on it is clickable. */
body.screen .side, body.screen header nav, body.screen .toast-wrap { display: none; }
body.screen .stage { pointer-events: none; position: relative; }

/* A projected tournament wants the tree beside the wheel, not in a panel
   nobody can see. */
body.screen .bracket {
  position: absolute; top: 16px; right: 16px; max-width: 38vw; max-height: 76vh;
  overflow: auto; padding: 12px 14px; margin: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.28);
}
body.screen .bracket .bracket-head button { display: none; }
body.screen .bracket-round { min-width: 104px; }
