:root {
  --bg: #0f1420;
  --panel: #182033;
  --line: #2a3550;
  --text: #f2f5fb;
  --dim: #93a0bb;
  --accent: #3b82f6;
  --mine: #1e3a66;
  --theirs: #1d2a22;
  --ok: #22c55e;
  --bad: #ef4444;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* ---- setup ---- */
#setup { padding: 28px 20px; gap: 10px; max-width: 520px; margin: 0 auto; }
#setup h1 { font-size: 26px; margin: 0 0 14px; }
#setup h1 span { display: block; font-size: 18px; color: var(--dim); font-weight: 500; }
.lbl { color: var(--dim); font-size: 14px; margin-top: 10px; }
.row { display: flex; gap: 10px; }
input {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); outline: none; min-width: 0;
}
input:focus { border-color: var(--accent); }
#roomInput { font-size: 26px; letter-spacing: 6px; text-align: center; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; padding: 14px 8px; font-weight: 600; }
.seg button small { display: block; font-weight: 400; color: var(--dim); font-size: 13px; }
.seg button.on { background: var(--accent); }
.seg button.on small { color: #dbe7ff; }
.seg.sm button { padding: 8px 12px; font-size: 15px; }
.primary { background: var(--accent); padding: 16px; border-radius: 12px; font-weight: 700; font-size: 19px; margin-top: 18px; }
.ghost { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 0 16px; white-space: nowrap; }
.ghost.sm { padding: 6px 14px; }
.hint { color: var(--dim); font-size: 14px; text-align: center; }
.err { color: #fecaca; background: #45141a; border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; font-size: 15px; }

/* ---- main ---- */
header {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.icon { font-size: 24px; width: 42px; height: 42px; border-radius: 10px; }
.status { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dim); min-width: 0; }
.status b { color: var(--text); font-size: 17px; letter-spacing: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.on { background: var(--ok); }
#peer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#settings { background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 12px 10px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 15px; }

.banner { background: #45141a; color: #fecaca; padding: 8px 12px; font-size: 14px; }

#list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 16px; position: relative; }
.msg.mine { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--theirs); border-bottom-left-radius: 4px; }
.msg .p { font-size: 22px; line-height: 1.35; word-break: break-word; }
.msg.theirs .p { font-size: 26px; }
.msg .s { font-size: 15px; color: var(--dim); margin-top: 6px; word-break: break-word; }
.msg .s.warn { color: #fca5a5; }
.msg .spk { margin-top: 6px; font-size: 22px; padding: 4px 10px; border-radius: 10px; background: rgba(255,255,255,.08); }
.msg .spk.busy { opacity: .5; }

.live { padding: 8px 14px; color: var(--dim); font-size: 17px; border-top: 1px dashed var(--line); max-height: 30vh; overflow: hidden; }
.live.me { color: #bfdbfe; }

footer { padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 10px; }
#textForm { display: flex; gap: 8px; }
#textForm .ghost { padding: 0 18px; font-size: 20px; }
.mic {
  background: var(--accent); border-radius: 18px; padding: 18px; font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px; user-select: none; -webkit-user-select: none;
}
.mic .ico { font-size: 26px; }
.mic.connecting { background: #64748b; }
.mic.on { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(239,68,68,.18); } }
