:root {
  /* FDL core theme API: component colors derive from these tokens. */
  --black: #000000;
  --main: #111427;
  --secondary: #faf9f5;
  --highlight: #479ff8;
  --earth-systems-lab: #019fa2;

  --ink: var(--main);
  --muted: color-mix(in srgb, var(--main) 58%, var(--secondary));
  --surface: var(--secondary);
  --surface-raised: var(--secondary);
  --surface-alt: color-mix(in srgb, var(--main) 4%, var(--secondary));
  --border: color-mix(in srgb, var(--main) 16%, var(--secondary));
  --border-strong: color-mix(in srgb, var(--main) 30%, var(--secondary));
  --accent: var(--highlight);
  --accent-ink: color-mix(in srgb, var(--highlight) 72%, var(--main));
  --accent-soft: color-mix(in srgb, var(--highlight) 12%, var(--secondary));
  --system-blue: #479ff8;
  --sar: color-mix(in srgb, var(--main) 70%, var(--secondary));
  color: var(--ink);
  background: var(--surface);
  color-scheme: light;
  font-family: "Helvetica Neue", "Helvetica New", Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

body.earth-systems-lab {
  --highlight: var(--earth-systems-lab);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--surface);
}

h1,
h2,
h3,
p {
  font-family: "Helvetica Neue", "Helvetica New", Helvetica, Arial, sans-serif;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.topbar {
  min-height: 58px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--secondary);
  background: var(--main);
  border-bottom: 3px solid var(--accent);
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  color: var(--secondary);
  font-size: 14px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 50%;
}

.brand-mark::before {
  content: "";
  width: 17px;
  height: 17px;
  border: 2px solid var(--secondary);
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-34deg);
}

.brand-mark i {
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--secondary);
  border-radius: 50%;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}

.brand-copy strong {
  letter-spacing: -0.01em;
}

.brand-copy small {
  color: color-mix(in srgb, var(--secondary) 68%, var(--main));
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy b {
  color: var(--accent);
}

.data-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  color: color-mix(in srgb, var(--secondary) 72%, var(--main));
  background: color-mix(in srgb, var(--secondary) 5%, var(--main));
  border: 1px solid color-mix(in srgb, var(--secondary) 20%, var(--main));
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.data-badge i {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

.inference-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 11px;
  color: var(--muted);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--secondary));
  border-radius: 3px;
  font-size: 11px;
}

.inference-notice strong {
  color: var(--ink);
}

.icon-button,
.docs-link {
  color: var(--secondary);
  background: color-mix(in srgb, var(--secondary) 5%, var(--main));
  border: 1px solid color-mix(in srgb, var(--secondary) 24%, var(--main));
  border-radius: 3px;
}

.icon-button:hover,
.docs-link:hover {
  color: var(--main);
  background: var(--accent);
  border-color: var(--accent);
}

.icon-button {
  width: 31px;
  height: 31px;
}

.docs-link {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.workspace {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: minmax(500px, 1.08fr) minmax(480px, 0.92fr);
  overflow: hidden;
}

.map-panel {
  min-width: 0;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.map-heading,
.analytics-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.map-heading h1,
.analytics-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  letter-spacing: -0.03em;
}

.storm-switcher {
  min-width: 220px;
}

.storm-switcher label {
  display: block;
  position: relative;
}

.storm-switcher label > span {
  position: absolute;
  left: 10px;
  top: 5px;
  color: var(--accent-ink);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.storm-switcher select {
  width: 100%;
  padding: 17px 32px 6px 9px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: 0;
  font-size: 10px;
  font-weight: 700;
  appearance: none;
}

.storm-switcher label::after {
  content: "⌄";
  position: absolute;
  right: 10px;
  top: 10px;
  color: var(--accent-ink);
  pointer-events: none;
}

.map {
  position: relative;
  flex: 1;
  min-height: 330px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px 0;
  color: var(--muted);
}

.timeline > button {
  flex: none;
  width: 36px;
  height: 36px;
  padding-left: 4px;
  color: var(--ink);
  background: var(--accent-soft);
  border: 0;
  border-radius: 3px;
}

.timeline > div {
  flex: 1;
  min-width: 0;
}

.timeline p,
.timeline footer {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font-size: 9px;
}

.timeline p strong {
  color: var(--ink);
}

.timeline input {
  width: 100%;
  height: 3px;
  margin: 9px 0 5px;
  accent-color: var(--accent);
}

.timeline footer {
  color: var(--muted);
  font-size: 8px;
}

.animation-control,
.speed-control {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.animation-control {
  cursor: pointer;
}

.animation-control input,
.postprocess-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.animation-control i,
.postprocess-toggle i {
  position: relative;
  width: 26px;
  height: 13px;
  background: var(--border-strong);
  border-radius: 99px;
}

.animation-control i::after,
.postprocess-toggle i::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 9px;
  height: 9px;
  background: var(--secondary);
  border-radius: 50%;
  transition: transform 0.15s;
}

.animation-control input:checked + i,
.postprocess-toggle input:checked + i {
  background: var(--accent);
}

.animation-control input:checked + i::after {
  transform: translateX(13px);
}

.speed-control select {
  min-width: 60px;
  padding: 5px 18px 5px 7px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

.analytics {
  padding: 22px clamp(20px, 3vw, 34px) 28px;
  overflow-y: auto;
  background: var(--surface-alt);
}

.category {
  min-width: 48px;
  height: 42px;
  padding: 4px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
}

.category small {
  font-size: 7px;
}

.category strong {
  font-size: 18px;
  line-height: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.summary-strip div {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
}

.summary-strip div:last-child {
  border: 0;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 7px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.model-toolbar,
.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin: 0 0 8px;
}

.model-toolbar label,
.postprocess-toggle {
  color: var(--muted);
  font-size: 7px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.model-toolbar select {
  min-width: 92px;
  padding: 6px 24px 6px 8px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 8px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend i {
  display: inline-block;
  width: 18px;
  height: 2px;
}

.geo-line {
  background: var(--accent);
}

.sar-line {
  border-top: 2px dashed var(--sar);
}

.legend small {
  margin-left: auto;
  color: var(--muted);
  text-align: right;
}

.nwp-line {
  border-top: 2px dashed var(--system-blue);
}

.ibtracs-line {
  border-top: 2px solid var(--black);
}

.ibtracs-path {
  fill: none;
  stroke: var(--black);
  stroke-width: 1.5;
}

.legend b {
  font-weight: inherit;
}

.charts {
  display: grid;
  gap: 8px;
}

.chart-card {
  padding: 11px 13px 7px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

.chart-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.chart-heading h3 {
  margin: 0;
  font-size: 11px;
}

.chart-heading span {
  color: var(--muted);
  font-size: 8px;
}

.chart {
  position: relative;
  height: 102px;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis {
  fill: var(--muted);
  font-size: 7px;
}

.geo-dot {
  fill: var(--surface-raised);
  stroke: var(--accent);
  stroke-width: 2;
}

.geo-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
}

.nwp-path {
  fill: none;
  stroke: var(--system-blue);
  stroke-width: 1.2;
  opacity: .7;
}

.sar-path {
  fill: none;
  stroke: var(--sar);
  stroke-width: 1.6;
  stroke-dasharray: 5 4;
}

.sar-dot {
  fill: var(--surface-raised);
  stroke: var(--sar);
  stroke-width: 2;
}

.cursor-line {
  stroke: var(--accent-ink);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.method-note {
  margin: 10px 1px 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}

.graph-toolbar {
  margin-top: 6px;
}

.postprocess-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.postprocess-toggle i {
  width: 20px;
  height: 10px;
}

.postprocess-toggle i::after {
  width: 6px;
  height: 6px;
}

.postprocess-toggle input:checked + i::after {
  transform: translateX(10px);
}

.tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  min-width: 128px;
  padding: 8px 10px;
  color: var(--secondary);
  background: var(--main);
  border: 1px solid color-mix(in srgb, var(--secondary) 18%, var(--main));
  border-radius: 3px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--main) 24%, transparent);
  font-size: 8px;
  line-height: 1.55;
  pointer-events: none;
}

dialog {
  width: min(440px, calc(100% - 30px));
  padding: 26px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 3px;
}

dialog::backdrop {
  background: color-mix(in srgb, var(--main) 46%, transparent);
}

.dialog-close {
  position: absolute;
  right: 10px;
  top: 8px;
  color: var(--muted);
  background: none;
  border: 0;
  font-size: 22px;
}

dialog h2 {
  margin: 7px 0;
}

dialog > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

dialog #confirmDialog {
  padding: 8px 13px;
  color: var(--ink);
  background: var(--accent-soft);
  border: 0;
  border-radius: 3px;
  font-weight: 700;
}

.loading {
  position: fixed;
  inset: 58px 0 0;
  z-index: 30;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--secondary);
  background: var(--main);
  transition: opacity 0.2s;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading span {
  width: 28px;
  height: 28px;
  border: 3px solid color-mix(in srgb, var(--secondary) 20%, var(--main));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading p {
  margin: 11px 0 0;
  font-size: 11px;
}

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

.leaflet-container {
  color: var(--ink);
  background: var(--surface-alt);
  font-family: inherit;
}

.leaflet-tile-pane {
  filter: saturate(0.68) contrast(0.94) brightness(1.04);
}

.leaflet-control-zoom a {
  color: var(--ink);
}

.leaflet-control-attribution,
.leaflet-attribution-flag {
  display: none !important;
}

.map-credit {
  position: absolute;
  z-index: 800;
  left: 5px;
  bottom: 2px;
  color: var(--main) !important;
  font-size: 7px;
  text-decoration: none;
}

.sar-overlay,
.pmw-overlay,
.geo-overlay {
  image-rendering: auto;
  mix-blend-mode: normal;
  filter: none;
}

.sar-tooltip,
.pmw-tooltip,
.geo-tooltip {
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
}

.intensity-key,
.pmw-key,
.geostat-key,
.leaflet-control-layers {
  color: var(--ink);
  background: color-mix(in srgb, var(--secondary) 94%, transparent);
  border: 1px solid var(--border) !important;
  border-radius: 3px !important;
  box-shadow: none !important;
  font-size: 9px;
}

.intensity-key,
.pmw-key,
.geostat-key {
  width: 150px;
  padding: 8px 9px;
}

.intensity-key strong,
.pmw-key strong,
.geostat-key strong {
  display: block;
  margin-bottom: 5px;
  font-size: 8px;
}

.intensity-key i,
.pmw-key i,
.geostat-key i {
  display: block;
  height: 7px;
  border-radius: 2px;
}

.intensity-key i {
  background: linear-gradient(90deg, #238b69, #f9cd43, #d53e30);
}

.geostat-key i {
  background: linear-gradient(90deg, #ffffff, #8ba9d9, #1652b4);
  border: 1px solid #ccd8e5;
}

.pmw-key i {
  background: linear-gradient(90deg, #2d004b, #cc4778, #f0f921);
  border: 1px solid #9b547b;
}
.intensity-key span,
.pmw-key span,
.geostat-key span {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--muted);
  font-size: 7px;
}


.category-key {
  display: flex;
  gap: 5px !important;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.category-key b {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 6.5px;
  font-weight: 700;
}

.category-key b::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--cat);
  border-radius: 50%;
}

.category-threshold {
  opacity: 0.7;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

@media (max-width: 1020px) {
  html,
  body {
    height: auto;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .map-panel {
    min-height: 700px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .analytics {
    overflow: visible;
  }

  .chart {
    height: 130px;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 0 12px;
  }

  .brand-copy small,
  .data-badge {
    display: none;
  }

  .map-panel {
    min-height: 640px;
    padding: 16px 12px;
  }

  .map-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .storm-switcher {
    width: 100%;
    min-width: 0;
  }

  .analytics {
    padding: 20px 12px;
  }

  .summary-strip strong {
    font-size: 13px;
  }

  .legend {
    flex-wrap: wrap;
  }

  .legend small {
    width: 100%;
    margin: 0;
    text-align: left;
  }

  .speed-control {
    display: none;
  }

  .animation-control span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
  }
}

/* Viewport dashboard layout */
html,
body {
  overflow: hidden;
}

.topbar {
  height: 58px;
}

.map-panel,
.map {
  min-height: 0;
}

.analytics {
  min-width: 0;
  min-height: 0;
  padding: 18px clamp(18px, 2.5vw, 30px) 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.summary-strip {
  grid-template-columns: 1.25fr repeat(4, 1fr);
  flex: none;
}

.system-summary strong {
  white-space: nowrap;
}

.category {
  min-width: 0;
  height: auto;
  padding: 10px 12px;
  display: block;
  background: var(--accent-soft);
  border-radius: 0;
}

.category strong {
  font-size: 15px;
  line-height: 1;
}

.charts {
  flex: 1;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}

.chart-card {
  min-height: 0;
  padding: 8px 11px 5px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart {
  height: auto;
  min-height: 38px;
  flex: 1;
}

.method-note {
  flex: none;
  margin-top: 7px;
  font-size: 7px;
  line-height: 1.35;
}

@media (max-width: 1020px) {
  html,
  body {
    height: 100%;
  }

  .workspace {
    height: calc(100% - 58px);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 42%) minmax(0, 58%);
    overflow: hidden;
  }

  .map-panel {
    min-height: 0;
    padding: 12px 16px 10px;
  }

  .map {
    min-height: 0;
  }

  .analytics {
    padding: 10px 16px 8px;
    overflow: hidden;
  }

  .charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .map-heading {
    margin-bottom: 8px;
  }

  .timeline {
    padding-top: 8px;
  }

  .legend small,
  .method-note {
    display: none;
  }
}

@media (max-width: 620px) {
  .map-panel {
    min-height: 0;
    padding: 10px 12px 8px;
  }

  .map-heading {
    align-items: end;
    flex-direction: row;
    gap: 8px;
  }

  .storm-switcher {
    width: 48%;
    min-width: 145px;
  }

  .analytics {
    padding: 8px 12px 7px;
  }

  .summary-strip div,
  .category {
    padding: 7px 6px;
  }

  .summary-strip strong,
  .category strong {
    font-size: 11px;
  }

  .legend {
    gap: 5px 10px;
    margin-bottom: 5px;
  }

  .model-toolbar {
    margin-bottom: 5px;
  }
}

@media (max-height: 760px) and (min-width: 1021px) {
  .analytics {
    padding-top: 12px;
    padding-bottom: 8px;
  }

  .method-note {
    display: none;
  }

  .chart-card {
    padding-top: 6px;
  }
}
