:root {
  color-scheme: light dark;
  --paper: #eff2f5; --card: #ffffff; --ink: #15213b; --muted: #566174; --line: #d8dee6;
  --brand: #243b7a; --on-brand: #ffffff; --brand-soft: #e6ebf8;
  --ok: #0b6e55; --ok-bg: #e0f3ec; --warn: #8f5200; --warn-bg: #fff0d6; --bad: #a4261c; --bad-bg: #fbe8e5;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Malayalam", "Noto Naskh Arabic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1422; --card: #172033; --ink: #e8edf7; --muted: #9aa6bc; --line: #2a3650;
    --brand: #8ea6ff; --on-brand: #0d1422; --brand-soft: #1f2c4d;
    --ok: #55d6aa; --ok-bg: #12332b; --warn: #f2b04c; --warn-bg: #3a2c12; --bad: #ff948b; --bad-bg: #3b1d1b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font);
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.2; font-weight: 750; letter-spacing: -0.015em; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.005em; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
main { max-width: 560px; margin: 0 auto; padding: 18px 16px 0; display: grid; gap: 14px; }
.page-head { display: grid; gap: 6px; padding: 6px 0 2px; }
.page-head select { justify-self: start; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card > h2 + .small { margin-top: -8px; }
.group { display: grid; gap: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .label { display: grid; gap: 1px; min-width: 0; }
.row .label .small { color: var(--muted); }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.btn { min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 650; }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

input[type=text], input[type=password], input[type=number], input[type=time], select {
  min-height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); width: 100%;
}
input[type=time] { width: auto; min-width: 8.5rem; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.9rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.stepper button { width: 46px; height: 46px; border: 0; background: transparent; font-size: 1.35rem; line-height: 1; }
.stepper button:active { background: var(--brand-soft); }
.stepper output { min-width: 5.6rem; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; padding: 3px; background: var(--paper); gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 12px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--brand); color: var(--on-brand); }

.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--brand); outline-offset: 2px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 0.82rem; font-weight: 650; background: var(--brand-soft); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 0.92rem; background: var(--brand-soft); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

/* the sync lane: server on the left, board on the right, joined by a line that shows whether the board is caught up */
.lane { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.node { display: grid; gap: 2px; justify-items: start; }
.node.right { justify-items: end; text-align: right; }
.node .who { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.node .ver { font-size: 2.1rem; line-height: 1.05; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.node .when { font-size: 0.82rem; color: var(--muted); }
.link { align-self: center; width: clamp(40px, 14vw, 90px); height: 0; border-top: 4px solid var(--line); margin-top: 6px; position: relative; }
.lane.current .link { border-top-color: var(--ok); }
.lane.pending .link { border-top: 4px dashed var(--warn); }
.lane.current .right .ver { color: var(--ok); }
.lane.pending .right .ver { color: var(--warn); }

.today { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 18px; align-items: baseline; }
.today .h { font-size: 0.82rem; color: var(--muted); font-weight: 600; text-align: right; }
.today .name { font-weight: 650; }
.today .t { text-align: right; font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.big-times { display: flex; gap: 22px; flex-wrap: wrap; }
.big-times div { display: grid; }
.big-times b { font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.big-times span { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { font-weight: 600; color: var(--muted); border-top: 0; }

nav.tabs { position: fixed; z-index: 5; inset: auto 0 0 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs div { max-width: 560px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
nav.tabs a { display: grid; justify-items: center; gap: 2px; padding: 8px 4px 9px; font-size: 0.78rem; font-weight: 650; color: var(--muted); text-decoration: none; min-height: 56px; }
nav.tabs a[aria-current=page] { color: var(--brand); }
nav.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.actionbar { position: fixed; z-index: 4; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgb(0 0 0 / 0.08); }
.actionbar div { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.actionbar p { font-size: 0.95rem; font-weight: 650; line-height: 1.3; }
.actionbar .btn-row { flex-wrap: nowrap; }

#toast { position: fixed; z-index: 10; left: 16px; right: 16px; bottom: calc(130px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto; pointer-events: none; }
#toast div { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 0.93rem; }
#toast div.error { background: var(--bad); color: #fff; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); max-width: min(520px, calc(100vw - 32px)); padding: 20px; }
dialog::backdrop { background: rgb(8 12 22 / 0.55); }
dialog form { display: grid; gap: 12px; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.82rem; }
pre { margin: 0; padding: 12px; background: var(--paper); border-radius: 10px; border: 1px solid var(--line); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

.login { min-height: 100dvh; display: grid; align-content: center; gap: 22px; max-width: 420px; margin: 0 auto; padding: 24px 20px; }
.login img { width: 64px; height: 64px; border-radius: 16px; }
.login form { display: grid; gap: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* board preview */
.board-box { width: 100%; margin-top: 8px; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line, #333); }
.board-box.land { aspect-ratio: 16 / 9; }
.board-box.port { aspect-ratio: 9 / 16; height: min(78vh, 760px); width: auto; max-width: 100%; margin-inline: auto; }
.board-frame { width: 100%; height: 100%; border: 0; display: block; }
.board-box:fullscreen { width: 100vw; height: 100vh; max-width: none; aspect-ratio: auto; border: 0; border-radius: 0; margin: 0; }
