:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #5f6b7a;
  --line: #dde1e6;
  --accent: #8a1c1c;
  --accent-ink: #ffffff;
  --ok: #1d6b3a;
  --warn: #9a5b00;
  --bad: #a11d1d;
  --chip: #eef0f3;
  --bar: #1b1f24;
  --bar-ink: #f1f1f1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1d2127; --ink: #e6e8eb; --muted: #9aa4b1; --line: #2e343c;
    --accent: #d05a5a; --accent-ink: #14171b; --ok: #5fc48a; --warn: #e0a64a; --bad: #ef6b6b; --chip: #272c33;
    --bar: #0d0f12; --bar-ink: #e6e8eb;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
header.top { background: var(--bar); color: var(--bar-ink); display: flex; align-items: center; gap: 16px; padding: 10px 20px; }
header.top .brand { font-weight: 700; letter-spacing: .02em; }
header.top .brand span { color: #d97a7a; }
header.top .spacer { flex: 1; }
header.top .who { color: #b8c0ca; font-size: 13px; }
header.top button { background: transparent; color: var(--bar-ink); border: 1px solid #4a525c; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
p.lead { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; }
input[type=checkbox] { width: auto; }
button, .btn { font: inherit; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.small { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }
.err { color: var(--bad); min-height: 1.4em; margin-top: 8px; font-size: 14px; }
.note { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--chip); }
.pill.active { color: var(--ok); }
.pill.revoked, .pill.suspended, .pill.expired { color: var(--bad); }
.pill.invited, .pill.no-views-left { color: var(--warn); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.hidden { display: none !important; }
.linkbox { display: flex; gap: 8px; margin-top: 10px; }
.linkbox input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.checklist { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; }
.checklist label { display: flex; gap: 8px; align-items: center; color: var(--ink); margin: 4px 0; font-size: 14px; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lib .card { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lib .card .meta { color: var(--muted); font-size: 13px; }
.lib .card button { margin-top: auto; align-self: flex-start; }

/* viewer */
body.viewer { background: #2a2e34; user-select: none; -webkit-user-select: none; }
.vbar { position: sticky; top: 0; z-index: 2; background: var(--bar); color: var(--bar-ink); display: flex; gap: 10px; align-items: center; padding: 8px 14px; flex-wrap: wrap; }
.vbar .title { font-weight: 600; flex: 1; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbar button { background: #2f353d; color: var(--bar-ink); border-color: #444c56; }
.vbar input { width: 64px; padding: 5px 6px; background: #2f353d; color: var(--bar-ink); border-color: #444c56; text-align: center; }
.vbar .code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #b8c0ca; }
.stage { display: flex; justify-content: center; padding: 20px 12px 60px; }
.stage canvas { background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.4); max-width: 100%; height: auto; transition: filter .15s; }
.stage.veiled canvas { filter: blur(18px); }
.vmsg { color: #e6e8eb; text-align: center; padding: 30px 16px; }
@media print { body * { display: none !important; } body::after { content: "Printing is not permitted for this document."; display: block; } }
