/* ==========================================================================
   Skew-T Explorer -- house style adapted from not-pc-imat (reference/).
   Same palette variables, layout skeleton, and accessibility discipline;
   new components (station models, indices table, layer drawer, index
   popover, skew-T stub) are original work in the same voice.
   ========================================================================== */

: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);
  --panel-width-active: clamp(760px, 78vw, 1500px);
  --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 {
  display: grid;
  height: 100vh;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  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;
}

/* New elements added purely for the mobile sheet redesign (region-switcher
   aside): zero footprint on desktop by default. Each gets its real mobile
   display value set inside the max-width:820px block below -- never
   unhidden outside it, so desktop stays byte-for-byte unaffected. */
.mobile-only {
  display: none;
}

.sr-only {
  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;
}

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

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

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

/* ---------------------------------------------------------------- header */

.site-header {
  position: relative;
  z-index: 100;
  grid-row: 1;
  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-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-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 svg {
  width: 27px;
  height: 27px;
}

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

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

.brand-lockup .eyebrow {
  margin-bottom: 3px;
}

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

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

.launch-select-wrap select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 0.78rem;
  font-weight: 640;
}

.launch-select-wrap select:hover {
  border-color: var(--line-strong);
}

/* Hook for a future wave: stays visually invisible (zero footprint, no
   forced gap) until something is rendered into it. */
#library-nav-slot:empty {
  display: none;
}

.library-nav-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 0.78rem;
  font-weight: 640;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.library-nav-link:hover {
  border-color: var(--line-strong);
  background: #10303f;
  color: var(--cyan-300);
}

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

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

.icon-button:active {
  transform: translateY(1px);
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  position: relative;
  grid-row: 2;
  min-height: 0;
  overflow: hidden;
}

.map-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #062330;
  isolation: isolate;
}

#map {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #04141c;
}

.leaflet-container {
  font: inherit;
  background: #04141c;
}

.map-status {
  position: absolute;
  z-index: 20;
  top: 18px;
  left: 18px;
  max-width: min(360px, calc(100% - 36px));
  padding: 11px 14px;
  border: 1px solid rgba(150, 226, 236, 0.19);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(5, 24, 34, 0.96);
  box-shadow: var(--shadow-md);
}

.map-status strong {
  display: block;
  margin: 1px 0 3px;
  color: var(--text);
  font-size: 0.86rem;
}

.map-status span {
  display: block;
  font-size: 0.72rem;
  line-height: 1.4;
}

.map-tools {
  position: absolute;
  z-index: 20;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-tool {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: rgba(5, 24, 34, 0.96);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.map-tool:hover {
  border-color: var(--line-strong);
  background: #10303f;
}

.map-tool-text {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* -------------------------------------------------------- COCOM regions */

/* Always-visible AOR switcher. Base rule (mobile default, and the fallback
   before the desktop override below applies) is the vertical stack fixed
   directly under the .map-tools button stack (top-right map corner) --
   Sean liked it there on mobile and asked to keep it. On desktop (>=821px,
   see the media block further down) it moves to a horizontal row centered
   along the bottom of the map area instead, clear of .rail-stow-toggle. */
.region-switcher {
  position: absolute;
  z-index: 20;
  top: 170px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.region-button.map-tool-text {
  min-width: 96px;
  padding: 0 8px;
  font-size: 0.6rem;
  letter-spacing: 0.03em;
}

.region-button:hover {
  border-color: var(--line-strong);
  color: var(--cyan-300);
}

.region-button.is-active {
  border-color: rgba(92, 232, 241, 0.5);
  color: var(--cyan-300);
  background: rgba(92, 232, 241, 0.14);
}

.rail-stow-toggle {
  position: absolute;
  z-index: 25;
  top: 50%;
  right: 0;
  display: none;
  width: 22px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: linear-gradient(180deg, #103746, #071d28);
  box-shadow: -8px 8px 24px rgba(0, 8, 13, 0.35);
  cursor: pointer;
  transform: translateY(-50%);
}

/* Stowed (rail closed) -> chevron points LEFT ("click to pull it out").
   Open (rail expanded) -> chevron points RIGHT ("click to collapse toward
   the right edge"). This was backwards before -- the two rotations were
   swapped relative to the states they decorate. */
.rail-stow-chevron {
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--cyan-300);
  border-left: 2px solid var(--cyan-300);
  transform: rotate(-45deg);
  transition: transform 190ms var(--ease-out);
}

.rail-open .rail-stow-chevron {
  transform: rotate(135deg);
}

/* ------------------------------------------------------- station models */

.station-marker {
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
}

.station-plot {
  cursor: pointer;
}

.station-plot text {
  font-family: Inter, ui-sans-serif, sans-serif;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: #04141c;
  stroke-width: 2.4px;
  stroke-linejoin: round;
}

.station-plot .station-temp {
  fill: var(--coral-400);
  font-size: 12px;
  font-weight: 700;
}

.station-plot .station-dewpoint {
  fill: var(--cyan-300);
  font-size: 12px;
  font-weight: 700;
}

.station-plot .station-id {
  fill: var(--text);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.station-plot .station-sky {
  fill: #04141c;
  stroke: var(--text);
  stroke-width: 1.4px;
}

.station-plot .station-sky.is-filled {
  fill: var(--text);
}

.station-plot .station-sky.is-partial {
  fill: url(#station-partial-fill);
}

.station-plot .station-calm {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.4px;
}

.station-plot .station-barb {
  fill: none;
  stroke: var(--text);
  stroke-linecap: round;
  stroke-width: 1.6px;
}

.station-plot:focus-visible .station-sky,
.station-plot.is-active .station-sky {
  filter: drop-shadow(0 0 4px rgba(92, 232, 241, 0.9));
}

.station-plot.is-active .station-id {
  fill: var(--cyan-300);
}

/* Model-derived (no real launch) sites: dashed diamond-ish outline instead
   of the solid RAOB station circle, so it reads at a glance as "not a real
   balloon." */
.station-plot.is-model .station-sky {
  fill: none;
  stroke: var(--amber-400);
  stroke-dasharray: 3 2.4;
}

.station-plot.is-model.is-active .station-sky,
.station-plot.is-model:focus-visible .station-sky {
  filter: drop-shadow(0 0 4px rgba(245, 201, 106, 0.9));
}

.station-plot.is-model .station-id {
  fill: var(--amber-400);
}

/* ---------------------------------------------------------------- rail */

.teaching-rail {
  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: 62px;
  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);
}

.teaching-rail.is-expanded {
  height: min(58vh, 560px);
  grid-template-rows: 60px auto minmax(0, 1fr);
}

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

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

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

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

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

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

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

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

.rail-scroll {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
  scrollbar-color: var(--ink-600) transparent;
  scrollbar-width: thin;
}

.teaching-rail:not(.is-expanded) .rail-scroll {
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

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

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

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

/* Groups the skew-T card and the interpretation card so they stack in
   normal document flow, independent of the indices card's height (see the
   desktop two-column rule below). On mobile/tablet this wrapper has no
   layout role of its own -- `display: contents` -- so its two children
   keep participating directly in .rail-scroll's flex stack exactly as
   before. */
.rail-left-col {
  display: contents;
}

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

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

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid rgba(92, 232, 241, 0.36);
  border-radius: 999px;
  color: var(--cyan-300);
  background: rgba(31, 142, 158, 0.2);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rail-card-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

/* -------------------------------------------------------- skew-T stub */

/* --------------------------------------------------------- data source */

.diagram-source-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -2px 0 11px;
  padding: 3px 9px;
  border: 1px solid rgba(92, 232, 241, 0.35);
  border-radius: 999px;
  color: var(--cyan-300);
  background: rgba(92, 232, 241, 0.08);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
}

.diagram-source-line.is-model {
  padding: 3px 9px;
  border: 1px solid rgba(245, 201, 106, 0.4);
  border-radius: 999px;
  color: var(--amber-400);
  background: rgba(245, 201, 106, 0.1);
  font-weight: 700;
  width: fit-content;
}

.profile-chip-row {
  display: flex;
  gap: 6px;
  margin: 0 0 11px;
}

.profile-chip {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 0.7rem;
  font-weight: 660;
  cursor: pointer;
}

.profile-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.profile-chip.is-active {
  border-color: rgba(92, 232, 241, 0.5);
  color: var(--cyan-300);
  background: rgba(92, 232, 241, 0.14);
}

.profile-chip[data-profile="model"].is-active {
  border-color: rgba(245, 201, 106, 0.55);
  color: var(--amber-400);
  background: rgba(245, 201, 106, 0.14);
}

.interp-model-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--amber-400);
  border-radius: 0 9px 9px 0;
  color: #efe0bb;
  background: rgba(130, 93, 31, 0.18);
  font-size: 0.72rem;
  line-height: 1.5;
}

.interp-card-dimmed .interp-subsection#interp-subsection-main {
  opacity: 0.55;
}

/* -------------------------------------------------------------- zoom */

.zoom-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 640;
  cursor: pointer;
}

.zoom-toggle-wrap input {
  accent-color: var(--cyan-400);
}

.zoom-toggle-inline {
  margin: 2px 2px 10px;
}

.skewt-empty {
  display: grid;
  gap: 10px;
  padding: 26px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

.skewt-empty-glyph {
  justify-self: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(115deg, transparent 46%, var(--coral-400) 46%, var(--coral-400) 54%, transparent 54%),
    linear-gradient(65deg, transparent 46%, var(--cyan-400) 46%, var(--cyan-400) 54%, transparent 54%);
}

.skewt-empty p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
}

/* Wraps the optional hodograph panel, the skew-T container, and the line
   legend so a single class toggle ("skewt-theme-classic", the "Classic
   chart colors" layer-drawer control) can retint everything in here at
   once -- the renderer re-skins its own SVG when the class lands on
   #skewt-container directly (see skewt-classic.css), and app.js mirrors
   the same class onto this wrapper so the legend swatches below, which
   read the identical --coral-400/--cyan-400/etc custom properties, cascade
   to the same retinted values even though they're siblings of the
   container rather than descendants of it. */
.skewt-diagram-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skewt-container {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  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;
}

/* -------------------------------------------------------------- legend */

/* Even 2-rows-of-4 grid, centered under the diagram (8 entries, exactly
   fills it) -- consistent item widths instead of a ragged flex-wrap. */
.skewt-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  justify-items: center;
  gap: 8px 12px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.skewt-legend-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 620;
}

.skewt-legend-swatch {
  width: 26px;
  height: 10px;
  flex: 0 0 auto;
  overflow: visible;
}

.skewt-legend-swatch line {
  fill: none;
  stroke-linecap: round;
}

.lg-temp {
  stroke: var(--coral-400);
  stroke-width: 2.2;
}

.lg-dewpoint {
  stroke: var(--cyan-400);
  stroke-width: 2.2;
}

.lg-parcel {
  stroke: var(--amber-400);
  stroke-width: 2.2;
  stroke-dasharray: 4 3;
}

.lg-dry {
  stroke: var(--amber-400);
  stroke-width: 1.6;
  opacity: 0.55;
}

.lg-moist {
  stroke: var(--cyan-500);
  stroke-width: 1.6;
  stroke-dasharray: 1 2.4;
  opacity: 0.8;
}

.lg-mixing {
  stroke: var(--cyan-400);
  stroke-width: 1.6;
  stroke-dasharray: 3 2;
  opacity: 0.85;
}

.lg-cape {
  fill: var(--coral-400);
  opacity: 0.4;
}

.lg-cin {
  fill: var(--blue-500);
  opacity: 0.4;
}

.skewt-svg {
  display: block;
  width: 100%;
  height: auto;
}

.skewt-stub-note {
  position: absolute;
  inset: auto 12px 12px 12px;
  padding: 9px 11px;
  border-left: 3px solid var(--amber-400);
  border-radius: 0 9px 9px 0;
  color: #efe0bb;
  background: rgba(130, 93, 31, 0.18);
  font-size: 0.7rem;
  line-height: 1.45;
}

.skewt-stub-note strong {
  color: var(--amber-400);
}

/* -------------------------------------------------------- layer drawer */

.layer-drawer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.layer-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 660;
  cursor: pointer;
  list-style: none;
}

.layer-drawer summary::-webkit-details-marker {
  display: none;
}

.layer-drawer summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--cyan-300);
  border-left: 2px solid var(--cyan-300);
  transform: rotate(-135deg);
  transition: transform 160ms var(--ease-out);
}

.layer-drawer[open] summary::after {
  transform: rotate(45deg);
}

.layer-drawer-hint {
  margin-right: 10px;
  margin-left: auto;
  color: var(--cyan-300);
  font-size: 0.66rem;
  font-weight: 700;
}

.layer-drawer-body {
  padding: 4px 12px 12px;
  border-top: 1px solid var(--line);
}

.preset-row {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  margin: 10px 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #061721;
}

.preset-button {
  min-height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 680;
  cursor: pointer;
}

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

.layer-toggle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 0.73rem;
}

.layer-toggle input {
  accent-color: var(--cyan-400);
}

/* -------------------------------------------------------- indices table */

.indices-table-wrap {
  overflow-x: auto;
}

.indices-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.indices-table thead th {
  padding: 6px 8px;
  color: var(--quiet);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

/* Real table columns (a literal <td> per value) already align across every
   row on their own -- no table-layout:fixed needed, which was clipping
   wide unit strings ("J/kg", "hPa") against a hard em width. The name
   column gets the slack; the value column stays snug to its content. */
.indices-table thead th:first-child {
  width: 100%;
}

.indices-table thead th:last-child {
  text-align: right;
  white-space: nowrap;
}

.indices-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.indices-table tbody tr:hover,
.indices-table tbody tr:focus-visible {
  background: rgba(92, 232, 241, 0.06);
  outline: none;
}

.indices-table tbody tr.is-active {
  background: rgba(92, 232, 241, 0.14);
}

.indices-table td {
  height: 36px;
  padding: 0 8px;
  vertical-align: middle;
}

.index-name {
  overflow: hidden;
  color: var(--text);
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.index-value {
  color: var(--cyan-300);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

/* --------------------------------------------------------- index explainer */

/* Sub-tab pattern: clicking an index row replaces the table view with this
   detail view in the same card/space (see #index-explainer-back below);
   .indices-list-view and #index-explainer are mutually exclusive (app.js
   toggles their [hidden] attributes), never stacked. */
.index-explainer {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.index-explainer-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  padding: 0 12px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cyan-300);
  background: var(--surface-raised);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.index-explainer-back:hover,
.index-explainer-back:focus-visible {
  border-color: var(--line-strong);
  background: #10303f;
}

.index-explainer-back-chevron {
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(-45deg);
}

.index-explainer-header {
  margin-bottom: 6px;
}

.index-explainer h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
}

.index-explainer > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.index-explainer-sounding {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.index-calc {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.index-calc-equation {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.7;
}

.index-calc-equation-values {
  color: var(--text);
}

.index-calc-label {
  margin: 0 0 4px;
  color: var(--quiet);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.index-calc-note {
  margin: 10px 0 0;
  color: var(--quiet);
  font-size: 0.74rem;
  line-height: 1.55;
}

/* variable definition list ("where:") */
.eq-vardefs {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0 0 12px;
}

.eq-vardef {
  display: contents;
}

.eq-vardefs dt {
  color: var(--cyan-300);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.eq-vardefs dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.eq-sym {
  color: var(--muted);
}

.eq-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 0 1px;
  padding: 1px 7px;
  border: 1px solid rgba(245, 201, 106, 0.4);
  border-radius: 999px;
  color: var(--amber-400);
  background: rgba(245, 201, 106, 0.1);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.eq-chip-sym {
  opacity: 0.85;
}

.eq-chip:hover,
.eq-chip:focus-visible {
  border-color: rgba(245, 201, 106, 0.75);
  background: rgba(245, 201, 106, 0.22);
}

.eq-chip.is-pinned {
  border-color: var(--amber-400);
  color: #1a1204;
  background: var(--amber-400);
  font-weight: 700;
}

/* ------------------------------------------------------- interpretation */

.interp-subsection + .interp-subsection {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.interp-body {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.interp-body p {
  margin: 0 0 12px;
}

.interp-body p:last-child {
  margin-bottom: 0;
}

/* A genuine inline element: no inline-block box (the default UA style for
   <button>) so it flows with surrounding text instead of breaking the line
   around itself or stranding trailing punctuation on its own line.
   box-decoration-break keeps the background/underline looking continuous if
   a phrase happens to wrap across two lines. */
.interp-ref {
  display: inline;
  cursor: pointer;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dashed var(--cyan-400);
  border-radius: 3px;
  color: var(--cyan-300);
  background: rgba(92, 232, 241, 0.08);
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.interp-ref:hover,
.interp-ref:focus-visible {
  background: rgba(92, 232, 241, 0.2);
}

.interp-ref.is-pinned {
  border-bottom-style: solid;
  color: var(--ink-950);
  background: var(--cyan-400);
  font-weight: 700;
}

.interp-ref.is-flashing {
  animation: interp-flash 1100ms var(--ease-out);
}

@keyframes interp-flash {
  0%,
  100% {
    background: rgba(92, 232, 241, 0.08);
  }
  35% {
    background: rgba(92, 232, 241, 0.42);
  }
}

/* "Show the evidence" -- the folded, compact list of features the
   interpretation was built from. Collapsed by default; one line per
   feature when open. */
.evidence-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.evidence-list summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cyan-300);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  list-style: none;
}

.evidence-list summary::-webkit-details-marker {
  display: none;
}

.evidence-list summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-top: 2px solid var(--cyan-300);
  border-left: 2px solid var(--cyan-300);
  transform: rotate(-135deg);
  transition: transform 160ms var(--ease-out);
}

.evidence-list[open] summary::after {
  transform: rotate(45deg);
}

.evidence-list-body {
  margin-top: 10px;
}

.evidence-list-body p {
  margin: 0;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
  font-size: 0.76rem;
  line-height: 1.4;
}

.evidence-list-body p:first-child {
  border-top: 0;
}

/* -------------------------------------------------------------- dialog */

.app-dialog {
  width: min(600px, calc(100% - 32px));
  max-height: min(88vh, 720px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: var(--ink-900);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}

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

.dialog-shell {
  position: relative;
  margin: 0;
  padding: 22px 22px 18px;
  border: 0;
}

.dialog-shell h2 {
  margin: 6px 0 12px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.dialog-shell p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  cursor: pointer;
}

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

.fine-print {
  color: var(--quiet) !important;
  font-size: 0.72rem !important;
  line-height: 1.5 !important;
}

.dialog-done {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  color: #001217;
  background: var(--cyan-400);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.dialog-done:hover {
  background: var(--cyan-300);
}

/* -------------------------------------------------------- welcome dialog */
/* Small card, not a takeover -- Sean asked for a dismissible dialog on
   first visit, not a modal-sized wall of text. */

.welcome-dialog {
  width: min(440px, calc(100% - 32px));
  max-height: min(88vh, 560px);
}

.welcome-shell h2 {
  margin: 4px 28px 10px 0;
  font-size: 1.08rem;
}

.welcome-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.welcome-list {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.welcome-list li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.welcome-bullet {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--cyan-400);
  font-size: 0.62rem;
  line-height: 1.4;
}

.welcome-list li div {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.welcome-list li strong {
  color: var(--text);
}

.welcome-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.welcome-dismiss-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  cursor: pointer;
}

.welcome-dismiss-check input {
  accent-color: var(--cyan-400);
}

/* -------------------------------------------------------------- README */

@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);
  }
}

/* ================================================================ desktop */

@media (min-width: 821px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 0;
    grid-template-rows: minmax(0, 1fr);
    transition: grid-template-columns 220ms var(--ease-out);
  }

  .app-shell.rail-open {
    grid-template-columns: minmax(0, 1fr) var(--panel-width);
  }

  .map-stage {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 0;
  }

  .rail-stow-toggle {
    display: flex;
  }

  .teaching-rail {
    position: relative;
    inset: auto;
    grid-column: 2;
    grid-row: 1;
    width: auto;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    border-width: 0 0 0 1px;
    border-radius: 0;
    box-shadow: -14px 0 38px rgba(0, 8, 13, 0.2);
    transform: none;
    transition: none;
    grid-template-rows: minmax(0, 1fr);
  }

  .app-shell:not(.rail-open) .teaching-rail {
    display: none;
  }

  .teaching-rail.is-expanded {
    height: 100%;
    grid-template-rows: minmax(0, 1fr);
  }

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

  .rail-scroll {
    grid-column: 1;
    grid-row: 1;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* Once a station is loaded the rail widens to give the diagram room to
     breathe, and the map (grid column 1) shrinks to exactly the remaining
     strip -- app.js re-pans it so the station stays centered in that strip. */
  .app-shell.rail-open.has-site {
    grid-template-columns: minmax(0, 1fr) var(--panel-width-active);
  }

  /* Two-column teaching rail: skew-T + layer drawer + interpretation on the
     left (~70% width), indices table/detail on the right (~30% width).
     This used to be a single 2-row grid with the indices card placed in
     row 1 alongside the skew-T card. That made row 1's height equal to
     whichever of the two was taller -- and with a long index explainer
     open, the indices card routinely dwarfed the skew-T card, so the
     implicit row track grew to match it. The interpretation card (row 2,
     left column) then started only after that inflated row 1 ended,
     leaving a large dead gap between the bottom of the skew-T card and the
     top of the interpretation card. Root cause: skew-T height and indices
     height were coupled through a shared grid row.
     Fix: give the left column its own independent flow. .rail-left-col
     wraps the skew-T and interpretation cards and stacks them with normal
     block/flex flow (a plain gap, no row-track coupling to the right
     column), so the interpretation card always sits snugly under the
     skew-T card no matter how tall the indices card/detail view gets. The
     indices card is simply the grid's second column, sized independently. */
  .app-shell.has-site #rail-scroll {
    display: grid;
    /* ~63/37 split (was ~72/28): the indices card's sub-tab detail view
       (equation blocks, "where:" definition lists) needs real width to
       breathe instead of wrapping awkwardly -- per Sean's follow-up, a bit
       narrower skew-T column plus a wider indices/explainer column, while
       the skew-T stays the visually dominant element on the page. */
    grid-template-columns: minmax(0, 6.3fr) minmax(0, 3.7fr);
    align-items: start;
    gap: 16px;
  }

  .app-shell.has-site #rail-scroll > .rail-left-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }

  .app-shell.has-site #indices-card {
    min-width: 0;
  }

  /* The skew-T fills its column edge-to-edge; the SVG scales via viewBox
     so more width is strictly more readability. */
  .app-shell.has-site .skewt-container {
    width: 100%;
    min-height: 480px;
  }

  /* Region switcher relocation (redesign item 1): desktop moves the AOR
     chips off the right edge (where they overlapped .rail-stow-toggle) to a
     single horizontal row centered along the bottom of the map area.
     Mobile keeps the original right-side vertical stack -- Sean explicitly
     likes it there, and drawer overlap there is acceptable. */
  .region-switcher {
    top: auto;
    right: auto;
    bottom: 18px;
    left: 50%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-width: calc(100% - 36px);
    transform: translateX(-50%);
  }
}

/* ================================================================= mobile */

@media (max-width: 820px) {
  :root {
    /* Two-row header (brand + about on row 1, nav chips on row 2) --
       see the .site-header grid rule below. */
    --header-height: 96px;
  }

  /* ------------------------------------------------------------ header -- */
  /* Sean's iOS screenshots: the "Latest launch" select overlapped the brand
     mark, the title truncated, the eyebrow wrapped, and the nav buttons
     stacked messily inside one cramped flex row. Rebuilt as an explicit
     2-row grid: row 1 is brand + about button, row 2 is the nav chips
     (full width, horizontally scrollable). The launch select moves into
     the drawer sheet entirely (see .launch-select-wrap-mini below) --
     .header-actions itself contributes no box (display:contents) so its
     children place directly onto the header grid. */
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: center;
    gap: 0;
    row-gap: 8px;
    height: auto;
    min-height: var(--header-height);
    padding-top: 10px;
    padding-bottom: 8px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

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

  .brand-lockup {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  /* Eyebrow ("An interactive sounding teaching aid") dropped entirely on
     mobile per spec -- it's what was wrapping onto its own line and
     crowding the title. */
  .brand-lockup .eyebrow {
    display: none;
  }

  .brand-lockup > div:last-child {
    display: flex;
    align-items: center;
  }

  .brand-lockup h1 {
    margin: 0;
    font-size: 1.02rem;
  }

  .header-actions {
    display: contents;
  }

  /* "Latest launch" select: removed from the mobile header entirely (item
     2) -- it now lives as a small inline control inside the drawer sheet,
     just above the pinned chart (see .launch-select-wrap-mini). */
  .header-actions .launch-select-wrap {
    display: none;
  }

  #library-nav-slot {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1px;
  }

  #library-nav-slot:empty {
    display: none;
  }

  .library-nav-link {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.72rem;
  }

  #about-button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
  }

  /* ------------------------------------------------------ drawer / sheet -- */
  .teaching-rail {
    right: 6px;
    bottom: calc(6px + env(safe-area-inset-bottom, 0));
    left: 6px;
    width: auto;
    transform: none;
  }

  /* Collapsed handle bar: kill the old labeled container ("TEACHING RAIL /
     <site> / Tap to open") -- no eyebrow, no state text, just the station
     name (or "Select a station") centered with a chevron. */
  .rail-drawer-copy .eyebrow {
    display: none;
  }

  .rail-drawer-copy {
    justify-items: center;
    text-align: center;
  }

  #rail-drawer-state {
    display: none;
  }

  #rail-drawer-toggle {
    grid-template-columns: minmax(0, 1fr) 20px;
    justify-items: center;
  }

  /* Sheet takeover: once a site is selected the drawer auto-opens as a
     full-screen sheet (100dvh minus safe areas) instead of the old ~64dvh
     partial-height drawer. position:fixed so it truly covers the header
     too, not just the map-stage area beneath it. */
  .teaching-rail.is-expanded {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: env(safe-area-inset-top, 0);
    z-index: 300;
  }

  .teaching-rail.is-expanded #rail-drawer-toggle {
    display: none;
  }

  .mobile-sheet-header {
    grid-row: 1;
  }

  .teaching-rail.is-expanded .mobile-sheet-header {
    display: flex;
  }

  .teaching-rail.is-expanded #rail-scroll {
    grid-row: 2;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  }

  .mobile-sheet-header {
    position: relative;
    align-items: center;
    gap: 10px;
    padding: 16px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #0b2b39, #071d28);
  }

  .sheet-grab {
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--line-strong);
    transform: translateX(-50%);
  }

  .sheet-title-group {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 1px;
  }

  .sheet-title-group strong {
    overflow: hidden;
    color: var(--text);
    font-size: 0.92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sheet-station-id {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 640;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .sheet-close-btn {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    margin-left: auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: var(--surface-raised);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
  }

  .sheet-close-btn:hover {
    border-color: var(--line-strong);
    background: #10303f;
  }

  .rail-stow-toggle {
    display: none;
  }

  /* .rail-left-col (wrapping the skew-T and interpretation cards, added for
     the desktop whitespace-gap fix above) is `display: contents` here, so
     its children become direct flex items of .rail-scroll alongside
     #indices-card -- but that changed their DOM order to skewt/interp/
     indices. Mobile's card order must stay untouched (skewt, indices,
     interp): restore the original visual order with `order` rather than
     touching the DOM, which the desktop grid rule depends on staying as-is.
     The new segmented control (item 4) sits between the pinned skew-T and
     the two content cards it switches between. */
  #skewt-card {
    order: 1;
  }

  #mobile-segmented {
    display: flex;
    order: 2;
  }

  #indices-card {
    order: 3;
  }

  #interp-card {
    order: 3;
  }

  /* ------------------------------------------------------- diagram sheet -- */
  /* Kill the double-shell feel (item 3): no bordered card, no "The diagram /
     Skew-T log-P" header -- flatten source line + profile chips + chart +
     legend + layer drawer directly into the sheet. The badge, profile
     chips, and mini launch select form a compact row pinned (sticky) just
     above the equally-pinned chart, so the diagram never scrolls out of
     view while reading the indices/discussion/evidence content below it --
     that's the entire point of the redesign (item 4). CSS grid areas place
     the (nested) card-header's children directly since `display: contents`
     lifts them out of their non-grid wrapper without moving them in the
     DOM -- desktop's own #skewt-card rules are untouched, this block only
     ever applies under max-width:820px. */
  #skewt-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "src src src"
      "empty empty empty"
      "badge chips select"
      "chart chart chart"
      "layers layers layers";
    align-items: center;
    gap: 6px 8px;
    padding: 10px 14px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #skewt-card .card-header {
    display: contents;
  }

  /* "The diagram" eyebrow + "Skew-T log-P" title: this is the card-chrome
     header the spec says to suppress on mobile. */
  #skewt-card .card-header > div:first-child {
    display: none;
  }

  #diagram-source-line {
    grid-area: src;
    margin: 0;
  }

  #skewt-empty {
    grid-area: empty;
  }

  #site-badge {
    grid-area: badge;
    align-self: center;
    justify-self: start;
  }

  #profile-chip-row {
    grid-area: chips;
    margin: 0;
    justify-self: center;
  }

  .launch-select-wrap-mini {
    display: block;
    grid-area: select;
    justify-self: end;
  }

  .launch-select-wrap-mini select {
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.66rem;
  }

  #site-badge,
  #profile-chip-row,
  .launch-select-wrap-mini {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--ink-900);
  }

  #skewt-diagram-wrap {
    grid-area: chart;
    position: sticky;
    /* Approximates the pinned badge/chips/select row's height so the chart
       sticks directly beneath it with no gap and no overlap -- verified
       against real rendered layout via mobile-emulated screenshots. */
    top: 42px;
    z-index: 2;
    padding-top: 4px;
    background: var(--ink-900);
  }

  #layer-drawer {
    grid-area: layers;
    margin-top: 2px;
  }

  /* ------------------------------------------------------- segmented nav -- */
  .mobile-segmented {
    gap: 4px;
    margin: 2px 14px 0;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #061721;
  }

  .mobile-segment-btn {
    min-height: 34px;
    flex: 1 1 0;
    padding: 0 6px;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-size: 0.74rem;
    font-weight: 680;
    cursor: pointer;
  }

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

  /* Content cards shown under the segmented control lose their own
     redundant "eyebrow/title" card-chrome (the segmented tab already says
     "Indices" / "Discussion") but keep their border/background -- only the
     skew-T section fully flattens per spec. */
  #indices-card .card-header,
  #interp-card .card-header {
    display: none;
  }

  #indices-card,
  #interp-card {
    margin: 0 14px;
  }

  /* Segment visibility: exactly one of {indices, discussion, evidence} is
     shown at a time (app.js toggles .mseg-hidden). */
  .mseg-hidden {
    display: none !important;
  }

  /* Evidence, when shown as its own segment, is surfaced as a plain list
     rather than a collapsed <details> -- app.js force-opens the element on
     mobile and this hides the now-redundant "Show the evidence" summary
     (desktop's collapsible behavior is untouched; this rule never applies
     there). */
  #interp-determined-wrap {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  #interp-determined-wrap summary {
    display: none;
  }
}

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

/* Belt-and-suspenders body scroll lock while the mobile full-screen sheet
   is open (app.js toggles this via setBodyScrollLocked). body is already
   a fixed-height, non-scrolling grid (see the base body rule above), so
   this mostly guards against iOS Safari's rubber-band overscroll chrome. */
body.sheet-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

/* Minor-feature expander in the evidence list (engine-tagged upper-level
   structure — real but distracting; see brief.py _annotate_importance). */
.evidence-minor {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.evidence-minor summary {
  color: var(--quiet);
  font-size: 0.78rem;
  cursor: pointer;
}

.evidence-minor summary:hover {
  color: var(--muted);
}

.evidence-minor p {
  margin-top: 10px;
}

/* About dialog creator block (mirrors the rp33/Sound Below presentation). */
.creator-line {
  display: grid;
  gap: 2px;
}

#creator-name-line {
  font-size: 0.95rem;
}

#creator-role-line {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}
