:root {
  --bg: #0c110f; --panel: #131a17; --panel-2: #18211d; --line: #24312b; --line-hi: #3b5a4b;
  --text: #d3e0d9; --muted: #8b9e95; --accent: #52b98a; --accent-hi: #7fd3aa;
  --ok: #5fc28f; --warn: #d8b25e; --bad: #e07c7c; --chip: #1c2622;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); display: flex; flex-direction: column;
       padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
.dim { color: var(--muted); } .small { font-size: 0.85rem; } .mono, code { font-family: var(--mono); font-size: 0.8rem; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad, .err { color: var(--bad); }
.err:empty { display: none; } .spacer, .grow { flex: 1; min-width: 0; } .center-text { text-align: center; }
.pad { padding: 0.75rem; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 44rem; margin: 0 auto; }
.screen.center { justify-content: center; padding: 1rem; overflow: auto; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bar { display: flex; align-items: center; gap: 0.5rem; min-height: 52px; padding: 0 0.75rem; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.brand { font: 600 1rem var(--mono); color: var(--accent-hi); letter-spacing: 0.05em; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.foot { padding: 0.75rem; border-top: 1px solid var(--line); flex: none; }

button { font: 600 0.95rem var(--sans); cursor: pointer; color: #0c110f; background: var(--accent); border: 1px solid var(--accent); border-radius: 8px; padding: 0.6rem 1rem; min-height: 44px; }
button:active { background: var(--accent-hi); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line-hi); font-weight: 500; }
button.danger { background: transparent; color: var(--bad); border-color: rgba(224,124,124,0.5); }
button.small { min-height: 34px; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
button.wide { width: 100%; }
button.back { font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.8rem; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.7rem; width: 100%; }
textarea { resize: none; }
label { display: grid; gap: 0.25rem; font-size: 0.88rem; color: var(--muted); margin-bottom: 0.8rem; }
h1 { margin: 0 0 0.75rem; font: 600 1.3rem var(--mono); color: var(--accent-hi); }
h2 { margin: 0 0 0.6rem; font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.rowform { display: flex; gap: 0.5rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 0.75rem; }

.banner { padding: 0.5rem 0.9rem; font-size: 0.9rem; background: var(--chip); border-bottom: 1px solid var(--line); flex: none; }
.banner.error { color: var(--bad); }
.banner.alert { background: rgba(224,124,124,0.12); border-bottom-color: var(--bad); color: var(--bad); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 60px; }
.list li:active { background: var(--chip); }
.list li.none { cursor: default; justify-content: center; }
.preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 0.66rem; padding: 0.05rem 0.4rem; border: 1px solid currentColor; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.unread { background: var(--accent); color: #0c110f; border-radius: 999px; font-size: 0.75rem; font-weight: 700; padding: 0 0.5rem; }
.request { border: 1px solid var(--warn); border-radius: 10px; padding: 0.7rem; margin: 0.75rem; background: rgba(216,178,94,0.06); }
.fp { display: block; word-break: break-all; margin: 0.25rem 0; }
.result { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; }

.messages { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.msg { max-width: 82%; padding: 0.5rem 0.75rem; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; }
.msg.out { align-self: flex-end; background: #1b2b24; border-color: var(--line-hi); }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { font-size: 0.7rem; color: var(--muted); text-align: right; margin-top: 0.15rem; }
.send { display: flex; gap: 0.5rem; padding: 0.6rem 0.75rem; border-top: 1px solid var(--line); flex: none; }
#send-error { margin: 0; padding-top: 0; padding-bottom: 0.25rem; }

dl { display: grid; grid-template-columns: minmax(6.5rem, auto) minmax(0, 1fr); gap: 0.25rem 0.75rem; margin: 0.5rem 0 0; font-size: 0.85rem; }
dt { color: var(--muted); } dd { margin: 0; overflow-wrap: anywhere; }
.sn { font: 600 1.05rem/1.9 var(--mono); letter-spacing: 0.06em; text-align: center; color: var(--accent-hi); word-spacing: 0.35em; margin: 0.5rem 0; }
.log { border-left: 2px solid var(--line-hi); padding: 0.3rem 0 0.3rem 0.6rem; margin-bottom: 0.8rem; }
.log.ok { border-color: var(--ok); } .log.fail { border-color: var(--bad); } .log.warn { border-color: var(--warn); }
.log-title { font-size: 0.9rem; } .why { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
#scan-video { width: 100%; border-radius: 8px; margin-top: 0.6rem; background: #000; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-hi); border-radius: 10px; padding: 1.1rem; width: min(92vw, 26rem); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { font: 600 1.05rem var(--sans); text-transform: none; letter-spacing: 0; color: var(--text); }
