:root {
  --bg: #0b1020;
  --surface: #141b2e;
  --surface-2: #1c2540;
  --line: #27314f;
  --text: #eef1f8;
  --muted: #8d97b0;
  --accent: #5eead4;
  --accent-ink: #062b26;
  --danger: #fb7185;
  --mic-on: #f43f5e;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { height: 100%; }

.view { min-height: 100%; }
.view[hidden] { display: none !important; }
.center { display: grid; place-items: center; height: 100%; }

.card-view {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.02em; }

.lead { font-size: 1.08rem; color: var(--text); margin: 0; }
.fine { color: var(--muted); font-size: 0.9rem; margin: 0; }
.optional { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.95rem; }

.stack { display: flex; flex-direction: column; gap: 14px; }

.key-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  margin: 0;
}
.key-box legend { font-weight: 600; font-size: 0.95rem; padding: 0 6px; }
.key-saved { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--accent); }
.help { color: var(--muted); font-size: 0.9rem; }
.help summary { cursor: pointer; color: var(--accent); }
.help ol { padding-left: 20px; margin: 8px 0 0; }
.help li { margin-bottom: 6px; }
.help a { color: var(--accent); }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.95rem; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-weight: 400;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { padding: 16px 18px; font-size: 1.05rem; }
.btn.small { padding: 7px 13px; font-size: 0.9rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn:disabled { opacity: 0.6; }
.link { background: none; border: 0; color: var(--accent); font: inherit; padding: 0; cursor: pointer; }

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- conversation ---------- */

.room {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.room-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, black);
}
.people { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip.me { color: var(--accent); }
.bar-actions { display: flex; gap: 6px; flex-shrink: 0; }

.captions {
  overflow-y: auto;
  padding: 16px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.empty { color: var(--muted); text-align: center; margin: auto 0; padding: 0 20px; }

.cap { max-width: 92%; padding: 10px 14px; border-radius: var(--radius); }
.cap .who { font-size: 0.78rem; color: var(--muted); margin-bottom: 2px; }
.cap .text { margin: 0; white-space: pre-wrap; }
.cap .orig { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
.cap.theirs { background: var(--surface); align-self: flex-start; }
.cap.theirs .text { font-size: 1.35rem; line-height: 1.35; }
.cap.mine { background: transparent; border: 1px solid var(--line); align-self: flex-end; }
.cap.mine .text { font-size: 1rem; color: #c9d0e2; }
.cap.partial .text { opacity: 0.7; }

.room-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, black);
}
.lang-pill select { padding: 8px 10px; font-size: 0.85rem; border-radius: 999px; max-width: 150px; }
.mic-status { color: var(--muted); font-size: 0.85rem; margin: 0; text-align: right; }

.mic {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
}
.mic svg { width: 34px; height: 34px; fill: currentColor; }
.mic:active { transform: scale(0.96); }
.mic[data-mode="starting"] { opacity: 0.7; }
.mic[data-mode="on"] {
  background: var(--mic-on);
  color: white;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mic-on) 60%, transparent);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  to { box-shadow: 0 0 0 18px transparent; }
}

.center-text { text-align: center; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); }
.check small { color: var(--muted); font-weight: 400; }

/* ---------- single phone (duo) ---------- */

.duo {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}
.pane {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}
.pane.me { padding-bottom: env(safe-area-inset-bottom); }
.pane.them {
  transform: rotate(180deg); /* faces the person across the table */
  padding-bottom: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 35%, var(--bg));
}
.pane-caps {
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.pane-caps .cap { max-width: 96%; }
.pane-caps .cap.theirs .text { font-size: 1.5rem; }
.pane-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 14px 10px;
}
.pane-foot .chip { justify-self: start; font-size: 0.9rem; }
.duo-mic { width: 64px; height: 64px; }
.duo-mic svg { width: 28px; height: 28px; }
.mic[data-mode="muted"] { background: color-mix(in srgb, var(--mic-on) 45%, var(--surface-2)); color: white; }
.duo-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-block: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, black);
}
.duo-status { flex: 1; color: var(--muted); font-size: 0.82rem; text-align: center; }
.mini-toggle { flex-direction: row; align-items: center; gap: 5px; font-size: 0.85rem; font-weight: 500; white-space: nowrap; }
.mini-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.pane .empty { font-size: 1.4rem; }
.duo-debug {
  position: fixed; left: 8px; right: 8px; top: 50%; transform: translateY(-140%);
  font: 11px/1.3 ui-monospace, monospace; color: #9fe; background: #000a; padding: 4px 6px; border-radius: 6px;
  pointer-events: none; z-index: 5;
}

/* ---------- invite dialog ---------- */

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  width: min(92vw, 380px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
dialog h2 { margin: 0 0 4px; font-size: 1.25rem; }
.qr { display: grid; place-items: center; margin: 16px 0 10px; min-height: 120px; }
.qr img { width: 230px; height: 230px; image-rendering: pixelated; background: white; border-radius: 12px; }
.invite-link { font-size: 0.8rem; color: var(--muted); word-break: break-all; text-align: center; margin: 0 0 14px; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row .btn { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #000c;
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  max-width: 90vw;
  text-align: center;
  z-index: 10;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
