:root {
  --bg: #070c18; --panel: #0f1a2e; --panel2: #14213b; --line: #22304d; --gold: #d4af37; --gold2: #f3d77a;
  --green: #22c55e; --orange: #f59e0b; --red: #ef4444; --blue: #3b82f6; --text: #f1f5fb; --muted: #94a3c0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px; line-height: 1.4;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
a { color: var(--gold2); }
.wrap { max-width: 1100px; margin: 0 auto; }
.num { font-variant-numeric: tabular-nums; }
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.brand { font-weight: 800; letter-spacing: .12em; font-size: 18px; }
.brand .g { color: var(--gold); }
.brand .m { color: var(--muted); }
.spacer { flex: 1; }
.conn { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #1e293b; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.online { color: #bbf7d0; background: rgba(34,197,94,.15); }
.conn.online::before { background: var(--green); }
.conn.offline, .conn.reconnecting { color: #fecaca; background: rgba(239,68,68,.18); }
.conn.offline::before, .conn.reconnecting::before { background: var(--red); }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; }
.banner.warn { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.5); color: #fde68a; }
.banner.info { background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.4); color: #bfdbfe; }
.banner.done { background: rgba(212,175,55,.12); border: 1px solid rgba(212,175,55,.5); color: var(--gold2); }

.speakers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sp { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 2px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; transition: border-color .3s, box-shadow .3s; }
.sp .nm { font-weight: 800; letter-spacing: .05em; font-size: 18px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sp .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp .nm .dot { width: 10px; height: 10px; border-radius: 50%; background: #3a4660; flex: none; }
.sp .tag { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 2px 7px; border-radius: 5px; background: var(--green); color: #04210f; flex: none; }
.sp .tag:empty { display: none; }
.sp .tm { font-size: clamp(40px, 12vw, 76px); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.sp .ot { color: var(--red); font-weight: 800; font-size: 15px; min-height: 1.3em; }
.sp .bar { height: 7px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; margin: 6px 0; }
.sp .bar i { display: block; height: 100%; background: var(--blue); transition: width .25s linear; }
.sp[data-s="B"] .bar i { background: var(--gold); }
.sp dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.sp dd { margin: 0; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.sp.active { border-color: var(--green); box-shadow: 0 0 18px rgba(34,197,94,.3); }
.sp.active .dot { background: var(--green); }
.sp.lvl-warn .tm { color: var(--orange); } .sp.lvl-warn .bar i { background: var(--orange); }
.sp.lvl-danger .tm { color: var(--red); } .sp.lvl-danger .bar i { background: var(--red); }
.sp.lvl-expired { background: linear-gradient(180deg, #3a0f14, #220a0e); }
.sp.lvl-expired .tm { color: var(--red); } .sp.lvl-expired .bar i { background: var(--red); width: 100% !important; }
.sp.active.lvl-warn { border-color: var(--orange); }
.sp.active.lvl-danger, .sp.active.lvl-expired { border-color: var(--red); box-shadow: 0 0 18px rgba(239,68,68,.4); }
.expired-label { font-size: 12px; letter-spacing: .08em; }

.meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0; font-size: 14px; color: var(--muted); }
.meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.dist { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 700; font-size: 14px; }
.dist .a { color: #93c5fd; } .dist .b { color: var(--gold2); }
.dist span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 35%; }
.dbar { flex: 1; height: 12px; border-radius: 6px; display: flex; overflow: hidden; background: rgba(255,255,255,.1); }
.dbar i { display: block; height: 100%; transition: width .5s; }
.dbar .da { background: var(--blue); } .dbar .db { background: var(--gold); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 14px; }
.card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stats th, table.stats td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.stats th:first-child, table.stats td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
table.stats thead th { color: var(--text); overflow-wrap: anywhere; }

ol.events { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; font-size: 14px; }
ol.events li { display: flex; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
ol.events time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
ol.events li.t-time_adjusted span, ol.events li.t-settings_changed span { color: var(--orange); }
ol.events li.t-time_expired span { color: var(--red); font-weight: 700; }
ol.events li.t-server_recovery span { color: #93c5fd; }
.footer { margin-top: 20px; color: var(--muted); font-size: 12px; text-align: center; }

/* buttons */
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
button, .btn { font: inherit; font-weight: 800; letter-spacing: .04em; border: 0; border-radius: 12px; padding: 14px 10px; min-height: 58px; cursor: pointer;
  color: var(--text); background: #1e293b; border: 1px solid #334155; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; gap: 6px; touch-action: manipulation; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.b-a { background: #1d4ed8; border-color: #3b82f6; min-height: 84px; font-size: 18px; }
.b-b { background: #8a6d12; border-color: var(--gold); min-height: 84px; font-size: 18px; }
.b-a.on, .b-b.on { box-shadow: 0 0 0 3px var(--green); }
.b-pause { background: #334155; }
.b-resume { background: #166534; border-color: var(--green); }
.b-switch { grid-column: 1 / -1; background: #0f766e; border-color: #14b8a6; min-height: 70px; font-size: 18px; }
.b-round { background: #312e81; border-color: #6366f1; }
.b-finish { background: #7f1d1d; border-color: var(--red); }
.b-danger { background: #7f1d1d; border-color: var(--red); }
.b-small { min-height: 44px; padding: 8px 10px; font-size: 14px; }
.kbd { font-size: 11px; font-weight: 700; opacity: .7; border: 1px solid rgba(255,255,255,.35); border-radius: 4px; padding: 0 5px; }
.adjust { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adjust .grp { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.adjust .grp b { width: 100%; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adjust .grp button { flex: 1 1 calc(33% - 6px); min-height: 44px; padding: 6px; font-size: 14px; }

/* forms */
form.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
form.settings .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.chk { flex-direction: row; align-items: center; gap: 8px; }
input, select { font: inherit; color: var(--text); background: #0b1324; border: 1px solid #334155; border-radius: 10px; padding: 10px; min-height: 44px; width: 100%; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.err { color: #fecaca; font-weight: 600; min-height: 1.4em; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #1e293b; border: 1px solid #334155; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; max-width: 90vw; }
.toast.bad { border-color: var(--red); color: #fecaca; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--gold); border-radius: 14px; max-width: 420px; width: calc(100% - 32px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog h3 { margin: 0 0 8px; color: var(--gold2); }
dialog .row { justify-content: flex-end; margin-top: 16px; }
dialog button { min-height: 48px; padding: 10px 18px; }

.landing h1 { font-size: 26px; letter-spacing: .1em; }
.landing ul { list-style: none; padding: 0; display: grid; gap: 10px; }
.landing li a { display: block; padding: 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; }
.landing li a small { display: block; color: var(--muted); }
code { background: #0b1324; padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .controls { grid-template-columns: repeat(4, 1fr); }
  .b-a, .b-b { grid-column: span 2; }
  .b-switch { grid-column: span 2; min-height: 58px; }
  .ctl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .ctl-grid > .card { margin-top: 14px; }
}
@media (max-width: 420px) {
  body { font-size: 15px; }
  .sp { padding: 10px; }
  .sp .nm { font-size: 15px; }
  form.settings { grid-template-columns: 1fr; }
  .adjust { grid-template-columns: 1fr; }
}
.narrow { max-width: 420px; }
.wide { width: 100%; }
[hidden] { display: none !important; }
