/* ==========================================================================
   Gemini TTS 声音工坊 · Google 白底设计语言
   与 maps-live / s2st-live / asr-live 共用同一套设计令牌，保证培训现场
   多个 Demo 之间视觉连贯。
   ========================================================================== */

:root {
  /* Google 官方四色 + 语义色 */
  --g-blue: #1a73e8;
  --g-blue-hover: #1557b0;
  --g-blue-bg: #e8f0fe;
  --g-green: #1e8e3e;
  --g-green-deep: #137333;
  --g-green-bg: #e6f4ea;
  --g-orange: #e37400;
  --g-orange-bg: #fef7e0;
  --g-red: #d93025;
  --g-red-bg: #fce8e6;
  --g-purple: #9334e8;
  --g-purple-bg: #f3e8fd;

  /* 中性色阶 */
  --text-main: #202124;
  --text-sub: #5f6368;
  --text-mute: #80868b;
  --border: #dadce0;
  --border-soft: #e8eaed;
  --bg-page: #f8f9fa;
  --bg-card: #ffffff;
  --bg-subtle: #f1f3f4;

  --shadow-sm: 0 1px 2px 0 rgba(60,64,67,.08), 0 1px 3px 1px rgba(60,64,67,.05);
  --shadow-md: 0 1px 3px 0 rgba(60,64,67,.14), 0 4px 8px 3px rgba(60,64,67,.08);
  --shadow-lg: 0 8px 24px rgba(60,64,67,.18);

  --r-card: 16px;
  --r-pill: 999px;

  --font-sans: 'Google Sans', 'Google Sans Text', 'Noto Sans SC',
               -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}

.hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 60;
  box-shadow: 0 1px 3px rgba(60,64,67,.06);
}
.brand { display: flex; align-items: center; gap: 12px; }
.glogo { flex-shrink: 0; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--text-mute); letter-spacing: .4px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 13px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
}
.pill-model {
  background: var(--g-blue-bg); color: var(--g-blue);
  border: 1px solid #d2e3fc; font-family: var(--font-mono); font-size: 11.5px;
}
.pill-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--g-blue);
}
.pill-vertex {
  background: var(--g-green-bg); color: var(--g-green-deep);
  border: 1px solid #ceead6;
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #34a853;
  box-shadow: 0 0 0 0 rgba(52,168,83,.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,168,83,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52,168,83,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,168,83,0); }
}

.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; border: 1px solid var(--border);
  color: var(--text-sub);
  padding: 7px 15px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .16s;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-main); }
.btn-stop { border-color: #f5c3c0; color: var(--g-red); background: var(--g-red-bg); }
.btn-stop:hover { background: #fadad7; color: var(--g-red); }

.log-badge {
  background: var(--g-blue); color: #fff;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-pill); min-width: 20px; text-align: center;
}
.ico { font-size: 11px; line-height: 1; }

/* ---------------- 模式切换 ---------------- */
.mode-bar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 28px 0;
  max-width: 1400px; margin: 0 auto; width: 100%;
}
.mode-tabs {
  display: inline-flex; gap: 4px;
  background: var(--bg-subtle); padding: 4px;
  border-radius: var(--r-pill); border: 1px solid var(--border-soft);
}
.mode-tab {
  background: transparent; border: none; font-family: inherit;
  color: var(--text-sub); padding: 8px 20px;
  border-radius: var(--r-pill); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.mode-tab:hover { color: var(--text-main); background: rgba(255,255,255,.75); }
.mode-tab.active {
  background: var(--g-blue); color: #fff;
  box-shadow: 0 1px 3px rgba(26,115,232,.35);
}
.mode-hint { font-size: 13px; color: var(--text-mute); }

/* ---------------- 主舞台 ---------------- */
.stage { max-width: 1400px; margin: 0 auto; padding: 18px 28px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .split { grid-template-columns: 1fr; } }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text-main); }

.mini-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-sub); margin-bottom: 6px;
}
.mini-note { font-weight: 400; color: var(--text-mute); }

/* 示例 / 预设 芯片 */
.sample-chips, .preset-chips, .tag-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  background: var(--bg-subtle); border: 1px solid var(--border-soft);
  color: var(--text-sub); font-family: inherit;
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.chip:hover { background: var(--g-blue-bg); color: var(--g-blue); border-color: #d2e3fc; }
.chip.active { background: var(--g-blue); color: #fff; border-color: var(--g-blue); }
.chip-ico { margin-right: 5px; opacity: .8; }

.preset-chips { margin: 8px 0 14px; }

.tag-row {
  margin-top: 12px; padding: 12px 14px;
  background: var(--g-purple-bg); border: 1px solid #e9d5ff;
  border-radius: 12px;
}
.tag-row-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--g-purple); margin-bottom: 8px;
}
.badge-31 {
  background: var(--g-purple); color: #fff;
  font-size: 9.5px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--r-pill); margin-left: 6px; letter-spacing: .3px;
}
.tag-chips .chip {
  background: #fff; border-color: #e9d5ff; color: var(--g-purple);
  font-family: var(--font-mono); font-size: 11px;
}
.tag-chips .chip:hover { background: var(--g-purple); color: #fff; }
.tag-row.disabled { opacity: .45; pointer-events: none; filter: grayscale(1); }

/* 输入控件 */
.text-area, .style-input, .voice-select, .filter-input {
  width: 100%; font-family: inherit; font-size: 14px;
  color: var(--text-main); background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.text-area { resize: vertical; line-height: 1.65; min-height: 92px; }
.text-area:focus, .style-input:focus, .voice-select:focus, .filter-input:focus {
  border-color: var(--g-blue); box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
.style-input { font-size: 13.5px; }
.style-row { margin-bottom: 2px; }
.filter-input { width: 260px; font-size: 13px; padding: 8px 13px; }

.voice-row { display: flex; gap: 10px; }
.voice-select { cursor: pointer; }
.model-select { font-family: var(--font-mono); font-size: 12.5px; }

.action-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--g-blue); color: #fff; border: none;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 24px; border-radius: var(--r-pill);
  cursor: pointer; transition: all .16s;
  box-shadow: 0 1px 3px rgba(26,115,232,.3);
}
.btn-primary:hover { background: var(--g-blue-hover); box-shadow: 0 2px 8px rgba(26,115,232,.4); }
.btn-primary:disabled { background: #c6dafc; cursor: not-allowed; box-shadow: none; }

/* ---------------- 输出卡 ---------------- */
.out-card { min-height: 480px; }
.state-chip {
  font-size: 11.5px; font-weight: 600; padding: 4px 12px;
  border-radius: var(--r-pill);
  background: var(--bg-subtle); color: var(--text-sub);
}
.state-chip.gen { background: var(--g-blue-bg); color: var(--g-blue); }
.state-chip.play { background: var(--g-green-bg); color: var(--g-green-deep); }
.state-chip.err { background: var(--g-red-bg); color: var(--g-red); }

.wave-canvas {
  width: 100%; display: block;
  background: linear-gradient(180deg, #fbfcfe 0%, #f6f8fc 100%);
  border: 1px solid var(--border-soft); border-radius: 12px;
  margin-bottom: 16px;
}

.timeline-wrap { margin-bottom: 16px; }
.timeline-label {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--text-sub); margin: 8px 0 5px;
  font-weight: 500;
}
.timeline-label span:last-child { font-family: var(--font-mono); color: var(--text-main); }
.track {
  height: 7px; background: var(--bg-subtle);
  border-radius: var(--r-pill); overflow: hidden;
}
.track-fill { height: 100%; width: 0; border-radius: var(--r-pill); transition: width .08s linear; }
.track-fill.gen  { background: var(--g-blue); }
.track-fill.play { background: var(--g-green); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric {
  background: #fff; border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 12px 14px; text-align: center;
}
.metric.hl   { background: #f2fbf5; border-color: #c6e7ce; }
.metric.gold { background: #fffcf2; border-color: #fde293; }
.m-lbl { font-size: 11px; color: var(--text-sub); font-weight: 500; margin-bottom: 5px; }
.m-val {
  font-family: var(--font-mono); font-size: 19px; font-weight: 700;
  color: var(--text-main); letter-spacing: -.5px;
}
.m-val.green  { color: var(--g-green-deep); }
.m-val.blue   { color: var(--g-blue); }
.m-val.orange { color: var(--g-orange); }
.metric-note {
  margin-top: 10px; font-size: 11.5px; color: var(--text-mute); line-height: 1.6;
}

/* ---------------- 竞速 ---------------- */
.seg-switch {
  display: inline-flex; gap: 3px; background: var(--bg-subtle);
  padding: 3px; border-radius: var(--r-pill); border: 1px solid var(--border-soft);
}
.seg {
  background: transparent; border: none; font-family: inherit;
  color: var(--text-sub); padding: 6px 15px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .16s;
}
.seg.active { background: #fff; color: var(--g-blue); box-shadow: var(--shadow-sm); }

.explain {
  font-size: 13px; color: var(--text-sub); line-height: 1.7;
  background: var(--bg-subtle); border-radius: 10px;
  padding: 12px 15px; margin-bottom: 14px;
}

.lanes { display: grid; gap: 14px; margin-top: 22px; }
.lane {
  border: 1px solid var(--border-soft); border-radius: 14px;
  padding: 14px 16px; background: #fff; transition: all .2s;
}
.lane.winner { border-color: #c6e7ce; background: #f7fdf9; }
.lane-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 9px;
}
.lane-name { font-size: 13.5px; font-weight: 700; }
.lane-ttfa { font-family: var(--font-mono); font-size: 15px; font-weight: 700; }
.lane-track {
  position: relative; height: 26px; background: var(--bg-subtle);
  border-radius: 8px; overflow: hidden;
}
.lane-fill { height: 100%; width: 0; border-radius: 8px; transition: width .1s linear; }
.lane-fill.a { background: linear-gradient(90deg, #34a853, #1e8e3e); }
.lane-fill.b { background: linear-gradient(90deg, #bdc1c6, #9aa0a6); }
.lane-marker {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--g-red); display: none;
}
.lane-marker::after {
  content: '开口'; position: absolute; top: 3px; left: 5px;
  font-size: 9.5px; font-weight: 700; color: var(--g-red); white-space: nowrap;
}
.lane-foot {
  margin-top: 7px; font-size: 11.5px; color: var(--text-sub);
  font-family: var(--font-mono);
}

.verdict {
  margin-top: 18px; padding: 16px 18px;
  background: var(--g-green-bg); border: 1px solid #ceead6;
  border-radius: 12px; font-size: 14px; color: var(--g-green-deep);
  font-weight: 600; line-height: 1.7;
}
.verdict .big {
  font-family: var(--font-mono); font-size: 24px; font-weight: 700;
  color: var(--g-green-deep);
}

/* ---------------- 音色矩阵 ---------------- */
.gallery-line { display: flex; gap: 10px; margin-bottom: 16px; }
.gallery-line .style-input { flex: 1; }
.gallery-line .model-select { width: 250px; }

.voice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.vcard {
  border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; background: #fff;
  transition: all .16s; position: relative; overflow: hidden;
}
.vcard:hover {
  border-color: var(--g-blue); transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(26,115,232,.12);
}
.vcard.playing { border-color: var(--g-green); background: #f7fdf9; }
.vcard.loading { border-color: var(--g-blue); background: var(--g-blue-bg); }
.vname { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; }
.vtone {
  font-size: 11px; color: var(--g-blue); font-weight: 600;
  background: var(--g-blue-bg); display: inline-block;
  padding: 1px 8px; border-radius: var(--r-pill); margin-bottom: 5px;
}
.vuse { font-size: 11px; color: var(--text-mute); }
.vbar {
  position: absolute; left: 0; bottom: 0; height: 3px;
  background: var(--g-green); width: 0; transition: width .1s linear;
}

/* ---------------- 播客 ---------------- */
.pod-speakers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pod-sp-row { display: flex; gap: 8px; }
.sp-name { width: 110px; flex-shrink: 0; }
.note-chip {
  font-size: 11px; color: var(--g-orange); background: var(--g-orange-bg);
  border: 1px solid #fde293; padding: 3px 10px; border-radius: var(--r-pill);
  font-weight: 600;
}
.pod-state { font-size: 12.5px; color: var(--text-sub); font-family: var(--font-mono); }
#podCanvas { margin-top: 16px; }

/* ---------------- 日志抽屉 ---------------- */
.drawer { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; }
.drawer-mask {
  position: absolute; inset: 0; background: rgba(32,33,36,.28);
  backdrop-filter: blur(3px);
}
.drawer-sheet {
  position: relative; z-index: 2; width: 100%;
  max-height: 72vh; background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.16);
  padding: 20px 28px 24px;
  display: flex; flex-direction: column; gap: 14px;
  animation: slideUp .22s cubic-bezier(.16,1,.3,1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }

.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.drawer-head p { font-size: 11.5px; color: var(--text-mute); }
.drawer-head code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-subtle); padding: 1px 6px; border-radius: 4px;
  color: var(--g-blue);
}

.drawer-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.fpill {
  background: var(--bg-subtle); border: 1px solid var(--border-soft);
  color: var(--text-sub); font-family: inherit;
  padding: 4px 13px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.fpill.active { background: var(--g-blue); color: #fff; border-color: var(--g-blue); }
.drawer-btns { display: flex; gap: 6px; }
.btn-mini {
  background: #fff; border: 1px solid var(--border); color: var(--text-sub);
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 4px 12px; border-radius: var(--r-pill); cursor: pointer;
}
.btn-mini:hover { background: var(--bg-subtle); }

.log-viewport {
  flex: 1; overflow-y: auto; min-height: 220px;
  background: #fbfcfe; border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--font-mono); font-size: 11.5px;
}
.log-row {
  display: flex; gap: 9px; padding: 4px 8px;
  background: #fff; border-radius: 6px; align-items: baseline;
}
.log-ts    { color: #9aa0a6; flex-shrink: 0; }
.log-rel   { color: var(--g-blue); font-weight: 700; flex-shrink: 0; min-width: 58px; }
.log-delta { color: #bdc1c6; flex-shrink: 0; min-width: 52px; }
.log-cat {
  padding: 0 6px; border-radius: 4px; font-weight: 700;
  font-size: 10px; flex-shrink: 0;
}
.cat-LATENCY { background: var(--g-green-bg); color: var(--g-green); }
.cat-TTS_RUN { background: var(--g-blue-bg);  color: var(--g-blue); }
.cat-RACE    { background: var(--g-orange-bg);color: var(--g-orange); }
.cat-AUDIO   { background: var(--g-purple-bg);color: var(--g-purple); }
.cat-SYSTEM  { background: var(--bg-subtle);  color: var(--text-sub); }
.cat-ERROR   { background: var(--g-red-bg);   color: var(--g-red); }
.log-msg { color: var(--text-main); word-break: break-word; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #202124; color: #fff;
  padding: 11px 22px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500; z-index: 300;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }
