:root {
  --bg: #0f1218; --panel: #171b23; --line: #262c38; --text: #e6e9ef; --dim: #8b93a5;
  --self: #4f7df0; --partner: #e39a2d; --speed: #7fd3a8; --accent: #4f7df0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
body { display: grid; grid-template-rows: 52px 1fr 150px; height: 100vh; }

header { display: flex; align-items: center; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.brand { font-size: 17px; }
.brand span { color: var(--dim); margin-left: 8px; font-size: 13px; }
select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.pill { margin-left: auto; padding: 3px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.pill.ok { color: #7fd3a8; border-color: #2c5a45; }
.pill.bad { color: #f08a7a; border-color: #6a3029; }
.pill.wait { color: #d9b26a; border-color: #6a5529; }

main { display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
#stage { position: relative; min-height: 0;
  background: radial-gradient(ellipse at 50% 35%, #232a38 0%, #12151c 70%); }
#viewport { position: absolute; inset: 0; }
#viewport canvas { width: 100%; height: 100%; display: block; }
.badge { position: absolute; top: 16px; left: 16px; padding: 6px 14px; border-radius: 8px; font-weight: 600;
  background: #222836; color: var(--dim); transition: background .2s, color .2s; }
.badge.speak { background: var(--self); color: #fff; }
.badge.listen { background: var(--partner); color: #1a1205; }
.badge.both { background: linear-gradient(90deg, var(--self), var(--partner)); color: #fff; }
.badge.pause { background: #2d3546; color: #c9d2e4; }
#viewBtns { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
#viewBtns button { background: rgba(15, 18, 24, .6); }
#record.on { color: #fff; background: #c2483a; border-color: #c2483a; }
#recInfo { position: absolute; top: 48px; right: 14px; color: #f08a7a; font: 12px ui-monospace, Menlo, monospace; }
#stats { position: absolute; bottom: 12px; left: 16px; color: var(--dim); font: 12px/1.6 ui-monospace, Menlo, monospace; white-space: pre; }
/* Live subtitle under the avatar: the end of the AI's transcript (same text the recorder burns in). */
#caption { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: min(720px, 70%);
  padding: 8px 16px; border-radius: 8px; background: rgba(10, 12, 16, .65); backdrop-filter: blur(4px);
  font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The AI's full transcript, filling the dialogue panel. */
.panel[data-mode=dialogue] { flex: 1; min-height: 0; }
#chat { flex: 1; min-height: 160px; display: flex; flex-direction: column; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; }
.card-head { padding: 8px 12px; color: var(--dim); font-size: 12px; border-bottom: 1px solid var(--line); }
#chat .transcript { flex: 1; min-height: 0; max-height: none; background: none; border-radius: 0 0 10px 10px; }
#chat .transcript:empty::before { content: "The AI's words appear here."; color: #5b6375; }

aside { border-left: 1px solid var(--line); background: var(--panel); padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
#tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; background: var(--bg); padding: 4px; border-radius: 8px; }
#tabs button { background: none; border: 0; color: var(--dim); padding: 7px 0; border-radius: 6px; cursor: pointer; font-size: 13px; }
#tabs button.on { background: var(--panel); color: var(--text); }
.panel { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
.hint { color: var(--dim); margin: 0; font-size: 13px; }
.hint em { color: var(--partner); font-style: normal; }
.hint.warn { color: #d9b26a; }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.foot button { white-space: nowrap; }
.foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 600; }
button.primary.stop { background: #c2483a; }
button.ghost { background: none; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
button.small { padding: 2px 9px; }
button:disabled { opacity: .4; cursor: default; }
.meter { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.meter i, .progress i { display: block; height: 100%; width: 0; background: var(--speed); transition: width .08s; }
.progress { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.progress i { background: var(--accent); }
/* Upload drop zones: the native file input is hidden (its button text follows the OS language). */
.drop { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  border: 1px dashed #343c4c; border-radius: 10px; background: var(--bg); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #141a26; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-ico { flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: #1f2533; }
.drop-ico svg { width: 18px; height: 18px; fill: none; stroke: var(--dim); stroke-width: 1.8; stroke-linecap: round; }
.drop.self.has .drop-ico { background: rgba(79, 125, 240, .18); } .drop.self.has svg { stroke: var(--self); }
.drop.partner.has .drop-ico { background: rgba(227, 154, 45, .18); } .drop.partner.has svg { stroke: var(--partner); }
.drop.has { border-style: solid; border-color: var(--line); }
.drop-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.drop-txt b { font-size: 13px; font-weight: 600; }
.drop-txt b i { font-style: normal; font-weight: 400; color: var(--dim); font-size: 12px; margin-left: 4px; }
.drop-name { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop-name:empty::before { content: attr(data-empty); color: #5b6375; }
.drop-x { flex: none; display: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none;
  color: var(--dim); font-size: 18px; line-height: 1; }
.drop-x:hover { background: #262c38; color: var(--text); }
.drop.has .drop-x { display: block; }
.samples-head { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.samples-head span { font-weight: 400; color: var(--dim); font-size: 12px; margin-left: 4px; }
.sample-list { display: flex; flex-direction: column; gap: 4px; }
.sample { display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left; padding: 6px 10px;
  background: none; color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.sample:hover { border-color: var(--accent); background: #141a26; }
.sample.on { border-color: var(--accent); background: rgba(79, 125, 240, .12); }
.sample b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.sample span { color: var(--dim); font-size: 12px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sample time { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.transcript { min-height: 140px; max-height: 260px; overflow: auto; background: var(--bg); border-radius: 8px; padding: 10px; white-space: pre-wrap; font-size: 13px; }

footer { border-top: 1px solid var(--line); padding: 6px 18px 10px; display: flex; flex-direction: column; min-height: 0; }
.legend { display: flex; gap: 18px; color: var(--dim); font-size: 12px; }
.legend b { font-weight: 500; color: var(--text); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw.self { background: var(--self); } .sw.partner { background: var(--partner); } .sw.speed { background: var(--speed); }
#timeline { flex: 1; width: 100%; min-height: 0; }

.params { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.params-head { display: flex; align-items: center; justify-content: space-between; }
.params-head b { font-weight: 600; font-size: 13px; }
.params label { display: grid; grid-template-columns: 70px 1fr 34px; gap: 8px; align-items: center; color: var(--dim); font-size: 12px; }
.params input[type=range] { width: 100%; accent-color: var(--accent); }
.params output { color: var(--text); font: 12px ui-monospace, Menlo, monospace; text-align: right; }

/* password / offline gate (page hosted away from the backend) */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(15, 18, 24, .82); }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px 28px;
  display: grid; gap: 12px; width: min(340px, calc(100vw - 32px)); }
.gate-card form { display: flex; gap: 8px; }
.gate-card input { flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.gate-card .hint:empty { display: none; }
