:root{
  --bg:#0b1020; --panel:#131a30; --panel2:#0f1526; --line:#232c47;
  --tx:#e8ecf8; --tx2:#9aa5c4; --dim:#5c6888;
  --acc:#5b7cfa; --acc2:#22d3a7; --spa:#5b7cfa; --spb:#f0a35e;
  --red:#ff5d6c; --gold:#f5c451;
  --r:14px;
}
*{box-sizing:border-box; margin:0; padding:0}
html,body{height:100%}
body{
  background:
    radial-gradient(1200px 500px at 15% -10%, #1b2b5e55, transparent 60%),
    radial-gradient(900px 420px at 110% 10%, #123a3a44, transparent 55%),
    var(--bg);
  color:var(--tx);
  font:14px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC","Segoe UI","Microsoft YaHei",sans-serif;
  display:flex; flex-direction:column;
}
button{font:inherit; color:inherit; cursor:pointer; border:none; background:none}
select,input,textarea{font:inherit; color:var(--tx); background:var(--panel2); border:1px solid var(--line); border-radius:9px; padding:7px 9px; outline:none; width:100%}
textarea{resize:vertical; line-height:1.5; font-family:ui-monospace,Menlo,monospace; font-size:12.5px}
select:focus,input:focus{border-color:var(--acc)}
input[type=range]{padding:0; border:none; background:transparent; accent-color:var(--acc)}
.chk{display:flex; align-items:center; gap:8px; font-size:13px}
.chk input{width:auto}
.warn{color:var(--red); font-style:normal; font-size:11px}
.val{color:var(--acc2); font-variant-numeric:tabular-nums; white-space:nowrap}
.hint{color:var(--tx2); font-size:12px; margin:2px 0 10px}
h3{margin:18px 0 8px; font-size:13px; color:var(--acc2); letter-spacing:1px}
.row2{display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:10px; margin-bottom:8px}
label{display:block; font-size:12px; color:var(--tx2); margin-bottom:6px}
label input,label select{margin-top:4px}

/* header */
.topbar{display:flex; align-items:center; justify-content:space-between; padding:14px 22px 8px}
.brand{display:flex; gap:12px; align-items:center}
.logo{width:42px;height:42px;border-radius:12px;background:linear-gradient(135deg,#5b7cfa,#22d3a7);
  display:grid;place-items:center; font-size:16px; box-shadow:0 6px 18px #5b7cfa44}
h1{font-size:19px; letter-spacing:.5px}
h1 em{font-style:normal; color:var(--acc2); font-weight:500}
.sub{font-size:11px; color:var(--dim); margin-top:-2px}
.top-actions{display:flex; gap:8px; align-items:center}
.badge{font-size:11px; padding:3px 9px; border-radius:99px; background:#223}
.badge.mock{background:#4a3b1055; color:var(--gold); border:1px solid #7a621855}
.badge.ok{background:#0e3a2e55; color:var(--acc2); border:1px solid #1e5e4a55}
.ghost{border:1px solid var(--line); border-radius:99px; padding:6px 13px; font-size:13px; color:var(--tx2)}
.ghost:hover{border-color:var(--acc); color:var(--tx)}
.ghost.sm{padding:4px 11px; font-size:12px}
.primary{border-radius:9px; padding:8px 16px; background:linear-gradient(135deg,#5b7cfa,#4a5fd0); color:#fff; font-weight:600}
.primary.sm{padding:6px 14px; font-size:13px}
.primary:hover{filter:brightness(1.1)}
.primary:disabled{opacity:.5; cursor:default}

main{flex:1; overflow-y:auto; padding:10px 22px 130px; max-width:1060px; width:100%; margin:0 auto}
.card{background:linear-gradient(180deg,#151d36,#121831); border:1px solid var(--line); border-radius:var(--r); padding:14px 16px; margin-bottom:12px}

/* controls */
.controls{display:flex; flex-wrap:wrap; gap:14px; align-items:center}
.seg{display:inline-flex; background:var(--panel2); border:1px solid var(--line); border-radius:99px; padding:3px; gap:2px}
.seg button{padding:5px 14px; border-radius:99px; font-size:13px; color:var(--tx2)}
.seg button.on{background:linear-gradient(135deg,#5b7cfa,#3f55c9); color:#fff}
.dir-row{display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end}
.arrow{color:var(--acc2); font-size:16px; padding-bottom:8px}
.dir-row label{min-width:110px; margin:0}
.chipbar{display:flex; gap:6px; flex-wrap:wrap; margin-top:4px}
.chipbar button{border:1px solid var(--line); border-radius:99px; padding:4px 12px; font-size:13px; color:var(--tx2); background:var(--panel2)}
.chipbar button.on{background:#2a3766; border-color:var(--acc); color:#cdd8ff}
.chipbar .del{color:#888; padding:4px 6px; font-size:11px}
.sp-a{accent-color:var(--spa)} .sp-b{accent-color:var(--spb)}
.who label{min-width:auto}

/* live bar */
.live-bar{display:flex; flex-wrap:wrap; align-items:center; gap:10px 16px; box-shadow:0 4px 18px #00000044}
.live-now{display:flex; align-items:center; gap:8px; white-space:nowrap; font-size:12px; color:var(--tx2); min-width:88px}
.rec-dot{width:9px;height:9px;border-radius:50%;background:#3a4360}
.recording .rec-dot{background:var(--red); animation:pulse 1s infinite}
.recording .live-now{color:var(--red)}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.25}}
.live-text{flex:1; font-size:13.5px; color:var(--tx2); min-height:22px; letter-spacing:.2px}
.live-preview{flex:0 0 100%; order:9; font-size:15.5px; font-weight:600; color:#7ef0cf; letter-spacing:.3px; line-height:1.6;
  background:#0d2a2355; border:1px solid #22d3a744; border-radius:10px; padding:6px 12px; animation:fadein .2s; word-break:break-word}
@keyframes fadein{from{opacity:0}to{opacity:1}}
.live-text.idle{color:var(--dim)}
.meter{width:120px; height:8px; border-radius:99px; background:#1d2542; overflow:hidden}
.meter-fill{height:100%; width:0%; background:linear-gradient(90deg,#22d3a7,#5b7cfa,#ff5d6c); transition:width 80ms linear}

/* feed */
.feed{display:flex; flex-direction:column; gap:10px; margin-top:2px}
.fcard{border:1px solid var(--line); border-radius:var(--r); background:linear-gradient(180deg,#141c33,#11172b); overflow:hidden}
.fcard.speaking{border-color:var(--acc); box-shadow:0 0 0 1px #5b7cfa55, 0 6px 22px #5b7cfa22}
.fcard .fhead{display:flex; align-items:center; gap:8px; padding:7px 14px; font-size:11px; color:var(--dim); background:#0e14275e; border-bottom:1px solid #1b23401f}
.fhead .spk{font-weight:700; color:var(--tx2)}
.fhead .tlang{color:var(--dim)}
.fhead .lat{margin-left:auto; font-variant-numeric:tabular-nums}
.fhead .mk{font-size:10px; padding:1px 7px; border-radius:99px; background:#4a3b1055; color:var(--gold); border:1px solid #7a621855}
.fbody{padding:6px 14px 10px}
.row-orig{padding:5px 0; color:#cdd5ee; font-size:15px; line-height:1.65}
.row-tr{display:flex; gap:8px; align-items:flex-start; padding:5px 0}
.row-tr .tchip{flex:none; font-size:10px; padding:2px 8px; border-radius:99px; margin-top:3px; background:#233061; color:#aab8ff}
.row-tr.sp-b .tchip{background:#4a3014; color:#ffd9a8}
.row-tr .trtext{flex:1; font-size:14.5px; color:#dbe4ff; line-height:1.6; white-space:pre-wrap; word-break:break-word}
.row-tr .trtext.thinking{color:var(--dim)}
.row-tr .actions{flex:none; display:flex; gap:6px; opacity:0; transition:opacity .15s}
.fcard:hover .row-tr .actions, .row-tr.speaking .actions{opacity:1}
.mini{border:1px solid var(--line); border-radius:99px; padding:2px 9px; font-size:11px; color:var(--tx2)}
.mini:hover{border-color:var(--acc)}
.mini.playing{color:var(--acc2); border-color:var(--acc2); animation:pulse 1s infinite}
.row-tr.speaking .trtext{color:#9ff0d8}
.live-cursor{color:var(--dim)}

/* empty state */
.empty{text-align:center; padding:64px 0 20px; color:var(--dim)}
.empty-icon{font-size:44px; margin-bottom:8px}
.dim2{color:var(--dim); font-size:12px}

/* dock */
.dock{position:fixed; left:0; right:0; bottom:0; padding:12px 22px calc(12px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg,transparent,#0b1020 40%); pointer-events:none}
.dock-inner{max-width:700px; margin:0 auto; display:flex; align-items:center; gap:16px;
  background:#121a31f2; border:1px solid var(--line); border-radius:20px; padding:10px 18px;
  box-shadow:0 12px 40px #000a; backdrop-filter:blur(10px); pointer-events:auto}
.mic{display:flex; align-items:center; gap:9px; background:linear-gradient(135deg,#ff5d6c,#e63950);
  color:#fff; font-weight:700; padding:11px 26px; border-radius:99px; font-size:15px; box-shadow:0 8px 24px #ff5d6c44}
.mic:hover{filter:brightness(1.08)}
.mic.live{background:linear-gradient(135deg,#22d3a7,#0f9e7a); box-shadow:0 8px 24px #22d3a744}
.mic:disabled{opacity:.45}
.mic-icon{font-size:17px}
.dock-stats{display:flex; gap:14px; margin-left:auto}
.stat{text-align:center; line-height:1.25}
.stat b{display:block; font-size:16px; color:var(--tx); font-variant-numeric:tabular-nums}
.stat span{font-size:10px; color:var(--dim)}
.dock-btns{display:flex; gap:6px}

/* drawer */
.drawer{position:fixed; inset:0; z-index:30; background:#00000088; backdrop-filter:blur(3px);
  display:flex; justify-content:flex-end}
.drawer-inner-hidden{display:none}
.drawer-head{display:flex; justify-content:space-between; align-items:center; padding:18px 22px; border-bottom:1px solid var(--line)}
.drawer-panel{background:#111731; width:min(520px,100vw); height:100%; max-height:100vh; overflow:hidden;
  display:flex; flex-direction:column; box-shadow:-20px 0 60px #000a}
.drawer-body{padding:4px 22px 40px; overflow-y:auto; -webkit-overflow-scrolling:touch; flex:1 1 auto; min-height:0}
@media (max-width:560px){ .drawer-panel{width:100vw} .drawer-body{padding:4px 16px 60px} }

/* toast */
.toast{position:fixed; left:50%; bottom:110px; transform:translateX(-50%); z-index:60;
  background:#1c2444; border:1px solid var(--line); color:var(--tx); padding:9px 18px; border-radius:99px;
  font-size:13px; box-shadow:0 8px 30px #000a; max-width:80vw; text-align:center}
.test-result{font-size:12px; color:var(--tx2); align-self:center}

[hidden]{display:none!important}
/* 双语分屏（上面全英文、下面全中文） */
.dual{display:flex; flex-direction:column; gap:12px; padding:8px 2px; background:transparent; border:none; box-shadow:none}
.dual-pane{min-width:0}
.dual-label{font-size:11px; color:var(--dim); letter-spacing:2px; margin-bottom:4px}
.dual-body{max-height:260px; overflow-y:auto; scroll-behavior:smooth}
.dual-line{font-size:15px; line-height:1.6; color:#c3cdea; margin:0 0 10px; white-space:pre-wrap; word-break:break-word}
.dual-line.zh{color:#7ef0cf; font-weight:600; font-size:15.5px; margin-bottom:20px}
body.style-dual #feed{display:none}
/* 显示样式：纯文字（无框无底色无标签，像有道即时字幕） */
body.style-text .fcard{background:transparent; border:none; box-shadow:none; border-bottom:none; border-radius:0; padding:8px 2px; margin:0}
body.style-text .fcard .fhead{display:none}
body.style-text .fcard .row-orig{color:#b8c2dd; font-size:14px; line-height:1.65}
body.style-text .fcard .trtext{color:#7ef0cf; font-size:15.5px; line-height:1.75; font-weight:600}
body.style-text .row-tr{align-items:flex-start}
body.style-text .fbody{padding:0}
body.style-text #paraPanel{border:none; background:transparent; box-shadow:none; padding:2px 2px 4px}
body.style-text #paraPanel .para-head{display:none}
body.style-text .para-orig{font-size:14.5px; color:#c3cdea; min-height:0}
body.style-text .para-tr{font-size:16px; min-height:0; margin-top:2px}
/* 显示样式：对话框（气泡） */
body.style-bubble .fcard{background:linear-gradient(135deg,#1a2447f0,#141a30f0); border:1px solid var(--line); border-radius:16px; border-left:3px solid var(--acc); box-shadow:0 4px 16px #0005; margin:2px 0}
body.style-bubble .fcard .fhead{display:none}
body.style-bubble .fcard .row-orig{color:#c7d0ea; font-size:14px}
body.style-bubble .fcard .trtext{color:#8ef3d3; font-size:15px; font-weight:600}
.chipbar select{width:auto;font-size:12px;padding:4px 10px;border-radius:99px;color:var(--tx2)}
.feedbar{display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; margin:-2px 0 10px}
.para{border:1px solid #22d3a744; background:linear-gradient(180deg,#0f2a2418,#0e1626); padding:12px 16px}
.para-head{display:flex; gap:12px; align-items:baseline; font-size:11px; color:var(--dim); margin-bottom:6px}
.para-lang{color:var(--acc2); font-weight:600}
.para-stat{margin-left:auto; color:var(--dim)}
.para-orig{font-size:15.5px; color:#cdd5ee; line-height:1.7; white-space:pre-wrap; word-break:break-word; min-height:24px}
.para-tr{font-size:16px; font-weight:600; color:#7ef0cf; line-height:1.7; white-space:pre-wrap; word-break:break-word; margin-top:5px; min-height:24px; animation:fadein .2s}
.para-tr.thinking{color:var(--dim); font-weight:400}
.para.speaking{box-shadow:0 0 0 1px #22d3a755, 0 6px 22px #22d3a722}
.para-card .trtext{font-size:15px}
.fb-label{font-size:11px; color:var(--dim)}
.fb-state{margin-left:auto; font-size:11px; color:var(--dim)}
.seg.sm button{padding:3px 11px; font-size:12px}

@media (max-width:720px){
  .dock-inner{flex-wrap:wrap; justify-content:center; gap:10px}
  .dock-stats{margin-left:0; order:3; width:100%; justify-content:center}
  .topbar{padding:10px 12px 4px}
  main{padding:6px 10px 190px}
  .meter{width:70px}
}
