/* Lough Neagh temperature-dynamics diagram — Nature Reviews visual register.
   Palette: deep navy, cyan, terracotta, coral, slate-grey on white. */

:root {
  --navy: #0b2545;
  --navy-mid: #13315c;
  --cyan: #0aa6c2;
  --cyan-deep: #0e7c86;
  --cyan-pale: #d7f1f6;
  --terracotta: #c1663d;
  --coral: #e07a5f;
  --coral-hot: #e8856b;
  --slate: #6b7b8c;
  --slate-light: #9aa8b6;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --ink: #1a2332;
  --paper: #f7f9fb;
  --card: #ffffff;
  --line: rgba(11, 37, 69, 0.14);
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.06), 0 6px 18px rgba(11, 37, 69, 0.06);
  --radius: 10px;
  --font: "Segoe UI", "Helvetica Neue", "Arial", sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
}

#ln-app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ------------------------------------------------------------------ */
/* Header + controls                                                  */
/* ------------------------------------------------------------------ */
.ln-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 12px 18px 10px;
  background: #ffffff;
  border-bottom: 2px solid var(--navy);
}

.ln-title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--navy);
}

.ln-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--slate);
  letter-spacing: 0.02em;
}

.ln-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-end;
}

.ln-ctl-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  margin-bottom: 4px;
  font-weight: 600;
}

.ln-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.ln-seg-btn {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font: inherit;
  font-size: 11.5px;
  color: var(--navy-mid);
  cursor: pointer;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.ln-seg-btn:last-child {
  border-right: 0;
}

.ln-seg-btn:hover {
  background: var(--cyan-pale);
}

.ln-seg-btn.active {
  background: var(--navy);
  color: #fff;
}

.ln-ctl-diurnal {
  min-width: 220px;
}

.ln-phase-text {
  font-weight: 700;
  color: var(--navy);
}

.ln-diurnal-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 37, 69, 0.04);
  padding: 3px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.ln-phase-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--navy-mid);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ln-phase-btn:hover {
  background: var(--cyan-pale);
  border-color: var(--cyan);
}

.ln-phase-btn.active {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
  box-shadow: 0 1px 4px rgba(11, 37, 69, 0.2);
}

.ln-range-diurnal {
  width: 100px;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, #f4c430 0%, #7fd4e0 35%, #13315c 75%, #0a1628 100%);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.ln-range-diurnal::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--navy);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: grab;
  transition: transform 0.1s ease;
}

.ln-range-diurnal::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.ln-range-diurnal::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--navy);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

.ln-range {
  width: 160px;
  accent-color: var(--cyan-deep);
}

.ln-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ln-check {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--navy-mid);
  cursor: pointer;
  user-select: none;
}

.ln-check input {
  accent-color: var(--cyan-deep);
}

/* ------------------------------------------------------------------ */
/* Tier shells                                                        */
/* ------------------------------------------------------------------ */
.ln-tier {
  padding: 6px 18px 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.ln-tier-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 8px;
}

.ln-tier-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* Tier 1 — forcing ------------------------------------------------- */
.ln-forcing-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.ln-force-card {
  text-align: left;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
  background: var(--card);
  padding: 6px 9px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.ln-force-card:hover {
  transform: translateY(-1px);
  border-left-color: var(--coral);
}

.ln-force-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.ln-force-sym {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.ln-force-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--navy-mid);
}

.ln-force-unit {
  font-size: 10px;
  color: var(--slate);
  margin-bottom: 4px;
}

.ln-badge {
  display: block;
  margin: 4px 0;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  line-height: 1.35;
  text-align: left;
}

.ln-badge strong {
  display: block;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.ln-badge span {
  display: block;
  color: inherit;
  opacity: 0.92;
}

.ln-badge-high {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(180, 83, 9, 0.35);
}

.ln-badge-medium {
  background: #fff1ec;
  color: var(--terracotta);
  border: 1px solid rgba(193, 102, 61, 0.35);
}

.ln-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ln-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--cyan-pale);
  color: var(--cyan-deep);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* Mid / stage ------------------------------------------------------ */
.ln-mid {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
  display: flex;
  border-bottom: 1px solid var(--line);
}

.ln-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
  background: linear-gradient(180deg, #ffffff 0%, #f2f7fa 100%);
}

.ln-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}


.ln-eq-card {
  pointer-events: auto;
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  box-shadow: var(--shadow);
}

.ln-eq-card.inline {
  max-width: none;
  margin: 8px 0;
}

.ln-eq-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
  font-weight: 700;
  margin-bottom: 3px;
}

.ln-eq {
  font-family: var(--font-display);
  font-size: 13.5px;
  color: var(--navy);
  line-height: 1.5;
  overflow-x: auto;
  white-space: normal;
  padding-bottom: 2px;
}

.ln-tier-overlay {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.ln-eq-note {
  font-size: 10.5px;
  color: var(--slate);
  margin-top: 3px;
}

.ln-bathy-card {
  pointer-events: auto;
  width: 100%;
  max-width: 340px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan-deep);
  border-radius: var(--radius);
  padding: 7px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-left-color 0.12s ease;
  color: inherit;
  font: inherit;
}

.ln-bathy-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(11, 37, 69, 0.12);
  border-left-color: var(--coral);
}

.ln-bathy-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.ln-bathy-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
}

.ln-bathy-badge {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--cyan-deep);
  background: var(--cyan-pale);
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.ln-bathy-zoom-hint {
  font-size: 9px;
  font-weight: 700;
  color: var(--navy);
  background: #ffffff;
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: auto;
  margin-right: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

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

.ln-legend {
  pointer-events: auto;
  align-self: flex-end;
  width: 100%;
  max-width: 220px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  box-shadow: var(--shadow);
}

.ln-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--navy-mid);
  margin: 3px 0;
}

.ln-legend-swatch {
  width: 28px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.ln-k-radiative {
  background: linear-gradient(90deg, var(--coral) 0%, var(--coral) 45%, transparent 45%, transparent 55%, var(--coral) 55%);
  background-size: 8px 8px;
  background-color: #f6d7cf;
}

.ln-k-turbulent {
  background: var(--slate);
}

.ln-k-advected {
  background: repeating-linear-gradient(90deg, var(--coral) 0 8px, var(--cyan-deep) 8px 16px);
}

.ln-k-diffusion {
  background: var(--terracotta);
  opacity: 0.7;
}

/* Tier 3 — pipeline ------------------------------------------------ */
.ln-pipe-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
}

.ln-pipe-card {
  flex: 1 1 0;
  min-width: 180px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 6px 9px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}

.ln-pipe-card:hover {
  transform: translateY(-1px);
}

.ln-pipe-card.v-fail {
  border-top: 3px solid var(--slate);
}

.ln-pipe-card.v-partial {
  border-top: 3px solid var(--coral);
}

.ln-pipe-card.v-pass {
  border-top: 3px solid var(--cyan-deep);
}

.ln-pipe-card.v-mixed {
  border-top: 3px solid var(--terracotta);
}

.ln-pipe-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--slate);
  font-weight: 700;
}

.ln-pipe-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin: 2px 0 4px;
  font-family: var(--font-display);
}

.ln-pipe-points {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--navy-mid);
}

.ln-pipe-points li {
  margin: 1px 0;
}

.ln-pipe-verdict {
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ln-v-fail {
  color: var(--slate);
}

.ln-v-partial {
  color: var(--terracotta);
}

.ln-v-pass {
  color: var(--cyan-deep);
}

.ln-v-mixed {
  color: var(--warn);
}

.ln-pipe-arrow {
  display: flex;
  align-items: center;
  color: var(--cyan-deep);
  font-size: 18px;
  font-weight: 700;
  padding: 0 2px;
}

.ln-model-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ln-note-pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--navy-mid);
}

/* Tier 4 — error matrix -------------------------------------------- */
.ln-error-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ln-error-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 6px 9px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
}

.ln-error-card.e-b0 {
  border-top: 3px solid var(--cyan);
}

.ln-error-card.e-b1 {
  border-top: 3px solid var(--coral);
}

.ln-error-card.e-range {
  border-top: 3px solid var(--terracotta);
}

.ln-error-card.ln-roadmap {
  border-top: 3px solid var(--navy);
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fa 100%);
}

.ln-error-head {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  line-height: 1.3;
}

.ln-panel-tag {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  font-family: var(--font);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: 1px;
}

.ln-error-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.ln-error-row-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  padding: 2px 0;
  border-bottom: 1px dotted var(--line);
}

.ln-error-row-line .k {
  color: var(--slate);
  font-weight: 600;
}

.ln-error-row-line .v {
  color: var(--navy);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ln-error-cause,
.ln-error-fix {
  font-size: 11px;
  color: var(--navy-mid);
  margin-top: 4px;
}

.ln-k-label {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
  margin-right: 5px;
}

.ln-road-item {
  padding: 3px 0;
  border-bottom: 1px dotted var(--line);
}

.ln-road-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--navy);
}

.ln-road-why {
  font-size: 10.5px;
  color: var(--slate);
}

/* ------------------------------------------------------------------ */
/* Detail drawer + tooltip                                            */
/* ------------------------------------------------------------------ */
.ln-detail {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 92vw);
  height: 100%;
  background: #fff;
  border-left: 2px solid var(--navy);
  box-shadow: -8px 0 24px rgba(11, 37, 69, 0.12);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  z-index: 40;
  overflow-y: auto;
  padding: 16px 16px 24px;
}

.ln-detail.open {
  transform: translateX(0);
}

.ln-detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--slate);
  cursor: pointer;
}

.ln-detail-body h3 {
  margin: 8px 28px 10px 0;
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--navy);
  line-height: 1.25;
}

.ln-detail-text {
  font-size: 12.5px;
  color: var(--ink);
}

.ln-detail-text p {
  margin: 8px 0;
}

.ln-detail-list {
  margin: 6px 0;
  padding-left: 18px;
}

.ln-detail-road {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.ln-verdict {
  font-weight: 700;
  margin-top: 8px;
}

.ln-muted {
  color: var(--slate);
}

.ln-tip {
  position: fixed;
  z-index: 50;
  max-width: 320px;
  background: rgba(11, 37, 69, 0.95);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.ln-tip.show {
  opacity: 1;
  transform: translateY(0);
}

.ln-tip strong {
  display: block;
  font-family: var(--font-display);
  font-size: 12.5px;
  margin-bottom: 3px;
  color: #bfe8f0;
}

.ln-tip span {
  display: block;
  line-height: 1.4;
  opacity: 0.95;
}

/* ------------------------------------------------------------------ */
/* Widescreen / compact tweaks                                        */
/* ------------------------------------------------------------------ */
@media (min-width: 1400px) {
  .ln-title h1 {
    font-size: 24px;
  }

  .ln-eq {
    font-size: 14.5px;
  }
}

@media (max-width: 1100px) {
  .ln-forcing-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .ln-error-row {
    grid-template-columns: repeat(2, 1fr);
  }

}

@media (max-width: 720px) {
  .ln-forcing-row {
    grid-template-columns: 1fr 1fr;
  }

  .ln-error-row {
    grid-template-columns: 1fr;
  }

  .ln-mid {
    min-height: 300px;
  }

  .ln-modal-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .ln-modal-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ------------------------------------------------------------------ */
/* Transect Bathymetry Zoom Modal                                     */
/* ------------------------------------------------------------------ */
.ln-bathy-modal-backdrop,
.ln-map-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ln-bathy-modal-backdrop.open,
.ln-map-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.ln-bathy-modal,
.ln-map-modal {
  position: relative;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(11, 37, 69, 0.35), 0 4px 16px rgba(11, 37, 69, 0.1);
  border: 1px solid rgba(11, 37, 69, 0.18);
  width: 100%;
  max-width: 1040px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ln-bathy-modal-backdrop.open .ln-bathy-modal,
.ln-map-modal-backdrop.open .ln-map-modal {
  transform: scale(1) translateY(0);
}

.ln-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ln-modal-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan-deep);
  background: var(--cyan-pale);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.ln-modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}

.ln-modal-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--slate);
  line-height: 1.4;
}

.ln-modal-close {
  background: #f0f4f8;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: var(--navy);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.ln-modal-close:hover {
  background: var(--coral);
  color: #ffffff;
  border-color: var(--coral);
}

.ln-modal-svg-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fb 100%);
  padding: 12px 14px 6px;
  box-shadow: inset 0 1px 3px rgba(11, 37, 69, 0.04);
}

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

.ln-bathy-dot {
  fill: #5c4632;
  transition: all 0.15s ease;
  cursor: pointer;
}

.ln-bathy-dot:hover {
  fill: var(--coral);
  r: 5px;
}

.ln-modal-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.ln-modal-metric {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
}

.ln-metric-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate);
  margin-bottom: 2px;
}

.ln-metric-val {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.ln-metric-sub {
  font-size: 10.5px;
  color: var(--slate);
  margin-top: 2px;
}

.ln-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.ln-modal-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ln-action-note {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
}

.ln-modal-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--navy-mid);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ln-modal-btn:hover {
  background: var(--cyan-pale);
  border-color: var(--cyan);
}

.ln-btn-primary {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
}

.ln-btn-primary:hover {
  background: var(--navy-mid);
  color: #ffffff;
}

/* ------------------------------------------------------------------ */
/* 2D Satellite Background Map Card (like Transect Bathymetry)        */
/* ------------------------------------------------------------------ */
.ln-map-card {
  pointer-events: auto;
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan-deep);
  border-radius: var(--radius);
  padding: 7px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-left-color 0.12s ease;
  color: inherit;
  font: inherit;
  display: block;
}

.ln-map-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(11, 37, 69, 0.12);
  border-left-color: var(--coral);
}

.ln-map-preview-wrap {
  position: relative;
  width: 100%;
  height: 165px;
  border-radius: 6px;
  overflow: hidden;
  background: #0b2545;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4);
}

.ln-map-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0b2545;
}

.ln-map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ln-map-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8.5px;
  color: var(--slate);
  margin-top: 5px;
}

.ln-map-foot-left {
  font-weight: 600;
  color: var(--navy);
}

/* Modal high-resolution map viewer */
.ln-modal-map-wrap {
  background: #0b2545;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.ln-modal-map-container {
  position: relative;
  width: 100%;
  max-width: 820px;
  height: 480px;
}

.ln-modal-map-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ln-modal-map-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.ln-modal-pin {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.ln-modal-pin:hover {
  filter: brightness(1.25) drop-shadow(0 0 8px #ffffff);
}

@media (max-width: 900px) {
  .ln-modal-map-container {
    height: 320px;
  }
}

/* W0 reference flux controls and compact scene key */
.ln-flux-select {
  min-height: 30px;
  padding: 5px 30px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font: inherit;
}
.ln-controls button:focus-visible,
.ln-controls select:focus-visible,
.ln-controls input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.ln-flux-key {
  flex: 0 0 286px;
  padding: 18px 16px;
  background: #fff;
  border-left: 1px solid var(--line);
  color: var(--navy);
  z-index: 2;
}
.ln-flux-key h2 {
  margin: 0 0 3px;
  font: 700 18px/1.2 var(--font-display);
}
.ln-flux-sub { margin: 0 0 12px; font-weight: 700; color: var(--cyan-deep); }
.ln-flux-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ln-flux-table caption { text-align: left; font-size: 11px; color: var(--slate); padding-bottom: 4px; }
.ln-flux-table th, .ln-flux-table td { padding: 5px 2px; border-bottom: 1px solid var(--line); }
.ln-flux-table th { text-align: left; font-weight: 500; }
.ln-flux-table td { text-align: right; font-weight: 700; white-space: nowrap; }
.ln-flux-solar td { color: #806300; }
.ln-flux-radiative td { color: #a14a30; }
.ln-flux-turbulent td { color: #455468; }
.ln-flux-note, .ln-flux-source { font-size: 11px; line-height: 1.45; margin: 12px 0 0; }
.ln-flux-source { padding-top: 10px; border-top: 1px solid var(--line); color: #48596b; }
.ln-stage { min-width: 0; min-height: 540px; }
.ln-tier-overlay { font-size: 11px; }
@media (max-width: 1100px) {
  .ln-mid { flex-direction: column; }
  .ln-stage { flex: none; min-height: 500px; height: 500px; }
  .ln-flux-key { flex: none; border-left: 0; border-top: 1px solid var(--line); }
  .ln-flux-table { max-width: 640px; }
}
@media (max-width: 720px) {
  .ln-header { padding: 12px; }
  .ln-controls { gap: 8px; }
  .ln-ctl { min-width: 0; }
  .ln-seg { max-width: calc(100vw - 24px); overflow-x: auto; }
  .ln-seg-btn { padding: 7px 8px; }
  .ln-stage { height: 400px; min-height: 400px; }
  .ln-tier-overlay { max-width: calc(100% - 18px); white-space: normal; text-align: center; }
  .ln-flux-key { padding: 16px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ln-phase-btn, .ln-seg-btn { transition: none; }
}
.ln-flux-scene-badge {
  position: absolute;
  z-index: 5;
  top: 48px;
  right: 12px;
  padding: 5px 9px;
  border: 1px solid rgba(11,37,69,.2);
  border-radius: 6px;
  background: rgba(255,255,255,.94);
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
@media (max-width: 720px) {
  .ln-flux-scene-badge { top: 58px; right: 8px; }
}
@media (max-width: 720px) {
  .ln-tier-overlay {
    left: 8px;
    top: 8px;
    transform: none;
    width: 172px;
    max-width: 172px;
    border-radius: 8px;
    padding: 5px 7px;
    font-size: 9px;
    line-height: 1.25;
  }
  .ln-flux-scene-badge {
    top: 8px;
    right: 8px;
    max-width: 170px;
    text-align: right;
    font-size: 10px;
    line-height: 1.3;
  }
}

/* Restored equation/map/bathymetry rail and live Tier 1 budget */
.ln-budget-live {
  margin: 0 0 8px;
  padding: 9px 14px;
  background: #eef7f9;
  border: 1px solid rgba(14,124,134,.25);
  border-left: 4px solid var(--cyan-deep);
  border-radius: 8px;
  color: var(--navy);
}
.ln-budget-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--cyan-deep); }
.ln-budget-note { margin-top: 3px; color: #475b68; font-size: 10.5px; }
.ln-context-rail {
  flex: 0 0 244px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  background: #f2f7fa;
  border-right: 1px solid var(--line);
}
.ln-context-rail .ln-eq-card,
.ln-context-rail .ln-map-card,
.ln-context-rail .ln-bathy-card,
.ln-context-rail .ln-legend { width: 100%; max-width: none; }
.ln-context-rail .ln-map-preview-wrap { height: 125px; }
.ln-context-rail .ln-eq-card { padding: 7px 9px; }
.ln-context-rail .ln-eq { font-size: 12px; }
.ln-context-rail .ln-legend { align-self: stretch; }
.ln-context-rail .ln-bathy-head { flex-wrap: wrap; }
.ln-context-rail .ln-bathy-badge { white-space: normal; }
@media (max-width: 1250px) {
  .ln-mid { flex-wrap: wrap; }
  .ln-context-rail { order: 3; flex: 1 1 100%; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; border-right: 0; border-top: 1px solid var(--line); }
  .ln-context-rail .ln-map-preview-wrap { height: 160px; }
}
@media (max-width: 720px) {
  .ln-context-rail { display: flex; }
  .ln-context-rail .ln-map-preview-wrap { height: 180px; }
}
.ln-forcing-details { margin-top: 6px; }
.ln-forcing-details summary {
  display: inline-block;
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--navy);
  background: white;
  font-size: 11px;
  font-weight: 700;
}
.ln-forcing-details summary:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.ln-forcing-details[open] .ln-forcing-row { margin-top: 8px; }
.ln-flux-scale { margin: 12px 0 0; padding: 9px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.ln-flux-scale-item { display: flex; align-items: center; gap: 8px; min-height: 18px; font-size: 10px; }
.ln-flux-scale-value { width: 28px; font-variant-numeric: tabular-nums; }
.ln-flux-scale-bar { display: inline-block; width: 65px; min-height: 2px; border-radius: 99px; background: var(--navy); }
@media (min-width: 1251px) {
  .ln-mid { height: 550px; min-height: 550px; flex: none; }
  .ln-stage { min-height: 0; }
  .ln-context-rail, .ln-flux-key { overflow-y: auto; scrollbar-width: thin; }
}

/* Section 1: equation assembled from live value panes */
.ln-budget-live { padding: 11px 12px; }
.ln-budget-head { margin-bottom: 8px; }
.ln-budget-math { display: flex; align-items: stretch; gap: 5px; }
.ln-budget-pane {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 112px;
  padding: 9px 10px;
  border: 1px solid rgba(11,37,69,.15);
  border-top: 4px solid var(--slate);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(11,37,69,.05);
}
.ln-budget-result { flex: 1.16 1 0; border-top-color: var(--navy); background: #f5f8fb; }
.ln-budget-solar { border-top-color: #d6a900; }
.ln-budget-longwave { border-top-color: var(--coral); }
.ln-budget-emitted { border-top-color: #a64630; }
.ln-budget-turbulent { border-top-color: var(--slate); }
.ln-budget-symbol { color: var(--navy); font: 700 16px/1.2 var(--font-display); }
.ln-budget-name { min-height: 32px; margin-top: 3px; color: #45586b; font-size: 11px; line-height: 1.2; }
.ln-budget-number { margin-top: 6px; color: var(--navy); font-size: 23px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.ln-budget-unit { margin-top: 3px; color: #526477; font-size: 10px; }
.ln-budget-op { align-self: center; flex: 0 0 20px; text-align: center; color: var(--navy); font: 700 23px/1 var(--font-display); }
.ln-budget-mobile-op { display: none; }
.ln-budget-note { margin-top: 8px; }

/* Section 3/4 disclosures stay compact until opened. */
.ln-collapsible-tier { margin: 0; border-bottom: 1px solid var(--line); background: #fff; }
.ln-collapsible-tier > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  padding: 9px 18px;
  margin: 0;
}
.ln-collapsible-tier > summary::-webkit-details-marker { display: none; }
.ln-collapsible-tier > summary::after { content: "⌄"; margin-left: 3px; color: var(--navy); font-size: 16px; }
.ln-collapsible-tier[open] > summary::after { content: "⌃"; }
.ln-collapsible-tier > summary:focus-visible { outline: 3px solid var(--cyan); outline-offset: -3px; }
.ln-collapsible-tier .ln-tier { padding-top: 0; }
.ln-collapsible-tier .ln-tier > .ln-tier-head { display: none; }
.ln-disclosure-hint { margin-left: auto; color: var(--cyan-deep); font-size: 10px; font-weight: 700; text-transform: none; letter-spacing: 0; }

/* Give map, bathymetry and equation cards a readable desktop width. */
.ln-context-rail { flex-basis: 322px; padding: 14px; }
.ln-context-rail .ln-map-preview-wrap { height: 170px; }
.ln-context-rail .ln-eq { font-size: 14px; }
.ln-context-rail .ln-eq-title, .ln-context-rail .ln-bathy-title { font-size: 11px; }
@media (max-width: 1250px) {
  .ln-context-rail { flex-basis: 100%; }
}
@media (max-width: 1050px) {
  .ln-budget-math { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
  .ln-budget-op { display: none; }
  .ln-budget-pane { min-height: 105px; }
  .ln-budget-mobile-op { display: inline-block; position: absolute; right: 9px; top: 7px; color: var(--navy); font-size: 18px; font-weight: 700; }
  .ln-budget-result { grid-column: 1 / -1; min-height: 88px; }
  .ln-budget-result .ln-budget-name { min-height: 0; }
}
@media (max-width: 600px) {
  .ln-budget-math { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ln-budget-pane { min-height: 116px; }
  .ln-budget-number { font-size: 21px; }
  .ln-budget-symbol { font-size: 15px; }
  .ln-budget-name { font-size: 10.5px; }
  .ln-collapsible-tier > summary { padding: 10px 12px; font-size: 10px; }
}

/* Twice-width context rail with a full model column beside it. */
.ln-mid {
  display: grid;
  grid-template-columns: minmax(0, 644px) minmax(0, 1fr);
  align-items: start;
  height: auto;
  min-height: 0;
  flex: none;
}
.ln-model-column { min-width: 0; display: flex; flex-direction: column; }
.ln-model-column .ln-stage { flex: none; height: 630px; min-height: 630px; }
.ln-model-column .ln-flux-key { flex: none; border-left: 0; border-top: 1px solid var(--line); }
.ln-context-rail {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 18px;
  overflow: visible;
}
.ln-context-rail .ln-map-preview-wrap { height: 280px; }
.ln-context-rail .ln-eq { font-size: 17px; }
.ln-context-rail .ln-eq-title, .ln-context-rail .ln-bathy-title { font-size: 12px; }

/* Bottom drawers leave the model area free until requested. */
#ln-app { padding-bottom: 46px; }
.ln-bottom-drawers {
  position: fixed;
  inset: auto 0 0;
  z-index: 60;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: white;
  border-top: 2px solid var(--navy);
  box-shadow: 0 -3px 14px rgba(11,37,69,.13);
}
.ln-bottom-drawers .ln-collapsible-tier { min-width: 0; border-bottom: 0; }
.ln-bottom-drawers .ln-collapsible-tier + .ln-collapsible-tier { border-left: 1px solid var(--line); }
.ln-bottom-drawers .ln-collapsible-tier > summary { min-height: 44px; padding: 7px 16px; }
.ln-bottom-drawers .ln-collapsible-tier[open] > summary { background: var(--navy); color: white; }
.ln-bottom-drawers .ln-collapsible-tier[open] > summary .ln-tier-num { background: white; color: var(--navy); }
.ln-bottom-drawers .ln-collapsible-tier[open] > summary::after,
.ln-bottom-drawers .ln-collapsible-tier[open] .ln-disclosure-hint { color: white; }
.ln-bottom-drawers .ln-collapsible-tier > .ln-tier {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 46px;
  z-index: 59;
  max-height: min(72vh, 720px);
  overflow-y: auto;
  padding: 18px 20px;
  background: #f7f9fb;
  border-top: 2px solid var(--navy);
  box-shadow: 0 -14px 30px rgba(11,37,69,.2);
}
.ln-bottom-drawers .ln-collapsible-tier[open] > .ln-tier { animation: ln-drawer-up .24s ease-out both; }
@keyframes ln-drawer-up { from { transform: translateY(32px); opacity: .2; } to { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ln-bottom-drawers .ln-collapsible-tier[open] > .ln-tier { animation: none; }
}
@media (max-width: 1300px) {
  .ln-mid { display: flex; flex-direction: column; }
  .ln-model-column { order: 0; width: 100%; }
  .ln-context-rail { order: 1; height: auto; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .ln-model-column .ln-stage { height: 570px; min-height: 570px; }
}
@media (max-width: 720px) {
  .ln-model-column .ln-stage { height: 400px; min-height: 400px; }
  .ln-context-rail { display: flex; padding: 14px; }
  .ln-context-rail .ln-map-preview-wrap { height: 200px; }
  .ln-bottom-drawers .ln-collapsible-tier > summary { padding: 5px 8px; min-height: 46px; font-size: 10px; line-height: 1.15; }
  .ln-bottom-drawers .ln-disclosure-hint { display: none; }
  .ln-bottom-drawers .ln-collapsible-tier > .ln-tier { bottom: 46px; padding: 12px; max-height: 75vh; }
}

/* Keep the reference values in a right rail, level with the cutaway. */
@media (min-width: 1301px) {
  .ln-mid { grid-template-columns: minmax(0, 644px) minmax(0, 1fr) 270px; align-items: stretch; }
  .ln-model-column { min-width: 0; }
  .ln-model-column .ln-stage { height: 700px; min-height: 700px; }
  .ln-mid > .ln-flux-key {
    width: 270px;
    height: 700px;
    min-height: 0;
    overflow-y: auto;
    border-top: 0;
    border-left: 1px solid var(--line);
    scrollbar-width: thin;
  }
  .ln-context-rail { height: 700px; overflow-y: auto; scrollbar-width: thin; }
}
@media (min-width: 721px) and (max-width: 1300px) {
  .ln-mid { display: grid; grid-template-columns: minmax(0,1fr) 270px; }
  .ln-model-column { grid-column: 1; grid-row: 1; width: auto; }
  .ln-mid > .ln-flux-key {
    grid-column: 2;
    grid-row: 1;
    width: 270px;
    height: 570px;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    border-top: 0;
  }
  .ln-context-rail { grid-column: 1 / -1; grid-row: 2; order: 0; }
}
@media (max-width: 720px) {
  .ln-mid > .ln-flux-key { order: 1; width: 100%; }
  .ln-context-rail { order: 2; }
}
/* Keep every desktop panel in one row; no empty second grid row. */
@media (min-width: 1200px) {
  .ln-mid {
    display: grid;
    grid-template-columns: clamp(360px, calc(100% - 960px), 644px) minmax(0, 1fr) 270px;
    align-items: stretch;
    flex: 1 0 700px;
    min-height: 700px;
  }
  .ln-context-rail {
    grid-column: 1;
    grid-row: 1;
    order: 0;
    width: 100%;
    height: 100%;
    display: flex;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-top: 0;
  }
  .ln-model-column { grid-column: 2; grid-row: 1; width: auto; height: 100%; }
  .ln-model-column .ln-stage { height: 100%; min-height: 700px; }
  .ln-mid > .ln-flux-key {
    grid-column: 3;
    grid-row: 1;
    width: 270px;
    height: 100%;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    border-top: 0;
  }
}
