:root {
  color-scheme: dark;
  --ink-950: #020a10;
  --ink-900: #05131d;
  --ink-850: #071a26;
  --ink-800: #0a2230;
  --ink-700: #123444;
  --ink-600: #1f4757;
  --cyan-500: #29d4e3;
  --cyan-400: #5ce8f1;
  --cyan-300: #95f3f7;
  --blue-500: #3b82f6;
  --amber-400: #f5c96a;
  --coral-400: #ff7b78;
  --text: #edf9fb;
  --muted: #93b3bf;
  --quiet: #668794;
  --line: rgba(137, 211, 222, 0.17);
  --line-strong: rgba(92, 232, 241, 0.34);
  --surface: #081a25;
  --surface-raised: #0b2230;
  --surface-soft: #0d2836;
  --shadow-lg: 0 20px 52px rgba(0, 7, 13, 0.42);
  --shadow-md: 0 12px 30px rgba(0, 7, 13, 0.28);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --header-height: 66px;
  --panel-width: clamp(340px, 32vw, 468px);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--ink-950);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 14% -12%, rgba(24, 127, 151, 0.2), transparent 38%),
    var(--ink-950);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: var(--cyan-400);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--cyan-300);
}

svg,
canvas,
video,
img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#app,
.app,
.app-shell {
  width: 100%;
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.site-header,
.app-header,
.topbar {
  z-index: 50;
  display: flex;
  min-width: 0;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(16px, 2.5vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 17, 25, 0.98);
}

.brand,
.brand-lockup,
.site-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark,
.logo-mark {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(92, 232, 241, 0.4);
  border-radius: 11px;
  color: var(--cyan-300);
  background: linear-gradient(145deg, #0d3d4b, #071a25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.brand-mark::after,
.logo-mark::after {
  position: absolute;
  right: -7px;
  bottom: 7px;
  width: 28px;
  height: 8px;
  border-top: 1px solid currentColor;
  border-radius: 50%;
  content: "";
  transform: rotate(-12deg);
}

.brand-copy,
.title-copy {
  min-width: 0;
}

.brand-title,
.site-name {
  overflow: hidden;
  margin: 0;
  font-size: clamp(0.92rem, 1.4vw, 1.06rem);
  font-weight: 690;
  letter-spacing: 0.015em;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-kicker,
.site-kicker {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.header-actions,
.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.btn,
.icon-button,
.header-button,
.map-control-button,
.tab-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  cursor: pointer;
  transition:
    border-color 140ms var(--ease-out),
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    transform 140ms var(--ease-out);
}

.button,
.btn,
.header-button {
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 650;
}

.icon-button,
.map-control-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.button:hover,
.btn:hover,
.icon-button:hover,
.header-button:hover,
.map-control-button:hover,
.tab-button:hover {
  border-color: var(--line-strong);
  background: #10303f;
}

.button:active,
.btn:active,
.icon-button:active,
.header-button:active,
.map-control-button:active,
.tab-button:active {
  transform: translateY(1px);
}

.button.primary,
.btn-primary,
.button--primary {
  border-color: rgba(92, 232, 241, 0.55);
  color: #001217;
  background: var(--cyan-400);
}

.button.primary:hover,
.btn-primary:hover,
.button--primary:hover {
  background: var(--cyan-300);
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid rgba(92, 232, 241, 0.48);
  outline-offset: 2px;
}

.workspace,
.main-grid,
.experience,
.dashboard {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
  overflow: hidden;
}

.map-panel,
.map-stage,
.map-shell,
.map-view {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #062330;
  isolation: isolate;
}

.map-panel::after,
.map-stage::after,
.map-shell::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  border: 1px solid rgba(155, 236, 243, 0.06);
  box-shadow: inset 0 0 76px rgba(0, 8, 14, 0.24);
  content: "";
  pointer-events: none;
}

#map,
.ocean-map,
.map-canvas,
.map-container {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 48% 42%, rgba(41, 212, 227, 0.11), transparent 35%),
    linear-gradient(145deg, #0a4150 0%, #062937 42%, #041923 100%);
  touch-action: pan-x pan-y;
}

.map-overlay,
.map-ui {
  position: absolute;
  z-index: 10;
  inset: 0;
  pointer-events: none;
}

.map-overlay > *,
.map-ui > * {
  pointer-events: auto;
}

.map-toolbar,
.map-controls {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  max-width: calc(100% - 36px);
  flex-wrap: wrap;
  gap: 8px;
}

.map-toolbar.right,
.map-controls.right,
.map-controls--right {
  right: 18px;
  left: auto;
  flex-direction: column;
}

.map-control,
.scale-control,
.coordinate-readout,
.map-hint,
.map-status,
.location-card {
  border: 1px solid rgba(150, 226, 236, 0.19);
  border-radius: 12px;
  color: var(--text);
  background: rgba(5, 24, 34, 0.96);
  box-shadow: var(--shadow-md);
}

.map-control,
.scale-control,
.coordinate-readout,
.map-status {
  padding: 9px 11px;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  line-height: 1.2;
}

.scale-control {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 112px;
  padding-top: 7px;
  text-align: center;
}

.scale-control::before {
  display: block;
  width: 100%;
  height: 6px;
  margin-bottom: 4px;
  border-right: 1px solid var(--cyan-300);
  border-bottom: 2px solid var(--cyan-300);
  border-left: 1px solid var(--cyan-300);
  content: "";
}

.map-hint,
.location-card {
  position: absolute;
  bottom: 18px;
  left: 18px;
  max-width: min(420px, calc(100% - 164px));
  padding: 13px 15px;
}

.map-hint strong,
.location-card strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 0.84rem;
}

.map-hint span,
.location-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.source-marker,
.map-source-marker {
  position: relative;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--coral-400);
  box-shadow:
    0 0 0 5px rgba(255, 123, 120, 0.22),
    0 5px 14px rgba(0, 0, 0, 0.38);
}

.source-marker::after,
.map-source-marker::after {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 2px;
  height: 12px;
  background: rgba(255, 255, 255, 0.78);
  content: "";
  transform: translateX(-50%);
}

.maplibregl-map {
  font-family: inherit;
}

.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right {
  top: 10px;
}

.maplibregl-ctrl-top-left {
  left: 10px;
}

.maplibregl-ctrl-top-right {
  right: 10px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid rgba(150, 226, 236, 0.2) !important;
  border-radius: 11px !important;
  background: #081f2b !important;
  box-shadow: var(--shadow-md) !important;
}

.maplibregl-ctrl-group button {
  width: 42px !important;
  height: 42px !important;
  border-color: var(--line) !important;
  background-color: #081f2b !important;
}

.maplibregl-ctrl-group button:hover {
  background-color: #10303f !important;
}

.maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: invert(92%) sepia(13%) saturate(506%) hue-rotate(146deg) brightness(105%);
}

.maplibregl-ctrl-attrib {
  color: #648894;
  background: rgba(3, 16, 23, 0.86) !important;
}

.maplibregl-ctrl-attrib a {
  color: #8eb4bf;
}

.maplibregl-popup-content {
  padding: 12px 14px !important;
  border: 1px solid var(--line-strong);
  border-radius: 12px !important;
  color: var(--text);
  background: #071c27 !important;
  box-shadow: var(--shadow-md) !important;
}

.maplibregl-popup-tip {
  border-top-color: #071c27 !important;
  border-bottom-color: #071c27 !important;
}

.side-panel,
.analysis-panel,
.inspector,
.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  border-left: 1px solid var(--line);
  background: var(--ink-900);
  overscroll-behavior: contain;
  scrollbar-color: var(--ink-600) transparent;
  scrollbar-width: thin;
}

.side-panel::-webkit-scrollbar,
.analysis-panel::-webkit-scrollbar,
.inspector::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 7px;
}

.side-panel::-webkit-scrollbar-thumb,
.analysis-panel::-webkit-scrollbar-thumb,
.inspector::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  border-radius: 9px;
  background: var(--ink-600);
}

.panel-card,
.card,
.chart-card,
.control-card,
.lesson-card,
.explainer-card {
  min-width: 0;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 7, 12, 0.15);
}

.panel-card,
.card,
.control-card,
.lesson-card,
.explainer-card {
  padding: 15px;
}

.card-header,
.panel-heading,
.chart-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.card-title,
.panel-title,
.chart-title {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 690;
  letter-spacing: 0.012em;
  line-height: 1.25;
}

.card-kicker,
.eyebrow,
.chart-kicker {
  display: block;
  margin: 0 0 4px;
  color: var(--cyan-400);
  font-size: 0.64rem;
  font-weight: 740;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.card-meta,
.panel-meta,
.chart-meta {
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
}

.badge,
.chip,
.pill,
.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(17, 50, 64, 0.58);
  font-size: 0.65rem;
  font-weight: 690;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge.accent,
.chip.active,
.status-badge.active {
  border-color: rgba(92, 232, 241, 0.36);
  color: var(--cyan-300);
  background: rgba(31, 142, 158, 0.2);
}

.chart-card,
.ssp-card,
.ray-card,
.ray-panel {
  overflow: hidden;
}

.chart-card > .card-header,
.ssp-card > .card-header,
.ray-card > .card-header,
.ray-panel > .card-header {
  padding: 14px 15px 0;
}

.chart,
.chart-wrap,
.ssp-chart,
.ray-chart,
.ray-cross-section,
.plot {
  position: relative;
  width: 100%;
  min-height: 190px;
  overflow: hidden;
  color: var(--muted);
  background:
    linear-gradient(rgba(102, 158, 173, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 158, 173, 0.08) 1px, transparent 1px),
    #061721;
  background-position: -1px -1px;
  background-size: 34px 34px;
}

.ssp-chart,
.ssp-plot {
  min-height: 212px;
}

.ray-chart,
.ray-cross-section,
.ray-plot {
  min-height: 226px;
}

.chart svg,
.chart canvas,
.chart-wrap svg,
.chart-wrap canvas,
.ssp-chart svg,
.ssp-chart canvas,
.ray-chart svg,
.ray-chart canvas,
.ray-cross-section svg,
.ray-cross-section canvas,
.plot svg,
.plot canvas {
  width: 100%;
  height: 100%;
}

.chart text,
.axis text,
.tick text,
.axis-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.axis path,
.axis line,
.grid line,
.gridline {
  stroke: rgba(137, 211, 222, 0.17);
  shape-rendering: crispEdges;
}

.ssp-line {
  fill: none;
  stroke: var(--cyan-400);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4px;
  vector-effect: non-scaling-stroke;
}

.ssp-axis-marker,
.channel-axis-marker {
  fill: var(--amber-400);
  stroke: #08141b;
  stroke-width: 1.5px;
}

.sound-ray,
.ray-path {
  fill: none;
  stroke: rgba(91, 230, 239, 0.72);
  stroke-linecap: round;
  stroke-width: 1.15px;
  vector-effect: non-scaling-stroke;
}

.sound-ray.secondary,
.ray-path.secondary {
  stroke: rgba(84, 144, 246, 0.52);
}

.bottom-line,
.bathymetry-line {
  fill: rgba(38, 49, 51, 0.92);
  stroke: rgba(245, 201, 106, 0.7);
  stroke-width: 1.3px;
  vector-effect: non-scaling-stroke;
}

.sea-surface-line {
  stroke: rgba(153, 243, 247, 0.7);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.chart-legend,
.legend {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(137, 211, 222, 0.1);
  color: var(--muted);
  font-size: 0.68rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.control-grid,
.parameter-grid,
.scenario-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.control-group,
.field,
.parameter {
  min-width: 0;
}

.control-group.full,
.field.full,
.parameter.full {
  grid-column: 1 / -1;
}

.control-label,
.field-label,
.parameter-label,
label.control-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 660;
  letter-spacing: 0.02em;
}

.control-value,
.field-value,
.parameter-value,
output {
  color: var(--cyan-300);
  font-variant-numeric: tabular-nums;
  font-weight: 690;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--text);
  background: #071923;
}

select:hover,
input[type="number"]:hover,
input[type="text"]:hover {
  border-color: var(--line-strong);
}

input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  accent-color: var(--cyan-400);
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan-500), #244a5a);
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 3px solid #08202b;
  border-radius: 50%;
  background: var(--cyan-300);
  box-shadow: 0 0 0 1px rgba(92, 232, 241, 0.62);
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: #244a5a;
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--cyan-500);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #08202b;
  border-radius: 50%;
  background: var(--cyan-300);
  box-shadow: 0 0 0 1px rgba(92, 232, 241, 0.62);
}

.segmented-control,
.view-tabs,
.chart-tabs {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #061721;
}

.segmented-control button,
.view-tabs button,
.chart-tabs button,
.tab-button {
  min-height: 36px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.7rem;
  font-weight: 680;
}

.segmented-control button[aria-pressed="true"],
.view-tabs button[aria-selected="true"],
.chart-tabs button[aria-selected="true"],
.tab-button.active,
.tab-button[aria-selected="true"] {
  color: var(--text);
  background: #123342;
  box-shadow: inset 0 0 0 1px rgba(92, 232, 241, 0.22);
}

.explainer,
.explainer-panel,
.lesson-copy {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.58;
}

.explainer p,
.explainer-panel p,
.lesson-copy p {
  margin: 0 0 10px;
}

.explainer p:last-child,
.explainer-panel p:last-child,
.lesson-copy p:last-child {
  margin-bottom: 0;
}

.callout,
.science-note,
.teaching-note {
  padding: 11px 12px;
  border-left: 3px solid var(--cyan-500);
  border-radius: 0 9px 9px 0;
  color: #bdd3da;
  background: rgba(24, 89, 103, 0.17);
  font-size: 0.73rem;
  line-height: 1.48;
}

.callout.warning,
.science-note.warning {
  border-left-color: var(--amber-400);
  background: rgba(130, 93, 31, 0.15);
}

.mobile-tabs,
.bottom-tabs,
.sheet-handle {
  display: none;
}

.modal,
.dialog-layer {
  position: fixed;
  z-index: 200;
  display: grid;
  inset: 0;
  place-items: center;
  padding: 24px;
}

.modal-backdrop,
.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 7, 12, 0.82);
}

.modal-dialog,
.dialog,
.video-modal {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--ink-900);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}

.modal-dialog.narrow,
.dialog.narrow {
  width: min(600px, 100%);
}

.modal-header,
.dialog-header {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title,
.dialog-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.modal-close,
.dialog-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  cursor: pointer;
}

.modal-body,
.dialog-body {
  padding: 20px;
}

.video-frame,
.video-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-frame video,
.video-frame iframe,
.video-wrap video,
.video-wrap iframe {
  position: absolute;
  width: 100%;
  height: 100%;
  inset: 0;
  border: 0;
  object-fit: contain;
}

.video-caption,
.modal-copy {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.tooltip,
[role="tooltip"] {
  z-index: 220;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #04131c;
  box-shadow: var(--shadow-md);
  font-size: 0.7rem;
  line-height: 1.4;
  pointer-events: none;
}

.site-credit,
.authorship,
.footer-credit {
  color: var(--quiet);
  font-size: 0.66rem;
  line-height: 1.35;
}

@media (max-width: 1080px) {
  :root {
    --panel-width: clamp(320px, 37vw, 410px);
  }

  .side-panel,
  .analysis-panel,
  .inspector,
  .sidebar {
    padding: 11px;
  }

  .control-grid,
  .parameter-grid,
  .scenario-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .control-group.full,
  .field.full,
  .parameter.full {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  :root {
    --header-height: 58px;
  }

  body {
    min-height: 100vh;
    overflow: hidden;
  }

  .app-shell {
    min-height: 100vh;
    height: 100vh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .site-header,
  .app-header,
  .topbar {
    gap: 10px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .brand-mark,
  .logo-mark {
    width: 33px;
    height: 33px;
    border-radius: 10px;
  }

  .brand-kicker,
  .site-kicker {
    display: none;
  }

  .header-actions .button-label,
  .topbar-actions .button-label,
  .header-button .button-label {
    display: none;
  }

  .header-actions .header-button,
  .topbar-actions .header-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .app-shell.panel-expanded {
    --mobile-drawer-height: var(--mobile-drawer-expanded-height);
  }

  .workspace,
  .main-grid,
  .experience,
  .dashboard {
    display: block;
    height: 100%;
  }

  .map-panel,
  .map-stage,
  .map-shell,
  .map-view {
    position: absolute;
    inset: 0;
  }

  .side-panel,
  .analysis-panel,
  .inspector,
  .sidebar,
  .bottom-sheet {
    position: absolute;
    z-index: 40;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0));
    left: 8px;
    display: flex;
    width: auto;
    max-height: min(48vh, 440px);
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0));
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: #061721;
    box-shadow: 0 -10px 38px rgba(0, 8, 14, 0.42);
    transform: translateZ(0);
  }

  .side-panel.collapsed,
  .analysis-panel.collapsed,
  .inspector.collapsed,
  .sidebar.collapsed,
  .bottom-sheet.collapsed {
    max-height: 82px;
    overflow: hidden;
  }

  .sheet-handle {
    display: block;
    width: 44px;
    height: 4px;
    flex: 0 0 auto;
    margin: 0 auto 4px;
    border-radius: 999px;
    background: #365867;
  }

  .mobile-tabs,
  .bottom-tabs {
    position: sticky;
    z-index: 3;
    top: -10px;
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    margin: -2px -2px 1px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #071b26;
  }

  .mobile-tabs button,
  .bottom-tabs button {
    min-width: 0;
    min-height: 38px;
    padding: 0 5px;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-size: 0.66rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-tabs button[aria-selected="true"],
  .bottom-tabs button[aria-selected="true"],
  .mobile-tabs button.active,
  .bottom-tabs button.active {
    color: var(--text);
    background: #123442;
    box-shadow: inset 0 0 0 1px rgba(92, 232, 241, 0.21);
  }

  .mobile-tab-panel[hidden] {
    display: none !important;
  }

  .panel-card,
  .card,
  .control-card,
  .lesson-card,
  .explainer-card {
    padding: 13px;
  }

  .ssp-chart,
  .ssp-plot {
    min-height: 188px;
  }

  .ray-chart,
  .ray-cross-section,
  .ray-plot {
    min-height: 202px;
  }

  .map-toolbar,
  .map-controls {
    top: 12px;
    left: 12px;
    max-width: calc(100% - 24px);
  }

  .map-toolbar.right,
  .map-controls.right,
  .map-controls--right {
    right: 12px;
    left: auto;
  }

  .map-hint,
  .location-card {
    top: 12px;
    bottom: auto;
    left: 12px;
    max-width: min(330px, calc(100% - 78px));
    padding: 10px 12px;
  }

  .scale-control {
    right: 12px;
    bottom: min(51vh, 464px);
  }

  .modal,
  .dialog-layer {
    align-items: end;
    padding: 10px 8px calc(8px + env(safe-area-inset-bottom, 0));
  }

  .modal-dialog,
  .dialog,
  .video-modal,
  .modal-dialog.narrow,
  .dialog.narrow {
    width: 100%;
    max-height: calc(100vh - 20px - env(safe-area-inset-top, 0));
    border-radius: 18px;
  }

  .modal-body,
  .dialog-body {
    padding: 15px;
  }
}

@media (max-width: 480px) {
  .brand-title,
  .site-name {
    max-width: 172px;
    font-size: 0.86rem;
  }

  .header-actions,
  .topbar-actions {
    gap: 5px;
  }

  .map-hint span,
  .location-card span {
    display: none;
  }

  .map-hint,
  .location-card {
    padding: 9px 11px;
  }

  .side-panel,
  .analysis-panel,
  .inspector,
  .sidebar,
  .bottom-sheet {
    right: 5px;
    bottom: calc(5px + env(safe-area-inset-bottom, 0));
    left: 5px;
    max-height: min(52vh, 430px);
    border-radius: 16px;
  }

  .scale-control {
    bottom: min(55vh, 454px);
  }

  .card-meta,
  .panel-meta,
  .chart-meta {
    font-size: 0.64rem;
  }
}

@supports (height: 100dvh) {
  .app-shell,
  #app,
  .app {
    min-height: 100dvh;
    height: 100dvh;
  }

  @media (max-width: 820px) {
    .modal-dialog,
    .dialog,
    .video-modal,
    .modal-dialog.narrow,
    .dialog.narrow {
      max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0));
    }
  }
}

/* Final cascade: one stowable teaching drawer on desktop and mobile. */
.app-shell {
  --mobile-drawer-height: 62px;
  --mobile-drawer-expanded-height: min(58vh, 560px);
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.app-shell.panel-expanded {
  --mobile-drawer-height: var(--mobile-drawer-expanded-height);
}

.map-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.learning-panel {
  position: absolute;
  z-index: 50;
  top: auto;
  right: auto;
  bottom: calc(10px + env(safe-area-inset-bottom, 0));
  left: 50%;
  display: grid;
  width: min(1120px, calc(100% - 24px));
  height: var(--mobile-drawer-height);
  max-height: none;
  grid-template-rows: 60px 0 minmax(0, 0);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  background: #061721;
  box-shadow: 0 -12px 40px rgba(0, 8, 14, 0.45);
  transform: translateX(-50%);
  transition: height 190ms var(--ease-out);
}

.learning-panel.is-expanded {
  height: var(--mobile-drawer-expanded-height);
  grid-template-rows: 60px auto minmax(0, 1fr);
}

.learning-panel::before {
  display: none;
  content: none;
}

.panel-drawer-toggle {
  z-index: 5;
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  align-items: center;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid transparent;
  color: var(--text);
  background: linear-gradient(180deg, #0b2b39, #071d28);
  cursor: pointer;
  text-align: left;
}

.learning-panel.is-expanded .panel-drawer-toggle {
  border-bottom-color: var(--line);
}

.panel-drawer-toggle:hover,
.panel-drawer-toggle:focus-visible {
  background: linear-gradient(180deg, #103946, #092530);
}

.panel-drawer-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.panel-drawer-copy .eyebrow {
  margin: 0;
  font-size: 0.52rem;
}

.panel-drawer-copy strong {
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-drawer-state {
  color: var(--cyan-300);
  font-size: 0.65rem;
  font-weight: 710;
  white-space: nowrap;
}

.panel-drawer-chevron {
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--cyan-300);
  border-left: 2px solid var(--cyan-300);
  transform: translateY(3px) rotate(45deg);
  transition: transform 190ms var(--ease-out);
}

.learning-panel.is-expanded .panel-drawer-chevron {
  transform: translateY(-3px) rotate(225deg);
}

.panel-tabs {
  grid-column: 1;
  grid-row: 2;
  padding: 7px;
}

.panel-scroll {
  grid-column: 1;
  grid-row: 3;
}

.learning-panel:not(.is-expanded) .panel-tabs,
.learning-panel:not(.is-expanded) .panel-scroll {
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.scale-control,
.map-legend,
.plot-button {
  bottom: calc(var(--mobile-drawer-height) + 22px + env(safe-area-inset-bottom, 0));
  transition: bottom 190ms var(--ease-out);
}

.plot-button:not(:disabled) {
  border-color: rgba(149, 243, 247, 0.92);
  box-shadow:
    0 0 0 3px rgba(92, 232, 241, 0.16),
    0 12px 30px rgba(0, 7, 13, 0.42);
}

.plot-icon {
  display: none;
}

@media (max-width: 820px) {
  .app-shell {
    --mobile-drawer-expanded-height: min(64dvh, 560px);
  }

  .learning-panel {
    top: auto;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0));
    left: 6px;
    width: auto;
    transform: none;
  }

  .scale-control,
  .map-legend,
  .plot-button {
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
  }
}

@media (max-width: 520px) {
  .plot-button {
    min-width: 116px;
    justify-content: center;
    padding: 0 11px;
    font-size: 0.64rem;
  }
}

/* Unified teaching drawer: the map owns the viewport on every screen size. */
.app-shell {
  --mobile-drawer-height: 62px;
  --mobile-drawer-expanded-height: min(58vh, 560px);
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.app-shell.panel-expanded {
  --mobile-drawer-height: var(--mobile-drawer-expanded-height);
}

.map-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.learning-panel {
  position: absolute;
  z-index: 50;
  right: auto;
  bottom: calc(10px + env(safe-area-inset-bottom, 0));
  left: 50%;
  display: grid;
  width: min(1120px, calc(100% - 24px));
  height: var(--mobile-drawer-height);
  max-height: none;
  grid-template-rows: 60px 0 minmax(0, 0);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  background: #061721;
  box-shadow: 0 -12px 40px rgba(0, 8, 14, 0.45);
  transform: translateX(-50%);
  transition: height 190ms var(--ease-out);
}

.learning-panel.is-expanded {
  height: var(--mobile-drawer-expanded-height);
  grid-template-rows: 60px auto minmax(0, 1fr);
}

.learning-panel::before {
  display: none;
  content: none;
}

.panel-drawer-toggle {
  z-index: 5;
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 60px;
  align-items: center;
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: minmax(0, 1fr) auto 20px;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid transparent;
  color: var(--text);
  background: linear-gradient(180deg, #0b2b39, #071d28);
  cursor: pointer;
  text-align: left;
}

.learning-panel.is-expanded .panel-drawer-toggle {
  border-bottom-color: var(--line);
}

.panel-drawer-toggle:hover,
.panel-drawer-toggle:focus-visible {
  background: linear-gradient(180deg, #103946, #092530);
}

.panel-drawer-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.panel-drawer-copy .eyebrow {
  margin: 0;
  font-size: 0.52rem;
}

.panel-drawer-copy strong {
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-drawer-state {
  color: var(--cyan-300);
  font-size: 0.65rem;
  font-weight: 710;
  white-space: nowrap;
}

.panel-drawer-chevron {
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--cyan-300);
  border-left: 2px solid var(--cyan-300);
  transform: translateY(3px) rotate(45deg);
  transition: transform 190ms var(--ease-out);
}

.learning-panel.is-expanded .panel-drawer-chevron {
  transform: translateY(-3px) rotate(225deg);
}

.panel-tabs {
  grid-column: 1;
  grid-row: 2;
  padding: 7px;
}

.panel-scroll {
  grid-column: 1;
  grid-row: 3;
}

.learning-panel:not(.is-expanded) .panel-tabs,
.learning-panel:not(.is-expanded) .panel-scroll {
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.scale-control,
.map-legend,
.plot-button {
  bottom: calc(var(--mobile-drawer-height) + 22px + env(safe-area-inset-bottom, 0));
  transition: bottom 190ms var(--ease-out);
}

.plot-button:not(:disabled) {
  border-color: rgba(149, 243, 247, 0.92);
  box-shadow:
    0 0 0 3px rgba(92, 232, 241, 0.16),
    0 12px 30px rgba(0, 7, 13, 0.42);
}

.plot-icon {
  display: none;
}

.about-section {
  margin: 14px 0;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(10, 42, 55, 0.44);
}

.about-section > .eyebrow {
  margin: 0 0 5px;
}

.about-section p {
  margin: 4px 0;
}

.source-citation {
  margin-top: 10px !important;
  color: var(--quiet) !important;
  font-size: 0.67rem !important;
  line-height: 1.45 !important;
}

@media (max-width: 820px) {
  .app-shell {
    --mobile-drawer-expanded-height: min(64dvh, 560px);
  }

  .learning-panel {
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0));
    left: 6px;
    width: auto;
    transform: none;
  }

  .scale-control,
  .map-legend,
  .plot-button {
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
  }
}

@media (max-width: 520px) {
  .plot-button {
    min-width: 116px;
    justify-content: center;
    padding: 0 11px;
    font-size: 0.64rem;
  }
}

/* Real-data, lesson-video, and deployment additions. */
.map-provenance {
  position: absolute;
  z-index: 20;
  right: 18px;
  bottom: 72px;
  padding: 5px 8px;
  border: 1px solid rgba(137, 211, 222, 0.14);
  border-radius: 7px;
  color: rgba(205, 229, 234, 0.7);
  background: rgba(3, 15, 22, 0.78);
  font-size: 0.56rem;
  line-height: 1;
  text-decoration: none;
}

.map-provenance:hover {
  color: var(--cyan-300);
}

.map-prompt.is-error {
  border-color: rgba(255, 160, 116, 0.46);
  color: #ffd8c4;
}

.map-prompt.is-error .prompt-pulse {
  background: #ff9a6b;
  box-shadow: 0 0 0 4px rgba(255, 154, 107, 0.14);
}

.map-status.is-synthetic .eyebrow {
  color: #ffb77b;
}

.compact-control > label {
  margin: 0;
}

.control-row select {
  min-height: 36px;
  max-width: 180px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #0a2431;
  font: inherit;
  font-size: 0.68rem;
}

.control-row select:focus-visible {
  outline: 2px solid var(--cyan-300);
  outline-offset: 2px;
}

.control-note {
  margin: -7px 0 0;
  color: var(--quiet);
  font-size: 0.57rem;
  line-height: 1.45;
}

.lesson-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #020b10;
}

.lesson-video[hidden] {
  display: none;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.creator-line {
  display: grid;
  gap: 4px;
  line-height: 1.35;
}

.creator-role-line {
  color: var(--muted);
  font-weight: 620;
}

.resource-links a {
  color: var(--cyan-300);
  font-size: 0.76rem;
}

@media (max-width: 820px) {
  .map-provenance {
    display: none;
  }

  .control-row select {
    max-width: 156px;
  }
}

/* Leaflet source, ring labels, and the two lesson illustrations. */
.ship-marker-wrap {
  border: 0;
  background: transparent;
}

.ship-marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid rgba(237, 249, 251, 0.92);
  border-radius: 50%;
  color: var(--coral-400);
  background: #09202b;
  box-shadow:
    0 0 0 5px rgba(255, 123, 120, 0.2),
    0 7px 18px rgba(0, 5, 9, 0.44);
}

.ship-marker svg {
  width: 28px;
  height: 28px;
  overflow: visible;
}

.ship-hull,
.ship-deck {
  fill: currentColor;
}

.ship-deck {
  fill: #eafafd;
}

.ship-mast {
  fill: none;
  stroke: #eafafd;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6px;
}

.pending-marker-wrap {
  border: 0;
  background: transparent;
}

.pending-marker {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--cyan-300);
  border-radius: 50%;
  background: rgba(3, 18, 26, 0.72);
  box-shadow:
    0 0 0 6px rgba(92, 232, 241, 0.18),
    0 7px 18px rgba(0, 5, 9, 0.44);
}

.pending-marker::before,
.pending-marker::after {
  position: absolute;
  background: var(--cyan-300);
  content: "";
}

.pending-marker::before {
  width: 18px;
  height: 2px;
}

.pending-marker::after {
  width: 2px;
  height: 18px;
}

.pending-marker i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(149, 243, 247, 0.9);
}

.map-ring {
  filter: drop-shadow(0 0 3px rgba(0, 8, 13, 0.9));
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ring-tooltip {
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: #071c27;
  box-shadow: var(--shadow-md);
  font-size: 0.66rem;
  font-weight: 680;
}

.ring-tooltip::before {
  border-top-color: #071c27;
}

.lesson-profile-stack {
  display: grid;
  min-height: 210px;
  grid-template-columns: minmax(66px, 1fr) auto minmax(66px, 1fr) auto minmax(66px, 1fr) auto minmax(76px, 1.1fr);
  align-items: center;
  gap: 8px;
  padding: 18px;
}

.lesson-curve {
  display: grid;
  min-width: 0;
  min-height: 124px;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 10px;
  padding: 12px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(4, 20, 28, 0.76);
}

.lesson-curve i {
  position: relative;
  display: block;
  width: 44px;
  height: 76px;
  overflow: hidden;
}

.lesson-curve i::before {
  position: absolute;
  top: 3px;
  right: 8px;
  bottom: 3px;
  left: 8px;
  border-right: 3px solid currentColor;
  border-radius: 54% 20% 62% 32%;
  content: "";
  transform: skewX(-12deg);
}

.lesson-curve b {
  overflow: hidden;
  max-width: 100%;
  color: currentColor;
  font-size: 0.59rem;
  font-weight: 720;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
}

.lesson-temperature {
  color: #ffaaa7;
}

.lesson-temperature i::before {
  border-radius: 25% 62% 25% 58%;
  transform: skewX(10deg);
}

.lesson-salinity {
  color: var(--cyan-300);
}

.lesson-salinity i::before {
  border-radius: 62% 22% 55% 18%;
  transform: skewX(-5deg);
}

.lesson-pressure {
  color: #f9dd99;
}

.lesson-pressure i::before {
  border-radius: 0;
  transform: rotate(13deg);
}

.lesson-speed {
  border-color: rgba(92, 232, 241, 0.4);
  color: var(--cyan-300);
  background: rgba(25, 100, 115, 0.2);
}

.lesson-plus,
.lesson-equals {
  color: var(--quiet);
  font-size: 1.05rem;
  font-weight: 500;
}

.lesson-equals {
  color: var(--cyan-400);
  font-size: 1.35rem;
}

.memory-line {
  padding: 10px 11px;
  border: 1px solid rgba(92, 232, 241, 0.18);
  border-radius: 9px;
  background: rgba(26, 103, 116, 0.12);
}

.lesson-ray-scene {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(39, 153, 174, 0.13), rgba(2, 12, 18, 0.08)),
    linear-gradient(0deg, rgba(112, 88, 48, 0.38) 0 16%, transparent 16%);
}

.lesson-source {
  position: absolute;
  z-index: 3;
  top: 38%;
  left: 8%;
  width: 15px;
  height: 15px;
  border: 3px solid #f3fbfd;
  border-radius: 50%;
  background: var(--coral-400);
  box-shadow: 0 0 0 5px rgba(255, 123, 120, 0.16);
}

.lesson-axis {
  position: absolute;
  z-index: 1;
  top: 58%;
  right: 7%;
  left: 7%;
  border-top: 1px dashed rgba(245, 201, 106, 0.68);
}

.lesson-axis::after {
  position: absolute;
  top: 5px;
  right: 0;
  color: #e6c77c;
  content: "slower water / channel axis";
  font-size: 0.56rem;
  font-style: normal;
}

.lesson-ray {
  position: absolute;
  z-index: 2;
  left: 10%;
  width: 82%;
  height: 76px;
  border-top: 2px solid var(--cyan-400);
  border-radius: 50%;
}

.ray-one {
  top: 38%;
  transform: rotate(1deg);
}

.ray-two {
  top: 29%;
  border-top-color: #a4f6fa;
  transform: rotate(6deg);
}

.ray-three {
  top: 49%;
  border-top-color: var(--blue-500);
  transform: rotate(-5deg);
}

@media (max-width: 520px) {
  .lesson-profile-stack {
    min-height: 175px;
    gap: 4px;
    padding: 10px 6px;
  }

  .lesson-curve {
    min-height: 108px;
    padding: 9px 2px 7px;
  }

  .lesson-curve i {
    width: 31px;
    height: 64px;
  }

  .lesson-curve b {
    font-size: 0.49rem;
  }

  .lesson-plus {
    font-size: 0.8rem;
  }

  .lesson-equals {
    font-size: 1.05rem;
  }

  .lesson-ray-scene {
    min-height: 175px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #c2dce3;
    --quiet: #9bbbc5;
    --line: rgba(180, 241, 247, 0.36);
    --line-strong: rgba(180, 241, 247, 0.68);
  }
}

/* --------------------------------------------------------------------------
   Sound Below markup contract
   -------------------------------------------------------------------------- */

body {
  display: grid;
  height: 100vh;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
}

.skip-link {
  position: fixed;
  z-index: 500;
  top: 8px;
  left: 12px;
  padding: 10px 13px;
  border-radius: 9px;
  color: #001217;
  background: var(--cyan-300);
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  grid-row: 1;
}

.brand-lockup h1 {
  overflow: hidden;
  margin: 1px 0 0;
  color: var(--text);
  font-size: clamp(1rem, 1.7vw, 1.24rem);
  font-weight: 720;
  letter-spacing: -0.018em;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup > div:last-child {
  min-width: 0;
}

.brand-lockup .eyebrow {
  margin-bottom: 3px;
  color: var(--cyan-400);
  font-size: 0.61rem;
}

.header-credit {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--quiet);
  font-size: 0.56rem;
  letter-spacing: 0.025em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark svg {
  width: 29px;
  height: 29px;
}

.brand-mark svg path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.lesson-chip {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 11px 0 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 670;
  transition:
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    background-color 140ms var(--ease-out);
}

.lesson-chip span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 8px;
  color: var(--cyan-300);
  background: rgba(41, 212, 227, 0.12);
  font-size: 0.61rem;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.lesson-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(15, 48, 62, 0.55);
}

.app-shell {
  grid-row: 2;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(540px, 41vw, 680px);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.map-stage {
  grid-column: 1;
  grid-row: 1;
}

.map-stage #map {
  cursor: crosshair;
}

.leaflet-container {
  color: var(--text);
  background: #082633;
  font-family: inherit;
}

.leaflet-tile-pane {
  filter: none;
}

.leaflet-control-attribution {
  padding: 2px 5px !important;
  color: #7998a2 !important;
  background: rgba(3, 15, 22, 0.9) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a {
  color: #9bc4cc !important;
}

.leaflet-tooltip,
.leaflet-popup-content-wrapper {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: #071c27;
  box-shadow: var(--shadow-md);
}

.leaflet-popup-tip {
  background: #071c27;
}

.map-prompt {
  position: absolute;
  z-index: 20;
  top: 18px;
  left: 50%;
  display: grid;
  width: max-content;
  max-width: min(440px, calc(100% - 36px));
  min-height: 48px;
  align-items: center;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px 9px 8px 13px;
  border: 1px solid rgba(149, 243, 247, 0.28);
  border-radius: 15px;
  color: #d9f6f8;
  background: rgba(4, 23, 32, 0.96);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  transform: translateX(-50%);
}

.map-prompt.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.prompt-pulse {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 0 4px rgba(92, 232, 241, 0.14);
}

.map-prompt-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.map-prompt-copy strong {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 730;
  line-height: 1.25;
}

.map-prompt-copy span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 520;
  line-height: 1.35;
}

.map-prompt-dismiss {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 1.12rem;
  line-height: 1;
}

.map-prompt-dismiss:hover,
.map-prompt-dismiss:focus-visible {
  color: var(--text);
  background: rgba(92, 232, 241, 0.1);
}

.map-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 7px;
  padding-top: 2px;
}

.map-confirm-actions button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 740;
}

.map-confirm-primary {
  color: #001217;
  background: var(--cyan-400);
}

.map-confirm-secondary {
  color: var(--text);
  background: #123442;
}

.map-status {
  position: absolute;
  z-index: 20;
  top: 18px;
  left: 18px;
  display: grid;
  min-width: 185px;
  padding: 11px 13px;
}

.map-status .eyebrow {
  margin-bottom: 4px;
  font-size: 0.57rem;
}

.map-status strong {
  overflow: hidden;
  max-width: 260px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-status span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.map-tools {
  position: absolute;
  z-index: 20;
  top: 18px;
  right: 18px;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #071e2a;
  box-shadow: var(--shadow-md);
}

.map-tool {
  display: grid;
  width: 42px;
  height: 40px;
  place-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 1.12rem;
  font-weight: 540;
}

.map-tool:last-child {
  border-bottom: 0;
}

.map-tool:hover {
  color: var(--cyan-300);
  background: #10303f;
}

.map-tool-text {
  font-size: 0.61rem;
  font-weight: 720;
  letter-spacing: 0.03em;
}

.scale-control {
  right: auto;
  bottom: 18px;
  left: 18px;
  display: block;
  width: 126px;
  min-width: 0;
  padding: 8px 10px 7px;
  text-align: left;
}

.scale-control::before {
  display: none;
}

.scale-line {
  width: 100%;
  height: 7px;
  border-right: 1px solid var(--cyan-300);
  border-bottom: 2px solid var(--cyan-300);
  border-left: 1px solid var(--cyan-300);
}

.scale-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

.scale-row button {
  min-width: 31px;
  padding: 2px 4px;
  border-radius: 5px;
  color: var(--cyan-300);
  background: rgba(41, 212, 227, 0.1);
  cursor: pointer;
  font-size: 0.6rem;
  font-weight: 740;
  text-transform: uppercase;
}

.map-legend {
  position: absolute;
  z-index: 20;
  bottom: 18px;
  left: 158px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(4, 22, 31, 0.96);
  box-shadow: var(--shadow-md);
}

.legend-toggle {
  display: none;
  width: 100%;
  padding: 9px 11px;
  color: var(--text);
  background: transparent;
  font-size: 0.69rem;
  font-weight: 690;
  text-align: left;
}

.legend-body {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
}

.legend-body span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.63rem;
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid currentColor;
}

.legend-cz {
  color: var(--cyan-300);
  border-top-style: dashed;
}

.legend-surface {
  color: var(--blue-500);
}

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

.plot-button {
  position: absolute;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid rgba(92, 232, 241, 0.5);
  border-radius: 12px;
  color: #001217;
  background: var(--cyan-400);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 760;
}

.plot-button:disabled {
  border-color: var(--line);
  color: #76909a;
  background: #18323e;
  box-shadow: none;
  cursor: not-allowed;
}

.plot-icon {
  position: relative;
  width: 20px;
  height: 13px;
  overflow: hidden;
}

.plot-icon::before,
.plot-icon::after {
  position: absolute;
  left: 0;
  width: 20px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  content: "";
  transform: rotate(-7deg);
}

.plot-icon::after {
  top: 5px;
  transform: rotate(7deg);
}

.learning-panel {
  position: relative;
  z-index: 30;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: var(--ink-900);
  box-shadow: -14px 0 38px rgba(0, 8, 13, 0.16);
}

.panel-drawer-toggle {
  display: none;
}

.panel-tabs {
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #061720;
}

.panel-tab {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 710;
  letter-spacing: 0.02em;
}

.panel-tab:hover {
  color: var(--text);
  background: rgba(16, 49, 63, 0.56);
}

.panel-tab.is-active,
.panel-tab[aria-selected="true"] {
  color: var(--text);
  background: #123442;
  box-shadow: inset 0 0 0 1px rgba(92, 232, 241, 0.22);
}

.panel-scroll {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
  scrollbar-color: var(--ink-600) transparent;
  scrollbar-width: thin;
}

.panel-scroll::-webkit-scrollbar {
  width: 7px;
}

.panel-scroll::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: var(--ink-600);
}

.viz-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 7, 12, 0.15);
}

.panel-view:not(.is-active) {
  display: none;
}

.viz-card .card-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 14px 15px 12px;
  border-bottom: 1px solid rgba(137, 211, 222, 0.1);
}

.card-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.91rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.card-heading .eyebrow,
.graph-pane-heading .eyebrow {
  margin-bottom: 4px;
  font-size: 0.57rem;
}

.help-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--cyan-300);
  background: #0b2633;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 760;
}

.help-button:hover {
  border-color: var(--line-strong);
  background: #103541;
}

.empty-state {
  display: grid;
  min-height: 248px;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  max-width: 310px;
  margin: 0;
  font-size: 0.77rem;
  line-height: 1.55;
}

.empty-curve,
.empty-rays {
  position: relative;
  width: 72px;
  height: 58px;
  opacity: 0.58;
}

.empty-curve::before {
  position: absolute;
  inset: 2px 16px;
  border-right: 2px solid var(--cyan-400);
  border-radius: 55% 18% 58% 35%;
  content: "";
  transform: skewX(-15deg);
}

.empty-curve::after,
.empty-rays::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: var(--line-strong);
  content: "";
}

.empty-rays::before {
  position: absolute;
  top: 8px;
  right: 4px;
  left: 4px;
  height: 34px;
  border-top: 2px solid var(--cyan-400);
  border-bottom: 2px solid var(--blue-500);
  border-radius: 50%;
  content: "";
  transform: rotate(-4deg);
}

.profile-content,
.paths-content {
  min-width: 0;
}

.graph-visibility {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 7px 11px;
  border-bottom: 1px solid rgba(137, 211, 222, 0.09);
}

.graph-visibility > span {
  margin-right: auto;
  color: var(--quiet);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toggle-check,
.series-toggle {
  position: relative;
  cursor: pointer;
}

.toggle-check input,
.series-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-check span,
.series-toggle span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--quiet);
  background: #071923;
  font-size: 0.61rem;
  font-weight: 700;
  line-height: 1;
  transition:
    border-color 120ms var(--ease-out),
    color 120ms var(--ease-out),
    background-color 120ms var(--ease-out);
}

.toggle-check input:checked + span,
.series-toggle input:checked + span {
  border-color: rgba(92, 232, 241, 0.34);
  color: var(--cyan-300);
  background: rgba(32, 126, 143, 0.2);
}

.toggle-check input:focus-visible + span,
.series-toggle input:focus-visible + span {
  outline: 3px solid rgba(92, 232, 241, 0.48);
  outline-offset: 2px;
}

.profile-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  background: #061720;
}

.profile-grid[data-visible-count="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.profile-grid[data-visible-count="0"] {
  display: none;
}

.graph-pane {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(137, 211, 222, 0.13);
  border-radius: 11px;
  background: #071923;
}

.graph-pane-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border-bottom: 1px solid rgba(137, 211, 222, 0.1);
}

.graph-pane-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 690;
  line-height: 1.22;
}

.series-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.series-toggle span {
  min-height: 25px;
  padding: 0 6px;
  font-size: 0.55rem;
}

.series-temperature input:checked + span {
  border-color: rgba(255, 123, 120, 0.45);
  color: #ffaaa7;
  background: rgba(150, 57, 53, 0.18);
}

.series-salinity input:checked + span {
  border-color: rgba(92, 232, 241, 0.4);
  color: var(--cyan-300);
}

.series-pressure input:checked + span {
  border-color: rgba(245, 201, 106, 0.45);
  color: #f9dd99;
  background: rgba(133, 92, 23, 0.17);
}

.sound-lazy-note {
  max-width: 112px;
  color: var(--muted);
  font-size: 0.55rem;
  line-height: 1.25;
  text-align: right;
}

.graph-pane svg {
  width: 100%;
  height: auto;
  min-height: 250px;
  background:
    linear-gradient(rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    #061721;
  background-size: 34px 34px;
}

.graph-pane svg text {
  font-family: inherit;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.environment-pane .profile-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.25px;
  vector-effect: non-scaling-stroke;
}

.chart-grid,
.chart-divider {
  stroke: rgba(137, 211, 222, 0.14);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.chart-divider {
  stroke-dasharray: 3 5;
}

.axis-label,
.axis-title,
.channel-axis-label {
  fill: var(--muted);
}

.axis-title {
  font-size: 9px !important;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.series-title {
  font-size: 9px !important;
  font-weight: 740;
}

.channel-axis-line {
  stroke: rgba(245, 201, 106, 0.66);
  stroke-dasharray: 5 4;
  stroke-width: 1.2px;
  vector-effect: non-scaling-stroke;
}

.channel-axis-label {
  font-size: 8.5px !important;
  font-weight: 700;
}

.channel-axis-dot {
  fill: var(--amber-400);
  stroke: #071923;
  stroke-width: 2px;
}

.sonic-layer-line {
  stroke: rgba(92, 232, 241, 0.72);
  stroke-dasharray: 3 4;
  stroke-width: 1.2px;
  vector-effect: non-scaling-stroke;
}

.sonic-layer-label {
  fill: var(--cyan-300) !important;
  font-size: 8.5px !important;
  font-weight: 700;
}

.sonic-layer-dot {
  fill: var(--cyan-300);
  stroke: #071923;
  stroke-width: 2px;
}

.graph-pane svg .grid,
.graph-pane svg .grid-line,
.graph-pane svg .tick-line {
  stroke: rgba(137, 211, 222, 0.13);
}

.graph-pane svg .axis,
.graph-pane svg .axis-line {
  stroke: rgba(173, 225, 232, 0.35);
}

.graph-pane svg .temperature-line,
.graph-pane svg [data-series="temperature"] {
  fill: none;
  stroke: var(--coral-400);
}

.graph-pane svg .salinity-line,
.graph-pane svg [data-series="salinity"] {
  fill: none;
  stroke: var(--cyan-400);
}

.graph-pane svg .pressure-line,
.graph-pane svg [data-series="pressure"] {
  fill: none;
  stroke: var(--amber-400);
}

.profile-readouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  border-top: 1px solid rgba(137, 211, 222, 0.1);
}

.profile-readouts > div {
  min-width: 0;
  padding: 10px 12px 11px;
  border-right: 1px solid rgba(137, 211, 222, 0.1);
}

.profile-readouts > div:last-child {
  border-right: 0;
}

.profile-readouts span,
.profile-readouts strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-readouts span {
  margin-bottom: 3px;
  color: var(--quiet);
  font-size: 0.57rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.profile-readouts strong {
  color: var(--text);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.ray-stage {
  position: relative;
  min-height: 310px;
  overflow: hidden;
  background:
    linear-gradient(rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    #061721;
  background-size: 42px 42px;
}

#ray-canvas {
  width: 100%;
  height: 100%;
  min-height: 310px;
}

.vertical-note {
  position: absolute;
  top: 8px;
  right: 9px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--quiet);
  background: rgba(3, 16, 23, 0.82);
  font-size: 0.55rem;
  font-weight: 670;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.trace-key {
  padding: 11px 13px 12px;
  border-top: 1px solid var(--line);
  background: rgba(7, 27, 38, 0.76);
}

.trace-key > .eyebrow {
  margin: 0 0 7px;
}

.trace-key-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
}

.trace-key-grid p {
  display: grid;
  min-width: 0;
  margin: 0;
  gap: 2px;
}

.trace-key-grid span {
  color: var(--quiet);
  font-size: 0.53rem;
  font-weight: 680;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.trace-key-grid strong {
  color: #cce1e6;
  font-size: 0.64rem;
  font-weight: 590;
  line-height: 1.38;
}

.trace-key-wide {
  grid-column: 1 / -1;
}

.path-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px 14px 13px;
  border-top: 1px solid rgba(137, 211, 222, 0.1);
}

.condition-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(92, 232, 241, 0.34);
  border-radius: 999px;
  color: var(--cyan-300);
  background: rgba(32, 126, 143, 0.18);
  font-size: 0.61rem;
  font-weight: 730;
  white-space: nowrap;
}

.path-summary p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.48;
}

.why-content {
  padding: 16px;
}

.why-lead {
  margin: 0 0 14px;
  color: #c4dce2;
  font-size: 0.8rem;
  line-height: 1.55;
}

.teaching-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.teaching-steps li {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(137, 211, 222, 0.11);
  border-radius: 10px;
  background: #071923;
}

.teaching-steps li > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: var(--cyan-300);
  background: rgba(41, 212, 227, 0.12);
  font-size: 0.66rem;
  font-weight: 760;
}

.teaching-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.48;
}

.teaching-steps strong {
  color: var(--text);
}

.control-card {
  display: grid;
  gap: 13px;
  margin-top: 12px;
}

.control-row > label,
.compact-control > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 660;
}

.control-row output {
  color: var(--cyan-300);
}

.compact-control {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.compact-control > span {
  margin: 0;
}

.segmented-control button.is-active {
  color: var(--text);
  background: #123342;
  box-shadow: inset 0 0 0 1px rgba(92, 232, 241, 0.22);
}

.model-note {
  margin: 11px 4px 4px;
  color: var(--quiet);
  font-size: 0.61rem;
  line-height: 1.5;
}

.lesson-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(88vh, 760px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: var(--ink-900);
  box-shadow: var(--shadow-lg);
}

.lesson-dialog::backdrop {
  background: rgba(0, 7, 12, 0.86);
}

.lesson-dialog.fallback-open {
  position: fixed;
  z-index: 600;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  display: block;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 100vmax rgba(0, 7, 12, 0.86), var(--shadow-lg);
}

.dialog-shell {
  position: relative;
  max-height: min(88vh, 760px);
  margin: 0;
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: inherit;
}

.lesson-dialog .dialog-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  font-size: 1.2rem;
  line-height: 1;
}

.dialog-shell > .eyebrow {
  margin: 2px 48px 6px 0;
}

.dialog-shell > h2 {
  max-width: 500px;
  margin: 0 48px 14px 0;
  color: var(--text);
  font-size: clamp(1.18rem, 3vw, 1.7rem);
  font-weight: 720;
  letter-spacing: -0.026em;
  line-height: 1.15;
}

.lesson-visual {
  min-height: 210px;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    linear-gradient(rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 158, 173, 0.07) 1px, transparent 1px),
    #061721;
  background-size: 38px 38px;
}

.lesson-copy,
.about-dialog p {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.62;
}

.lesson-copy strong,
.about-dialog strong {
  color: var(--text);
}

.video-note,
.fine-print {
  padding: 10px 11px;
  border-left: 3px solid var(--cyan-500);
  border-radius: 0 8px 8px 0;
  color: var(--quiet) !important;
  background: rgba(24, 89, 103, 0.14);
  font-size: 0.69rem !important;
  line-height: 1.48 !important;
}

.dialog-done {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  padding: 0 17px;
  border: 1px solid rgba(92, 232, 241, 0.5);
  border-radius: 10px;
  color: #001217;
  background: var(--cyan-400);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 760;
}

@media (max-width: 1180px) and (min-width: 821px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) minmax(500px, 48vw);
  }

  .lesson-chip {
    padding-right: 8px;
  }

  .lesson-chip span {
    display: none;
  }

  .graph-pane-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .series-toggles {
    justify-content: flex-start;
  }

  .sound-lazy-note {
    max-width: none;
    text-align: left;
  }
}

@media (max-width: 820px) {
  body {
    height: 100vh;
    grid-template-rows: var(--header-height) minmax(0, 1fr);
  }

  .site-header {
    height: var(--header-height);
  }

  .brand-lockup h1 {
    max-width: 150px;
    font-size: 0.96rem;
  }

  .brand-lockup .eyebrow {
    display: none;
  }

  .lesson-chip {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    justify-content: center;
    color: transparent;
    font-size: 0;
  }

  .lesson-chip span {
    display: grid;
    width: 28px;
    height: 28px;
    color: var(--cyan-300);
    font-size: 0.61rem;
  }

  .app-shell {
    --mobile-drawer-height: 62px;
    --mobile-drawer-expanded-height: min(64vh, 560px);
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
  }

  .map-stage {
    position: absolute;
    inset: 0;
  }

  .learning-panel {
    position: absolute;
    z-index: 50;
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0));
    left: 6px;
    display: grid;
    height: var(--mobile-drawer-height);
    max-height: none;
    grid-template-rows: 60px 0 minmax(0, 0);
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 17px;
    background: #061721;
    box-shadow: 0 -12px 40px rgba(0, 8, 14, 0.45);
    transition: height 190ms var(--ease-out);
  }

  .learning-panel::before {
    display: none;
    content: none;
  }

  .learning-panel.is-expanded {
    height: var(--mobile-drawer-expanded-height);
    grid-template-rows: 60px auto minmax(0, 1fr);
  }

  .panel-drawer-toggle {
    z-index: 5;
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 60px;
    align-items: center;
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: minmax(0, 1fr) auto 20px;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid transparent;
    color: var(--text);
    background: linear-gradient(180deg, #0b2835, #071d28);
    cursor: pointer;
    text-align: left;
  }

  .learning-panel.is-expanded .panel-drawer-toggle {
    border-bottom-color: var(--line);
  }

  .panel-drawer-toggle:hover,
  .panel-drawer-toggle:focus-visible {
    background: linear-gradient(180deg, #103441, #092530);
  }

  .panel-drawer-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .panel-drawer-copy .eyebrow {
    margin: 0;
    font-size: 0.52rem;
  }

  .panel-drawer-copy strong {
    overflow: hidden;
    font-size: 0.84rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel-drawer-state {
    color: var(--cyan-300);
    font-size: 0.62rem;
    font-weight: 690;
    white-space: nowrap;
  }

  .panel-drawer-chevron {
    width: 10px;
    height: 10px;
    border-top: 2px solid var(--cyan-300);
    border-left: 2px solid var(--cyan-300);
    transform: translateY(3px) rotate(45deg);
    transition: transform 190ms var(--ease-out);
  }

  .learning-panel.is-expanded .panel-drawer-chevron {
    transform: translateY(-3px) rotate(225deg);
  }

  .panel-tabs {
    padding: 7px;
    grid-column: 1;
    grid-row: 2;
  }

  .panel-scroll {
    grid-column: 1;
    grid-row: 3;
    padding: 8px;
  }

  .learning-panel:not(.is-expanded) .panel-tabs,
  .learning-panel:not(.is-expanded) .panel-scroll {
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }

  .viz-card .card-heading {
    padding: 11px 12px 10px;
  }

  .card-heading h2 {
    font-size: 0.83rem;
  }

  .graph-visibility {
    min-height: 38px;
    padding: 5px 8px;
  }

  .graph-visibility > span {
    display: none;
  }

  .profile-grid,
  .profile-grid[data-visible-count="2"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .graph-pane svg {
    min-height: 220px;
  }

  .profile-readouts > div {
    padding: 8px 9px 9px;
  }

  .profile-readouts span {
    font-size: 0.51rem;
  }

  .profile-readouts strong {
    font-size: 0.65rem;
  }

  .ray-stage,
  #ray-canvas {
    min-height: 230px;
  }

  .map-prompt {
    top: 10px;
    right: 60px;
    left: 10px;
    width: auto;
    max-width: 430px;
    min-height: 48px;
    padding: 8px 8px 8px 12px;
    transform: none;
  }

  .map-status {
    top: 80px;
    left: 10px;
    min-width: 0;
    max-width: calc(100% - 72px);
    padding: 9px 10px;
  }

  .map-status strong {
    max-width: 210px;
  }

  .map-tools {
    top: 10px;
    right: 10px;
  }

  .map-tool {
    width: 40px;
    height: 37px;
  }

  .scale-control {
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
    left: 10px;
    width: 106px;
  }

  .map-legend {
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
    left: 124px;
  }

  .legend-toggle {
    display: block;
  }

  .legend-body {
    display: none;
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding: 0 11px 10px;
  }

  .legend-toggle[aria-expanded="true"] + .legend-body {
    display: flex;
  }

  .plot-button {
    right: 10px;
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
    min-height: 42px;
    padding: 0 12px;
    font-size: 0.68rem;
  }

  .control-card {
    margin-top: 8px;
  }

  .model-note {
    padding-bottom: 2px;
  }

  .lesson-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px - env(safe-area-inset-top, 0));
    border-radius: 17px;
  }

  .dialog-shell {
    max-height: calc(100vh - 16px - env(safe-area-inset-top, 0));
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom, 0));
  }

  .lesson-visual {
    min-height: 175px;
  }
}

@media (max-width: 520px) {
  .header-actions {
    gap: 4px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-lockup h1 {
    max-width: 118px;
  }

  .header-credit {
    max-width: 128px;
    font-size: 0.52rem;
  }

  .learning-panel {
    max-height: none;
  }

  .panel-tab {
    min-height: 36px;
    font-size: 0.66rem;
  }

  .scale-control,
  .map-legend,
  .plot-button {
    bottom: calc(var(--mobile-drawer-height) + 18px + env(safe-area-inset-bottom, 0));
  }

  .map-legend {
    display: none;
  }

  .plot-button {
    font-size: 0;
  }

  .plot-icon {
    width: 22px;
  }

  .path-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .condition-pill {
    justify-self: start;
  }

  .compact-control {
    grid-template-columns: minmax(92px, 1fr) auto;
  }
}

/* Safari before dynamic viewport units reports 100vh behind its browser chrome. */
@supports (-webkit-touch-callout: none) {
  html {
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
  }

  body {
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
  }
}

@supports (height: 100dvh) {
  body {
    height: 100dvh;
  }

  @media (max-width: 820px) {
    .app-shell {
      --mobile-drawer-expanded-height: min(64dvh, 560px);
    }

    .lesson-dialog,
    .dialog-shell {
      max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0));
    }
  }
}
