:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1f1d1a; --muted: #655f56; --line: #dedad1; --soft: #efece5;
  --accent: #6b3fa0; --accent-ink: #ffffff; --warn: #8a5100; --warn-bg: #fff1d9; --bad: #b3261e; --bad-bg: #fde8e6;
  --good: #1e6b3a; --good-bg: #e2f3e8; --focus: #8f63c9; --series: #2f6fc4;
  --prod: #a3180f; --prod-ink: #ffffff; --prod-soft: #c9463d;
  --head: 0px; --stick: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a; --panel: #211f25; --ink: #ece9e4; --muted: #a8a399; --line: #38353e; --soft: #2b2931;
    --accent: #a77be0; --accent-ink: #17161a; --warn: #f0b45a; --warn-bg: #3a2c14; --bad: #f08a80; --bad-bg: #3d1d1a;
    --good: #7fd19a; --good-bg: #173322; --focus: #c4a3ef; --series: #6ea8ee;
    --prod: #b3221a; --prod-ink: #ffffff; --prod-soft: #d4554c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 18px; margin: 0; } h2 { font-size: 15px; margin: 0 0 10px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--soft); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------------------------------------------------------------- the frame */
.top { position: sticky; top: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line); }
.top-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 8px 16px 4px; }
.brand { font-weight: 700; font-size: 15px; } .brand span { font-weight: 400; color: var(--muted); }
.envs { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.env { border: 0; background: none; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.env + .env { border-left: 1px solid var(--line); }
.env[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.env.is-prod[aria-pressed="true"] { background: #ffffff; color: var(--prod); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); } .dot.bad { background: var(--bad); }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
/* Production: the whole head changes colour and says so. */
body[data-env="prod"] .top { background: var(--prod); color: var(--prod-ink); border-bottom-color: var(--prod); }
body[data-env="prod"] .top .brand span, body[data-env="prod"] .top .who, body[data-env="prod"] .tabs a, body[data-env="prod"] .env { color: #ffd9d5; }
body[data-env="prod"] .tabs a[aria-current="page"] { color: #ffffff; border-bottom-color: #ffffff; }
body[data-env="prod"] .envs { border-color: var(--prod-soft); } body[data-env="prod"] .env + .env { border-left-color: var(--prod-soft); }
body[data-env="prod"] .top .btn { background: transparent; color: #ffffff; border-color: var(--prod-soft); }
body[data-env="prod"] .top .pill { background: var(--prod-soft); color: #ffffff; }
.prod-strip { position: sticky; top: var(--head); z-index: 5; background: #2a0906; color: #ffd9d5; text-align: center; font-weight: 700; letter-spacing: .08em; font-size: 12px; padding: 3px 12px; }
main { max-width: 1440px; margin: 0 auto; padding: 16px; }
.pad { padding: 16px; } .muted { color: var(--muted); } .small { font-size: 12px; } .bad-text { color: var(--bad); }
.subnav { display: flex; gap: 4px; margin-bottom: 12px; }
.subnav a { padding: 5px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.subnav a[aria-current="page"] { background: var(--soft); color: var(--ink); font-weight: 600; }
.gate { max-width: 520px; margin: 48px auto; } .gate h1 { margin-bottom: 10px; }

/* ---------------------------------------------------------------- pieces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.card h3, .section-title { font-size: 12px; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 7px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--muted); } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); } .btn.mini { padding: 3px 8px; font-size: 12px; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; text-align: left; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); min-width: 0; }
textarea { resize: vertical; min-height: 60px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--soft); color: var(--muted); white-space: nowrap; font-weight: 400; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; white-space: pre-wrap; }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; background: var(--soft); }
.notice.warn { background: var(--warn-bg); color: var(--warn); } .notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice .actions { margin-top: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; } .actions.more { margin-top: 12px; }
.status { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.status.busy { color: var(--warn); } .status.good { color: var(--good); } .status.bad { color: var(--bad); white-space: pre-wrap; }
.check, .inline-label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.inline-label input { width: auto; } .inline-label input[type=number] { width: 90px; } .grow { flex: 1 1 180px; } .grow input { flex: 1; }
.bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.bar label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; } .n { text-align: right; font-variant-numeric: tabular-nums; }
.id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; } td.id, span.id { color: var(--muted); }
.path { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.table-wrap { overflow-x: auto; } .table-wrap.short { max-height: 320px; overflow-y: auto; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 13px; } .facts dt { color: var(--muted); } .facts dd { margin: 0; } .facts + .actions { margin-top: 10px; }
.notes { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--warn); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 12px; align-items: start; }
.big-number { font-size: 22px; margin-left: 8px; font-variant-numeric: tabular-nums; }
.danger-zone { border-color: var(--bad); }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------------------------------------------------------------- health */
.ready { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.ready-block h2 { font-size: 15px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.ready-block.big h2 { font-size: 20px; }
.verdict { padding: 2px 12px; border-radius: 99px; font-size: 14px; font-weight: 700; }
.verdict.good { background: var(--good-bg); color: var(--good); } .verdict.warn { background: var(--warn-bg); color: var(--warn); } .verdict.bad { background: var(--bad-bg); color: var(--bad); }
.ready-block p { margin: 0 0 8px; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.stage { display: grid; grid-template-columns: 22px 150px minmax(0, 1fr); gap: 6px; align-items: baseline; }
.stage .mark { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); }
.stage.good .mark { background: var(--good-bg); color: var(--good); } .stage.warn .mark { background: var(--warn-bg); color: var(--warn); } .stage.bad .mark { background: var(--bad-bg); color: var(--bad); }
.stage-name { font-weight: 600; } .stage-text { color: var(--muted); } .stage.bad .stage-text { color: var(--bad); }
.versions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .versus { color: var(--muted); font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile.bad { border-color: var(--bad); } .tile.warn { border-color: var(--warn); }
.tile-label { font-size: 12px; color: var(--muted); } .tile-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; } .tile-detail { font-size: 12px; color: var(--muted); }
.tiles.small { grid-template-columns: repeat(3, minmax(0, 1fr)); } .tiles.small .tile-value { font-size: 18px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; } .swatch.requests { background: var(--series); } .swatch.errors { background: var(--bad); }
.chart { position: relative; } .chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; } .chart .axis { fill: var(--muted); font-size: 11px; }
.chart .h-bar { fill: var(--series); } .chart .h-bad { fill: var(--bad); } .chart .hit { fill: transparent; } .chart .hour:hover .h-bar { opacity: .75; }
.tip { position: absolute; top: 0; background: var(--ink); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; max-width: 60%; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }

/* ---------------------------------------------------------------- dailies */
.cal { padding: 0; overflow: hidden; }
.cal-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.cal-row:last-child { border-bottom: 0; }
.cal-row > div { padding: 8px 10px; min-width: 0; }
.cal-head { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--soft); }
.cal-row.today { background: var(--good-bg); } .cal-row.past .cal-day b { font-weight: 500; }
.cal-day { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.cal-side { padding: 4px !important; }
.cal-cell { display: flex; flex-direction: column; gap: 3px; padding: 5px 8px; border-radius: 7px; text-decoration: none; color: inherit; height: 100%; }
a.cal-cell:hover { background: var(--soft); }
.cal-title { font-weight: 600; color: var(--accent); } .cal-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.cal-match { display: flex; align-items: center; justify-content: center; }
.daybar-title { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.saved { font-size: 12px; color: var(--muted); } .saved.busy { color: var(--warn); } .saved.good { color: var(--good); } .saved.bad { color: var(--bad); }
.epitaph { font-style: italic; margin: 0 0 8px; } .report-actions { margin: 0 0 10px; padding-left: 22px; } .report.resolved { opacity: .55; }

.notice-body { white-space: pre-wrap; margin: 0 0 10px; }
.notice-preview { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--bg); max-width: 380px; }
.notice-preview h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0 0 6px; }
.notices .f { margin-bottom: 10px; }

/* ---------------------------------------------------------------- the form */
.editor { display: grid; grid-template-columns: 190px minmax(0, 1fr) 310px; gap: 14px; align-items: start; }
.sections { position: sticky; top: calc(var(--stick) + 12px); display: flex; flex-direction: column; gap: 2px; padding: 8px; margin: 0; }
.sections button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.sections button.on { background: var(--soft); font-weight: 600; }
.panels { position: sticky; top: calc(var(--stick) + 12px); max-height: calc(100vh - var(--stick) - 24px); overflow-y: auto; }
.editor-main .card h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f > span { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.f .count { white-space: nowrap; } .f .count.over { color: var(--bad); font-weight: 600; }
.f.wide { grid-column: 1 / -1; }
.f.bad input, .f.bad textarea, .f.bad select { border-color: var(--bad); }
.problem { color: var(--bad); font-size: 12px; display: block; }
.problems { margin: 0 0 8px; padding-left: 18px; font-size: 13px; color: var(--bad); }
.sub { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; }
.sub.way { border-style: solid; }
.sub header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.checks { display: flex; gap: 10px; flex-wrap: wrap; } .checks label { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.clues { margin-top: 10px; display: grid; gap: 6px; } .clues > .btn { justify-self: start; }
.clue { display: grid; grid-template-columns: minmax(0, 1fr) 190px auto; gap: 8px; align-items: end; }
.scene { border-left: 3px solid var(--accent); padding-left: 12px; margin: 14px 0; } .scene h4 { margin: 0 0 6px; font-size: 13px; }
.section-tools { margin-bottom: 10px; }
.status-card h2 { overflow-wrap: anywhere; } .status-card .actions { margin-top: 10px; }
.modes { margin: 8px 0; }
.write-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; flex-basis: 100%; }
.steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.step { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.write-text { margin-top: 10px; max-height: 260px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.write-text h4 { margin: 6px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.write-text p { margin: 0 0 6px; } .write-text pre { margin: 0; white-space: pre-wrap; font-size: 12px; }
.write-text .arriving::after { content: "▍"; color: var(--accent); }
#live-checks.asking { opacity: .6; } #live-checks p { margin: 0 0 8px; }
.playtest h3 { margin-top: 10px; }
.revisions { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.revisions li { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- narrower screens */
@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .sections { position: static; flex-direction: row; overflow-x: auto; }
  .sections button { white-space: nowrap; }
  .panels { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 720px) {
  main { padding: 12px 16px; }
  .top { position: static; }
  .top-row { gap: 8px 10px; }
  .who { margin-left: 0; flex: 1 1 100%; justify-content: space-between; font-size: 12px; }
  .cal-row { grid-template-columns: minmax(0, 1fr); padding: 6px 0; }
  .cal-head { display: none; }
  .cal-row > div { padding: 2px 10px; }
  .cal-day { flex-direction: row; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  .cal-side::before { content: attr(data-label); font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; padding-left: 8px; }
  .cal-match { justify-content: flex-start; padding-left: 18px !important; }
  .cal-match:empty { display: none; }
  .stage { grid-template-columns: 22px minmax(0, 1fr); } .stage-text { grid-column: 2; }
  .clue { grid-template-columns: minmax(0, 1fr); }
  /* Wide tables become one block for each row, each value under its name. */
  table.players thead, table.audit thead { display: none; }
  table.players tr, table.audit tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.players td, table.audit td { display: block; border: 0; padding: 2px 0; text-align: left; }
  table.players td[data-label]::before, table.audit td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  table.players td:empty { display: none; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .cal-cell { transition: background-color .1s, border-color .1s; } }
