:root {
  --bg: #f4f5f7; --fg: #1d2330; --muted: #667085; --card: #ffffff; --line: #d8dce3;
  --accent: #2459d6; --accent-fg: #ffffff; --err: #c0362c; --stage: #10141c; --me: #e8efff; --ai: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1218; --fg: #e6e9ef; --muted: #98a2b3; --card: #171b23; --line: #2a303b;
    --accent: #5b8cff; --accent-fg: #0b0e14; --err: #ff7b6e; --stage: #05070a; --me: #1c2740; --ai: #171b23; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--muted); padding: 4px 6px; text-decoration: underline; }
input { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); width: 100%; }
.muted { color: var(--muted); }
.err { color: var(--err); min-height: 1.4em; }

.card { max-width: 380px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card form { display: grid; gap: 10px; margin-top: 16px; }

#call { max-width: 960px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }
.stage { position: relative; background: var(--stage); border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; color: #cfd6e4; gap: 8px; text-align: center; padding: 16px; }
.face { width: 96px; height: 96px; border-radius: 50%; background: #2b3448; display: grid; place-items: center; font-size: 40px; font-weight: 700; transition: transform .12s; }
.face.talking { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(91,140,255,.35); }
.status { position: absolute; left: 12px; top: 12px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 10px; border-radius: 999px; font-size: 13px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.log { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
#captions { max-height: 34vh; overflow-y: auto; display: grid; gap: 8px; }
.msg { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.me { background: var(--me); justify-self: end; max-width: 85%; }
.msg.ai { background: var(--ai); max-width: 95%; }
.msg.sys { color: var(--muted); font-size: 13px; border-style: dashed; }
.msg .interim { color: var(--muted); }
.textrow { display: flex; gap: 8px; }
.textrow input { flex: 1; }
.footer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.footer #caps { margin-right: auto; font-size: 13px; }

.meterbox { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; }
.meter { position: relative; width: 120px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--muted); transition: width .05s linear; }
.meter .bar.hot { background: var(--accent); }
.meter .th { position: absolute; top: -2px; bottom: -2px; width: 2px; left: 50%; background: var(--fg); opacity: .5; }
#sens { width: 90px; padding: 0; }
button.muted { color: var(--err); border-color: var(--err); }
@media (max-width: 560px) { .meterbox { margin-left: 0; width: 100%; } .meter { flex: 1; } }
