/* apps/study/study.css - PilotsFriend Learner-Facing Runtime Styles */
:root {
  --bg-primary: #0a0f1d;
  --bg-surface: #131b2e;
  --bg-surface-elevated: #1a253f;
  --border-subtle: #24324f;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.study-header {
  height: 56px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.area-badge {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.study-nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  background: var(--accent-cyan);
  color: #041019;
  font-weight: 700;
}

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

.area-select {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* Main Split View */
.study-viewport {
  flex: 1;
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}

/* Left Pane: Raster Chart */
.chart-pane {
  flex: 1.2;
  position: relative;
  background-color: #050811;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.chart-canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.chart-controls-bar {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  gap: 6px;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: 8px;
}

.chart-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.chart-ctrl-btn:hover {
  background: var(--bg-surface-elevated);
}

.chart-view-indicator {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Right Pane: Study Workspace */
.workspace-pane {
  flex: 1;
  background: var(--bg-surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.workspace-view {
  padding: 24px;
  display: none;
  flex-direction: column;
  gap: 20px;
}

.workspace-view.active {
  display: flex;
}

/* Overview Section */
.overview-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
}

.overview-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.overview-desc {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 16px;
}

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

.metric-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
}

.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.metric-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Guided Lights Workspace */
.lights-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lights-mode-toggle {
  display: flex;
  gap: 6px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.lights-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.lights-mode-btn.active {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

.light-study-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.aid-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aid-llnr-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
}

.aid-name-large {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.aid-signal-container {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.aid-char-text {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fef08a;
}

.aid-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.detail-item {
  background: var(--bg-primary);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Draw Recall Cover Card */
.draw-cover-overlay {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(19, 27, 46, 0.97);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  gap: 16px;
  z-index: 10;
}

.draw-cover-btn {
  background: var(--accent-amber);
  color: #0f172a;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.draw-cover-btn:hover {
  transform: scale(1.02);
}

/* Tour Stepper Controls */
.aid-stepper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.step-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.step-btn:hover:not(:disabled) {
  background: var(--border-subtle);
}

.step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Written Cinema Workspace */
.cinema-audio-bar {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.audio-play-btn {
  background: var(--accent-cyan);
  color: #0f172a;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.audio-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-seek-slider {
  width: 100%;
  accent-color: var(--accent-cyan);
}

.audio-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.cinema-transcript-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chapter-badge {
  align-self: flex-start;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-amber);
}

.transcript-caption-box {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #f8fafc;
  min-height: 80px;
}

/* Source Citation Card */
.source-citation-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-citation-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.source-citation-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Plotting Constructions Workspace */
.construction-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.construction-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.plot-instruction-list {
  padding-left: 20px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-main);
  margin: 0;
}

.plot-instruction-list li {
  margin-bottom: 6px;
  transition: all 0.2s ease;
}

.plot-instruction-list li.active-step {
  color: var(--accent-cyan);
  font-weight: 700;
  transform: translateX(4px);
}

.trick-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
}

/* OpenSeadragon Plotting Overlay Badges (Kachemak pattern) */
.chart-construction-badge {
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(244, 63, 94, 0.7);
  border-radius: 6px;
  padding: 5px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 12px rgba(244, 63, 94, 0.35);
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  margin-top: 12px;
  z-index: 100;
  transform: translate(-50%, 0);
}

.chart-construction-badge .badge-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.chart-construction-badge .badge-sub {
  font-size: 0.72rem;
  color: #fda4af;
  font-family: var(--font-mono, monospace);
  margin-top: 2px;
}

.chart-endpoint-label {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #f8fafc;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 90;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}

/* Animations */
@keyframes beacon-flash {
  0%, 15% { opacity: 1; filter: drop-shadow(0 0 8px currentColor); }
  25%, 100% { opacity: 0.15; filter: none; }
}

@keyframes beacon-pulse {
  0% { transform: scale(1); opacity: 0.4; }
  35% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes pulse-reticle {
  0% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.9; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1.0; box-shadow: 0 0 20px #38bdf8, inset 0 0 12px rgba(56, 189, 248, 0.6); }
  100% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.9; }
}

/* Area Verification Banner */
.verification-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 16px 16px 0 16px;
  color: #fef3c7;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Community & Contextual Q&A Thread Streaming */
.thread-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thread-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: #cbd5e1;
  font-size: 0.88rem;
  background: #0d1527;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.thread-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: thread-spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.post-box {
  background: #0b1322;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.82rem;
  color: #94a3b8;
  flex-wrap: wrap;
  gap: 6px;
}

.post-author-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}

.post-author {
  font-weight: 700;
  color: var(--accent-cyan);
  font-size: 0.9rem;
}

.post-number-badge {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
}

.post-content {
  font-size: 0.92rem;
  color: #f1f5f9;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
}

.post-content p {
  margin-bottom: 8px;
}

.post-content p:last-child {
  margin-bottom: 0;
}

.post-content a {
  color: var(--accent-cyan);
  text-decoration: underline;
  font-weight: 600;
}

.post-content a:hover {
  color: var(--accent-cyan-hover);
}

.post-content strong {
  color: #ffffff;
  font-weight: 700;
}

.post-content em {
  color: #cbd5e1;
  font-style: italic;
}

.post-content blockquote {
  border-left: 3px solid var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  padding: 8px 14px;
  margin: 10px 0;
  border-radius: 0 6px 6px 0;
  color: #cbd5e1;
}

.post-content img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.post-content img.emoji {
  width: 20px;
  height: 20px;
  display: inline-block;
}

.post-content pre {
  max-width: 100%;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 6px;
}

.thread-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 0.82rem;
  color: #94a3b8;
  flex-wrap: wrap;
  gap: 8px;
}

.thread-error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: 8px;
  padding: 14px 16px;
  color: #fecdd3;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-retry {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-retry:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Responsive Viewports */
@media (max-width: 840px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .study-header {
    height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    gap: 8px;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }

  .header-actions {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .area-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .study-nav-tabs {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
  }

  .study-nav-tabs::-webkit-scrollbar {
    display: none;
  }

  .nav-tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .study-viewport {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 56px);
    max-width: 100vw;
    overflow-x: hidden;
  }

  .chart-pane {
    height: 340px;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
    position: relative;
    max-width: 100vw;
  }

  .chart-measure-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    max-width: calc(100vw - 16px);
    padding: 10px 12px;
    gap: 8px;
    box-sizing: border-box;
  }

  .measure-point-coord {
    font-size: 0.74rem;
  }

  .measure-point-tag {
    font-size: 0.68rem;
    padding: 2px 4px;
  }

  .measure-adjust-btn {
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .workspace-pane {
    flex: 1;
    overflow-y: visible;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  .workspace-view {
    padding: 16px;
    box-sizing: border-box;
    max-width: 100%;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}

/* Accessible focus indicators for keyboard navigation */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.post-action-notice {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Interactive Chart Measurement Tool HUD & Reticle Overlays
   ========================================================================== */
.chart-ctrl-btn.active {
  background: var(--accent-cyan);
  color: #041019;
  font-weight: 700;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.chart-canvas.measure-mode-active,
.chart-canvas.measure-mode-active .openseadragon-canvas {
  cursor: crosshair !important;
}

.chart-measure-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  max-width: 440px;
  z-index: 95;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #f8fafc;
}

.chart-measure-hud[hidden] {
  display: none !important;
}

.measure-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.measure-hud-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.measure-hud-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.measure-hud-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}

.measure-hud-close {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s;
}

.measure-hud-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.measure-hud-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.measure-hud-uncalibrated {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 10px 12px;
}

.uncalibrated-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fbbf24;
  margin-bottom: 4px;
}

.uncalibrated-desc {
  font-size: 0.82rem;
  color: #e2e8f0;
  line-height: 1.45;
  margin: 0;
}

.measure-point-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  gap: 8px;
}

.measure-point-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.measure-point-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.measure-point-tag.tag-a {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.measure-point-tag.tag-b {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.measure-point-coord {
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  color: #e2e8f0;
}

.measure-adjust-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.measure-adjust-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  color: #38bdf8;
}

.measure-adjust-btn.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 700;
}

.measure-results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.measure-metric {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 10px;
}

.measure-metric.span-2 {
  grid-column: span 2;
}

.measure-metric .metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.measure-metric .metric-val {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.measure-metric .text-cyan {
  color: #38bdf8;
}

.measure-metric .text-amber {
  color: #fbbf24;
}

.measure-metric .text-emerald {
  color: #34d399;
}

.measure-disclaimer {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.45;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  padding-top: 8px;
}

.measure-hud-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.measure-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 85;
}

.measure-marker .marker-reticle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid;
  position: relative;
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}

.measure-marker .marker-reticle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.measure-marker.measure-marker-a .marker-reticle {
  border-color: #34d399;
}

.measure-marker.measure-marker-a .marker-reticle::before {
  background: #34d399;
}

.measure-marker.measure-marker-b .marker-reticle {
  border-color: #38bdf8;
}

.measure-marker.measure-marker-b .marker-reticle::before {
  background: #38bdf8;
}

.measure-marker.is-selected .marker-reticle {
  border-width: 3px;
  animation: reticle-pulse 1.5s infinite;
}

@keyframes reticle-pulse {
  0% { transform: scale(1); box-shadow: 0 0 6px rgba(56, 189, 248, 0.6); }
  50% { transform: scale(1.15); box-shadow: 0 0 14px rgba(56, 189, 248, 0.9); }
  100% { transform: scale(1); box-shadow: 0 0 6px rgba(56, 189, 248, 0.6); }
}

.measure-marker .marker-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.measure-marker.measure-marker-a .marker-badge {
  background: #059669;
  color: #ffffff;
}

.measure-marker.measure-marker-b .marker-badge {
  background: #0284c7;
  color: #ffffff;
}

.measure-midpoint-pill {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid #38bdf8;
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  pointer-events: none;
  z-index: 86;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 6px;
}

.measure-midpoint-pill .pill-brg {
  color: #38bdf8;
}

.measure-midpoint-pill .pill-dot {
  color: #64748b;
}

.measure-midpoint-pill .pill-dist {
  color: #34d399;
}

/* ==========================================================================
   ASK AI / PILOTAGE STUDY ASSISTANT STYLES
   ========================================================================== */

/* Header Trigger Button */
.btn-ask-ai-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(14, 165, 233, 0.35));
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #f0f9ff;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.btn-ask-ai-trigger:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.3), rgba(14, 165, 233, 0.5));
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.btn-ask-ai-trigger:active {
  transform: translateY(0);
}

.ai-sparkle {
  font-size: 0.95rem;
  animation: pulse-sparkle 2.5s infinite ease-in-out;
}

@keyframes pulse-sparkle {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 4px #38bdf8); }
}

/* Overview Card Styles */
.ask-ai-overview-card {
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
  background: linear-gradient(135deg, rgba(19, 27, 46, 0.95), rgba(15, 23, 42, 0.98)) !important;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.ask-ai-overview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #38bdf8, #818cf8);
}

.ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-tag {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.ai-card-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
}

.ai-mode-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.ai-card-heading {
  font-size: 1.12rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 6px;
}

.ai-card-desc {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 12px;
}

.ask-ai-quick-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.ask-ai-input {
  flex: 1;
  padding: 9px 14px;
  background: rgba(10, 15, 29, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: #f8fafc;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.ask-ai-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.ai-quick-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-prompt-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-prompt-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

/* ==========================================================================
   SLIDE-OUT ASK AI DRAWER
   ========================================================================== */

.ask-ai-drawer {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100vw;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.65);
  z-index: 95;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  overflow: hidden;
}

.ask-ai-drawer[hidden] {
  display: none !important;
}

/* Drawer Header */
.ask-ai-header {
  padding: 14px 16px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ask-ai-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-sparkle-icon {
  font-size: 1.1rem;
}

.ask-ai-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.ai-source-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ask-ai-subtitle {
  font-size: 0.76rem;
  color: #94a3b8;
}

.ask-ai-close-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.ask-ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* Context Bar */
.ask-ai-context-bar {
  padding: 8px 16px;
  background: rgba(10, 15, 29, 0.7);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.context-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.context-chip {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}

.chip-area {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.chip-tab {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.chip-detail {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Suggestions Bar */
.ask-ai-suggestions {
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.ask-ai-suggestions::-webkit-scrollbar {
  display: none;
}

/* Messages Feed */
.ask-ai-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.ai-message {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: fadeIn 0.2s ease;
}

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

.ai-message.user-message {
  align-self: flex-end;
}

.ai-message.user-message .message-bubble {
  background: #0284c7;
  color: #ffffff;
  border-radius: 12px 12px 2px 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.ai-message.assistant-message {
  align-self: flex-start;
  width: 100%;
}

.ai-message.assistant-message .message-bubble {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #f1f5f9;
  border-radius: 12px 12px 12px 2px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

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

.assistant-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Citations Container */
.ai-citations-wrap {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.citations-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
}

.citations-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.citation-pill {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-pill:hover {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  color: #ffffff;
}

/* Unanswerable / Community Crossover Box */
.ai-crossover-box {
  margin-top: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crossover-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fbbf24;
}

.btn-crossover-action {
  background: var(--accent-amber);
  color: #041019;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn-crossover-action:hover {
  background: #f59e0b;
}

/* Input Area */
.ask-ai-input-pane {
  padding: 12px 16px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
}

.ask-ai-input-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ask-ai-textarea {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: #f8fafc;
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
}

.ask-ai-textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.ai-input-buttons {
  display: flex;
  gap: 6px;
}

.ai-voice-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  border-radius: 8px;
  height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-voice-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.ai-voice-btn.recording {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #f87171;
  animation: pulse-recording 1.2s infinite ease-in-out;
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.ai-submit-btn {
  background: var(--accent-cyan);
  color: #041019;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-submit-btn:hover {
  background: #0ea5e9;
  transform: translateY(-1px);
}

.ai-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Voice Status Banner */
.ai-voice-status {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #fca5a5;
}

.voice-indicator-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulse-dot 1s infinite ease-in-out;
}

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

.btn-cancel-voice {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #f87171;
  font-size: 0.74rem;
  text-decoration: underline;
  cursor: pointer;
}

.ai-footer-note {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #64748b;
}

/* ==========================================================================
   CITATION INSPECTOR MODAL
   ========================================================================== */

.citation-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 16, 25, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.citation-modal-backdrop[hidden] {
  display: none !important;
}

.citation-modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.citation-modal-header {
  padding: 14px 16px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.citation-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
}

.citation-modal-meta {
  font-size: 0.78rem;
  color: #94a3b8;
}

.citation-modal-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.citation-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.citation-modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}

.citation-detail-badge-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.citation-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  text-transform: uppercase;
}

.citation-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.citation-excerpt-box {
  background: rgba(10, 15, 29, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  font-family: inherit;
}

.citation-modal-footer {
  padding: 12px 16px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Responsive adjustments for Drawer */
@media (max-width: 768px) {
  .ask-ai-drawer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 75vh;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    border-radius: 16px 16px 0 0;
  }
}

/* ==========================================================================
   COAST PILOT SOURCE VIEWER (COAST_PILOT_PDF_DIRECT & IMAGE_DIRECT)
   ========================================================================== */

body.cp-viewer-open {
  overflow: hidden !important;
}

.cp-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(4, 8, 16, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: cpFadeIn 0.2s ease-out;
}

.cp-modal-backdrop[hidden] {
  display: none !important;
}

@keyframes cpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cp-modal-dialog {
  background: var(--bg-surface);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  width: 100%;
  max-width: 1180px;
  height: 92vh;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85);
}

.cp-modal-header {
  padding: 12px 20px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.cp-modal-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cp-anchor-icon {
  font-size: 1.6rem;
}

.cp-modal-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.cp-badge-vol {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.cp-badge-purity {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.cp-badge-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.cp-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
}

.cp-modal-meta {
  font-size: 0.8rem;
  color: #94a3b8;
}

.cp-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-open-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.cp-open-pdf-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
}

.cp-modal-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.cp-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.cp-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
  background: #070d17;
}

.cp-viewer-loading,
.cp-viewer-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.95rem;
  color: #94a3b8;
  background: rgba(7, 13, 23, 0.95);
  z-index: 10;
}

.cp-viewer-stage {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 16px;
  padding: 16px;
}

.cp-media-sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
}

.cp-photo-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cp-photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

.cp-photo-tag {
  color: #38bdf8;
  font-weight: 700;
}

.cp-photo-class {
  color: #34d399;
  font-family: monospace;
  font-size: 0.68rem;
}

.cp-photo-img-wrap {
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  line-height: 0;
}

.cp-photo-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.cp-photo-caption {
  font-size: 0.82rem;
  color: #f1f5f9;
  line-height: 1.4;
  font-weight: 500;
}

.cp-photo-credit {
  font-size: 0.74rem;
  color: #94a3b8;
  font-style: italic;
}

.cp-page-container {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  background: #040810;
  border-radius: 6px;
  padding: 16px 8px;
  scrollbar-width: thin;
}

.cp-page-wrap {
  position: relative;
  width: 100%;
  max-width: 800px;
  align-self: flex-start;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.cp-page-img {
  display: block;
  width: 100%;
  height: auto;
}

.cp-highlights-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cp-highlight-mark {
  position: absolute;
  background: #ffe13c66;
  mix-blend-mode: multiply;
  border-bottom: 2px solid #cda611;
  border-radius: 2px;
  pointer-events: none;
}

.cp-modal-footer {
  padding: 10px 20px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cp-footer-note {
  font-size: 0.76rem;
  color: #94a3b8;
}

/* Route Walkthrough Photo Card */
.walkthrough-photo-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.walkthrough-photo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(56, 189, 248, 0.12);
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
}

.walkthrough-photo-body {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
}

.walkthrough-photo-thumb {
  width: 130px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.walkthrough-photo-thumb:hover {
  transform: scale(1.03);
}

.walkthrough-photo-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.walkthrough-photo-caption {
  font-size: 0.84rem;
  color: #f8fafc;
  font-weight: 600;
  line-height: 1.35;
}

.walkthrough-photo-credit {
  font-size: 0.74rem;
  color: #94a3b8;
  font-style: italic;
}

.btn-walkthrough-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  width: fit-content;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-walkthrough-source:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
}

@media (max-width: 900px) {
  .cp-viewer-stage {
    flex-direction: column;
  }
  .cp-media-sidebar {
    width: 100%;
    max-height: 220px;
  }
  .walkthrough-photo-body {
    flex-direction: column;
  }
  .walkthrough-photo-thumb {
    width: 100%;
    height: 140px;
  }
}

/* PWA Network Badge & Update Toast */
.pwa-network-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.pwa-network-badge.offline {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.pwa-network-badge.online {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.pwa-network-badge .badge-sub {
  font-weight: 400;
  opacity: 0.85;
}

.pwa-update-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid #38bdf8;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  animation: pwaSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.85rem;
  color: #f1f5f9;
}

@keyframes pwaSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-reload-btn {
  background: #0284c7;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.toast-reload-btn:hover {
  background: #0369a1;
}

.toast-dismiss-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 6px;
}

.toast-dismiss-btn:hover {
  color: #f1f5f9;
}

/* ============================================================
   LIVE COACH (GPT-LIVE FULL-DUPLEX PILOTAGE COACH)
   ============================================================ */

.btn-live-coach-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(6, 182, 212, 0.18));
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-live-coach-trigger:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(6, 182, 212, 0.3));
  border-color: #34d399;
  color: #ecfdf5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.live-dot-pulse {
  color: #10b981;
  font-size: 0.95rem;
  line-height: 1;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.3); }
}

/* Drawer Shell */
.live-coach-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: #080e1a;
  border-left: 1px solid #1e2d4a;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.75);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.live-coach-drawer[hidden] {
  display: none;
}

/* Header */
.live-coach-header {
  padding: 16px 20px;
  background: #0d1627;
  border-bottom: 1px solid #1a2740;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.live-coach-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #f8fafc;
}

.live-coach-subtitle {
  font-size: 0.78rem;
  color: #38bdf8;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.live-status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #334155;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.live-status-badge.live {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.live-status-badge.connecting {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.live-area-context {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
}

.live-coach-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.live-coach-close-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

/* Subbar: Timer & Modes */
.live-coach-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: #0a1120;
  border-bottom: 1px solid #162238;
  font-size: 0.8rem;
}

.live-timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
}

.live-timer-val {
  font-family: monospace;
  font-weight: 700;
  color: #38bdf8;
  font-size: 0.9rem;
}

.live-limit-label {
  font-size: 0.72rem;
  color: #64748b;
}

.live-mode-selector {
  display: flex;
  gap: 4px;
  background: #060b14;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid #1e293b;
}

.live-mode-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.live-mode-btn.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Visualizer / Banner */
.live-visualizer-container {
  padding: 14px 18px;
  background: linear-gradient(180deg, #091222, #070d18);
  border-bottom: 1px solid #162238;
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-audio-rings {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.live-audio-rings .ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid #0284c7;
  opacity: 0.3;
}

.live-audio-rings .ring-1 { width: 18px; height: 18px; background: #0284c7; opacity: 0.8; }
.live-audio-rings .ring-2 { width: 30px; height: 30px; }
.live-audio-rings .ring-3 { width: 42px; height: 42px; }

.live-coach-drawer.is-live .live-audio-rings .ring-2 {
  animation: rippleRing 2s infinite ease-out;
}
.live-coach-drawer.is-live .live-audio-rings .ring-3 {
  animation: rippleRing 2s infinite ease-out 0.6s;
}

@keyframes rippleRing {
  0% { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.live-coach-message {
  font-size: 0.83rem;
  color: #cbd5e1;
  line-height: 1.4;
}

/* Transcript Feed */
.live-transcript-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.live-intro-card {
  background: #0f1a2e;
  border: 1px solid #1e2d47;
  border-radius: 8px;
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #94a3b8;
}

.live-intro-card h4 {
  margin: 0 0 6px 0;
  color: #38bdf8;
  font-size: 0.95rem;
}

.live-intro-note {
  font-size: 0.74rem;
  color: #64748b;
  margin-top: 8px;
  margin-bottom: 0;
}

.live-turn {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: fadeInTurn 0.2s ease;
}

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

.live-turn.candidate {
  align-self: flex-end;
}

.live-turn.coach {
  align-self: flex-start;
}

.live-turn-speaker {
  font-size: 0.7rem;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-turn.candidate .live-turn-speaker {
  color: #38bdf8;
  text-align: right;
}

.live-turn.coach .live-turn-speaker {
  color: #34d399;
}

.live-turn-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.live-turn.candidate .live-turn-bubble {
  background: #1e293b;
  color: #f1f5f9;
  border-bottom-right-radius: 2px;
  border: 1px solid #334155;
}

.live-turn.coach .live-turn-bubble {
  background: #0d1e38;
  color: #f8fafc;
  border-bottom-left-radius: 2px;
  border: 1px solid #1e3a5f;
}

/* Citations inside turn */
.live-turn-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.live-cit-chip {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.live-cit-chip:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
}

/* Streaming Bubble */
.live-streaming-bubble {
  padding: 8px 16px;
  background: rgba(14, 23, 42, 0.85);
  border-top: 1px dashed #243553;
  font-size: 0.82rem;
  color: #94a3b8;
  font-style: italic;
}

.streaming-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* Footer / Controls */
.live-coach-footer {
  padding: 14px 18px;
  background: #09101d;
  border-top: 1px solid #1a2740;
}

.live-controls-row {
  display: flex;
  gap: 10px;
}

.btn-live-start {
  flex: 1;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.btn-live-start:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
}

.btn-live-mute {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  padding: 11px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-live-mute:hover {
  background: #334155;
  color: white;
}

.btn-live-mute.muted {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #f87171;
}

.btn-live-end {
  flex: 1;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
  padding: 11px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn-live-end:hover {
  background: #dc2626;
  color: white;
}

.live-footer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.72rem;
  color: #64748b;
}

/* Mobile Layout */
@media (max-width: 768px) {
  .live-coach-drawer {
    width: 100vw;
    height: 100vh;
    border-left: none;
  }
}





