:root {
  --bg: #0f1115; --card: #181b22; --line: #262a33; --text: #e8eaee; --muted: #8b93a1;
  --accent: #3b82f6; --ok: #22c55e; --bad: #ef4444; --warn: #f59e0b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: .08em; }
h2 { font-size: 1rem; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
.error { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card.warn { border-color: var(--warn); color: var(--warn); font-size: .9rem; }
.label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.big { font-size: 1.25rem; font-weight: 650; margin: 2px 0; }
button, .button { appearance: none; border: 0; border-radius: 10px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--accent); color: white; cursor: pointer; text-decoration: none; text-align: center; display: inline-block; }
button.secondary, .button.secondary { background: #262b36; color: var(--text); }
button.danger { background: #3a1d22; color: #fca5a5; }
button:disabled { opacity: .5; }
input[type=password], input[type=number], input[type=date] { width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0f1218; color: var(--text); font: inherit; }
input[type=range] { width: 100%; }
.screen { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: rgba(15,17,21,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .1em; }
.pill { font-size: .8rem; padding: 4px 10px; border-radius: 99px; background: #262b36; }
.pill.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.pill.bad { background: rgba(239,68,68,.15); color: var(--bad); }
.pill.rec { background: rgba(239,68,68,.9); color: white; }
main { padding: 14px 14px calc(env(safe-area-inset-bottom) + 84px); max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15,17,21,.96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { background: none; color: var(--muted); border-radius: 0; padding: 14px 4px; font-size: .9rem; }
.tabs button.active { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }

.arm { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.switch { position: relative; width: 60px; height: 34px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #39404d; border-radius: 99px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 26px; height: 26px; left: 4px; top: 4px; background: white; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(26px); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .card { margin: 0; }

.events { display: grid; gap: 10px; }
.event { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.event img, .event .noimg { width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #0b0d11; display: grid; place-items: center; color: var(--muted); font-size: .75rem; }
.event .t { font-weight: 650; }
.event.failed { opacity: .6; cursor: default; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

.player-wrap { position: relative; background: black; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; }
.player-wrap video { width: 100%; height: 100%; display: block; background: black; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; color: var(--muted); background: rgba(0,0,0,.6); }
.row { display: flex; gap: 10px; margin: 12px 0; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.days button { flex: none; padding: 8px 12px; font-size: .85rem; background: #262b36; color: var(--text); }
.days button.active { background: var(--accent); }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: .92rem; }
.form label.inline { display: flex; gap: 10px; align-items: center; }
.log { font-size: .8rem; max-height: 320px; overflow: auto; font-family: ui-monospace, monospace; }
.log div { padding: 3px 0; border-bottom: 1px solid var(--line); }
.log .warn { color: var(--warn); } .log .error { color: var(--bad); }

dialog { width: min(760px, 96vw); padding: 12px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; }
dialog::backdrop { background: rgba(0,0,0,.75); }
dialog video { width: 100%; border-radius: 8px; background: black; }
