:root {
  --bg: #12110e;
  --bg-raise: #1c1a15;
  --ink: #f3efe4;
  --muted: #b7b09f;
  --line: #3a362c;
  --accent: #e8a54b;
  --accent-ink: #1a1408;
  --danger: #e07a6a;
  --ok: #8fbf7a;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --ui: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 500px at 10% -10%, #2a2418 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--ui);
  min-height: 100vh;
  line-height: 1.45;
}

/* Browser-default blue is unreadable on this background; every link uses the accent. */
a { color: var(--accent); text-underline-offset: 0.15em; }
a:visited { color: var(--accent); }
a:hover { color: #f4c07a; }

.shell { max-width: 960px; margin: 0 auto; padding: 1.25rem 1.1rem 3rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; gap: 0.75rem; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(232, 165, 75, 0.18);
}
.brand-sub { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.topbar-meta { display: flex; gap: 1rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.clocks { display: flex; flex-direction: column; align-items: flex-end; gap: 0.12rem; }
.clock { font-variant-numeric: tabular-nums; }
.clock-device {
  font-size: 0.72rem;
  line-height: 1.2;
  color: #8d8778;
  font-variant-numeric: tabular-nums;
  max-width: 16rem;
  text-align: right;
}

h1, h2, .brand strong { font-family: var(--font); font-weight: 600; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0.2rem 0 0.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0;
}
.lede, .hint, .foot, .empty { color: var(--muted); }
.lede { max-width: 42rem; }

.hero { padding: 1.75rem 0 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.panel, .auth-card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
}
.auth-card { max-width: 28rem; margin: 2.5rem auto; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
input[type="password"], input[type="text"] {
  background: #0e0d0b;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.7rem 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
}
button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 650;
  font-size: 1rem;
  cursor: pointer;
}
button.linkish {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  text-decoration: underline; font: inherit;
}
.banner.error {
  background: rgba(224, 122, 106, 0.12);
  color: var(--danger);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
}
.empty, .hint { font-size: 0.92rem; }
.kv { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.kv li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.roadmap { list-style: none; padding: 0; margin: 0; }
.roadmap li { display: flex; gap: 0.75rem; padding: 0.4rem 0; }
.roadmap span { color: var(--accent); min-width: 4.5rem; font-size: 0.8rem; }
.foot { margin-top: 2rem; font-size: 0.8rem; }
code { font-size: 0.85em; }
.inline { display: inline; }

/* Phase 1 — media library */
.mainnav { display: flex; gap: 1rem; font-size: 0.9rem; }
.mainnav a { color: var(--muted); text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: var(--ink); border-bottom-color: var(--accent); }

.hero.tight { padding: 1.25rem 0 0.5rem; }
.page-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0 0; }
.page-actions.end { margin-top: 1.5rem; }
.btn-link.primary { background: var(--accent); border-color: var(--accent); font-weight: 650; }
.btn-link, .btn-link:visited, .btn-link:hover { color: var(--ink); }
.btn-link.primary, .btn-link.primary:visited, .btn-link.primary:hover { color: var(--accent-ink); }
.page-actions .btn-link { font-size: 1rem; }
.crumb { margin: 0.25rem 0 0; font-size: 0.85rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.pad-top { margin-top: 1rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.opt { color: #8d8778; font-weight: 400; font-size: 0.82rem; }

.banner.ok { background: rgba(143, 191, 122, 0.12); color: var(--ok); padding: 0.65rem 0.75rem; border-radius: 8px; }
.banner.warn { background: rgba(232, 165, 75, 0.12); color: var(--accent); padding: 0.65rem 0.75rem; border-radius: 8px; }

button, .btn-link {
  background: #262219; color: var(--ink); border: 1px solid var(--line);
  padding: 0.6rem 0.9rem; border-radius: 8px; font: inherit; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .btn-link:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 650; }
button.danger { background: transparent; color: var(--danger); border-color: rgba(224,122,106,0.4); }
button.danger:hover { border-color: var(--danger); }

input[type="text"], input[type="search"], input[type="number"], input[type="file"], input[type="date"], input[type="time"], textarea {
  -webkit-appearance: none;
  appearance: none;
  background: #0e0d0b; border: 1px solid var(--line); color: var(--ink);
  padding: 0.6rem 0.7rem; border-radius: 8px; font-size: 1rem; width: 100%;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button { -webkit-appearance: none; }
input[type="file"] { padding: 0.5rem; font-size: 0.9rem; }

details.more { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }

.meter { height: 0.5rem; background: #0e0d0b; border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; background: var(--accent); }
.kv.tight li { font-size: 0.88rem; padding: 0.3rem 0; }
.kv.tight li:last-child { border-bottom: 0; }
.mini-list { list-style: none; padding: 0; margin: 0.75rem 0 0; font-size: 0.9rem; }
.mini-list li { padding: 0.25rem 0; }
.mini-list a { color: var(--ink); }

.media-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 0.9rem; align-items: stretch; }
@media (min-width: 620px) { .media-grid { grid-template-columns: 1fr 1fr; } }
.media-card { display: flex; min-width: 0; height: 100%; }
.card-frame {
  display: flex; flex-direction: column; width: 100%; height: 100%;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #171510;
}
.card-frame:hover { border-color: var(--accent); }
.card-link { display: flex; flex-direction: column; flex: 1 1 auto; color: inherit; text-decoration: none; min-width: 0; }
.card-link .media-meta { flex: 1 1 auto; }
.card-link .media-meta strong { min-height: 2.7em; }
a.card-action { display: block; margin-top: auto; margin-left: 0.75rem; margin-right: 0.75rem; margin-bottom: 0.75rem; text-align: center; }
.time-prefix-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 0.75rem; align-items: end; }
.media-card img { width: 100%; height: auto; display: block; aspect-ratio: 16/9; object-fit: cover; background: #0e0d0b; }
.media-meta { padding: 0.65rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }
.media-meta span { color: var(--muted); font-size: 0.82rem; }
.tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.2rem; }
.tag { font-style: normal; font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 99px; border: 1px solid var(--line); }
.tag.ok { color: var(--ok); border-color: rgba(143,191,122,0.4); }
.tag.warn { color: var(--accent); border-color: rgba(232,165,75,0.4); }
.tag.block { color: var(--danger); border-color: rgba(224,122,106,0.4); }
.tag.pin { color: var(--accent); }
.tag.live { color: var(--danger); border-color: rgba(224,122,106,0.6); }

.thumb-preview { width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #0e0d0b; }
fieldset.choices { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
fieldset.choices legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.82rem; }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list > li { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.history-list > li:last-child { border-bottom: 0; }
.date-time-row { display: grid; grid-template-columns: 5rem 1fr 1fr 1.3fr; gap: 0.75rem; align-items: end; }
.showing-block { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.35rem 0; }
.when-fields { display: grid; grid-template-columns: 4.5rem 6.5rem 5.5rem minmax(8rem, 1fr); gap: 0.5rem; align-items: end; }
.when-fields label { gap: 0.25rem; }
.history-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.history-row a { color: var(--ink); }
.history-row .opt { margin-right: auto; }
.history-thumb, .desk-thumb {
  display: block;
  width: 4.5rem; height: 2.55rem; object-fit: cover; border-radius: 4px;
  background: #0e0d0b; border: 1px solid var(--line); flex: 0 0 auto;
}
.history-thumb { width: 3.2rem; height: 1.8rem; }
.desk-list, .pick-list { list-style: none; padding: 0; margin: 0; }
.pick-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center;
  padding: 0.45rem 0; border-top: 1px solid var(--line);
}
.pick-row input { width: auto; }
.pick-row a { color: var(--ink); font-weight: 650; }
.pick-row .desk-when { margin-left: auto; }
.desk-head, .desk-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1.5fr) minmax(11rem, 1fr) minmax(9rem, 1.1fr);
  gap: 0.75rem;
  align-items: center;
}
.desk-head.with-action, .desk-row.with-action {
  grid-template-columns: 4.5rem minmax(0, 1.4fr) 11.5rem minmax(9rem, 1.2fr) auto;
}
.desk-head {
  color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding-bottom: 0.25rem;
}
.desk-row { padding: 0.55rem 0; border-top: 1px solid var(--line); }
.desk-title { color: var(--ink); font-weight: 650; }
.desk-when, .desk-status { font-size: 0.88rem; }
.desk-status { color: var(--muted); }
button.btn-small, a.btn-small { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
[hidden] { display: none !important; }
.leave-dialog {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); padding: 1rem;
}
.leave-card {
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 12px; padding: 1.2rem; max-width: 28rem; width: 100%;
}
.leave-card p { margin: 0 0 1rem; }
.schedule-top { display: grid; grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
input[name="extra_loops"] { max-width: 8rem; }
@media (max-width: 620px) {
  .schedule-top, .time-prefix-row { grid-template-columns: 1fr; }
  .when-fields { grid-template-columns: 1fr 1fr; }
  .desk-head { display: none; }
  .desk-row, .desk-row.with-action { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .desk-when, .desk-status { grid-column: 2; }
  .desk-row.with-action > :last-child { grid-column: 2; }
}
label.radio { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.92rem; }
label.radio input { width: auto; }
label.indent { margin-left: 1.5rem; font-size: 0.85rem; }
label.indent input[type="number"] { max-width: 9rem; }

/* Phase 2 — settings, drive */
.pad-bottom { margin-bottom: 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; font-family: var(--font); }
select {
  background: #0e0d0b; border: 1px solid var(--line); color: var(--ink);
  padding: 0.6rem 0.7rem; border-radius: 8px; font-size: 1rem; width: 100%;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.toc { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.5rem 0 1rem; font-size: 0.9rem; }
section.panel + section.panel { margin-top: 1rem; }
code.copy { display: inline-block; background: #0e0d0b; border: 1px solid var(--line); padding: 0.35rem 0.5rem; border-radius: 6px; word-break: break-all; user-select: all; }
.checks { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.checks li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.15rem; }
.checks li span { color: var(--muted); }
.checks li.ok strong { color: var(--ok); }
.checks li.fail strong { color: var(--danger); }
.drive-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.drive-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.drive-list li div { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.drive-list li strong { overflow-wrap: anywhere; }
.row input[type="text"] { flex: 1 1 14rem; width: auto; }

/* Phase 6 hardening: Debug page, FFmpeg log, health, alerts, worker line */
.debug-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }
.debug-filters label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); }
.debug-list { list-style: none; margin: 0; padding: 0; }
.debug-row { border-bottom: 1px solid var(--line); padding: 0.45rem 0; }
.debug-row.error .debug-summary { color: var(--danger); }
.debug-line { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; font-size: 0.88rem; }
.debug-when { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 10.5rem; }
.debug-summary { flex: 1 1 18rem; overflow-wrap: anywhere; }
.debug-row details summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; margin-top: 0.25rem; }
.tag.bad { color: var(--danger); border-color: var(--danger); }
pre.log { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem;
  font-size: 0.78rem; line-height: 1.4; overflow: auto; max-height: 22rem; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.log.tall { max-height: 70vh; }
.health.good { color: var(--ok); }
.health.warn { color: var(--accent); }
.health.bad { color: var(--danger); }
.issues { margin: 0.25rem 0 0.75rem; padding-left: 1.2rem; color: var(--accent); font-size: 0.86rem; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-row { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid rgba(224, 122, 106, 0.25); }
.alert-row:last-child { border-bottom: 0; }
.alert-text { flex: 1; overflow-wrap: anywhere; }
.alert-text strong { color: var(--danger); margin-right: 0.35rem; }
.alert-when { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.panel.alerts { border-color: var(--danger); }
.worker-line { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }
.worker-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--ok); flex: none; }
.worker-line.stale .worker-dot { background: var(--danger); }
.worker-line.stale { color: var(--danger); }
@media (max-width: 640px) {
  .alert-row { flex-direction: column; align-items: flex-start; }
  .debug-when { min-width: 0; }
}
.review-picture { margin: 0.5rem 0 1rem; max-width: 22rem; }
.review-picture img { width: 100%; height: auto; border-radius: 8px; }
.kept-picture { display: flex; gap: 0.6rem; align-items: center; margin: 0.25rem 0; }
.thumb-mini { width: 8rem; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.event-picture { max-width: 22rem; width: 100%; height: auto; border-radius: 8px; margin-bottom: 0.75rem; }
.wrap { overflow-wrap: anywhere; text-align: right; }
.issue-when { color: var(--muted); font-size: 0.8rem; margin-right: 0.35rem; white-space: nowrap; }
input[type="file"].has-file { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
