:root {
  --bg: #0b0d10;
  --panel: rgba(20, 23, 28, 0.92);
  --line: #2a2f37;
  --text: #e6e8eb;
  --muted: #8b93a0;
  --accent: #fbbf24;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
button, select, input {
  font: inherit; color: inherit; background: #1b1f25;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
[hidden] { display: none !important; }

#bar {
  position: fixed; inset: 0 0 auto 0; height: 44px; z-index: 2;
  display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#bar .spacer { flex: 1; }
#title { font-size: 15px; white-space: nowrap; }
#search { width: 200px; }
#progress { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#mode.all { border-color: var(--accent); color: var(--accent); }
#present { border-color: var(--muted); }
#present.live { border-color: #ef4444; color: #fca5a5; }

#stage { position: fixed; inset: 44px 0 0 0; }
#deck { width: 100%; height: 100%; display: block; }
#tooltip {
  position: absolute; z-index: 1; pointer-events: none; max-width: 360px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#adjust {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 260px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
#adjust label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
#adjust label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
#adjust input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); }
#adjust p { margin: 0; font-size: 11px; color: var(--muted); }
#adjust-btn.changed { border-color: var(--accent); color: var(--accent); }
#loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 18px; pointer-events: none;
}

#zoom {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px;
}
#zoom button { width: 34px; height: 34px; padding: 0; font-size: 18px; background: var(--panel); }
body.display #zoom { display: none; }

#info {
  position: fixed; left: 10px; bottom: 10px; z-index: 2; width: 280px; max-height: 50vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
#info h3 { margin: 0 0 4px; font-size: 14px; word-break: break-all; }
#info .muted { color: var(--muted); }
#info table { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 12px; }
#info td { padding: 1px 4px 1px 0; vertical-align: top; word-break: break-word; }
#info td:first-child { color: var(--muted); white-space: nowrap; }
.bar-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 3px; }
.bar-row .bar { height: 8px; border-radius: 4px; min-width: 2px; }

#classes {
  position: fixed; right: 10px; bottom: 10px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 70vw;
}
#classes button { display: flex; align-items: center; gap: 6px; background: var(--panel); }
#classes .swatch { width: 12px; height: 12px; border-radius: 3px; }
#classes kbd { color: var(--muted); font: 12px ui-monospace, monospace; }
#classes button.active { border-color: var(--text); }
#classes .count { color: var(--muted); font-variant-numeric: tabular-nums; }
#classes.legend-only button { cursor: default; opacity: 1; }

#help {
  position: fixed; top: 54px; right: 10px; z-index: 3; width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 16px 12px;
}
#help h2 { font-size: 15px; }
#help td { padding: 2px 10px 2px 0; }
#help td:first-child { font-family: ui-monospace, monospace; color: var(--accent); white-space: nowrap; }
#help p { color: var(--muted); font-size: 12px; }

dialog {
  background: #14171c; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 22px; min-width: 300px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
dialog input { width: 100%; margin-bottom: 8px; }
#gate-error { color: #f87171; min-height: 1em; margin: 0 0 8px; font-size: 12px; }

#toast {
  position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: 4;
  background: #7f1d1d; padding: 6px 14px; border-radius: 6px; opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.ok { background: #14532d; }

/* Big-screen display: no controls, just the images and the tally. */
body.display #bar { display: none; }
body.display #stage { inset: 0; }
body.display #title-overlay {
  position: fixed; top: 14px; left: 18px; z-index: 2; font-size: 26px; font-weight: 700;
  text-shadow: 0 2px 8px #000;
}
body.display #classes { font-size: 18px; }
body.display #title-overlay.live::after {
  content: "● LIVE"; margin-left: 14px; font-size: 16px; color: #f87171; vertical-align: middle;
}
body.display #info { width: 440px; font-size: 18px; padding: 14px 18px; }
body.display #info h3 { font-size: 24px; }
body.display .bar-row { font-size: 16px; }
body.display .bar-row .bar { height: 14px; }

/* ---------------------------------------------------------------- admin page */
/* The viewer locks page scrolling on html and body; the admin page scrolls normally. */
html.admin-page, html.admin-page body { overflow: auto; height: auto; }
.tag { font-size: 12px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 6px; }
a.button {
  color: inherit; text-decoration: none; background: #1b1f25;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; white-space: nowrap;
}
a.button:hover { border-color: var(--muted); }
main.admin { max-width: 1200px; margin: 0 auto; padding: 64px 20px 40px; }
main.admin section {
  background: #12151a; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 16px;
}
main.admin h2 { margin: 0 0 12px; font-size: 16px; }
.muted { color: var(--muted); }
.good { color: #4ade80; }
.bad { color: #f87171; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill { padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.pill.ok { background: #14532d; color: #bbf7d0; }
.pill.off { background: #7f1d1d; color: #fecaca; }
button.primary { background: #a16207; border-color: #ca8a04; color: #fff; }
button.danger:hover { border-color: #ef4444; color: #fca5a5; }
button:disabled { opacity: 0.45; cursor: default; }

table.links { margin-top: 12px; border-collapse: collapse; }
table.links td { padding: 3px 8px 3px 0; }
table.links input { width: 420px; font-family: ui-monospace, monospace; font-size: 12px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 6px 8px; }
table.grid td { border-bottom: 1px solid #1d2128; padding: 8px; vertical-align: middle; }
button.switch { min-width: 44px; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
button.switch.on { background: #14532d; border-color: #166534; color: #bbf7d0; }
button.switch.off { color: var(--muted); }
table.grid tr.removed td { opacity: 0.5; }
table.grid tr.removed td:last-child { opacity: 1; }
.row.heading { margin-bottom: 12px; }
.row.heading h2 { margin: 0; }
.row .spacer { flex: 1; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
table.grid .actions button, table.grid .actions a.button { font-size: 12px; padding: 2px 8px; }
.stack { display: flex; width: 140px; height: 10px; border-radius: 5px; overflow: hidden; background: #1d2128; }
.status { display: flex; flex-direction: column; gap: 3px; font-size: 12px; min-width: 140px; }
progress { width: 160px; accent-color: var(--accent); }

#upload { display: flex; flex-direction: column; gap: 12px; }
p.intro { margin: -6px 0 12px; }
.drop {
  display: grid; place-items: center; min-height: 90px; border: 2px dashed var(--line); border-radius: 10px;
  color: var(--muted); cursor: pointer; text-align: center; padding: 10px;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }
.fields { display: flex; gap: 14px; flex-wrap: wrap; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fields input, .fields select { min-width: 220px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
label.choice { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }
