/* Mobile-first, system fonts only, no external resources. */
:root {
  --bg: #111418;
  --card: #1b2027;
  --line: #2c333d;
  --text: #eef1f5;
  --muted: #8a94a3;
  --accent: #3b82f6;
  --live: #16a34a;
  --danger: #ef4444;
  color-scheme: dark;
}

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

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#room.screen { min-height: 100dvh; }

h1 { font-size: 22px; margin: 4px 0; }
h1 .sub { display: block; font-size: 14px; font-weight: 400; color: var(--muted); }
h2 { font-size: 18px; margin: 0 0 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.label { font-size: 14px; color: var(--muted); }
input, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
textarea { resize: vertical; margin-top: 8px; }
#room-code { text-transform: uppercase; letter-spacing: 0.15em; }

button {
  font: inherit;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #252b34;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.5; }
button.primary { width: 100%; background: var(--accent); border-color: var(--accent); font-weight: 600; font-size: 18px; }
button.toggle { width: 100%; }
button.on { background: #1e3a8a; border-color: var(--accent); }

.pills { display: flex; gap: 8px; }
.pills > button { flex: 1 1 0; }
.pills.wrap { flex-direction: column; }
.pills.wrap > button { text-align: left; }

details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); }

.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.error { color: var(--danger); font-size: 15px; }
.small { font-size: 13px; color: var(--muted); word-break: break-all; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.topbar .code { font-size: 24px; font-weight: 700; letter-spacing: 0.12em; }
.topbar button { flex: 1 1 40%; }
.badge { padding: 4px 10px; border-radius: 999px; background: #1e3a8a; font-size: 13px; }

.status { font-size: 14px; color: var(--muted); }
.row { display: flex; flex-direction: column; gap: 8px; }

#host-controls { display: flex; flex-direction: column; gap: 10px; }
button.mic { width: 100%; min-height: 72px; font-size: 22px; font-weight: 700; background: #3a2a2a; border-color: #5b3b3b; }
button.mic.live { background: var(--live); border-color: var(--live); }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
#meter-bar { height: 100%; width: 0; background: var(--live); transition: width 80ms linear; }

.feed {
  flex: 1 1 auto;
  min-height: 40vh;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font-size: 19px;
  line-height: 1.45;
}
.para { padding: 8px 0; border-bottom: 1px solid var(--line); }
.para:last-child { border-bottom: 0; }
.speaker { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; margin-bottom: 4px; border-radius: 999px; background: #334155; color: #cbd5e1; }
.line.original { color: var(--muted); }
.line.translation { color: var(--text); font-weight: 500; }
.line .interim { opacity: 0.55; font-style: italic; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modal-box { background: #fff; color: #111; border-radius: 16px; padding: 16px; width: min(92vw, 380px); display: flex; flex-direction: column; gap: 10px; }
.modal-box .small { color: #444; }
.qr svg { width: 100%; height: auto; display: block; }

@media (min-width: 560px) {
  .pills.wrap { flex-direction: row; flex-wrap: wrap; }
  .pills.wrap > button { flex: 1 1 45%; }
}
