/* Mobile-first dark theme. Large tap targets (min 48 px), portrait phone first. */
:root {
  --bg: #111418;
  --card: #1b2027;
  --line: #2c333d;
  --text: #e9edf2;
  --muted: #9aa5b1;
  --accent: #4da3ff;
  --ok: #2fb36b;
  --warn: #e0a526;
  --danger: #e5484d;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }
h1 { font-size: 1.6rem; margin: 16px 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 6px; color: var(--muted); }
p { margin: 8px 0; }
.lead { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.95rem; }
.error { color: var(--danger); }
b { font-variant-numeric: tabular-nums; }

button, .role-btn, input {
  font: inherit;
  min-height: 48px;
  border-radius: var(--radius);
}
button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(0.98); }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.big { min-height: 56px; font-size: 1.15rem; padding: 12px 24px; }
button.quiet { background: transparent; }
.danger-text { color: var(--danger); }
input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #0c0f12;
  color: var(--text);
}
label { display: block; color: var(--muted); font-size: 0.95rem; margin-bottom: 4px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row > input { flex: 1 1 8em; width: auto; }
.stack > * { margin: 6px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 12px 0;
}
details.card > summary { cursor: pointer; min-height: 32px; font-weight: 600; }

.banner { border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; font-weight: 600; }
.banner.danger { background: rgba(229, 72, 77, 0.18); border: 1px solid var(--danger); color: #ffb3b5; }
.banner.warn { background: rgba(224, 165, 38, 0.16); border: 1px solid var(--warn); color: #ffd98a; }
.banner.ok { background: rgba(47, 179, 107, 0.15); border: 1px solid var(--ok); color: #a6f0c6; }
.banner.alert { background: var(--warn); color: #1d1500; font-size: 1.15rem; text-align: center; }

/* language switch (every page) */
.lang-switch { display: flex; justify-content: flex-end; gap: 4px; margin: 0 0 4px; }
.lang-switch button { min-height: 40px; min-width: 48px; padding: 4px 10px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #04121f; }

/* home */
.roles { display: grid; gap: 12px; margin: 20px 0; }
.role-btn {
  display: block; text-decoration: none; color: #04121f;
  background: var(--accent); padding: 18px; min-height: 80px;
}
.role-btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.role-title { display: block; font-size: 1.25rem; font-weight: 700; }
.role-sub { display: block; font-size: 0.9rem; opacity: 0.8; }

/* video */
.video-box {
  position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4 / 3; width: 100%;
}
.video-box.small { max-width: 320px; margin: 8px auto; }
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; }
.badge {
  position: absolute; top: 8px; left: 8px; padding: 4px 10px; border-radius: 999px;
  font-weight: 700; font-size: 0.9rem; background: #3a424d; color: var(--text); z-index: 2;
}
.badge[data-status="live"] { background: var(--ok); color: #03140a; }
.badge[data-status="offline"], .badge[data-status="replaced"] { background: var(--danger); color: #fff; }
.offline-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  align-items: center; text-align: center; padding: 16px;
  background: rgba(120, 10, 14, 0.82); color: #fff; font-weight: 600;
}
.tap-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  min-height: 56px; padding: 12px 20px; background: var(--accent); border-color: var(--accent);
  color: #04121f; font-weight: 700;
}
.offline-title { font-size: 1.8rem; font-weight: 800; letter-spacing: 0.04em; margin: 0; }

/* timer */
.timer { text-align: center; margin: 8px 0 12px; }
.digits { display: block; font-size: 4.2rem; line-height: 1.05; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-label { color: var(--muted); }
.timer-sub { color: var(--muted); margin-top: 4px; }
#running.overtime .digits { color: var(--warn); }
body.alerting { animation: flash 0.5s 6 alternate; }
@keyframes flash { to { background: #4a3a00; } }
.stop-reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stop-reasons button { min-height: 64px; font-weight: 600; }
.stop-reasons .stop-distress { grid-column: 1 / -1; background: var(--danger); border-color: var(--danger); color: #fff; }
.stop-reasons .stop-planned-end { grid-column: 1 / -1; background: var(--ok); border-color: var(--ok); color: #03140a; }

/* log */
.log { list-style: none; padding: 0; margin: 0; }
.log-row { border-top: 1px solid var(--line); padding: 10px 0; }
.log-head { display: flex; justify-content: space-between; gap: 8px; }
.log-date { color: var(--muted); }
.log-outcome { font-weight: 700; }
.outcome-success .log-outcome { color: var(--ok); }
.outcome-distress .log-outcome { color: var(--danger); }
.outcome-incomplete .log-outcome { color: var(--warn); }
.log-next { color: var(--muted); font-size: 0.95rem; }

/* stats */
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

/* camera page */
.indicator { font-weight: 700; font-size: 1.2rem; padding: 10px 12px; border-radius: var(--radius); background: var(--card); }
.indicator[data-state="streaming"] { background: var(--danger); color: #fff; }
.dim-overlay {
  position: fixed; inset: 0; background: #000; color: #555; z-index: 10;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 24px;
}
