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

:root {
  --bg:          #0d0f18;
  --surface:     #13151f;
  --surface2:    #1c1f2e;
  --surface3:    #232638;
  --border:      #272a3a;
  --text:        #e2e8f0;
  --muted:       #556070;
  --accent:      #6366f1;
  --accent-dim:  rgba(99,102,241,0.15);
  --success:     #22c55e;
  --warning:     #f59e0b;
  --error:       #ef4444;

  /* Agent colours */
  --agent-chitchat: #6366f1;
  --agent-expert:   #06b6d4;
  --agent-gaming:   #f59e0b;

  --user-bg:    rgba(59,130,246,0.15);
  --user-border: rgba(59,130,246,0.25);
  --ai-bg:      rgba(34,197,94,0.08);
  --ai-border:  rgba(34,197,94,0.18);

  --radius:     14px;
  --radius-sm:  9px;
  --radius-msg: 18px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Two-column layout ─────────────────────────── */
.layout {
  display: flex;
  gap: 16px;
  height: 100dvh;
  max-height: 900px;
  width: 100%;
  max-width: 1100px;
  padding: 16px;
  align-items: stretch;
}

/* ── App shell (left column) ───────────────────── */
.app {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

/* ── Header ────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-text h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.agent-state {
  display: block; font-size: 11px; color: var(--muted);
  margin-top: 2px; transition: color 0.3s;
}

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
.avatar svg { width: 20px; height: 20px; color: #fff; }

.conn-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); transition: background 0.4s, box-shadow 0.4s;
}
.conn-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}

/* ── VAD bar ───────────────────────────────────── */
.vad-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  flex-shrink: 0; transition: background 0.3s;
}

/* Waveform bars */
.vad-waves { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.vad-waves span {
  display: block; width: 3px; border-radius: 2px;
  background: var(--muted); transition: background 0.2s, height 0.2s;
}
.vad-waves span:nth-child(1) { height: 6px; }
.vad-waves span:nth-child(2) { height: 10px; }
.vad-waves span:nth-child(3) { height: 14px; }
.vad-waves span:nth-child(4) { height: 10px; }
.vad-waves span:nth-child(5) { height: 6px; }

/* listening — green animated waves */
.vad-bar.listening { background: rgba(34,197,94,0.04); }
.vad-bar.listening .vad-waves span { background: var(--success); }
.vad-bar.listening .vad-waves span:nth-child(1) { animation: wave 0.9s ease-in-out infinite 0.0s; }
.vad-bar.listening .vad-waves span:nth-child(2) { animation: wave 0.9s ease-in-out infinite 0.1s; }
.vad-bar.listening .vad-waves span:nth-child(3) { animation: wave 0.9s ease-in-out infinite 0.2s; }
.vad-bar.listening .vad-waves span:nth-child(4) { animation: wave 0.9s ease-in-out infinite 0.3s; }
.vad-bar.listening .vad-waves span:nth-child(5) { animation: wave 0.9s ease-in-out infinite 0.4s; }

/* processing — amber */
.vad-bar.processing { background: rgba(245,158,11,0.04); }
.vad-bar.processing .vad-waves span { background: var(--warning); animation: pulse-flat 1s ease-in-out infinite; }

/* speaking — accent purple animated */
.vad-bar.speaking { background: rgba(99,102,241,0.05); }
.vad-bar.speaking .vad-waves span { background: var(--accent); }
.vad-bar.speaking .vad-waves span:nth-child(1) { animation: wave 0.7s ease-in-out infinite 0.0s; }
.vad-bar.speaking .vad-waves span:nth-child(2) { animation: wave 0.7s ease-in-out infinite 0.15s; }
.vad-bar.speaking .vad-waves span:nth-child(3) { animation: wave 0.7s ease-in-out infinite 0.3s; }
.vad-bar.speaking .vad-waves span:nth-child(4) { animation: wave 0.7s ease-in-out infinite 0.15s; }
.vad-bar.speaking .vad-waves span:nth-child(5) { animation: wave 0.7s ease-in-out infinite 0.0s; }

.vad-label { flex: 1; }

@keyframes wave {
  0%,100% { transform: scaleY(1); }
  50%      { transform: scaleY(2.2); }
}
@keyframes pulse-flat {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ── Conversation ──────────────────────────────── */
.conversation {
  flex: 1; overflow-y: auto;
  padding: 18px 16px 10px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.conversation::-webkit-scrollbar { width: 4px; }
.conversation::-webkit-scrollbar-track { background: transparent; }
.conversation::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.convo-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px;
  font-size: 13px; color: var(--muted); text-align: center; padding: 20px;
  line-height: 1.6;
}
.convo-empty-icon svg { width: 40px; height: 40px; color: var(--border); }

/* Message rows */
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai   { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 5px; padding: 0 4px;
}

/* Agent-specific label colours */
.msg.ai .msg-label                    { color: var(--agent-chitchat); }
.msg.ai .msg-label[data-agent="sme"]  { color: var(--agent-expert); }
.msg.ai .msg-label[data-agent="gaming"] { color: var(--agent-gaming); }

.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--radius-msg);
  font-size: 14px; line-height: 1.6; word-break: break-word;
  transition: outline 0.2s;
}
.msg.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-bottom-right-radius: 5px;
  color: #bfdbfe;
}
.msg.ai .msg-bubble {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 5px;
  color: #d1fae5;
}

/* Agent-tinted AI bubble */
.msg.ai[data-agent="sme"] .msg-bubble {
  background: rgba(6,182,212,0.07);
  border-color: rgba(6,182,212,0.2);
  color: #a5f3fc;
}
.msg.ai[data-agent="gaming"] .msg-bubble {
  background: rgba(245,158,11,0.07);
  border-color: rgba(245,158,11,0.2);
  color: #fde68a;
}

.msg-bubble.speaking  { outline: 2px solid var(--accent); outline-offset: 2px; }
.pending-text         { opacity: 0.45; font-style: italic; }

/* Audio player row */
.msg-audio { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.play-btn {
  background: var(--accent); border: none; border-radius: 50%;
  width: 28px; height: 28px; cursor: pointer; color: #fff;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 0.2s, transform 0.15s;
}
.play-btn:hover:not(:disabled) { opacity: 0.85; transform: scale(1.08); }
.play-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.audio-status { font-size: 11px; color: var(--muted); }

/* ── Footer ────────────────────────────────────── */
.app-footer {
  padding: 10px 14px 12px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}

.footer-top {
  display: flex; gap: 8px; align-items: center;
}

.footer-name-row {
  display: flex; margin-bottom: 6px;
}

.name-input {
  max-width: 220px;
}

.footer-text-row {
  display: flex; gap: 6px; align-items: center;
}

.text-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.text-input::placeholder { color: var(--muted); }
.text-input:focus { border-color: var(--accent); }
.text-input:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-send {
  padding: 9px 12px;
  background: var(--accent); color: #fff;
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { opacity: 0.88; }
.btn-send svg { width: 15px; height: 15px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, background 0.2s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-connect {
  padding: 10px 16px;
  background: var(--accent); color: #fff;
}
.btn-connect:hover:not(:disabled) { opacity: 0.88; }

.btn-mic {
  flex: 1; padding: 11px 14px;
  background: var(--surface3); color: var(--text);
  border: 1px solid var(--border);
}
.btn-mic:hover:not(:disabled) { background: var(--surface2); border-color: var(--accent); }
.btn-mic.active {
  background: var(--accent-dim);
  border-color: var(--accent); color: var(--accent);
}
.btn-mic.active .mic-icon { color: var(--accent); }

.btn-interrupt {
  padding: 10px 13px;
  background: rgba(239,68,68,0.1); color: var(--error);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-interrupt:hover:not(:disabled) { background: rgba(239,68,68,0.2); }

/* ── Agent badge in header ─────────────────────── */
.agent-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 20px;
  margin-left: 6px; vertical-align: middle;
  background: var(--accent-dim); color: var(--accent);
  transition: background 0.3s, color 0.3s;
}
.agent-badge[data-agent="sme"]    { background: rgba(6,182,212,0.12); color: #06b6d4; }
.agent-badge[data-agent="gaming"] { background: rgba(245,158,11,0.12); color: #f59e0b; }

/* ══════════════════════════════════════════════════
   Pipeline Diagram Panel (right column)
══════════════════════════════════════════════════ */

.pipeline-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.pipeline-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px;
}
.pipeline-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.pipeline-live {
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--success); background: rgba(34,197,94,0.1);
  padding: 2px 6px; border-radius: 10px;
  animation: live-blink 2s ease-in-out infinite;
}
@keyframes live-blink {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* ── Diagram container ─────────────────────────── */
.pipeline-diagram {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  min-height: 0;
}
.pipeline-diagram::-webkit-scrollbar { width: 3px; }
.pipeline-diagram::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Pipeline node ─────────────────────────────── */
.pipe-node {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background 0.25s, border-color 0.25s;
  position: relative;
}

/* idle */
.pipe-node { background: transparent; }

/* active — node is currently processing */
.pipe-node.active {
  background: rgba(99,102,241,0.07);
  border-color: rgba(99,102,241,0.25);
}
.pipe-node[data-stage="stt"].active    { background: rgba(34,197,94,0.06);  border-color: rgba(34,197,94,0.2); }
.pipe-node[data-stage="intent"].active { background: rgba(245,158,11,0.07); border-color: rgba(245,158,11,0.25); }
.pipe-node[data-stage="agent"].active  { background: rgba(6,182,212,0.06);  border-color: rgba(6,182,212,0.2); }
.pipe-node[data-stage="tts"].active    { background: rgba(168,85,247,0.06); border-color: rgba(168,85,247,0.2); }

/* done — fades to subtle tint */
.pipe-node.done { background: rgba(255,255,255,0.02); border-color: var(--border); }

/* error */
.pipe-node.error { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.2); }

/* Icon circle */
.pipe-node-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s;
}
.pipe-node-icon svg { width: 14px; height: 14px; color: var(--muted); transition: color 0.25s; }

.pipe-node.active .pipe-node-icon { background: var(--accent-dim); border-color: var(--accent); }
.pipe-node.active .pipe-node-icon svg { color: var(--accent); }
.pipe-node[data-stage="stt"].active    .pipe-node-icon { background: rgba(34,197,94,0.1);  border-color: var(--success); }
.pipe-node[data-stage="stt"].active    .pipe-node-icon svg { color: var(--success); }
.pipe-node[data-stage="intent"].active .pipe-node-icon { background: rgba(245,158,11,0.1); border-color: var(--warning); }
.pipe-node[data-stage="intent"].active .pipe-node-icon svg { color: var(--warning); }
.pipe-node[data-stage="agent"].active  .pipe-node-icon { background: rgba(6,182,212,0.1);  border-color: #06b6d4; }
.pipe-node[data-stage="agent"].active  .pipe-node-icon svg { color: #06b6d4; }
.pipe-node[data-stage="tts"].active    .pipe-node-icon { background: rgba(168,85,247,0.1); border-color: #a855f7; }
.pipe-node[data-stage="tts"].active    .pipe-node-icon svg { color: #a855f7; }
.pipe-node.done .pipe-node-icon svg { color: var(--success); }
.pipe-node.error .pipe-node-icon svg { color: var(--error); }

/* Node text */
.pipe-node-body { flex: 1; min-width: 0; }
.pipe-node-label { font-size: 12px; font-weight: 700; color: var(--text); }
.pipe-node-sub   { font-size: 10px; color: var(--muted); margin-top: 1px; }
.pipe-node-detail {
  font-size: 10px; color: var(--muted); margin-top: 5px;
  line-height: 1.5; word-break: break-word;
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease;
}
.pipe-node-detail.has-content { max-height: 80px; }

/* Status dot top-right */
.pipe-node-status {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); flex-shrink: 0; margin-top: 4px;
  transition: background 0.25s;
}
.pipe-node.active .pipe-node-status { background: var(--accent); animation: pulse-dot 0.8s ease-in-out infinite; }
.pipe-node[data-stage="stt"].active    .pipe-node-status { background: var(--success); }
.pipe-node[data-stage="intent"].active .pipe-node-status { background: var(--warning); }
.pipe-node[data-stage="agent"].active  .pipe-node-status { background: #06b6d4; }
.pipe-node[data-stage="tts"].active    .pipe-node-status { background: #a855f7; }
.pipe-node.done .pipe-node-status  { background: var(--success); animation: none; }
.pipe-node.error .pipe-node-status { background: var(--error); animation: none; }

@keyframes pulse-dot {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: 0.6; }
}

/* ── Connector line between nodes ──────────────── */
.pipe-connector {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 0 0 25px;        /* aligns with centre of icon */
  transition: background 0.3s;
  position: relative;
}
.pipe-connector.active {
  background: var(--accent);
}
.pipe-connector.active::after {
  content: '';
  position: absolute;
  top: 0; left: -2px;
  width: 5px; height: 100%;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
  animation: flow-down 0.6s linear infinite;
}
@keyframes flow-down {
  0%   { transform: translateY(-100%); opacity: 0; }
  50%  { opacity: 1; }
  100% { transform: translateY(100%); opacity: 0; }
}

/* ── Routing decision card ─────────────────────── */
.routing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  flex-shrink: 0;
}
.routing-card-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 10px;
}
.routing-empty { font-size: 11px; color: var(--muted); }
.routing-rows { display: flex; flex-direction: column; gap: 6px; }
.routing-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.routing-row-key {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); flex-shrink: 0;
}
.routing-row-val {
  font-size: 11px; font-weight: 600; color: var(--text);
  text-align: right; min-width: 0; word-break: break-word;
}
.routing-row-val.tag {
  font-size: 10px; padding: 1px 7px; border-radius: 10px;
  background: var(--surface2); color: var(--text);
}
.routing-row-val.tag[data-agent="chitchat"] { background: rgba(99,102,241,0.15); color: #818cf8; }
.routing-row-val.tag[data-agent="sme"]      { background: rgba(6,182,212,0.15);  color: #22d3ee; }
.routing-row-val.tag[data-agent="gaming"]   { background: rgba(245,158,11,0.15); color: #fbbf24; }
.routing-row-val.confidence { color: var(--success); }
.routing-row-val.confidence.mid { color: var(--warning); }
.routing-row-val.confidence.low { color: var(--error); }
.routing-switched {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700;
  background: rgba(99,102,241,0.12); color: var(--accent);
}
.routing-stayed {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 700;
  background: rgba(100,116,139,0.12); color: var(--muted);
}

/* ── SME Section Cards ─────────────────────────── */
.msg.sme-card {
  background: linear-gradient(135deg, rgba(6,182,212,0.06) 0%, rgba(6,182,212,0.02) 100%);
  border: 1px solid rgba(6,182,212,0.22);
  border-radius: var(--radius-msg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: stretch;
}

.sme-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sme-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(6,182,212,0.18); color: #22d3ee;
  border-radius: 6px; padding: 2px 7px;
  flex-shrink: 0; margin-top: 2px;
}

.sme-card-title {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;
}

.sme-section-name {
  font-size: 14px; font-weight: 700; color: #e0f7fa;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sme-chapter-name {
  font-size: 11px; color: var(--muted);
}

.sme-similarity {
  font-size: 10px; font-weight: 700; color: #22d3ee;
  flex-shrink: 0; margin-top: 2px;
}

.sme-summary {
  font-size: 12px; line-height: 1.6; color: #b0c4d8;
  border-left: 2px solid rgba(6,182,212,0.3);
  padding-left: 10px;
}

/* ── SME Seekable Player ────────────────────────── */
.sme-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6,182,212,0.06);
  border: 1px solid rgba(6,182,212,0.18);
  border-radius: 10px;
  padding: 7px 10px;
}

.sme-pp-btn {
  background: rgba(6,182,212,0.18);
  border: 1px solid rgba(6,182,212,0.35);
  color: #22d3ee;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.sme-pp-btn:hover { background: rgba(6,182,212,0.3); }

.sme-time-cur,
.sme-time-dur {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
}
.sme-time-cur { text-align: right; }

.sme-scrubber {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(6,182,212,0.2);
  outline: none;
  cursor: pointer;
}
.sme-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #22d3ee;
  cursor: pointer;
  transition: transform 0.1s;
}
.sme-scrubber::-webkit-slider-thumb:hover { transform: scale(1.3); }
.sme-scrubber::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #22d3ee;
  border: none;
  cursor: pointer;
}

.sme-questions {
  display: flex; flex-direction: column; gap: 5px;
}

.sme-questions-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
  margin-bottom: 2px;
}

.sme-question-btn {
  background: rgba(6,182,212,0.07);
  border: 1px solid rgba(6,182,212,0.15);
  color: #7dd3fc;
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.sme-question-btn:hover { background: rgba(6,182,212,0.15); }
.sme-question-btn.active-question {
  background: rgba(6,182,212,0.25);
  border-color: rgba(6,182,212,0.5);
  color: #e0f7fa;
}
.sme-q-num {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #22d3ee;
  padding-top: 1px;
}
.sme-q-text {
  font-size: 11px;
  line-height: 1.45;
  color: #cce9ff;
}

/* Summary audio label + player wrapper */
.sme-section-summary-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sme-audio-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.sme-player-active {
  border-color: rgba(6,182,212,0.5) !important;
  background: rgba(6,182,212,0.08) !important;
}

/* ── SME Question Card (in conversation) ───────── */
.msg.sme-question-card {
  background: rgba(6,182,212,0.05);
  border: 1px solid rgba(6,182,212,0.2);
  border-left: 3px solid #22d3ee;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-self: flex-start;
  max-width: 85%;
}
.sme-q-label {
  font-size: 9px; font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: #22d3ee;
}
.sme-q-text {
  font-size: 13px; color: var(--text); line-height: 1.5;
}

/* ── Chapter Card ───────────────────────────────── */
.msg.chapter-card {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(139,92,246,0.08) 0%, rgba(139,92,246,0.03) 100%);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: var(--radius-msg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 82%;
}

.chapter-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chapter-badge {
  font-size: 9px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(139,92,246,0.2); color: #a78bfa;
  border-radius: 6px; padding: 2px 7px;
  flex-shrink: 0; margin-top: 2px;
}

.chapter-card-title {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;
}

.chapter-name {
  font-size: 14px; font-weight: 700; color: #ede9fe;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chapter-meta {
  font-size: 11px; color: var(--muted);
}

.chapter-sections-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.chapter-section-row.chapter-section-active {
  background: rgba(139,92,246,0.15);
  border-color: rgba(139,92,246,0.35);
}

.chapter-section-num {
  font-size: 9px; font-weight: 800;
  color: #a78bfa;
  background: rgba(139,92,246,0.15);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
}

.chapter-section-name {
  font-size: 12px; color: #d4c8f9;
  line-height: 1.4;
}

.chapter-section-row.chapter-section-active .chapter-section-name {
  color: #ede9fe;
  font-weight: 600;
}

/* ── Responsive: mobile ────────────────────────── */
@media (max-width: 780px) {
  body { align-items: stretch; }

  .layout {
    flex-direction: column;
    padding: 0;
    gap: 0;
    max-height: none;
    height: 100dvh;
  }

  /* Hide pipeline panel on mobile — it's a dev tool */
  .pipeline-panel { display: none; }

  /* App shell fills viewport */
  .app {
    flex: 1;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    min-height: 0;
  }

  /* Header */
  .app-header { padding: 12px 14px; }
  .header-text h1 { font-size: 14px; }
  .avatar { width: 36px; height: 36px; }

  /* VAD bar */
  .vad-bar { padding: 7px 14px; }

  /* Conversation */
  .conversation { padding: 14px 12px 8px; gap: 12px; }
  .msg { max-width: 88%; }
  .msg-bubble { font-size: 13px; padding: 10px 13px; }

  /* SME + chapter cards full width on mobile */
  .msg.sme-card,
  .msg.chapter-card { max-width: 96%; }

  /* Footer */
  .app-footer { padding: 8px 12px 10px; gap: 7px; }

  /* Bigger tap targets */
  .btn-mic    { padding: 13px 14px; font-size: 14px; }
  .btn-connect { padding: 13px 18px; font-size: 14px; }
  .btn-interrupt { padding: 12px 14px; }

  .text-input { font-size: 14px; padding: 10px 12px; }
  .btn-send   { padding: 10px 14px; }
  .btn-send svg { width: 17px; height: 17px; }

  /* Prevent iOS zoom on input focus */
  input, textarea, select { font-size: 16px !important; }
  .text-input { font-size: 16px !important; }
}
