/* Kachemak Bay — Free Guided Light Tour Styles */
:root {
  --bg-primary: #070b14;
  --bg-secondary: #0d1527;
  --bg-card: #131f38;
  --bg-card-hover: #1c2c4e;
  --border-color: #233454;
  --border-accent: #334e7a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --accent-gold: #fbbf24;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-top {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-tag {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.header-nav a:hover {
  color: var(--text-main);
  background: var(--bg-card);
  border-color: var(--border-color);
}

.header-nav a.active {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
}

.header-nav a.coach-lock {
  color: var(--accent-gold);
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.08);
}

/* Main Container */
.tour-container {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 85px;
  gap: 12px;
}

/* Mode bar / Exam alert */
.top-notice-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(19, 31, 56, 0.6);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}

.exam-notice {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.exam-notice strong {
  color: var(--accent-gold);
}

.ais-toggle-btn {
  background: transparent;
  border: 1px dashed var(--border-accent);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s;
}

.ais-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.1);
}

/* Mode Switcher */
.mode-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.mode-btn.active {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* Main workspace */
.tour-workspace {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 16px;
  min-height: 520px;
  flex: 1;
}

/* When listen only mode is active */
body.mode-listen .tour-workspace {
  grid-template-columns: 1fr;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

body.mode-listen .chart-pane {
  display: none !important;
}

/* Chart Pane */
.chart-pane {
  background: #09131e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.chart-viewport {
  position: absolute;
  inset: 0;
  background: #d6e2e2;
}

.chart-canvas {
  position: absolute;
  inset: 0;
}

.chart-destination {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 24px);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(7, 24, 32, 0.92);
  color: #f5fbff;
  font-size: 0.8rem;
  font-weight: 500;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 5;
}

.anchor-photo {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 120px;
  padding: 0;
  border: 2px solid #e5f2e8;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #071820;
  color: white;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  z-index: 5;
}

.anchor-photo img {
  display: block;
  width: 100%;
  max-height: 100px;
  object-fit: cover;
}

.anchor-photo span {
  display: block;
  padding: 4px;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}

/* Card Pane */
.card-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-scroll-area {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Card Header */
.card-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chapter-pill {
  background: rgba(37, 99, 235, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(37, 99, 235, 0.4);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.progress-pill {
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.aid-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aid-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

.aid-llnr-badge {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Recall Phase Banner */
.recall-banner {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
}

.recall-banner.phase-listen {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--accent-green);
}

.recall-banner.phase-silence {
  background: rgba(251, 191, 36, 0.16);
  border: 2px solid rgba(251, 191, 36, 0.6);
  color: #fef08a;
  animation: pulse-border 2s infinite ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(251, 191, 36, 0.6); }
  50% { border-color: rgba(251, 191, 36, 1); }
}

.recall-banner .prompt-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recall-banner .prompt-time {
  font-family: monospace;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Draw along specific prompt */
.draw-along-cover {
  background: rgba(13, 21, 39, 0.95);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0;
}

.draw-along-cover h3 {
  font-size: 1.15rem;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
}

.draw-along-cover p {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.peek-facts-btn {
  align-self: center;
  background: transparent;
  border: 1px solid var(--border-accent);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.peek-facts-btn:hover {
  color: var(--text-main);
  border-color: var(--accent-cyan);
}

/* Light rhythm & visual indicator */
.aid-signal-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.light-beacon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.light-beacon .bulb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--beacon-color, #f4f9ff);
  box-shadow: 0 0 12px var(--beacon-color, #f4f9ff);
  transition: opacity 0.15s ease;
}

.light-beacon.flashing .bulb {
  animation: flash-pulse var(--flash-period, 4s) infinite;
}

.light-beacon.still .bulb {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 0 16px var(--beacon-color, #ff656d);
  animation: none;
}

.light-beacon.flashing-quick .bulb {
  animation: flash-quick 1s infinite;
}
@keyframes flash-quick {
  0%, 30% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ff656d); }
  30.1%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.light-beacon.flashing-2-5 .bulb {
  animation: flash-2-5 2.5s infinite;
}
@keyframes flash-2-5 {
  0%, 20% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #f4f9ff); }
  20.1%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.light-beacon.flashing-4 .bulb {
  animation: flash-4 4s infinite;
}
@keyframes flash-4 {
  0%, 18.75% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #f4f9ff); }
  18.76%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.light-beacon.flashing-6 .bulb {
  animation: flash-6 6s infinite;
}
@keyframes flash-6 {
  0%, 16.67% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #f4f9ff); }
  16.68%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.light-beacon.flashing-aoos-20 .bulb {
  animation: flash-aoos-20 20s infinite;
}
@keyframes flash-aoos-20 {
  0%, 2.5% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ffd85f); }
  2.51%, 9.99% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
  10%, 12.5% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ffd85f); }
  12.51%, 19.99% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
  20%, 22.5% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ffd85f); }
  22.51%, 29.99% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
  30%, 32.5% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ffd85f); }
  32.51%, 39.99% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
  40%, 42.5% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #ffd85f); }
  42.51%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.daymark-svg {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.ais-beacon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid rgba(56, 189, 248, 0.6);
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

@keyframes flash-pulse {
  0%, 18% { opacity: 1; transform: scale(1.1); box-shadow: 0 0 16px var(--beacon-color, #f4f9ff); }
  18.1%, 100% { opacity: 0.15; transform: scale(0.9); box-shadow: none; }
}

.signal-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.signal-rhythm {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.signal-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Fact Grid */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.fact-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.fact-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.fact-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-top: 1px;
}

/* Discrepancy Box */
.discrepancy-details {
  margin-top: 8px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-md);
  background: rgba(251, 191, 36, 0.04);
  overflow: hidden;
}

.discrepancy-summary {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--accent-gold);
  font-size: 0.8rem;
  font-weight: 700;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.discrepancy-summary:hover {
  background: rgba(251, 191, 36, 0.08);
}

.discrepancy-details[open] .discrepancy-summary {
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
}

.discrepancy-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  font-size: 0.84rem;
  color: #fef08a;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.discrepancy-card strong {
  color: var(--accent-gold);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.discrepancy-comparison {
  display: flex;
  gap: 16px;
  margin-top: 2px;
}

.disc-val {
  display: flex;
  flex-direction: column;
}

.disc-val span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.disc-val strong {
  font-size: 1rem;
  color: #fff;
}

/* Structure & Remarks */
.detail-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.84rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.detail-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.detail-val {
  color: var(--text-main);
}

/* Sector Layout */
.sector-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 4px;
}

.sector-container h4 {
  font-size: 0.82rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sector-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sector-map {
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  display: block;
}

.sector-explain {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bearing-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-main);
}

.bearing-slider {
  width: 100%;
  cursor: pointer;
}

.sector-result {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
  text-align: center;
}

.sector-result.obscured {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.sector-explain .small {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Card Next Preview */
.card-next-preview {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

.card-next-preview strong {
  color: var(--text-muted);
}

/* Bottom Player Bar */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13, 21, 39, 0.96);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(14px);
  z-index: 90;
  padding: 8px 16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.player-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Scrubber row */
.scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
  min-width: 44px;
}

.time-label.current {
  text-align: right;
  color: var(--text-main);
  font-weight: 600;
}

.time-scrubber {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #1c2c4e;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Controls row */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.left-controls, .center-controls, .right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ctrl-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.ctrl-btn.play-pause {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  min-width: 90px;
  font-size: 0.95rem;
}

.ctrl-btn.play-pause:hover {
  background: #1d4ed8;
}

.chapter-select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.82rem;
  max-width: 200px;
  cursor: pointer;
  min-height: 40px;
}

.speed-btn-group {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.speed-btn {
  background: var(--bg-card);
  border: none;
  border-right: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 38px;
}

.speed-btn:last-child {
  border-right: none;
}

.speed-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.speed-btn.active {
  background: var(--accent-cyan);
  color: #070b14;
  font-weight: 700;
}

/* Modals & Dialogs */
dialog {
  margin: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-accent);
  background: var(--bg-secondary);
  color: var(--text-main);
  padding: 20px;
  max-width: 600px;
  width: 90vw;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.dialog-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

.dialog-close:hover {
  color: #fff;
}

.ais-list-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.ais-list-item h4 {
  color: var(--accent-cyan);
  font-size: 1rem;
  margin-bottom: 4px;
}

.ais-list-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Responsive Rules for Mobile (390x844 & 430x932) */
@media (max-width: 900px) {
  .tour-workspace {
    grid-template-columns: 1fr;
  }
  
  .chart-pane {
    min-height: 320px;
    height: 42vh;
  }
  
  .card-pane {
    min-height: 380px;
  }
  
  .controls-row {
    justify-content: center;
  }
  
  .chapter-select {
    max-width: 150px;
  }
}

@media (max-width: 600px) {
  .tour-container {
    padding: 8px 10px 105px;
  }
  
  .top-notice-bar {
    font-size: 0.76rem;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .top-bar-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .mode-switcher {
    width: 100%;
    display: flex;
  }

  .mode-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 0.78rem;
    justify-content: center;
    min-width: 0;
  }

  .ais-toggle-btn {
    width: 100%;
    text-align: center;
    padding: 6px;
  }
  
  .chart-pane {
    height: 38vh;
    min-height: 250px;
  }
  
  .aid-name {
    font-size: 1.15rem;
  }
  
  .fact-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  
  .controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .left-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
  }

  .right-controls {
    display: flex;
    justify-content: center;
    width: 100%;
  }
  
  .ctrl-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 0.74rem;
    min-height: 38px;
    min-width: 0;
  }

  .ctrl-btn.play-pause {
    flex: 1.4;
  }
  
  .chapter-select {
    display: none; /* Hide chapter dropdown on small screens, use prev/next */
  }
}

/* Chart Aid Pin Marker Overlay */
.chart-aid-marker {
  position: relative;
  pointer-events: none;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 0;
  height: 0;
}

.marker-pulse {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.25);
  border: 2px solid #38bdf8;
  animation: marker-pulse-anim 1.8s infinite ease-out;
}

.marker-center {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 6px #fbbf24;
}

.marker-badge {
  position: absolute;
  top: 14px;
  white-space: nowrap;
  background: rgba(13, 21, 39, 0.94);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #38bdf8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.chart-aid-marker.ais-marker .marker-center {
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 8px #38bdf8;
  border-color: #e0f2fe;
}

.chart-aid-marker.ais-marker .marker-pulse {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.35);
}

.chart-aid-marker.ais-marker .marker-badge {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(8, 47, 73, 0.96);
}

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

/* Draw Along Rehearsal Mode */
body.mode-draw .tour-workspace {
  grid-template-columns: 1.6fr 1fr;
}

body.mode-draw .chart-pane {
  min-height: 520px;
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.12);
}

body.mode-draw .chart-pane::after {
  content: '✏️ DRAW-ALONG REHEARSAL ACTIVE';
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(251, 191, 36, 0.92);
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  z-index: 20;
  pointer-events: none;
}

.draw-controls-bar {
  display: none;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

body.mode-draw .draw-controls-bar {
  display: flex;
}

.draw-step-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.draw-step-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.draw-step-btn.reveal {
  background: var(--accent-gold);
  color: #0f172a;
  border-color: #f59e0b;
  flex: 1.5;
  justify-content: center;
}

.draw-step-btn.reveal:hover {
  background: #f59e0b;
}

.draw-step-btn.restart {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.1);
}

.draw-step-btn.restart:hover {
  color: var(--accent-gold);
}

/* Prompt Banner */
.draw-prompt-banner {
  display: none;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #fef08a;
  line-height: 1.45;
}

body.mode-draw .draw-prompt-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.draw-prompt-banner strong {
  color: #fff;
}

/* Trainer Handoff Links */
.trainer-handoff-bar {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.trainer-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.trainer-link-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-cyan);
  color: #fff;
}

.trainer-link-btn.secondary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-muted);
}

.trainer-link-btn.secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

/* ============================================================
   CHART CONSTRUCTION TRICK / PLOTTING SHORTCUT
   ============================================================ */
.construction-trick-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.construction-trick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.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;
}

.construction-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #f0f9ff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.construction-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.28);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.construction-toggle-btn[aria-pressed="true"] {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.5);
  color: #ffe4e6;
}

.construction-toggle-btn[aria-pressed="true"]:hover {
  background: rgba(244, 63, 94, 0.3);
  border-color: #f43f5e;
}

.construction-trick-details {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-top: 8px;
  line-height: 1.45;
}

.construction-trick-details strong {
  color: #f8fafc;
}

/* OpenSeadragon Overlay Elements */
.chart-construction-badge {
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(244, 63, 94, 0.7);
  border-radius: 6px;
  padding: 5px 9px;
  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.78rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.chart-construction-badge .badge-sub {
  font-size: 0.70rem;
  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.72rem;
  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;
}

