/* ═══════════════════════════════════════════════════════
   DADGA — Kurdish Voice Transcription Platform
   Stylesheet v1.0
   ═══════════════════════════════════════════════════════ */

:root {
  /* Deep navy judicial base */
  --bg-deep: #0a1024;
  --bg-mid: #0e1836;
  --bg-glass: rgba(255, 255, 255, 0.045);
  --bg-glass-hover: rgba(255, 255, 255, 0.075);
  --border-glass: rgba(201, 165, 78, 0.16);
  --border-glass-hover: rgba(201, 165, 78, 0.34);

  /* Gold = primary accent (kept under legacy --purple names so the whole app cascades) */
  --purple: #c9a54e;
  --purple-light: #e6c976;
  --purple-glow: rgba(201, 165, 78, 0.38);
  --gold: #c9a54e;
  --gold-light: #e6c976;
  --gold-deep: #b78a2e;

  /* Royal navy = secondary accent */
  --blue: #24417f;
  --blue-light: #3f68c0;
  --navy: #16233f;
  --navy-deep: #0e1836;
  --indigo: #2f4a9e;
  --cyan: #c9a54e;

  --accent-grad: linear-gradient(135deg, #d9b551 0%, #b78a2e 100%);
  --accent-grad-soft: linear-gradient(135deg, rgba(201,165,78,0.18) 0%, rgba(36,65,127,0.20) 100%);
  --navy-grad: linear-gradient(135deg, #1c2f57 0%, #12203f 100%);

  --text-primary: #f4f1e9;
  --text-secondary: #b3bdd1;
  --text-muted: #6b7794;

  --success: #2f9e6f;
  --warning: #d99a1c;
  --danger: #d64550;
  --info: #c9a54e;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-glass: 0 10px 34px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(201,165,78,0.10);
  --shadow-glow: 0 0 40px var(--purple-glow);

  --font-primary: 'Noto Sans Arabic', 'Inter', sans-serif;
  --font-serif: 'Noto Naskh Arabic', 'Noto Sans Arabic', serif;

  --navbar-h: 72px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme overrides — formal cream/white + navy + gold */
body.light-mode {
  --bg-deep: #f5f2ea;
  --bg-mid: #ece6d8;
  --bg-glass: rgba(255, 255, 255, 0.82);
  --bg-glass-hover: rgba(255, 255, 255, 0.94);
  --border-glass: rgba(36, 65, 127, 0.16);
  --border-glass-hover: rgba(201, 165, 78, 0.45);
  --text-primary: #14213d;
  --text-secondary: #3d4a63;
  --text-muted: #8a93a6;
  --shadow-glass: 0 10px 30px rgba(20, 33, 61, 0.10), inset 0 1px 0 rgba(255,255,255,0.9);
}

/* ═══════════ RESET & BASE ═══════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-primary);
  font-size: 15px;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  direction: rtl;
}

/* ═══════════ ANIMATED BACKGROUND ═══════════ */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: drift 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(201,165,78,0.18) 0%, transparent 70%);
  top: -200px; right: -100px;
  animation-duration: 18s;
}

.orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(36,65,127,0.15) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  animation-duration: 24s;
  animation-delay: -8s;
}

.orb-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(201,165,78,0.1) 0%, transparent 70%);
  top: 40%; left: 40%;
  animation-duration: 30s;
  animation-delay: -15s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.05); }
  66% { transform: translate(-30px, 20px) scale(0.97); }
}

/* ═══════════ NAVBAR ═══════════ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(10, 16, 36, 0.78);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  box-shadow: 0 2px 0 rgba(201,165,78,0.12);
  gap: 20px;
}

body.light-mode .navbar {
  background: rgba(245, 242, 234, 0.85);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon svg { width: 40px; height: 40px; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.navbar-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  padding: 5px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.tab-btn.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 2px 20px var(--purple-glow);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.loading { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

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

.btn-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-glass-hover); background: var(--bg-glass-hover); }

.btn-logout:hover {
  color: var(--danger) !important;
  border-color: rgba(239,68,68,0.4) !important;
  background: rgba(239,68,68,0.08) !important;
}

/* ═══════════ GLASS CARD ═══════════ */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow: var(--shadow-glass);
}

/* ═══════════ MAIN CONTENT ═══════════ */
.main-content {
  margin-top: var(--navbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--navbar-h));
}

.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ RECORDER LAYOUT ═══════════
   Named grid areas keep the three panels explicitly ordered so the
   layout can be reshuffled per breakpoint without touching markup —
   this is what lets it adapt to any standard court-room display
   (ultra-wide walls, standard desktop monitors, laptops, tablets). */
.recorder-layout {
  --recorder-h: calc(100vh - var(--navbar-h) - 56px);
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(440px, 1fr) minmax(300px, 380px);
  grid-template-areas: "control center transcript";
  gap: clamp(14px, 1.4vw, 22px);
  height: var(--recorder-h);
  max-width: 2000px;
  margin: 0 auto;
}
body.has-case-strip .recorder-layout { --recorder-h: calc(100vh - var(--navbar-h) - 34px - 56px); }

/* ══ CONTROL PANEL ══ */
.control-panel {
  grid-area: control;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.panel-title svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--gold-light); }

/* Grouped section inside the control panel — mirrors the fieldset
   language used on the case-info tab for a consistent, organized feel */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 18px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}
/* Pin the stats block to the bottom of the panel without stretching
   its own border/background — avoids an empty box with dead space. */
.panel-section-fill { margin-top: auto; }
body.light-mode .panel-section { background: rgba(20,33,61,0.02); }

.section-heading {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--border-glass);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 8px var(--purple-glow);
  cursor: pointer;
  transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple-light);
  min-width: 36px;
  text-align: center;
}

.mode-btns {
  display: flex;
  gap: 6px;
}

.mode-btn {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.mode-btn:hover { color: var(--text-primary); border-color: var(--border-glass-hover); }
.mode-btn.active {
  background: var(--accent-grad-soft);
  border-color: var(--purple);
  color: var(--purple-light);
}

.select-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
}

.select-input:focus { border-color: var(--purple); }
.select-input option { background: var(--bg-mid); }

.divider {
  height: 1px;
  background: var(--border-glass);
  border-radius: var(--radius-full);
}

/* ═══════════ SPEAKER ROLE SELECTOR ═══════════ */
.speaker-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.speaker-btn {
  padding: 10px 8px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border-glass);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary, #cbd5e1);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}
.speaker-btn:hover {
  border-color: var(--purple);
  color: var(--purple-light);
}
.speaker-btn.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--purple-glow);
}
.speaker-current {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary, #94a3b8);
  text-align: center;
}
.speaker-current strong { color: var(--purple-light); }

/* Speaker badge on each transcript segment */
.segment-speaker {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-grad);
}
.segment-speaker.speaker-0 { background: linear-gradient(135deg,#d9b551,#b78a2e); } /* دادوەر */
.segment-speaker.speaker-1 { background: linear-gradient(135deg,#2f6f9e,#24417f); } /* سکاڵاکار */
.segment-speaker.speaker-2 { background: linear-gradient(135deg,#c1483f,#8f2d27); } /* تۆمەتبار */
.segment-speaker.speaker-3 { background: linear-gradient(135deg,#3d6cc0,#2f4a9e); } /* نوێنەر */
.segment-speaker.speaker-4 { background: linear-gradient(135deg,#2f9e6f,#1f7a53); } /* شاهێد */
.segment-speaker.speaker--1 { background: var(--navy-grad); }

/* Justified paragraphs in the editor */
#quillEditor .ql-editor { text-align: justify; }
#quillEditor .ql-editor p { text-align: justify; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--accent-grad-soft);
  border: 1px solid rgba(201,165,78,0.2);
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ══ RECORDER CENTER (recording deck) ══
   Wrapped as its own glass-card with a header, matching the two side
   panels — the previous version floated unbordered between two cards,
   which read as inconsistent/unfinished. */
.recorder-center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  padding: 22px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.recorder-center-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-glass);
  flex-wrap: wrap;
}

.rec-live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.rec-live-sep { color: var(--text-muted); }
.rec-live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.rec-live-chip.is-recording .rec-live-dot {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
  animation: pulse-dot 1s ease-in-out infinite;
}

/* Centered with auto margins rather than flex:1 + justify-content:center —
   auto margins keep the deck's own height purely content-based (never
   compressed to a flex-basis:0 box), so it degrades to plain top-aligned
   overflow when the panel is short instead of overlapping the toolbar. */
.recorder-deck {
  flex-shrink: 0;
  margin-top: auto;
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.4vh, 28px);
  padding: 12px 0;
  width: 100%;
}

/* RECORD BUTTON — a single restrained pulse ring rather than three
   layered glowing orbits; reads as professional recording equipment
   rather than a consumer voice-assistant animation. */
.mic-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(140px, 16vw, 180px);
  height: clamp(140px, 16vw, 180px);
  flex-shrink: 0;
}

.mic-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: 0;
  pointer-events: none;
}

.mic-container.active .mic-ring {
  animation: ring-active 1.8s ease-out infinite;
}

@keyframes ring-active {
  0% { opacity: 0.55; transform: scale(0.94); }
  100% { opacity: 0; transform: scale(1.18); }
}

.mic-btn {
  width: 68%;
  height: 68%;
  border-radius: 50%;
  border: none;
  background: var(--accent-grad);
  color: #201607;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  box-shadow: 0 6px 24px rgba(201,165,78,0.35), var(--shadow-glass);
  transition: transform var(--transition), box-shadow var(--transition);
}

.mic-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 30px rgba(201,165,78,0.5), var(--shadow-glass);
}

.mic-btn:active { transform: scale(0.97); }

.mic-btn.recording {
  background: linear-gradient(135deg, #d64550 0%, #a5303a 100%);
  color: #fff;
  box-shadow: 0 6px 26px rgba(214,69,80,0.45), var(--shadow-glass);
  animation: mic-throb 1.6s ease-in-out infinite;
}

@keyframes mic-throb {
  0%, 100% { box-shadow: 0 6px 26px rgba(214,69,80,0.4), var(--shadow-glass); }
  50% { box-shadow: 0 6px 34px rgba(214,69,80,0.6), var(--shadow-glass); }
}

.mic-icon, .stop-icon {
  width: clamp(32px, 4vw, 44px);
  height: clamp(32px, 4vw, 44px);
  transition: opacity var(--transition);
}

.hidden { display: none !important; }

/* STATUS LABEL */
.recorder-status-label {
  text-align: center;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text-secondary);
}

.status-pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}

.status-indicator.recording .status-pulse {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse-dot 1s ease-in-out infinite;
}

.status-indicator.processing .status-pulse {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse-dot 0.6s ease-in-out infinite;
}

.status-indicator.ready .status-pulse {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* WAVEFORM VISUALIZER */
.visualizer-block {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visualizer-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.visualizer-wrapper {
  width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.12));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: clamp(84px, 13vh, 120px);
}

#waveCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ═══════════ PRO AUDIO METERING ═══════════ */

/* Live quality banner — the contextual alert line */
.quality-banner {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.quality-banner .quality-icon { width: 18px; height: 18px; flex-shrink: 0; }
.quality-banner.q-idle,
.quality-banner.q-listening {
  background: var(--bg-glass);
  border-color: var(--border-glass);
  color: var(--text-secondary);
}
.quality-banner.q-good {
  background: rgba(47,158,111,0.14);
  border-color: rgba(47,158,111,0.4);
  color: #4cc38a;
}
.quality-banner.q-low {
  background: rgba(217,154,28,0.14);
  border-color: rgba(217,154,28,0.4);
  color: #e0a83a;
}
.quality-banner.q-noisy,
.quality-banner.q-loud {
  background: rgba(214,69,80,0.16);
  border-color: rgba(214,69,80,0.5);
  color: #f07782;
  animation: alarm-pulse 1s ease-in-out infinite;
}
@keyframes alarm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214,69,80,0.0); }
  50% { box-shadow: 0 0 0 4px rgba(214,69,80,0.18); }
}

/* Mic reactive energy glow (driven by --energy 0..1 from JS) */
.mic-container { --energy: 0; }
.mic-glow {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,165,78,calc(0.22 + var(--energy) * 0.5)) 0%, rgba(201,165,78,0) 68%);
  transform: scale(calc(1 + var(--energy) * 0.4));
  transition: transform 0.06s linear;
  pointer-events: none;
  z-index: 0;
}
.mic-container.mic-alarm .mic-glow {
  background: radial-gradient(circle, rgba(214,69,80,calc(0.25 + var(--energy) * 0.5)) 0%, rgba(214,69,80,0) 68%);
}
.mic-container.mic-alarm .mic-ring { border-color: var(--danger); }

/* dB level meter */
.meter-block {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meter-caption-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.meter-caption {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meter-db {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}
.meter-track {
  position: relative;
  height: 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  overflow: hidden;
}
/* red "hot" zone at the top end of the scale (right side, LTR) */
.meter-zone-hot {
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 12%;
  background: rgba(214,69,80,0.22);
}
.meter-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  background: linear-gradient(90deg, #3f68c0 0%, #2f9e6f 45%, #c9a54e 75%, #d6a83a 90%, #d64550 100%);
  border-radius: var(--radius-full);
  transition: width 0.06s linear;
}
.meter-peak {
  position: absolute;
  top: -1px; bottom: -1px;
  left: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
  transition: left 0.08s linear;
}
.meter-gate {
  position: absolute;
  top: -3px; bottom: -3px;
  left: 0;
  width: 2px;
  background: var(--gold-light);
  border-radius: var(--radius-full);
}
.meter-gate::after {
  content: '';
  position: absolute;
  top: -4px; left: -3px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--gold-light);
}
.meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 1px;
}

/* Metric chips */
.metrics-row {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.metric-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), background var(--transition);
}
.metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
}
.metric-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.metric-chip.metric-good { border-color: rgba(47,158,111,0.45); background: rgba(47,158,111,0.10); }
.metric-chip.metric-good .metric-val { color: #4cc38a; }
.metric-chip.metric-warn { border-color: rgba(217,154,28,0.45); background: rgba(217,154,28,0.10); }
.metric-chip.metric-warn .metric-val { color: #e0a83a; }
.metric-chip.metric-bad  { border-color: rgba(214,69,80,0.5); background: rgba(214,69,80,0.12); }
.metric-chip.metric-bad .metric-val { color: #f07782; }

/* Voice adaptation panel */
.voice-adapt {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
}
body.light-mode .voice-adapt { background: rgba(20,33,61,0.02); }
.va-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.va-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.va-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201,165,78,0.4);
  background: var(--accent-grad-soft);
  color: var(--gold-light);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.va-btn:hover { border-color: var(--gold); transform: translateY(-1px); }
.va-btn.is-busy { opacity: 0.7; cursor: progress; }
.va-btn:disabled { cursor: progress; }

/* toggle switch */
.va-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
.va-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.va-switch {
  position: relative;
  width: 38px; height: 20px;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.va-switch::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;                 /* start on the right (RTL "off") */
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}
.va-toggle input:checked + .va-switch {
  background: var(--accent-grad);
  border-color: transparent;
}
.va-toggle input:checked + .va-switch::after {
  transform: translateX(-18px);
  background: #201607;
}
.va-toggle input:focus-visible + .va-switch { box-shadow: 0 0 0 3px rgba(201,165,78,0.3); }
.va-gate {
  margin-inline-start: auto;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.va-gate strong { color: var(--gold-light); font-variant-numeric: tabular-nums; }

.va-progress {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  overflow: hidden;
}
.va-progress[hidden] { display: none; }
.va-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

/* QUICK ACTION TOOLBAR — segmented row, same visual language as the
   editor toolbar (.toolbar-btn) so every tab reads as one system. */
.action-toolbar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 18px;
  margin-top: 4px;
  border-top: 1px solid var(--border-glass);
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.action-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-glass-hover);
  background: var(--bg-glass-hover);
  transform: translateY(-1px);
}
.action-btn-primary {
  background: var(--accent-grad-soft);
  border-color: rgba(201,165,78,0.35);
  color: var(--gold-light);
}
.action-btn-primary:hover {
  border-color: var(--gold);
  background: var(--accent-grad-soft);
}

/* Test-microphone button in the control panel */
.testmic-btn {
  justify-content: center;
  width: 100%;
  margin-top: 2px;
  background: var(--accent-grad-soft);
  border-color: rgba(201,165,78,0.35);
  color: var(--gold-light);
}
.testmic-btn:hover { border-color: var(--gold); color: var(--gold-light); }
.mic-active-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: right;
}

/* ══ TRANSCRIPT PANEL ══ */
.transcript-panel {
  grid-area: transcript;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.transcript-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--transition);
}

.transcript-badge.processing {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

.transcript-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.transcript-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
}

.transcript-scroll::-webkit-scrollbar { width: 5px; }
.transcript-scroll::-webkit-scrollbar-track { background: transparent; }
.transcript-scroll::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: var(--radius-full); }

.transcript-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  flex: 1;
}

.transcript-placeholder svg { width: 60px; height: 60px; opacity: 0.5; }
.transcript-placeholder p { font-size: 13px; line-height: 1.5; }

.transcript-segments { display: flex; flex-direction: column; gap: 10px; }

.segment {
  padding: 12px 14px;
  background: var(--accent-grad-soft);
  border: 1px solid rgba(201,165,78,0.2);
  border-radius: var(--radius-md);
  border-right: 3px solid var(--purple);
  animation: slideIn 0.3s ease;
  direction: rtl;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.segment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.segment-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.segment-num {
  font-size: 10px;
  color: var(--purple-light);
  font-weight: 600;
  background: rgba(201,165,78,0.15);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.segment-actions {
  display: flex;
  gap: 4px;
  margin-right: auto;
}

.segment-delete-btn, .segment-editor-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.segment:hover .segment-delete-btn,
.segment:hover .segment-editor-btn {
  opacity: 1;
}

.segment-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  transform: scale(1.15);
}

.segment-editor-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  transform: scale(1.15);
}

.segment-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.7;
  word-break: break-word;
  outline: none;
  border-radius: var(--radius-sm);
  transition: background 0.2s, padding 0.2s;
  white-space: pre-wrap;
}

.segment-text[contenteditable="true"]:hover {
  background: rgba(255, 255, 255, 0.05);
  cursor: text;
}

.segment-text[contenteditable="true"]:focus {
  background: rgba(0, 0, 0, 0.15);
  padding: 4px 8px;
  margin: -4px -8px;
}

/* Audio attachment row */
.segment-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(201,165,78,0.12);
}

.segment-audio-player {
  flex: 1;
  height: 28px;
  min-width: 0;
  border-radius: var(--radius-sm);
  accent-color: var(--purple);
  filter: brightness(0.9);
}

.segment-audio-player::-webkit-media-controls-panel {
  background: rgba(201,165,78,0.12);
  border-radius: var(--radius-sm);
}

.segment-dl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(201,165,78,0.12);
  color: var(--purple-light);
  border: 1px solid rgba(201,165,78,0.2);
  text-decoration: none;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.segment-dl-btn:hover {
  background: rgba(201,165,78,0.25);
  color: white;
  transform: translateY(-1px);
}

/* ── Failed segment card ── */
.segment-failed {
  background: rgba(239,68,68,0.07) !important;
  border-color: rgba(239,68,68,0.25) !important;
  border-right-color: var(--danger) !important;
}

.segment-fail-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--danger);
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.segment-fail-msg {
  font-size: 12px;
  color: #fca5a5;
  margin: 6px 0 0;
  line-height: 1.5;
  direction: rtl;
}

.segment-retry-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 16px;
  width: 100%;
  justify-content: center;
  background: rgba(201,165,78,0.1);
  border: 1px solid rgba(201,165,78,0.3);
  border-radius: var(--radius-sm);
  color: var(--purple-light);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-retry-btn:hover {
  background: rgba(201,165,78,0.22);
  border-color: var(--purple);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,165,78,0.25);
}

.segment-retry-btn:hover svg {
  animation: spin-once 0.5s ease;
}

@keyframes spin-once {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ═══════════ EDITOR TAB ═══════════ */
.editor-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - var(--navbar-h) - 56px);
}

.editor-toolbar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-grad-soft);
  border: 1px solid rgba(201,165,78,0.3);
  border-radius: var(--radius-sm);
  color: var(--purple-light);
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toolbar-btn svg { width: 16px; height: 16px; }
.toolbar-btn:hover {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--purple-glow);
}

.toolbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.divider-v {
  width: 1px;
  height: 14px;
  background: var(--border-glass);
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Quill overrides */
#quillToolbar {
  background: var(--bg-glass) !important;
  border: none !important;
  border-bottom: 1px solid var(--border-glass) !important;
  padding: 10px 16px !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  direction: ltr;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ql-toolbar.ql-snow {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

.ql-toolbar .ql-stroke { stroke: var(--text-secondary) !important; }
.ql-toolbar .ql-fill { fill: var(--text-secondary) !important; }
.ql-toolbar button:hover .ql-stroke { stroke: var(--purple-light) !important; }
.ql-toolbar button:hover .ql-fill { fill: var(--purple-light) !important; }
.ql-toolbar button.ql-active .ql-stroke { stroke: var(--purple-light) !important; }
.ql-toolbar button.ql-active .ql-fill { fill: var(--purple-light) !important; }
.ql-toolbar .ql-picker-label { color: var(--text-secondary) !important; }
.ql-toolbar .ql-picker-options { background: var(--bg-mid) !important; border: 1px solid var(--border-glass) !important; color: var(--text-primary) !important; }
.ql-toolbar .ql-picker-item:hover { color: var(--purple-light) !important; }
.ql-toolbar button { border-radius: 4px !important; transition: background var(--transition) !important; }
.ql-toolbar button:hover, .ql-toolbar button.ql-active { background: rgba(201,165,78,0.15) !important; }

.ql-container.ql-snow {
  border: none !important;
  flex: 1;
  overflow-y: auto;
  direction: rtl;
}

.ql-editor {
  font-family: var(--font-primary) !important;
  font-size: 16px !important;
  line-height: 1.9 !important;
  color: var(--text-primary) !important;
  padding: 28px 36px !important;
  direction: rtl !important;
  text-align: right !important;
  min-height: 400px;
}

.ql-editor.ql-blank::before {
  color: var(--text-muted) !important;
  right: 36px !important;
  left: unset !important;
  font-style: normal !important;
  font-size: 15px !important;
}

/* ═══════════ HISTORY TAB ═══════════ */
.history-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - var(--navbar-h) - 56px);
}

.history-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.history-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-ghost {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-ghost:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
}

.empty-state svg { width: 80px; height: 80px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-state p { font-size: 13px; color: var(--text-muted); }

.history-item {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition);
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--border-glass-hover);
  background: var(--bg-glass-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-date {
  font-size: 12px;
  color: var(--text-muted);
}

.history-item-actions {
  display: flex;
  gap: 6px;
}

.history-action-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-primary);
}

.history-action-btn:hover {
  border-color: var(--purple);
  color: var(--purple-light);
}

.history-item-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  direction: rtl;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════ TOAST ═══════════ */
.toast-container {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  direction: rtl;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-mid);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 13px;
  color: var(--text-primary);
  backdrop-filter: blur(16px);
  min-width: 280px;
  animation: toastIn 0.3s ease;
}

.toast.success { border-right: 3px solid var(--success); }
.toast.error { border-right: 3px solid var(--danger); }
.toast.info { border-right: 3px solid var(--info); }
.toast.warning { border-right: 3px solid var(--warning); }

.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* ═══════════ LOADING OVERLAY ═══════════ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(8, 9, 26, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.hidden { display: none; }

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.spinner-ring {
  width: 56px; height: 56px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════ SCROLLBAR GLOBAL ═══════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ═══════════ PROCESSING ANIMATION ═══════════ */
.processing-segment {
  padding: 12px 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--warning);
  animation: fadeIn 0.3s ease;
}

.processing-dots {
  display: flex;
  gap: 4px;
}

.processing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warning);
  animation: bounceDot 1.2s ease-in-out infinite;
}

.processing-dots span:nth-child(2) { animation-delay: 0.2s; }
.processing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounceDot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ═══════════ RESPONSIVE ═══════════
   Named grid-areas (set on .recorder-layout / .control-panel /
   .recorder-center / .transcript-panel above) let each breakpoint
   reflow the three panels into whatever shape fits the screen —
   ultra-wide court display, standard monitor, laptop, or tablet —
   without any change to the HTML markup. */
@media (max-width: 1440px) {
  .recorder-layout {
    grid-template-columns: minmax(230px, 270px) minmax(400px, 1fr) minmax(270px, 340px);
  }
}

/* Laptop / narrow desktop: settings + transcript move under the deck.
   Row minimums are kept modest so the deck's primary controls (mic,
   status, start of the waveform) stay visible without scrolling on
   common 1280×800 / 1366×768 laptop screens; anything beyond that
   scrolls within its own card rather than being clipped. */
@media (max-width: 1300px) {
  /* The full recording deck is taller than a squeezed top row can show,
     so switch to content-driven heights and let the page scroll — the
     deck stays fully visible above the two shorter panels. */
  .recorder-layout {
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
    grid-template-areas:
      "center   center"
      "control  transcript";
    grid-template-rows: auto minmax(320px, 1fr);
    height: auto;
    max-width: 1100px;
  }
  .recorder-center { overflow: visible; }
  .transcript-panel { min-height: 340px; }
  .control-panel { max-height: 560px; }
}

/* Tablet / narrow screens: single column, recording deck first,
   then live transcript (most watched while a session is running),
   then settings last */
@media (max-width: 860px) {
  .recorder-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "center"
      "transcript"
      "control";
    grid-template-rows: auto auto auto;
    height: auto;
  }
  .recorder-center { overflow: visible; }
  .transcript-panel { min-height: 340px; }
  .control-panel { max-height: 460px; }
  .navbar-tabs .tab-btn span { display: none; }
}

/* ═══════════════════════════════════════════════════════
   FORMAL COURT PLATFORM — case strip, case form, signatures
   ═══════════════════════════════════════════════════════ */

/* Case header strip under the navbar */
.case-strip {
  position: fixed;
  top: var(--navbar-h);
  left: 0; right: 0;
  z-index: 90;
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: linear-gradient(90deg, rgba(27,42,74,0.92), rgba(14,24,54,0.92));
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
  white-space: nowrap;
}
.case-strip[hidden] { display: none; }
.case-strip-inner { display: flex; align-items: center; gap: 10px; }
.case-strip-court { color: var(--gold-light); font-weight: 700; }
.case-strip-item strong { color: var(--text-primary); font-weight: 600; }
.case-strip-sep { color: var(--text-muted); }
body.has-case-strip .main-content { margin-top: calc(var(--navbar-h) + 34px); }
/* Height itself is handled via the --recorder-h custom property set on
   .recorder-layout (see the RECORDER LAYOUT section) — that keeps every
   responsive breakpoint's own `height` override (auto, row-based, etc.)
   in charge instead of a second, higher-specificity rule stomping on it. */
body.light-mode .case-strip {
  background: linear-gradient(90deg, rgba(27,42,74,0.95), rgba(36,65,127,0.92));
  color: #e8ecf5;
}

/* ── Case / Session info form ── */
.case-layout { max-width: 1000px; margin: 0 auto; }
.case-card { padding: 30px 32px 26px; }
.case-card-head { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border-glass); }
.case-card-head .panel-title {
  font-family: var(--font-serif);
  font-size: 22px;
}
.case-card-sub { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.case-fieldset {
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 18px 18px 20px;
  margin-bottom: 18px;
}
.case-fieldset legend {
  padding: 2px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-light);
  background: var(--accent-grad-soft);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
}
.case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.case-col-full { grid-column: 1 / -1; }

.case-input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
body.light-mode .case-input { background: rgba(255,255,255,0.7); }
.case-input::placeholder { color: var(--text-muted); }
.case-input:focus {
  border-color: var(--gold);
  background: rgba(201,165,78,0.06);
  box-shadow: 0 0 0 3px rgba(201,165,78,0.15);
}
.case-input option { color: #14213d; }

.case-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.case-saved-note { font-size: 13px; color: var(--success); font-weight: 600; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-grad);
  color: #1a1206;
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(201,165,78,0.32);
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(201,165,78,0.5); }
.btn-primary:active { transform: translateY(0); }

/* Witness picker */
.witness-pick { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.witness-pick[hidden] { display: none; }

/* Wide speaker button + name sublabel */
.speaker-btn-wide { grid-column: 1 / -1; }
.speaker-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.25; }
.speaker-btn-name {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Serif touch for formal headings */
.brand-name { font-family: var(--font-primary); }

/* Responsive: single-column case form */
@media (max-width: 640px) {
  .case-grid { grid-template-columns: 1fr; }
  .case-card { padding: 22px 18px; }
}
