:root {
  --bg: #080a0d;
  --panel: #10141a;
  --panel2: #0c1015;
  --line: #1d242e;
  --txt: #e8eef6;
  --muted: #76808f;
  --accent: #34d399;
  --accent-dim: #1b6b52;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(130% 70% at 50% -10%, #111a24 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--txt);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); min-height: 20px; margin: 8px 0 0; font-size: 13px; }

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#login { min-height: 100vh; justify-content: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: .2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background .2s, box-shadow .2s; }
body.live .dot { background: var(--accent); box-shadow: 0 0 12px var(--accent); }

input[type=password], #sayInput {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--txt);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent-dim); }

button {
  border: 0; border-radius: 10px; padding: 12px 16px;
  font-size: 15px; font-weight: 600; color: #06231a; background: var(--accent);
  cursor: pointer; transition: transform .08s, filter .15s, border-color .15s;
}
button:active { transform: scale(.985); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); font-weight: 500; padding: 8px 12px; font-size: 13px; }
.ghost:hover { border-color: var(--accent-dim); }
.danger { background: var(--danger); color: #2a0b0b; }
.big { padding: 15px 34px; font-size: 17px; border-radius: 999px; }

header { display: flex; align-items: center; justify-content: space-between; }
.meta { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; }

/* ── 通话舞台 ── */
.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 0 2px; }
.orb { position: relative; width: 132px; height: 132px; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--line); transition: transform .09s linear, border-color .2s; }
.core {
  width: 74px; height: 74px; border-radius: 50%;
  background: linear-gradient(160deg, #16202b, #0a0f14);
  border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--muted);
  transition: color .2s, box-shadow .2s, border-color .2s;
}
body.live .core { color: var(--accent); border-color: var(--accent-dim); box-shadow: 0 0 30px -8px rgba(52,211,153,.6); }
body.speaking .core { box-shadow: 0 0 46px -4px rgba(52,211,153,.9); }
.state { font-size: 18px; font-weight: 600; }
.substate { font-size: 13px; color: var(--muted); margin-top: -6px; }
.controls { display: flex; gap: 10px; align-items: center; margin-top: 2px; }

/* ── 指标 ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.m { background: var(--panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.m label { font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.m b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.m .u { font-size: 10px; color: var(--muted); height: 12px; }
.m b.bad { color: var(--danger); }
.m b.warn { color: var(--warn); }
.m b.good { color: var(--accent); }

/* ── 字幕 ── */
.subs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sub { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 190px; max-height: 34vh; }
.sub-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted); letter-spacing: .4px;
}
.sub-h i { font-style: normal; font-size: 11px; opacity: .8; }
.sub-b { padding: 10px 12px; overflow-y: auto; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.sub-b .line { background: #0d1218; border: 1px solid #161d26; border-radius: 9px; padding: 7px 10px; }
.sub-b .line.live { border-color: var(--accent-dim); color: #cdece0; }
.sub-b .line.live::after { content: "▌"; opacity: .55; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.sub-b .ph { color: #4a5361; font-size: 13px; }

.say { display: flex; gap: 8px; }
.say input { flex: 1; }
footer { text-align: center; padding-top: 2px; }

@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .subs { grid-template-columns: 1fr; }
  .sub { min-height: 120px; }
}

/* ── 上游错误诊断条 ── */
.diag {
  border: 1px solid #4a2626;
  background: #1a0f11;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.diag-h { display: flex; align-items: center; gap: 8px; }
.diag-h b { color: var(--danger); font-size: 13px; letter-spacing: .3px; }
.diag-h span { font-size: 12px; color: var(--muted); }
.diag-h button { margin-left: auto; }
.tiny { padding: 4px 9px; font-size: 12px; }
.diag-msg { font-size: 14px; color: #ffd7d7; word-break: break-word; }
.diag-hint { font-size: 13px; color: #e8c9a0; line-height: 1.6; }
.diag-rid { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
