/* ViewerPlay's one look, used by every page of the site (not the OBS overlays,
   which have their own). Colors are tokens; dark mode follows the computer's setting.
   Each tool has its own color and icon (body class tool-*, icons in /assets/icons.js),
   so its pages can be told apart at a glance. */
:root {
  color-scheme: light dark;
  --bg: #faf9f5; --surface: #ffffff; --hover: #f1efe8; --line: #e7e4da; --line-2: #d6d2c5;
  --text: #1f1e1d; --dim: #6b6a64; --faint: #9c9a92;
  --accent: #c96442;
  --ok: #2b7a4b; --ok-bg: #e3f1e7; --bad: #b3382c; --bad-bg: #fbe6e2; --live: #d33a2c; --live-bg: #fde7e3;
  --tool: #6b6a64; --tool-bg: #eeece5;
  --shadow: 0 1px 2px rgba(31, 30, 29, .05), 0 8px 24px rgba(31, 30, 29, .07);
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
.tool-bits   { --tool: #c05a12; --tool-bg: #fbeadb; }
.tool-subs   { --tool: #2b7a4b; --tool-bg: #e3f1e7; }
.tool-poll   { --tool: #2c6cb0; --tool-bg: #e2edf9; }
.tool-irlsub { --tool: #b8336f; --tool-bg: #fae4ee; }
.tool-actionpoll { --tool: #6a4fc4; --tool-bg: #ece7fa; }
.tool-wheel { --tool: #1d7f86; --tool-bg: #dcf1f1; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1e1c; --surface: #272624; --hover: #31302d; --line: #383733; --line-2: #4a4843;
    --text: #f0eee6; --dim: #b0aea6; --faint: #84827b;
    --accent: #e0805f;
    --ok: #6cc28e; --ok-bg: #213a2a; --bad: #f08a7c; --bad-bg: #44241f; --live: #ff6b5c; --live-bg: #4a221d;
    --tool: #b0aea6; --tool-bg: #34332f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
  .tool-bits   { --tool: #ee9a5c; --tool-bg: #45301f; }
  .tool-subs   { --tool: #6cc28e; --tool-bg: #213a2a; }
  .tool-poll   { --tool: #6eaaea; --tool-bg: #1e3247; }
  .tool-irlsub { --tool: #ee7fae; --tool-bg: #45223a; }
  .tool-actionpoll { --tool: #a993f0; --tool-bg: #2f2747; }
  .tool-wheel { --tool: #5cc6cc; --tool-bg: #1d3a3c; }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1 { margin: 0; font: 500 32px/1.15 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { margin: 0; font: 600 15px/1.3 var(--sans); }
p { margin: 0; }
code { font: 13px var(--mono); background: var(--hover); border-radius: 5px; padding: 2px 6px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar: brand / where you are / account ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 20px;
  background: var(--bg); border-bottom: 1px solid var(--line); font-size: 14px; }
body[class*=tool-] .topbar { box-shadow: inset 0 3px 0 var(--tool); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand .logo { width: 22px; height: 22px; display: block; }
.topbar .sep { color: var(--faint); }
.topbar a:not(.brand) { color: var(--dim); text-decoration: none; white-space: nowrap; }
.topbar a:not(.brand):hover { color: var(--text); }
.topbar .here { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .me { margin-left: auto; display: flex; align-items: center; gap: 4px; color: var(--dim); white-space: nowrap; }

/* ---------- page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 36px 20px 96px; }
.page.narrow { max-width: 760px; }
.head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; flex-wrap: wrap; }
.head .titles { flex: 1 1 260px; min-width: 0; }
.head .kind { font-size: 13px; font-weight: 600; color: var(--tool); margin-bottom: 2px; }
.section { margin-top: 40px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: center; gap: 10px; min-height: 34px; margin-bottom: 10px; }
.section-head h2 { flex: 1; }
.num { color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.dim { color: var(--dim); }
.center { max-width: 440px; margin: 16vh auto 0; padding: 0 20px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.center p { color: var(--dim); }

/* tool icon tile */
.ticon { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--tool-bg); color: var(--tool); }
.ticon svg { width: 17px; height: 17px; }
.ticon.lg { width: 48px; height: 48px; border-radius: 12px; }
.ticon.lg svg { width: 26px; height: 26px; }
.ico { width: 16px; height: 16px; flex: none; }

/* ---------- controls ---------- */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--text);
  font: 500 14px/1 var(--sans); text-decoration: none; white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
button:hover, .btn:hover { background: var(--hover); }
.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.primary:hover { background: var(--text); opacity: .86; }
.quiet { background: transparent; border-color: transparent; color: var(--dim); }
.quiet:hover { background: var(--hover); color: var(--text); }
.danger { color: var(--bad); }
.danger:hover { color: var(--bad); }
.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
button.lg, .btn.lg { height: 42px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.icon { width: 30px; padding: 0; }
.icon.sm { width: 28px; }
button:disabled, .btn[aria-disabled=true] { opacity: .4; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); }
.primary:disabled:hover { background: var(--text); opacity: .4; }
.quiet:disabled:hover { background: transparent; }

input[type=text], input[type=number], input[type=url], input[type=password], textarea, select {
  height: 34px; min-width: 0; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); color: var(--text); font: 400 14px/1.4 var(--sans); }
textarea { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; width: 100%; }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%239c9a92' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 16px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[readonly] { color: var(--dim); background: var(--bg); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--text); cursor: pointer; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-size: 13px; font-weight: 500; color: var(--dim); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); cursor: pointer; white-space: nowrap; }
.err { color: var(--bad); font-size: 14px; }
.err:empty { display: none; }

/* on / off switch (a button with role=switch) */
.switch { gap: 10px; padding: 0 12px 0 8px; }
.switch::before { content: ''; width: 30px; height: 18px; border-radius: 999px; background: var(--line-2) radial-gradient(circle at 9px 9px, #fff 6px, transparent 6.5px); transition: background .15s; }
.switch[aria-checked=true]::before { background: var(--ok) radial-gradient(circle at 21px 9px, #fff 6px, transparent 6.5px); }

/* segmented choice (preview tabs, type picker) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--hover); border-radius: 9px; }
.seg button { height: 28px; border: 0; background: transparent; color: var(--dim); font-size: 13px; border-radius: 7px; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* page tabs */
.tabs { display: flex; gap: 2px; margin: 0 0 28px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { height: 40px; padding: 0 12px; border: 0; border-radius: 0; background: none; color: var(--dim); box-shadow: inset 0 -2px 0 transparent; }
.tabs button:hover { background: none; color: var(--text); }
.tabs button[aria-selected=true] { color: var(--text); box-shadow: inset 0 -2px 0 var(--tool); }
body:not([class*=tool-]) .tabs button[aria-selected=true] { box-shadow: inset 0 -2px 0 var(--text); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rows > li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.rows > li.off { opacity: .55; }
.rows > li:has(> a.fill) { padding: 0; }
.rows a.fill { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; align-self: stretch; padding: 10px 16px; text-decoration: none; }
.rows > li:has(a.fill):hover { background: var(--hover); }
.rows .name { font-weight: 500; overflow-wrap: anywhere; }
.rows .meta { color: var(--dim); font-size: 13px; }
.rows .meta a { color: inherit; text-decoration: none; }
.rows .meta a:hover { text-decoration: underline; }
.rows > li.empty, .empty { justify-content: center; color: var(--dim); padding: 28px 16px; text-align: center; }
.arrow { color: var(--faint); flex: none; }

/* actions that show on hover (always on touch screens) */
.reveal { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .12s; }
li:hover .reveal, li:focus-within .reveal { opacity: 1; }
@media (hover: none) { .reveal { opacity: 1; } }

/* status pills */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--hover); color: var(--dim); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.live { background: var(--live-bg); color: var(--live); }
.badge.accent { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.badge.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .badge.live::before { animation: none; } }

.notice { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 10px 10px 16px; margin-bottom: 20px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px; }
.notice > span { flex: 1 1 260px; }
.notice.bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--dim); font-weight: 500; font-size: 13px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 20, 19, .4); }
dialog h2 { font: 500 22px/1.2 var(--serif); margin-bottom: 4px; }
dialog form { display: grid; gap: 16px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, 6px); transition: opacity .18s, transform .18s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .page { padding: 24px 16px 80px; }
  .topbar { padding: 0 16px; }
  .topbar .me > span { display: none; }
  h1 { font-size: 27px; }
}
