:root {
  --bg: #0f1720; --panel: #17212b; --panel2: #1f2c38; --text: #e7edf3; --muted: #8a99a8;
  --accent: #2fb67c; --mine: #1d5c45; --theirs: #22303d; --warn: #e0a43a; --err: #e05a5a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

.screen { height: 100dvh; display: flex; flex-direction: column; }
#join { align-items: center; justify-content: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 24px; }
.logo { font-size: 40px; text-align: center; }
h1 { text-align: center; margin: 4px 0; }
.card > p { text-align: center; margin-top: 0; }
label { display: block; margin: 14px 0 0; font-size: .9rem; color: var(--muted); }
input, textarea { width: 100%; margin-top: 6px; padding: 12px; border-radius: 10px; border: 1px solid #2c3b49;
  background: var(--bg); color: var(--text); font: inherit; }
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.hint { font-size: .78rem; color: var(--muted); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 12px 16px;
  background: var(--accent); color: #062317; font-weight: 600; }
button:disabled { opacity: .5; }
#joinBtn { width: 100%; margin-top: 8px; }
.status { min-height: 1.4em; text-align: center; font-size: .9rem; color: var(--muted); }
.status.err { color: var(--err); }

header { display: flex; align-items: center; gap: 8px; padding: 8px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); }
header .title { flex: 1; display: flex; flex-direction: column; }
button.icon { background: transparent; color: var(--text); padding: 8px 12px; font-size: 1.2rem; }
.banner { padding: 6px 12px; font-size: .85rem; background: var(--warn); color: #241800; text-align: center; }

#messages { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
#messages li { max-width: 82%; padding: 8px 10px 4px; border-radius: 12px; background: var(--theirs); word-wrap: break-word; white-space: pre-wrap; }
#messages li.mine { align-self: flex-end; background: var(--mine); }
#messages li.sys { align-self: center; background: transparent; color: var(--muted); font-size: .8rem; text-align: center; }
#messages li.locked { opacity: .65; font-style: italic; }
#messages li.warn { border: 1px solid var(--err); }
.who { font-size: .78rem; font-weight: 600; margin-bottom: 2px; }
.meta { font-size: .68rem; color: var(--muted); text-align: right; margin-top: 2px; }

#sendForm { display: flex; gap: 8px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--panel); }
#sendForm textarea { margin: 0; resize: none; max-height: 140px; }
#sendBtn { padding: 0 16px; font-size: 1.2rem; }

dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 16px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 14px 0 4px; font-size: .9rem; color: var(--muted); }
dialog ul { list-style: none; padding: 0; margin: 0; max-height: 45vh; overflow-y: auto; }
dialog li { padding: 6px 0; border-bottom: 1px solid #263442; }
.fp { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; font-size: .9rem; margin: 2px 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--accent); }
