/* 同传测试台 —— 版式参照各家官方 Playground：左侧导航、中间原话/译文两栏、右侧运行设置、底部麦克风 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #15171c;
  --text-2: #4a505c;
  --muted: #7a8190;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --accent-text: #1d4fbf;
  --primary: #15171c;
  --primary-text: #ffffff;
  --live: #e5484d;
  --live-soft: #fdecec;
  --ok: #1f9d55;
  --warn: #b7791f;
  --warn-soft: #fdf6e7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #16191f; --surface-2: #1d2128; --border: #2a2f38; --border-strong: #39404b;
    --text: #eceef2; --text-2: #c2c7d0; --muted: #8a919e; --accent: #6b9bff; --accent-soft: #1b2944; --accent-text: #9dbcff;
    --primary: #eceef2; --primary-text: #0f1115; --live: #ff6369; --live-soft: #3a1a1c; --warn-soft: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #16191f; --surface-2: #1d2128; --border: #2a2f38; --border-strong: #39404b;
  --text: #eceef2; --text-2: #c2c7d0; --muted: #8a919e; --accent: #6b9bff; --accent-soft: #1b2944; --accent-text: #9dbcff;
  --primary: #eceef2; --primary-text: #0f1115; --live: #ff6369; --live-soft: #3a1a1c; --warn-soft: #33290f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- 外框 ---------- */
.app { display: grid; grid-template-columns: 72px 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; }
.rail .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.rail a { width: 56px; padding: 8px 0 6px; border-radius: 10px; color: var(--text-2); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.rail a svg { width: 20px; height: 20px; }
.rail a:hover { background: var(--surface-2); }
.rail a.on { background: var(--accent-soft); color: var(--accent-text); }
.rail .spacer { flex: 1; }
.rail button.linklike { background: none; border: 0; cursor: pointer; width: 56px; padding: 8px 0 6px; border-radius: 10px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.rail button.linklike:hover { background: var(--surface-2); color: var(--text); }
.rail button.linklike svg { width: 20px; height: 20px; }

.main { display: grid; grid-template-columns: 1fr 340px; min-width: 0; min-height: 0; }
.main.no-side { grid-template-columns: 1fr; }
.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); min-height: 60px; }
.topbar h1 { font-size: 18px; }
.topbar .chip { margin-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.topbar .grow { flex: 1; }
.side { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 18px 20px 28px; }
.side h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 4px 0 14px; }
.side .group { padding: 14px 0; border-top: 1px solid var(--border); }
.side .group:first-of-type { border-top: 0; padding-top: 0; }
.side .group > .label { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-bottom: 8px; display: block; }

/* ---------- 控件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { opacity: .9; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .model-card:focus-visible, .mic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type=text], input[type=password], textarea { width: 100%; height: 36px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 10px; }
textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.field { margin-bottom: 12px; }
.field .label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 5px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; margin-bottom: 12px; font-size: 13px; color: var(--text-2); }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 20px; background: var(--border-strong); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.chip.gray { background: var(--surface-2); color: var(--text-2); }
.chip.live { background: var(--live-soft); color: var(--live); }
.chip.ok { background: #e6f6ec; color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* 模型选择卡（像各家的模型下拉，这里摊开） */
.models { display: grid; gap: 8px; }
.model-card { text-align: left; border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; background: var(--surface); cursor: pointer; display: grid; gap: 2px; }
.model-card:hover { border-color: var(--muted); }
.model-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.model-card .vendor { font-size: 11.5px; color: var(--muted); }
.model-card .name { font-weight: 600; font-size: 13.5px; }
.model-card .id { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.model-card.down { opacity: .6; }
.model-note { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }

/* ---------- 原话 / 译文 两栏（跟官方 Playground 一样） ---------- */
.panes { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; background: var(--surface); }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane + .pane { border-left: 1px solid var(--border); }
.pane-head { padding: 18px 28px 6px; display: flex; align-items: baseline; gap: 10px; }
.pane-head h2 { font-size: 15px; color: var(--text-2); font-weight: 500; }
.pane-body { flex: 1; overflow-y: auto; padding: 8px 28px 28px; scroll-behavior: smooth; }
.seg { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 6px 0; font-size: 16.5px; line-height: 1.6; }
.seg .chip { margin-top: 3px; }
.seg.pending .txt { color: var(--text-2); }
.seg .txt { white-space: pre-wrap; word-break: break-word; }
.empty { color: var(--muted); font-size: 14px; padding: 24px 0; max-width: 46ch; }

/* ---------- 底部麦克风区 ---------- */
.dock { border-top: 1px solid var(--border); background: var(--surface); padding: 14px 24px 18px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.dock .left, .dock .right { display: flex; gap: 8px; align-items: center; min-width: 0; }
.dock .right { justify-content: flex-end; }
.mic { justify-self: center; width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-text); cursor: pointer; display: grid; place-items: center; position: relative; box-shadow: var(--shadow); }
.mic svg { width: 26px; height: 26px; }
.mic.live { background: var(--live); color: #fff; }
.mic.live::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--live); opacity: .35; animation: pulse 1.6s ease-out infinite; }
.mic.busy { background: var(--muted); }
@keyframes pulse { from { transform: scale(.92); opacity: .5; } to { transform: scale(1.18); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mic.live::before { animation: none; } }
.status { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.live .dot { background: var(--live); }
.status.ok .dot { background: var(--ok); }
.meter { width: 120px; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; flex: none; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.meter.out > i { background: var(--ok); }
.meters { display: grid; gap: 5px; font-size: 11px; color: var(--muted); }
.meters label { display: flex; align-items: center; gap: 8px; }
.meters label > span:first-child { width: 40px; white-space: nowrap; }

.banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; display: none; }
.banner.show { display: block; }
.banner.err { background: var(--live-soft); color: var(--live); }

/* ---------- 通用卡片 / 表格 ---------- */
.page { overflow-y: auto; padding: 24px; display: grid; gap: 16px; align-content: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .clip { max-width: 360px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 对比页三栏 */
.cmp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cmp-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 320px; }
.cmp-col header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.cmp-col header .name { font-weight: 600; }
.cmp-col .body { padding: 12px 14px; display: grid; gap: 10px; align-content: start; flex: 1; }
.cmp-col .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cmp-col .txt { white-space: pre-wrap; font-size: 14.5px; }
.cmp-col footer { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 报告页 */
details.case { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
details.case > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.case > summary::-webkit-details-marker { display: none; }
details.case[open] > summary { border-bottom: 1px solid var(--border); }
details.case .inner { padding: 16px 18px; display: grid; gap: 14px; }
.turn { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.turn > .src { padding: 12px 14px; background: var(--surface-2); display: grid; gap: 8px; }
.res-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.res { padding: 12px 14px; display: grid; gap: 6px; align-content: start; }
.res + .res { border-left: 1px solid var(--border); }
.res .head { display: flex; align-items: center; gap: 8px; }
.score { display: flex; gap: 6px; flex-wrap: wrap; }
audio { width: 100%; height: 34px; }

/* 登录 */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow); }
.login h1 { font-size: 20px; margin: 14px 0 4px; }
.login .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login .err { color: var(--live); font-size: 13px; min-height: 20px; margin: 4px 0 8px; }

.only-mobile { display: none; }

/* ---------- 手机 ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); }
  .rail .logo, .rail .spacer { display: none; }
  .rail a, .rail button.linklike { width: auto; flex: 1; }
  .main { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; max-height: 82vh; max-height: 82dvh; border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .22s ease; z-index: 30; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; display: none; }
  .scrim.show { display: block; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--border); }
  .pane-head { padding: 12px 16px 4px; }
  .pane-body { padding: 4px 16px 14px; }
  .seg { font-size: 15.5px; }
  .dock { padding: 10px 16px 12px; grid-template-columns: auto 1fr; }
  .dock .left { display: none; }
  .dock .mic { width: 56px; height: 56px; }
  .topbar #dir-chip { display: none; }
  .topbar .chip { max-width: 34vw; }
  .meter { width: 80px; }
  .page { padding: 16px; }
  .cmp-grid, .res-grid { grid-template-columns: 1fr; }
  .res + .res { border-left: 0; border-top: 1px solid var(--border); }
  .banner { margin: 10px 16px 0; }
}
