/* ==========================================================
   Connected Speech & Rhythm Lab
   Clean Daylight Editorial Stylesheet + Dark Spectrogram Well
   ========================================================== */

:root {
  --paper: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --ink: #0f172a;
  --ink-body: #334155;
  --ink-muted: #475569;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --crimson: #be123c;
  --crimson-soft: #fff1f2;
  --crimson-border: #fecdd3;
  --sky: #0284c7;
  --sky-dark: #0369a1;
  --sky-soft: #f0f9ff;
  --sky-border: #bae6fd;
  --emerald: #047857;
  --emerald-soft: #ecfdf5;
  --emerald-border: #6ee7b7;
  --amber: #92400e;
  --amber-soft: #fffbeb;
  --amber-border: #fcd34d;
  --well-bg: #070d1b;
  --well-surface: #0f172a;
  --well-border: #1e293b;
  --shadow-card: 0 10px 26px -6px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-pill: 0 1px 2px rgba(15, 23, 42, 0.06);
}

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

html {
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: linear-gradient(to bottom, rgba(226, 232, 240, 0.35) 1px, transparent 1px);
  background-size: 100% 32px;
  color: var(--ink-body);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--sky-dark);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.page-shell {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Editorial Top Header ---------- */
.site-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--sky-dark);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: var(--shadow-pill);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 280px;
}

.breadcrumb-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.back-link {
  color: var(--sky-dark);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
}

.back-link:hover {
  text-decoration: underline;
  color: var(--ink);
}

.header-sep {
  color: var(--border-strong);
}

.desk-kicker {
  color: var(--crimson);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.72rem;
  font-weight: 800;
}

.site-header h1 {
  margin: 0;
  font-family: 'Playfair Display', 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.5rem, 3.6vw, 2.15rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.header-subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.header-art {
  width: 158px;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: block;
}

/* ---------- HUD Bar ---------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pill);
  white-space: nowrap;
}

.hud-btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-pill);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.hud-btn:hover {
  background: var(--sky-soft);
  border-color: var(--sky);
  color: var(--sky-dark);
}

.hud-btn[aria-pressed="true"] {
  background: var(--sky-dark);
  border-color: var(--sky-dark);
  color: #ffffff;
}

.hud-btn.hud-duel-btn {
  border-color: var(--crimson-border);
  color: var(--crimson);
}

.hud-btn.hud-duel-btn:hover {
  background: var(--crimson-soft);
  border-color: var(--crimson);
}

.mode-badge {
  background: var(--crimson-soft);
  color: var(--crimson);
  border: 1px solid var(--crimson-border);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.mode-badge.daily-active {
  background: var(--sky-soft);
  color: var(--sky-dark);
  border-color: var(--sky-border);
}

.hud-exit-btn {
  background: var(--surface-muted);
  color: var(--ink);
}

/* ---------- Act Jump Bar ---------- */
.act-jump-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-pill);
}

.act-pill {
  appearance: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--paper);
  color: var(--ink-body);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.act-pill:hover {
  background: var(--sky-soft);
  border-color: var(--sky);
  color: var(--sky-dark);
}

.act-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.act-pill.pill-mode-daily.active {
  background: var(--sky-dark);
  border-color: var(--sky-dark);
}

.act-pill.pill-mode-duel.active {
  background: var(--crimson);
  border-color: var(--crimson);
}

/* ---------- Duel Forge Drawer ---------- */
.duel-forge-drawer {
  background: var(--surface);
  border: 1px solid var(--crimson-border);
  border-left: 4px solid var(--crimson);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.duel-forge-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.duel-forge-head h2 {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--ink);
}

.duel-forge-sub {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.duel-forge-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.duel-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.duel-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.duel-slot-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.duel-slot-field label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.duel-slot-select,
.duel-name-input {
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.duel-name-input {
  max-width: 210px;
}

.duel-preview-list {
  margin: 0;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.84rem;
  color: var(--ink-body);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.duel-forge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ---------- Main Card ---------- */
.lab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0;
}

.duel-target-banner {
  background: var(--crimson-soft);
  border: 1px solid var(--crimson-border);
  border-left: 4px solid var(--crimson);
  color: var(--crimson);
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 800;
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.meta-tag {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sky-dark);
  background: var(--sky-soft);
  border: 1px solid var(--sky-border);
  padding: 4px 10px;
  border-radius: 999px;
}

.phase-pill {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--emerald);
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  padding: 4px 10px;
  border-radius: 999px;
}

.drill-title {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.22rem, 2.8vw, 1.55rem);
  color: var(--ink);
  line-height: 1.25;
}

.scene-context {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
  background: var(--paper);
  border-left: 3px solid var(--border-strong);
  padding: 9px 13px;
  border-radius: 0 8px 8px 0;
}

/* ---------- Sentence & Speed Controls Stage ---------- */
.sentence-stage {
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.sentence-stage-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.feature-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--crimson);
  background: var(--crimson-soft);
  border: 1px solid var(--crimson-border);
  padding: 3px 10px;
  border-radius: 999px;
}

.sentence-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.legend-stress {
  color: var(--amber);
}

.legend-weak {
  color: var(--sky-dark);
}

.sentence-segments {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 7px 8px;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(1.25rem, 3.2vw, 1.52rem);
  line-height: 1.45;
}

.word-token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

.word-token.is-stress {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: #78350f;
  font-weight: 700;
}

.word-token.is-weak {
  border-style: dashed;
  border-color: var(--sky-border);
  background: var(--sky-soft);
  color: var(--sky-dark);
  font-weight: 500;
}

.token-ipa {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-top: 1px;
}

.playback-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.speed-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.speed-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-right: 3px;
}

.speed-btn {
  appearance: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-body);
  cursor: pointer;
  transition: all 0.15s;
}

.speed-btn:hover {
  border-color: var(--sky);
  color: var(--sky-dark);
}

.speed-btn.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.btn-ref-play {
  appearance: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid #d97706;
  background: #f59e0b;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
  transition: background-color 0.15s, transform 0.1s;
}

.btn-ref-play:hover {
  background: #fbbf24;
}

.btn-ref-play.is-playing {
  background: #0f172a;
  border-color: #0f172a;
  color: #fde047;
}

/* ---------- Crisp Dark Spectrogram & Rhythm Well inside Daylight Card ---------- */
.spectrogram-well {
  background: linear-gradient(170deg, #0b1326 0%, #050a18 100%);
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 15px 16px;
  color: #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.14), 0 12px 24px -10px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.well-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.well-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.well-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  flex-shrink: 0;
}

.well-dot.is-rec {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.28);
}

.well-dot.is-play {
  background: #fbbf24;
}

.well-dot.is-ok {
  background: #10b981;
}

.well-status-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #bae6fd;
}

.well-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  font-weight: 700;
}

.wleg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #cbd5e1;
}

.wleg-swatch {
  width: 11px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.wleg-gold { background: #fbbf24; }
.wleg-cyan { background: #38bdf8; }
.wleg-schwa { background: #34d399; }

.well-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: #0f172a;
  border: 1px solid #334155;
  color: #f8fafc;
}

.canvas-stack {
  position: relative;
  width: 100%;
  height: 250px;
  border-radius: 10px;
  overflow: hidden;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.canvas-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#cs-live-canvas {
  pointer-events: none;
}

.well-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-well {
  appearance: none;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 700;
  padding: 9px 13px;
  border-radius: 9px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f1f5f9;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-well:hover:not(:disabled) {
  background: #1e293b;
  border-color: #38bdf8;
}

.btn-well:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-well-mic {
  background: #0ea5e9;
  border-color: #38bdf8;
  color: #020617;
  font-weight: 800;
  flex: 1 1 180px;
}

.btn-well-mic:hover:not(:disabled) {
  background: #38bdf8;
}

.btn-well-mic.is-recording {
  background: #ef4444;
  border-color: #fca5a5;
  color: #ffffff;
}

.btn-well-sim {
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}

.btn-well-sim:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.15);
  border-color: #34d399;
}

.well-privacy {
  margin: 0;
  font-size: 0.74rem;
  color: #94a3b8;
}

.rhythm-strip {
  border-top: 1px solid #1e293b;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rhythm-strip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
}

.btn-link-muted {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.btn-link-muted:hover {
  color: #ffffff;
}

.rhythm-pads {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.rhythm-pad {
  appearance: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background-color 0.15s;
}

.rhythm-pad.pad-stress {
  border-color: rgba(245, 158, 11, 0.55);
  color: #fde68a;
}

.rhythm-pad.pad-weak {
  border-style: dashed;
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
  font-size: 0.74rem;
}

.rhythm-pad:hover {
  border-color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
}

.rhythm-pad.is-hit {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.22);
  color: #d1fae5;
}

/* ---------- Match Score Card ---------- */
.score-card {
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  border-left: 4px solid var(--emerald);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-card.is-developing {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  border-left-color: #d97706;
}

.score-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.score-badge {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--emerald);
}

.score-card.is-developing .score-badge {
  color: var(--amber);
}

.score-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.metric-chip {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 0.71rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.score-feedback {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-body);
}

/* ---------- Action Bar & Phonetic Blueprint ---------- */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.btn-primary,
.btn-secondary,
.btn-blueprint,
.btn-crimson {
  appearance: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 9px 15px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--sky-dark);
  color: #ffffff;
  border: 1px solid var(--sky-dark);
  margin-left: auto;
}

.btn-primary:hover:not(:disabled) {
  background: #075985;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--ink-muted);
}

.btn-blueprint {
  background: var(--sky-soft);
  color: var(--sky-dark);
  border: 1px solid var(--sky-border);
}

.btn-blueprint:hover {
  background: #e0f2fe;
  border-color: var(--sky);
}

.btn-crimson {
  background: var(--crimson);
  color: #ffffff;
  border: 1px solid var(--crimson);
}

.btn-crimson:hover {
  background: #9f1239;
}

.blueprint-panel {
  background: var(--paper);
  border: 1px solid var(--sky-border);
  border-left: 4px solid var(--sky-dark);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.blueprint-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.blueprint-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sky-dark);
}

.blueprint-title {
  margin: 2px 0 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.blueprint-cefr {
  font-size: 0.76rem;
  font-weight: 800;
  background: var(--ink);
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 999px;
}

.blueprint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 9px;
}

.bp-box {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.formula-tag {
  align-self: flex-start;
  font-size: 0.67rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--ink);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 4px;
}

.bp-box code,
.bp-written-text {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bp-written-text {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.06rem;
}

.blueprint-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-body);
}

.feedback-line {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-body);
}

.feedback-line.is-error {
  color: var(--crimson);
}

.feedback-line.is-success {
  color: var(--emerald);
}

/* ---------- Course Bridge & Belfast Desk Strip ---------- */
[data-course-bridge] {
  width: 100%;
}

.belfast-desk-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--crimson);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  box-shadow: var(--shadow-pill);
}

.belfast-desk-copy {
  flex: 1 1 320px;
  min-width: 0;
}

.belfast-desk-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--crimson);
  margin-bottom: 4px;
}

.belfast-desk-strip h2 {
  margin: 0 0 6px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--ink);
}

.belfast-desk-strip p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-body);
}

.belfast-desk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-desk-primary,
.btn-desk-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.desk-drawer {
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.desk-drawer.hidden { display: none; }
.desk-drawer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink);
}
.desk-context-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--sky-dark);
  background: var(--sky-soft);
  border: 1px solid var(--sky-border);
  padding: 3px 9px;
  border-radius: 999px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.desk-drawer-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.desk-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.desk-field-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
}
.desk-input,
.desk-textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--paper);
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}
.desk-input:focus,
.desk-textarea:focus {
  outline: none;
  border-color: var(--sky-dark);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.14);
}
.desk-form-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}
.desk-email-input {
  flex: 1 1 200px;
}
.desk-form-status {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.45;
}
.desk-form-status:empty { display: none; }
.desk-form-status.is-success {
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  color: var(--emerald);
  padding: 9px 12px;
  border-radius: 8px;
}
.desk-form-status.is-error {
  background: var(--crimson-soft);
  border: 1px solid var(--crimson-border);
  color: var(--crimson);
  padding: 9px 12px;
  border-radius: 8px;
}

.btn-desk-primary {
  background: var(--sky-dark);
  border: 1px solid var(--sky-dark);
  color: #ffffff;
}

.btn-desk-primary:hover {
  background: #075985;
}

.btn-desk-secondary {
  background: var(--paper);
  border: 1px solid var(--border-strong);
  color: var(--ink);
}

.btn-desk-secondary:hover {
  background: var(--crimson-soft);
  border-color: var(--crimson);
  color: var(--crimson);
}

body.gm-clean-screenshare #belfast-desk-strip,
body.gm-clean-screenshare [data-course-bridge],
body.gm-clean-screenshare #gm-course-bridge {
  display: none !important;
}

/* ---------- End-of-Run Recap Modal ---------- */
.recap-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}

.recap-modal.open {
  display: flex;
}

.recap-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--sky-dark);
  border-radius: 16px;
  padding: 24px;
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recap-panel h2 {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  color: var(--ink);
}

.recap-summary {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink-body);
}

.recap-verdict {
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 800;
  background: var(--sky-soft);
  border: 1px solid var(--sky-border);
  color: var(--sky-dark);
}

.recap-verdict.verdict-win {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.recap-verdict.verdict-loss {
  background: var(--crimson-soft);
  border-color: var(--crimson-border);
  color: var(--crimson);
}

.recap-step-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 36vh;
  overflow-y: auto;
  padding-right: 4px;
}

.recap-step-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.85rem;
}

.recap-step-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.recap-step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.recap-step-sentence {
  color: var(--ink);
  font-weight: 700;
}

.recap-step-note {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.recap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

/* ---------- Site Footer ---------- */
.site-footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 0.84rem;
  color: var(--ink-muted);
  box-shadow: var(--shadow-pill);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
}

.site-footer a {
  color: var(--sky-dark);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}

/* ---------- Mobile Safe (<= 540px & 360px safe) ---------- */
@media (max-width: 540px) {
  body {
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .site-header {
    padding: 14px;
  }

  .header-art {
    display: none;
  }

  .lab-card {
    padding: 15px 14px;
    gap: 13px;
  }

  .spectrogram-well {
    padding: 12px;
  }

  .canvas-stack {
    height: 210px;
  }

  .action-bar .btn-primary,
  .recap-actions .btn-primary {
    margin-left: 0;
    width: 100%;
  }

  .belfast-desk-actions {
    width: 100%;
  }

  .belfast-desk-actions .btn-desk-primary,
  .belfast-desk-actions .btn-desk-secondary {
    width: 100%;
    text-align: center;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .recap-panel {
    padding: 18px 15px;
  }
}

@media print {
  .hud, .act-jump-bar, .action-bar, .well-controls, .rhythm-strip, .belfast-desk-strip, [data-course-bridge], .site-footer {
    display: none !important;
  }
}
