/* ════════════════════════════════════════════════════════════════
   24-Waveform — וייב קוד ניוז · גל קול
   Audio waveform timeline on canvas. Each VIBE_CONTENT item is a
   segment. Click segment → Web Speech API TTS plays summary.
   Palette: deep midnight + phosphor waveform green + accent hues.
   RTL Hebrew. All content from window.VIBE_CONTENT.
   ════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  /* Backgrounds */
  --bg-0: #060912;          /* deepest */
  --bg-1: #0a0e1a;          /* main midnight */
  --bg-2: #111729;          /* surface */
  --bg-3: #1a2238;          /* elevated surface */

  /* Waveform palette */
  --wf-green:    #00ff88;          /* primary waveform green */
  --wf-green-d:  #00b25e;          /* dimmer green */
  --wf-green-x:  rgba(0, 255, 136, 0.18);
  --wf-green-2:  rgba(0, 255, 136, 0.10);
  --wf-green-3:  rgba(0, 255, 136, 0.04);

  /* Segment highlights */
  --breaking:    #ff5b6b;          /* red for breaking */
  --breaking-2:  rgba(255, 91, 107, 0.65);
  --high:        #ffb000;          /* amber for high */
  --high-2:      rgba(255, 176, 0, 0.60);
  --featured:    #a78bfa;          /* soft purple for featured */
  --featured-2:  rgba(167, 139, 250, 0.60);
  --chat-msg:    #66d9ef;          /* cyan for chat segments */
  --chat-msg-2:  rgba(102, 217, 239, 0.55);

  /* Chat skins (used by the chat component) */
  --wa-bg:      #efe7df;
  --wa-green:   #25D366;
  --wa-green-d: #128C7E;
  --tg-bg:      #e7eef5;
  --tg-blue:    #2AABEE;
  --tg-blue-d:  #229ED9;
  --ms-bg:      #f0eaf5;

  /* Text */
  --ink:        #e6ecf2;
  --ink-soft:   #b6c2d4;
  --ink-dim:    #7d8aa2;
  --ink-mute:   #4a556b;

  /* Lines */
  --line:       rgba(0, 255, 136, 0.18);
  --line-soft:  rgba(255, 255, 255, 0.06);

  /* Fonts */
  --font-ui:    'Heebo', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Sizes */
  --waveform-h:        220px;
  --waveform-h-tall:   360px;
  --header-h:          64px;
  --controlbar-h:      72px;
  --chat-h:            360px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  direction: rtl;
}
html {
  background: var(--bg-0);
  color-scheme: dark;
}
body {
  background:
    radial-gradient(ellipse at 100% 0%, rgba(0, 255, 136, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 0% 100%, rgba(167, 139, 250, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 40%, var(--bg-0) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

/* ─── Page Header (subtle brand strip) ─── */
.page-header {
  flex-shrink: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 9, 18, 0.85);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--wf-green) 0%, var(--featured) 100%);
  color: var(--bg-0);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.32);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 4px;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.0) 0 1px,
      rgba(0, 0, 0, 0.5) 1px 2px,
      rgba(0, 0, 0, 0.0) 2px 3px);
  border-radius: 4px;
  opacity: 0.35;
}
.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--wf-green-d);
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}
.page-title {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.page-title-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.10em;
  color: var(--ink-dim);
  font-weight: 500;
  text-transform: uppercase;
}
.page-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.page-nav a {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-weight: 500;
}
.page-nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-soft);
}
.page-nav a.active {
  color: var(--wf-green);
  border-color: var(--line);
  background: rgba(0, 255, 136, 0.06);
}

/* ─── Main Stage ─── */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 8px 20px;
  gap: 14px;
  overflow-y: auto;
}

/* ─── Waveform Canvas Block ─── */
.waveform-block {
  background:
    linear-gradient(180deg, rgba(0, 255, 136, 0.02) 0%, rgba(0, 0, 0, 0) 100%),
    var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(0, 255, 136, 0.04) inset,
    0 12px 36px rgba(0, 0, 0, 0.30);
}

.waveform-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--wf-green-d);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.18);
}
.waveform-block-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.waveform-block-title .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wf-green);
  box-shadow: 0 0 8px var(--wf-green);
  animation: live-pulse 1.6s infinite ease-in-out;
}
@keyframes live-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.waveform-block-meta {
  color: var(--ink-dim);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  display: flex;
  gap: 14px;
}
.waveform-block-meta b {
  color: var(--ink);
  font-weight: 700;
  font-family: var(--font-mono);
}

.waveform-canvas-wrap {
  position: relative;
  height: var(--waveform-h);
  width: 100%;
  background:
    repeating-linear-gradient(90deg,
      rgba(0, 255, 136, 0.04) 0 1px,
      transparent 1px 80px),
    linear-gradient(180deg, rgba(0, 255, 136, 0.025), rgba(0, 0, 0, 0));
}
.waveform-canvas-wrap.tall { height: var(--waveform-h-tall); }
.waveform-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Tooltip / current-speaker overlay */
.waveform-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(6, 9, 18, 0.94);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 280px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: normal;
}
.waveform-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.waveform-tooltip .tt-title {
  font-weight: 700;
  color: var(--wf-green);
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.waveform-tooltip .tt-cat {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--ink-soft);
}
.waveform-tooltip .tt-text {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}
.waveform-tooltip .tt-time {
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  margin-top: 4px;
  letter-spacing: 0.06em;
}

/* "Now speaking" caption — always visible while TTS is active */
.now-speaking {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 10px 18px;
  background:
    linear-gradient(0deg, rgba(0, 255, 136, 0.18) 0%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.now-speaking.visible {
  opacity: 1;
}
.now-speaking .ns-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wf-green);
  box-shadow: 0 0 10px var(--wf-green);
  animation: live-pulse 1.0s infinite ease-in-out;
  flex-shrink: 0;
}
.now-speaking .ns-label {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--wf-green);
  font-weight: 700;
  flex-shrink: 0;
}
.now-speaking .ns-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.now-speaking .ns-time {
  color: var(--ink-dim);
  font-size: 10.5px;
  font-weight: 500;
  flex-shrink: 0;
}

/* ─── Playback Control Bar ─── */
.controlbar {
  flex-shrink: 0;
  height: var(--controlbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(6, 9, 18, 0.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  position: sticky;
  bottom: 0;
}
.ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 18px;
  font-family: var(--font-ui);
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: relative;
}
.ctrl-btn:hover {
  background: rgba(0, 255, 136, 0.10);
  color: var(--wf-green);
}
.ctrl-btn.play-pause {
  width: 56px;
  height: 56px;
  background: var(--wf-green);
  color: var(--bg-0);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.40);
}
.ctrl-btn.play-pause:hover {
  background: var(--wf-green);
  color: var(--bg-0);
  transform: scale(1.05);
}
.ctrl-btn.muted {
  color: var(--breaking);
  background: rgba(255, 91, 107, 0.10);
}
.ctrl-btn .sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.ctrl-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  min-width: 96px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.ctrl-time b {
  color: var(--wf-green);
  font-weight: 600;
  font-family: var(--font-mono);
}
.ctrl-scrubber {
  flex: 1;
  min-width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}
.ctrl-scrubber-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--wf-green) 0%, var(--featured) 100%);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}
.ctrl-scrubber-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--wf-green);
  box-shadow: 0 0 12px var(--wf-green);
  pointer-events: none;
  /* width set inline by JS */
}
.ctrl-mode {
  display: flex;
  gap: 4px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.ctrl-mode-btn {
  padding: 6px 11px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  background: transparent;
  color: var(--ink-soft);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.12s;
}
.ctrl-mode-btn:hover { color: var(--ink); }
.ctrl-mode-btn.active {
  background: var(--wf-green);
  color: var(--bg-0);
}

/* ─── Segment List Panel (mobile fallback) ─── */
.segments-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
}
.segment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: right;
  font-family: var(--font-ui);
}
.segment-row:hover {
  background: var(--bg-3);
  border-color: var(--line);
}
.segment-row.active {
  background: rgba(0, 255, 136, 0.10);
  border-color: var(--wf-green);
  box-shadow: 0 0 0 1px var(--wf-green) inset;
}
.segment-row .sr-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  font-weight: 700;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.segment-row .sr-cat {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--ink-soft);
  font-weight: 700;
  flex-shrink: 0;
}
.segment-row .sr-cat.breaking { background: var(--breaking); color: white; }
.segment-row .sr-cat.high { background: var(--high); color: var(--bg-0); }
.segment-row .sr-cat.featured { background: var(--featured); color: var(--bg-0); }
.segment-row .sr-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.segment-row .sr-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.segment-row .sr-play {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wf-green-x);
  color: var(--wf-green);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* ─── Two-column layout on wide screens ─── */
.waveform-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
@media (min-width: 980px) {
  .waveform-grid.with-side {
    grid-template-columns: 1fr 320px;
  }
}

/* ─── Side panel — quick legend / chapter list ─── */
.side-panel {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--wf-green-d);
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.side-panel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-inline-end: 4px;
}
.side-panel-list::-webkit-scrollbar { width: 6px; }
.side-panel-list::-webkit-scrollbar-track { background: transparent; }
.side-panel-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid transparent;
}
.legend-item:hover {
  background: var(--bg-3);
  color: var(--ink);
}
.legend-item.active {
  background: rgba(0, 255, 136, 0.10);
  color: var(--wf-green);
  border-color: var(--line);
}
.legend-item .li-bar {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  background: var(--wf-green);
  flex-shrink: 0;
}
.legend-item .li-bar.breaking { background: var(--breaking); }
.legend-item .li-bar.high { background: var(--high); }
.legend-item .li-bar.featured { background: var(--featured); }
.legend-item .li-bar.chat { background: var(--chat-msg); }
.legend-item .li-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  min-width: 22px;
  font-weight: 700;
}
.legend-item .li-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.legend-item .li-cat {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  flex-shrink: 0;
}

/* ─── Chat component (waveform-flavored) ─── */
.chat-block {
  flex-shrink: 0;
  height: var(--chat-h);
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
  font-family: var(--font-ui);
  margin-bottom: 12px;
}
.chat-block .chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  flex-shrink: 0;
}
.chat-block .chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wf-green) 0%, var(--featured) 100%);
  color: var(--bg-0);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-block .chat-head-info { flex: 1; min-width: 0; }
.chat-block .chat-head-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}
.chat-block .chat-head-status {
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-block .chat-head-status .dot {
  width: 6px; height: 6px;
  background: var(--wf-green);
  border-radius: 50%;
  display: inline-block;
  animation: typing-pulse 1.4s infinite ease-in-out;
  box-shadow: 0 0 6px var(--wf-green);
}
@keyframes typing-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* Chat waveform row — chat messages appear as waveform ticks (small waveform) */
.chat-waveform {
  position: relative;
  flex: 1;
  min-height: 80px;
  background: var(--bg-1);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
  cursor: pointer;
}
.chat-waveform canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.chat-waveform-legend {
  position: absolute;
  bottom: 6px;
  inset-inline-start: 12px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  pointer-events: none;
}
.chat-waveform-active {
  position: absolute;
  top: 8px;
  inset-inline-end: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--wf-green);
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-waveform-active.visible { opacity: 1; }
.chat-waveform-active .pulse-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--wf-green);
  box-shadow: 0 0 6px var(--wf-green);
  margin-inline-end: 6px;
  vertical-align: 1px;
  animation: live-pulse 1.0s infinite ease-in-out;
}

.chat-messages {
  flex: 0 0 160px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background:
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.bubble {
  max-width: 86%;
  align-self: flex-start;
  padding: 7px 10px 5px;
  border-radius: 10px 10px 10px 2px;
  background: var(--bg-3);
  border: 1px solid var(--line-soft);
  position: relative;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink);
}
.bubble.urgent {
  background: rgba(255, 91, 107, 0.10);
  border-color: var(--breaking-2);
}
.bubble-text { color: var(--ink); }
.bubble-time {
  display: block;
  text-align: left;
  font-size: 9.5px;
  color: var(--ink-dim);
  margin-top: 3px;
  letter-spacing: 0.02em;
  font-family: var(--font-mono);
}
.bubble-top {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
  align-items: center;
  flex-wrap: wrap;
}
.bubble-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--wf-green);
  color: var(--bg-0);
}
.urgent-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--breaking);
  color: white;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: var(--bg-3);
  border-radius: 10px 10px 10px 2px;
  border: 1px solid var(--line-soft);
}
.typing-dot {
  width: 6px; height: 6px;
  background: var(--wf-green);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
  box-shadow: 0 0 4px var(--wf-green-x);
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-3);
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.chat-input-field {
  flex: 1;
  background: var(--bg-1);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--ink-dim);
  border: 1px solid var(--line-soft);
}
.chat-send {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--wf-green);
  color: var(--bg-0);
  display: grid;
  place-items: center;
  cursor: pointer;
  border: 0;
  font-size: 13px;
  font-family: var(--font-ui);
}

.skin-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-1);
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.skin-label {
  font-size: 9.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-inline-start: auto;
  font-weight: 600;
}
.skin-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-3);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 11.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s;
  display: grid;
  place-items: center;
}
.skin-btn:hover { border-color: var(--line); color: var(--ink); }
.skin-btn.active {
  background: var(--wf-green);
  color: var(--bg-0);
  border-color: var(--wf-green);
  box-shadow: 0 0 8px var(--wf-green-x);
}

/* ─── Chat skins ─── */
/* The chat keeps the dark 24-waveform aesthetic but each skin changes
   the accent color used by the chat-waveform and the chat-header.
   Layout is NOT changed by the skin. */
.chat-block { --chat-accent: var(--wa-green); --chat-accent-d: var(--wa-green-d); --chat-accent-name: 'WhatsApp'; }
.chat-block.skin-wa { --chat-accent: var(--wa-green); --chat-accent-d: var(--wa-green-d); --chat-accent-name: 'WhatsApp'; }
.chat-block.skin-tg { --chat-accent: var(--tg-blue); --chat-accent-d: var(--tg-blue-d); --chat-accent-name: 'Telegram'; }
.chat-block.skin-ms { --chat-accent: #A033FF; --chat-accent-d: #0099FF; --chat-accent-name: 'Messenger'; }

.chat-block .chat-header { border-bottom-color: var(--chat-accent-d); }
.chat-block .chat-avatar { background: linear-gradient(135deg, var(--chat-accent-d), var(--chat-accent)); color: var(--bg-0); }
.chat-block.skin-ms .chat-avatar { background: linear-gradient(135deg, #0099FF, #A033FF); }

.chat-block .chat-waveform-legend { color: var(--chat-accent-d); }
.chat-block .chat-waveform-active { color: var(--chat-accent); }
.chat-block .chat-waveform-active .pulse-dot { background: var(--chat-accent); box-shadow: 0 0 6px var(--chat-accent); }

.chat-block .bubble-tag { background: var(--chat-accent); color: var(--bg-0); }
.chat-block.skin-ms .bubble-tag { background: linear-gradient(135deg, #0099FF, #A033FF); color: white; }

.chat-block .skin-btn.active { background: var(--chat-accent); color: var(--bg-0); border-color: var(--chat-accent); box-shadow: 0 0 8px var(--chat-accent); }
.chat-block.skin-ms .skin-btn.active { background: linear-gradient(135deg, #0099FF, #A033FF); border-color: #A033FF; }

.chat-block .chat-send { background: var(--chat-accent); color: var(--bg-0); }
.chat-block.skin-ms .chat-send { background: linear-gradient(135deg, #0099FF, #A033FF); color: white; }

.chat-block .chat-head-status .dot { background: var(--chat-accent); box-shadow: 0 0 6px var(--chat-accent); }

/* ─── Chapter/legend mode label ─── */
.tag-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-3);
  color: var(--ink-soft);
  vertical-align: middle;
}
.tag-pill.breaking { background: var(--breaking); color: white; }
.tag-pill.high { background: var(--high); color: var(--bg-0); }
.tag-pill.featured { background: var(--featured); color: var(--bg-0); }
.tag-pill.chat { background: var(--chat-msg); color: var(--bg-0); }

/* ─── Mobile ─── */
@media (max-width: 760px) {
  .page-header { padding: 0 12px; }
  .page-title { display: none; }
  .page-nav a { padding: 5px 8px; font-size: 11.5px; }
  .stage { padding: 12px 12px 8px 12px; gap: 10px; }
  .waveform-canvas-wrap { height: 160px; }
  .waveform-canvas-wrap.tall { height: 220px; }
  .controlbar { padding: 0 12px; gap: 10px; height: 64px; }
  .ctrl-btn { width: 42px; height: 42px; font-size: 16px; }
  .ctrl-btn.play-pause { width: 48px; height: 48px; }
  .ctrl-time { font-size: 11px; min-width: 78px; }
  .ctrl-mode { display: none; }
  .chat-block { height: 320px; }
  .waveform-tooltip { max-width: 200px; font-size: 12px; }
  .now-speaking { padding: 8px 12px; font-size: 11px; }
  .now-speaking .ns-title { font-size: 12px; }
}

@media (max-width: 480px) {
  .waveform-block-header { padding: 8px 12px; font-size: 10px; }
  .waveform-block-meta { display: none; }
  .controlbar { gap: 6px; }
  .ctrl-btn { width: 38px; height: 38px; }
  .ctrl-btn.play-pause { width: 44px; height: 44px; }
  .ctrl-time { min-width: 60px; }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .waveform-block-title .pulse-dot,
  .now-speaking .ns-dot,
  .chat-block .chat-head-status .dot,
  .chat-waveform-active .pulse-dot,
  .typing-dot,
  .skin-btn,
  .ctrl-btn,
  .ctrl-scrubber-fill {
    animation: none !important;
    transition: none !important;
  }
}
