:root {
  --bg: #0f1217; --card: #161b22; --sheet: #1c222b; --line: #30363d; --line2: #484f58;
  --text: #e6edf3; --dim: #8b949e;
  --green: #3fb950; --blue: #58a6ff; --red: #f85149; --orange: #d29922; --purple: #bc8cff; --gold: #d9a54d;
  --gold-ink: #1b1610; --switch-on: #238636; --danger-bg: #3d1417;
  --tabbar: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; }
.d { color: var(--dim); } .g { color: var(--green); } .b { color: var(--blue); } .r { color: var(--red); }
.o { color: var(--orange); } .p { color: var(--purple); } .y { color: var(--gold); }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: calc(12px + env(safe-area-inset-top)) 16px calc(var(--tabbar) + 20px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 4px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--gold); flex: none; }
.top .sub { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { background: none; border: 0; color: var(--dim); font-size: 26px; line-height: 1; padding: 0 6px 4px 0; cursor: pointer; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.line { color: var(--dim); font-size: 12px; margin: 0 0 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--line2); }
.dot.g { background: var(--green); } .dot.o { background: var(--orange); } .dot.p { background: var(--purple); }
.dot.r { background: var(--red); } .dot.b { background: var(--blue); }

.banner { border-radius: 10px; padding: 9px 12px; margin: 0 0 10px; font-size: 13px; border: 1px solid; }
.banner.bad { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.banner.info { border-color: var(--line); background: var(--card); color: var(--dim); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 8px; }
.card.bad { border-color: var(--red); }
.card.goldline { border-color: var(--gold); }
.card.tap { cursor: pointer; }
.card.tap:active { background: #1b2129; }
.card.faded { opacity: .62; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.grid2 .card { margin: 0; }
.kpi .l { color: var(--dim); font-size: 12px; }
.kpi .v { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.kpi .v b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .v span { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.bad .v b, .kpi.bad .v span { color: var(--red); }

.sec { color: var(--dim); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin: 16px 2px 8px; display: flex; align-items: center; gap: 6px; }
.sec button { background: none; border: 0; color: var(--dim); font-weight: 700; padding: 0; cursor: pointer; letter-spacing: .04em; font-size: 12px; text-transform: uppercase; }
.rows .row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; }
.rows .row > :first-child { color: var(--dim); flex: none; }
.rows .row > :last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.rows.split .row + .row { border-top: 1px solid var(--line); }
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 13px; padding: 0 2px; }
.counters div { display: flex; justify-content: space-between; gap: 6px; }
.counters div span:last-child { font-variant-numeric: tabular-nums; }
.counters .bad span:last-child { color: var(--red); }

.events { padding: 6px 10px; }
.ev { display: flex; gap: 10px; font: 12px/1.5 ui-monospace, Consolas, monospace; padding: 3px 0; }
.ev .t { color: var(--dim); flex: none; }
.ev .x { min-width: 0; overflow-wrap: anywhere; }
.ev.bad .x { color: var(--red); }

.switchrow { display: flex; align-items: center; gap: 10px; }
.switchrow .txt { flex: 1; min-width: 0; }
.switchrow .txt small { display: block; color: var(--dim); font-size: 12px; }
.switch { position: relative; width: 46px; height: 26px; border-radius: 13px; background: var(--line); border: 0; flex: none; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s; }
.switch.on { background: var(--switch-on); }
.switch.on::after { transform: translateX(20px); background: var(--text); }
.switch:disabled { opacity: .45; cursor: default; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip { border: 1px solid var(--line2); background: none; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text); white-space: nowrap; }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 700; }
.chip.r { color: var(--red); border-color: var(--red); } .chip.o { color: var(--orange); border-color: var(--orange); }
.chip.p { color: var(--purple); }
.chip.r.on, .chip.o.on, .chip.p.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

.pill { display: inline-block; font-size: 11px; border: 1px solid var(--line2); border-radius: 999px; padding: 0 8px; line-height: 18px; white-space: nowrap; }
.pill.g { border-color: var(--green); } .pill.b { border-color: var(--blue); } .pill.r { border-color: var(--red); }
.pill.y { border-color: var(--gold); } .pill.o { border-color: var(--orange); }
.pills { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }

.room .head { display: flex; align-items: baseline; gap: 8px; }
.room .head b { font-size: 17px; letter-spacing: .04em; }
.room .head .meta { margin-left: auto; color: var(--dim); font-size: 12px; white-space: nowrap; }
.room .seats { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--dim); }
.room .seats .dot { margin-right: 1px; }
.room .seats .txt { margin-left: 6px; }

.seat { display: flex; gap: 10px; align-items: flex-start; }
.seat .n { color: var(--dim); width: 12px; flex: none; padding-top: 1px; }
.seat .body { flex: 1; min-width: 0; }
.seat .nm { font-weight: 700; overflow-wrap: anywhere; }
.seat .st { font-size: 13px; margin-left: 6px; }
.seat .sm { color: var(--dim); font-size: 12px; margin-top: 2px; }
.seat .pills { margin: 6px 0 0; }

.btn { border: 1px solid var(--line2); background: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--text); }
.btn.r { color: var(--red); border-color: var(--red); }
.btn.y { color: var(--gold); border-color: var(--gold); }
.btn.g { color: var(--green); border-color: var(--green); }
.btn.sm { padding: 2px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .4; cursor: default; }
.big { display: block; width: 100%; border-radius: 10px; padding: 12px; font-size: 15px; text-align: center; cursor: pointer; margin: 8px 0; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.big.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 700; }
.big.goldline { border-color: var(--gold); color: var(--gold); }
.big.danger { background: var(--danger-bg); border-color: var(--red); color: var(--red); font-weight: 700; }
.big:disabled { opacity: .45; cursor: default; }
.btngrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btngrid .btn { padding: 6px 4px; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.menu .item { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 10px 12px; }
.menu .item .ic { color: var(--gold); width: 20px; text-align: center; font-size: 17px; flex: none; }
.menu .item .tx { flex: 1; min-width: 0; }
.menu .item .tx small { display: block; color: var(--dim); font-size: 12px; }
.menu .item .chev { color: var(--dim); }
.menu .item .rdot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tiles .card { margin: 0; cursor: pointer; display: flex; align-items: center; gap: 8px; position: relative; padding: 13px 12px; }
.badge { position: absolute; top: 6px; right: 8px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: var(--text); font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.hint { color: var(--dim); font-size: 12px; margin: 10px 2px; }

.list .li { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.list .li:last-child { border-bottom: 1px solid var(--line); }
.list .li .main { flex: 1; min-width: 0; }
.list .li .main b { overflow-wrap: anywhere; }
.list .li .main small { display: block; font-size: 11px; }
.list .li .end { color: var(--dim); font-size: 12px; text-align: right; white-space: nowrap; }

input.field, textarea.field, select.field { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; }
input.field:focus, textarea.field:focus, select.field:focus { border-color: var(--gold); }
textarea.field { min-height: 110px; resize: vertical; border-color: var(--gold); }
.fieldrow { display: flex; gap: 8px; align-items: stretch; }
.fieldrow .field { flex: 1; min-width: 0; }
.counter { text-align: right; color: var(--dim); font-size: 11px; margin-top: 4px; }
label.lbl { display: block; color: var(--dim); font-size: 12px; margin: 10px 2px 4px; }
.err { color: var(--red); font-size: 12px; margin-top: 4px; }

.preview { background: #2a2116; border-radius: 10px; padding: 16px; }
.preview .box { background: #3a2d1c; border: 1px solid var(--gold); border-radius: 8px; padding: 10px 12px; text-align: center; }
.preview .box b { color: var(--gold); font-size: 11px; letter-spacing: .04em; }
.preview .box div { color: #efe6d4; font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.preview.warn .box { border-color: var(--red); }
.preview.warn .box b { color: var(--red); }

.note .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.note .stars { font-size: 15px; letter-spacing: 1px; }
.note .meta { color: var(--dim); font-size: 11px; white-space: nowrap; }
.note .text { margin: 6px 0; font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.note .foot { color: var(--dim); font-size: 11px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { color: var(--dim); font-weight: 400; font-size: 11px; text-align: left; padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tr.tap { cursor: pointer; }
table.tbl tr.sel td { background: #1c222b; }

.kv { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.kv input.k { flex: 1.6; min-width: 0; }
.kv input.v { flex: 1; min-width: 0; }
.kv .x { flex: none; }
.kv.bad input.k { border-color: var(--red); }

.empty { color: var(--dim); text-align: center; padding: 22px 8px; font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* bottom tab bar */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
nav.tabs .in { display: flex; width: 100%; max-width: 560px; }
nav.tabs button { flex: 1; background: none; border: 0; color: var(--dim); padding: 8px 0 7px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; height: var(--tabbar); justify-content: center; }
nav.tabs button .i { font-size: 19px; line-height: 1.1; }
nav.tabs button .l { font-size: 11px; }
nav.tabs button.on { color: var(--gold); }
nav.tabs[hidden] { display: none; }

/* bottom sheet (confirmations, edits) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.62); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.scrim[hidden] { display: none; }
.sheet { background: var(--sheet); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; width: 100%; max-width: 560px; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.sheet.danger { border-color: var(--red); }
.sheet.gold { border-color: var(--gold); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line2); margin: 0 auto 12px; }
.sheet .warnic { text-align: center; font-size: 30px; color: var(--red); line-height: 1; }
.sheet h3 { text-align: center; margin: 8px 0 4px; font-size: 17px; }
.sheet .what { text-align: center; color: var(--dim); font-size: 13px; }
.sheet .effect { text-align: center; color: var(--red); font-size: 13px; margin-top: 4px; }
.sheet .typehint { color: var(--dim); font-size: 12px; margin: 16px 0 6px; }
.sheet .typebox { position: relative; }
.sheet .typebox input { width: 100%; background: var(--bg); border: 1px solid var(--gold); border-radius: 8px; padding: 9px 70px 9px 12px; font: 16px ui-monospace, Consolas, monospace; outline: none; text-transform: none; }
.sheet .typebox .target { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: 11px; font-family: ui-monospace, Consolas, monospace; pointer-events: none; }
.sheet .finger { width: 44px; height: 44px; border: 2px solid var(--line2); border-radius: 50%; margin: 14px auto 4px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--dim); }
.sheet .finger.ready { border-color: var(--gold); color: var(--gold); }
.sheet .fhint { text-align: center; color: var(--dim); font-size: 11px; }
.sheet .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.sheet .acts button { border-radius: 10px; padding: 11px; font-size: 15px; cursor: pointer; border: 1px solid var(--line2); background: none; color: var(--text); }
.sheet .acts .go { background: #5a1f22; border-color: #5a1f22; color: #ffb3ad; font-weight: 700; }
.sheet .acts .go.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.sheet .acts .go:disabled { opacity: .55; color: #a0605c; cursor: default; }
.sheet .result { text-align: center; font-size: 13px; margin-top: 12px; min-height: 18px; }
.sheet .result.bad { color: var(--red); } .sheet .result.ok { color: var(--green); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; z-index: 60; font-size: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
.toast.ok { border-color: var(--green); } .toast.bad { border-color: var(--red); color: var(--red); }
.toast[hidden] { display: none; }

/* pairing */
.pairwrap { padding-top: 8vh; }
.pairwrap h1 { color: var(--gold); font-size: 26px; margin: 0 0 6px; }
.pairwrap p { color: var(--dim); font-size: 14px; margin: 0 0 16px; }
.codein { font: 22px ui-monospace, Consolas, monospace; letter-spacing: .12em; text-align: center; text-transform: uppercase; }
video.scan { width: 100%; border-radius: 10px; background: #000; margin-top: 8px; }
.lockscreen { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.lockscreen .finger { width: 64px; height: 64px; border: 2px solid var(--gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--gold); }
.scrim:not([hidden]) ~ .toast { bottom: auto; top: calc(16px + env(safe-area-inset-top)); }
