:root {
  --bg: #16181d;
  --panel: #20232b;
  --text: #e8e9ec;
  --muted: #9aa0ab;
  --accent: #4f8cff;
  --ok: #3ccf7a;
  --wait: #f0b94a;
  --bad: #ff6464;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 560px;
  margin-inline: auto;
}

h1 { font-size: 1.15rem; margin: 12px 0 8px; }
h1 .sub { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: 6px; }
h2 { font-size: 1.05rem; margin: 16px 0 10px; }

.status {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin: 0;
  padding: 8px 12px;
  background: var(--panel);
  border-radius: 10px;
  font-size: .82rem;
}
.status dt { color: var(--muted); }
.status dd { margin: 0; font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.status dd[data-state="ok"] { color: var(--ok); }
.status dd[data-state="wait"] { color: var(--wait); }
.status dd[data-state="bad"] { color: var(--bad); }

#banner {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .9rem;
  border: 1px solid;
}
#banner[data-kind="warn"] { color: var(--wait); border-color: var(--wait); background: #f0b94a14; }
#banner[data-kind="bad"] { color: var(--bad); border-color: var(--bad); background: #ff646414; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #ffffff22;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}
button.big {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 16px;
  font-size: 1.05rem;
  background: var(--accent);
  border: none;
  color: #fff;
}
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; margin: 16px 0; }

.hint { color: var(--muted); font-size: .85rem; }

.qr { display: flex; justify-content: center; }
.qr svg { width: min(100%, 340px); height: auto; border-radius: 8px; }

video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #000;
  border-radius: 10px;
}

details { margin: 12px 0; }
pre { font: .72rem/1.3 ui-monospace, Consolas, monospace; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
summary { color: var(--muted); cursor: pointer; }
textarea {
  width: 100%;
  margin: 8px 0;
  font: .8rem/1.3 ui-monospace, Consolas, monospace;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #ffffff22;
  border-radius: 8px;
  padding: 8px;
  word-break: break-all;
}

#chat { display: flex; flex-direction: column; height: calc(100dvh - 250px); min-height: 280px; margin-top: 12px; }
#chat[hidden] { display: none; }
#log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.msg { max-width: 80%; padding: 7px 11px; border-radius: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.them { align-self: flex-start; background: var(--panel); }
.msg.sys { align-self: center; color: var(--muted); font-size: .8rem; background: none; }

#chat-form { display: flex; gap: 8px; padding: 8px 0; }
#msg {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #ffffff22;
  border-radius: 20px;
  padding: 10px 14px;
}
#chat-form button { border-radius: 50%; width: 44px; background: var(--accent); border: none; color: #fff; }
