:root {
  --text: #1d2433;
  --muted: #5b6475;
  --accent: #231c1a; /* the near-black of the Dymaxion logo */
  --line: #dfe2e8;
  --notice: #fff4d6;
  --error: #b42318;
  --ok: #1f7a3a;
  --bg: #f7f8fa;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
main {
  max-width: 40rem;
  margin: 4rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}
body.signed-in main { max-width: 60rem; margin: 1.5rem auto; }
header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
header .home img { height: 32px; display: block; }
header .who { margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.logo { display: block; width: 220px; max-width: 60%; margin: 0 auto 1.5rem; }
h1 { margin-top: 0; font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }
#editor h2 { margin-top: 0; }
a { color: var(--accent); }
button {
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
button:hover { background: #000; }
button:disabled { opacity: 0.5; cursor: default; }
button.quiet { margin: 0; padding: 0.3rem 0.8rem; background: none; color: var(--accent); border: 1px solid var(--line); }
button.link { margin: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
.notice { background: var(--notice); padding: 0.6rem 0.8rem; border-radius: 6px; }
.error-box { background: #fdecea; color: var(--error); }
.error-box ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.error { color: var(--error); }
.ok { color: var(--ok); font-weight: 600; }
.muted, .soon { color: var(--muted); }
.soon { font-size: 0.85em; }
.lead { color: var(--muted); }
code { background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 4px; }

table.list { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
table.list th, table.list td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

form.inline { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
form.inline label { display: flex; flex-direction: column; font-size: 0.9rem; }
form.inline button { margin: 0; }
input, textarea, select { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid #c6cad3; border-radius: 6px; }
input[type='color'] { padding: 0.1rem; width: 4rem; height: 2.2rem; }

#editor section { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.9rem; font-size: 0.9rem; font-weight: 600; }
.field input:not([type]), .field textarea { width: 100%; font-weight: 400; }
.field.short { display: inline-flex; flex-direction: row; align-items: center; gap: 0.5rem; margin-right: 1.5rem; }
.field.short input[type='number'] { width: 5.5rem; }
.count, .hint { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.check { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.row > .field:first-child { flex: 1; min-width: 14rem; }
.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.template { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; cursor: pointer; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.template input { position: absolute; opacity: 0; pointer-events: none; }
.template.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.template span { color: var(--muted); }
.thumb { max-width: 240px; max-height: 160px; border-radius: 6px; border: 1px solid var(--line); }
.thumb.small { width: 48px; height: 48px; object-fit: cover; vertical-align: middle; }
.colours { display: flex; flex-wrap: wrap; }
.publish { position: sticky; bottom: 0; background: #fff; padding: 1rem 0; border-top: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; }
.publish button { margin: 0; }
.areas li { margin-bottom: 0.4rem; }
button.quiet:disabled { opacity: 0.4; cursor: default; }

/* W-03: buttons in focus order, and the live preview beside the form. */
body.signed-in main:has(.editor-layout) { max-width: 96rem; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 36rem); gap: 2rem; align-items: start; }
.button-list { list-style: none; padding: 0; margin: 0; }
.button-list li { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem 0.25rem; margin-bottom: 0.75rem; }
.button-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.move button { margin: 0 0 0 0.3rem; padding: 0.15rem 0.6rem; }
.preview { position: sticky; top: 1rem; }
.preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
.preview-tv { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2b3a55, #5b7a8f 55%, #a7b8a8); border-radius: 6px; overflow: hidden; }
.preview-tv:focus { outline: 3px solid var(--accent); outline-offset: 3px; }
.preview-line { position: absolute; left: 0; right: 0; top: 75%; border-top: 1px dashed rgb(255 255 255 / 0.5); }
.preview-captions { position: absolute; left: 10%; right: 10%; top: 80%; text-align: center; font: 600 clamp(9px, 1.1vw, 16px)/1.3 ui-monospace, monospace; color: #fff; }
.preview-captions span { background: #000; padding: 0 0.4em; }
.preview-stages, .preview-try { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.preview-stages button, .preview-try button { margin: 0; }
.preview-stages button { padding: 0.3rem 0.8rem; }
.preview-stages button[aria-pressed='true'] { background: var(--accent); color: #fff; }
.preview-log { font: 0.8rem/1.5 ui-monospace, monospace; color: var(--muted); max-height: 11rem; overflow: auto; margin: 0.5rem 0 0; padding-left: 1.4rem; }
.publish > div { flex: 1; }
#draft-status { color: var(--muted); font-size: 0.9rem; }
.versions { font-size: 0.85rem; color: var(--muted); margin-top: 0.75rem; }
.versions ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.master { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1.5rem; }
.master button { margin: 0; }
.master.off { border-color: var(--error); background: #fdecea; }
button.danger { background: var(--error); }
button.danger-quiet { color: var(--error); border-color: var(--error); }
.switch-line button { margin: 0 0 0 0.5rem; padding: 0.2rem 0.8rem; }
.master-banner { background: var(--error); color: #fff; padding: 0.6rem 1.5rem; font-weight: 600; }
.master-banner a { color: #fff; }
table.changes td { font-size: 0.9rem; }
header a + a { margin-left: 1rem; }
/* R-01: the pilot dashboard. */
body.signed-in main:has(.tiles) { max-width: 72rem; }
.report-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin: 1rem 0; }
.report-filters button { margin: 0; padding: 0.3rem 0.8rem; }
.report-filters button[aria-pressed='true'] { background: var(--accent); color: #fff; }
.report-filters label { display: flex; gap: 0.4rem; align-items: center; font-size: 0.9rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem; }
.tile-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { font-weight: 600; font-size: 0.9rem; margin-top: 0.2rem; }
.tile-note { color: var(--muted); font-size: 0.8rem; }
.chart { position: relative; margin: 0 0 1rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .mark { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .bar.on .hit, .chart .bar:focus .hit { fill: rgb(0 0 0 / 0.04); }
.chart .bar:focus { outline: none; }
.chart-tip { position: absolute; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.6rem;
  font-size: 0.8rem; box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); pointer-events: none; white-space: nowrap; }
.report-table { margin-bottom: 1.5rem; }
.report-filters #csv { margin-left: auto; }
table.funnel { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
table.funnel th, table.funnel td { padding: 0.5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.funnel th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
table.funnel td.num, table.funnel th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.funnel .bar-cell { width: 40%; }
.funnel-bar { display: block; height: 14px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
@media (max-width: 700px) { table.funnel .bar-cell { display: none; } }
table.answers .bar-cell { width: 35%; }
.answer-img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 10px; border: 1px solid var(--line); }
table.answers tr.leader td { font-weight: 700; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #fff; vertical-align: middle; }
@media (max-width: 700px) { table.answers .bar-cell { display: none; } }
.report-table table { margin: 0.5rem 0 0; }
.report-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0 2rem; }
table.list th.num, table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { table.days { font-size: 0.8rem; } .report-table { overflow-x: auto; } }
.viewer { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; }
.viewer h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.brand-choices { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.viewer button { margin: 0.25rem 0 0; }
.timeline { margin: 0.25rem 0 0.75rem; padding-left: 1.4rem; font-size: 0.9rem; }
.timeline li { margin-bottom: 0.2rem; }
.timing-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 0.5rem; }
.timing-table th, .timing-table td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); }
.timing-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.preview-clock { margin: 0.5rem 0 0; font: 600 0.9rem ui-monospace, monospace; }

/* W-05: the preview at TV size, in a full-window overlay. */
body.tv-open { overflow: hidden; }
.tv-overlay { position: fixed; inset: 0; z-index: 50; background: #0b0d10; color: #e6eaf0; display: flex; flex-direction: column; }
.tv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 0.6rem 1rem; background: #161a20; font-size: 0.9rem; }
.tv-bar button { margin: 0; padding: 0.35rem 0.9rem; }
.tv-bar button.quiet { color: #e6eaf0; border-color: #3a424e; }
.tv-bar [data-close] { margin-left: auto; background: #e6eaf0; color: #161a20; }
.tv-bar select { padding: 0.25rem 0.4rem; }
.tv-bar .preview-clock { margin: 0; color: #9fe0b0; }
.tv-frame { flex: 1; overflow: auto; display: flex; padding: 1rem; }
.preview-tv.tv-fit { margin: auto; width: min(100%, calc((100vh - 6rem) * 16 / 9)); }
.preview-tv.tv-actual { margin: 0 auto; flex: none; width: 1920px; height: 1080px; aspect-ratio: auto; }
.preview-tv.tv-actual .preview-captions { font-size: 40px; }
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
}
@media (max-width: 700px) { .templates { grid-template-columns: 1fr; } }
/* Ad-ID / ISCI codes (N-01) */
.spots { margin: 1.25rem 0 1.5rem; }
.spots h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
table.list.compact { margin-bottom: 0.75rem; }
table.list.compact td, table.list.compact th { padding: 0.35rem 0.5rem; }
table.list.compact button { margin: 0; padding: 0.2rem 0.7rem; }
#spot-status { font-size: 0.9rem; align-self: center; }
form.find { margin-bottom: 0.5rem; }
form.find input { min-width: 18rem; }
#find-result p { margin: 0 0 1rem; }
.qr-note { margin: -0.4rem 0 1rem; font-size: 0.85rem; }
/* Conversion pixel install code (C-03) */
.pixel { margin: 0 0 1.5rem; }
.pixel summary { cursor: pointer; font-weight: 600; }
.pixel pre { background: var(--line); padding: 0.6rem 0.8rem; border-radius: 6px; overflow-x: auto; font-size: 0.8rem; }
/* Weekly pilot report (R-03) */
table.list.weekly { margin-bottom: 1.5rem; }
table.list.weekly td:first-child { width: 45%; }
a.button { display: inline-block; text-decoration: none; padding: 0.5rem 1rem; border: 1px solid var(--line); border-radius: 6px; }
.caption-files { margin-top: 1rem; }
.caption-files input[type=file] { font-size: 0.85rem; }
.table-scroll { overflow-x: auto; }
.nowrap { white-space: nowrap; }
table.log td { font-size: 0.9rem; vertical-align: top; }
