:root {
  --space: #000000;
  --surface: #051b41;          
  --line: #0b3d91;             
  --text: #ffffff;
  --muted: #aeb0b5;            
  --accent: #fc3d21;           
  --on-accent: #000000;        

  --radius: 4px;

  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  
  --step--1: 0.8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;

  
  --s1: 0.5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2rem;

  --measure: 70ch;
  --gutter: clamp(1rem, 3vw, 2rem);
  --tool: 2.75rem;             
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--space);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 100%;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
p { max-width: var(--measure); }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

#app { position: fixed; inset: 0; overflow: hidden; background: var(--space); }
#globe-container { position: absolute; inset: 0; }
#globe-container canvas { display: block; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }



h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step-4);
  line-height: 1.1;
  letter-spacing: 0;
}
.eyebrow { font-size: var(--step--1); font-weight: 500; color: var(--muted); margin-bottom: var(--s1); }
.lede { font-size: var(--step-0); color: var(--muted); margin-top: var(--s1); max-width: 48ch; }

#intro-overlay {
  position: absolute;
  inset: 0;
  padding: calc(var(--s3) + var(--safe-t)) var(--gutter) 0 calc(var(--gutter) + var(--safe-l));
  pointer-events: none;
  transition: opacity 600ms linear;
}
#intro-overlay.fade-out { opacity: 0; }
#intro-text { text-align: left; max-width: 28rem; }



#left-rail {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(calc(21rem + var(--gutter) * 2), 100%);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: calc(var(--s3) + var(--safe-t)) var(--gutter) calc(var(--s3) + 2.5rem + var(--s1) + var(--safe-b)) calc(var(--gutter) + var(--safe-l));
  pointer-events: none;
}
#left-rail > * { pointer-events: auto; }
.head { pointer-events: none !important; text-align: left; }



#nisar-panel, #timeline, #settings-panel, #menu-panel, #change-legend, #status-bar, .tool-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s2);
}
.kicker { font-size: var(--step--1); color: var(--muted); }
h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--step-2); line-height: 1.1; letter-spacing: 0; }
h3 { font-size: var(--step--1); font-weight: 600; color: var(--muted); }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--step-0);
}
.icon-btn:disabled { color: var(--muted); border-color: transparent; cursor: default; opacity: 0.4; }
.ph { display: block; }



#nisar-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: var(--s2);
  gap: var(--s2);
}
#panel-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: var(--s2); min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

#compare-figure {
  position: relative;
  flex: 1 1 auto;
  min-height: 12rem;
  height: auto;
  background: var(--space);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
#compare-img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Before/After switch sits centred directly under the comparison image */
.compare-bar { display: flex; justify-content: center; }
.comparison-switch {
  display: flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.comparison-option {
  min-width: 4.5rem;
  height: 2rem;
  padding: 0 var(--s2);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 600;
}
.comparison-option.is-active { background: var(--accent); color: var(--on-accent); }


#nisar-no-img { padding: var(--s3) var(--s2); }
#nisar-no-img .ph, #calendar-empty .ph { font-size: var(--step-2); color: var(--muted); margin-bottom: var(--s1); }
.empty-title { font-size: var(--step-0); font-weight: 600; }
.empty-body { font-size: var(--step--1); color: var(--muted); margin-top: 0.25rem; max-width: 36ch; }

.readout-label { font-size: var(--step--1); color: var(--muted); }
.readout-date { font-family: var(--font-display); font-weight: 700; font-size: var(--step-2); line-height: 1.1; font-variant-numeric: tabular-nums; }

.facts { display: grid; gap: 0.25rem; padding-top: var(--s2); border-top: 1px solid var(--line); font-size: var(--step--1); }
.facts > div { display: grid; grid-template-columns: 4.5rem 1fr; gap: var(--s1); }
.facts dt { color: var(--muted); }
.facts dd { font-weight: 500; font-variant-numeric: tabular-nums; }
.validation-status { margin-top: var(--s2); }
.validation-status > div { grid-template-columns: 4.5rem 1fr; }
.validation-status dd { line-height: 1.45; }

#comparison-explanation { font-size: var(--step--1); color: var(--muted); padding-top: var(--s2); border-top: 1px solid var(--line); }

#nisar-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.375rem;
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}



#toolbar {
  position: absolute;
  z-index: 30;
  top: calc(var(--s3) + var(--safe-t));
  right: calc(var(--gutter) + var(--safe-r));
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s1);
}
.tool-btn {
  display: grid;
  place-items: center;
  width: var(--tool);
  height: var(--tool);
  padding: 0;
  font-size: var(--step-2);
}
.tool-btn[aria-expanded="true"] { border-color: var(--accent); }
.history-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: auto;
  min-width: var(--tool);
  padding: 0 0.85rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.history-tool-btn .ph { font-size: 1.15rem; }
.history-tool-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }

#menu-panel {
  position: absolute;
  top: 0;
  right: calc(var(--tool) + var(--s1));
  display: grid;
  gap: 0.25rem;
  width: min(19rem, calc(100vw - var(--tool) - var(--gutter) * 2 - var(--s2)));
  padding: 0.65rem;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  backdrop-filter: blur(22px) saturate(145%);
  box-shadow: 0 18px 55px rgb(0 0 0 / 22%), 0 2px 8px rgb(0 0 0 / 10%);
  transform-origin: top right;
}
#menu-panel:not([hidden]) { animation: menu-enter 220ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes menu-enter {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.menu-heading { display: grid; gap: 0.2rem; padding: 0.8rem 0.8rem 0.95rem; }
.menu-eyebrow, .menu-section-label { color: var(--muted); font-size: 0.62rem; font-weight: 700; letter-spacing: .13em; }
.menu-heading strong { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: -.02em; }
.menu-section-label { padding: 0.35rem 0.8rem 0.15rem; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 3.45rem;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) * .8);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.menu-item:hover, .menu-item:focus-visible {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}
.menu-item:active { transform: scale(.985); }
.menu-icon { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: .7rem; background: color-mix(in srgb, var(--surface) 70%, var(--line)); font-size: 1.15rem; }
.menu-copy { display: grid; flex: 1; gap: .12rem; min-width: 0; }
.menu-copy strong { font-size: .83rem; font-weight: 650; }
.menu-copy small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.menu-arrow { color: var(--muted); font-size: .9rem; }
.menu-divider { height: 1px; margin: .35rem .7rem; background: var(--line); }
.menu-footer { display: flex; align-items: center; gap: .5rem; padding: .65rem .8rem .35rem; color: var(--muted); font-size: .68rem; }
.menu-status-dot { width: .42rem; height: .42rem; border-radius: 50%; background: #35b779; box-shadow: 0 0 0 3px rgb(53 183 121 / 14%); }
#menu-btn { transition: transform 180ms ease, border-color 180ms ease, background 180ms ease; }
#menu-btn[aria-expanded="true"] { transform: rotate(90deg); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
#settings-panel:not([hidden]) { animation: menu-enter 200ms cubic-bezier(.2,.8,.2,1) both; }

#settings-panel {
  position: absolute;
  z-index: 31;
  top: calc(var(--s3) + var(--safe-t));
  right: calc(var(--gutter) + var(--safe-r) + var(--tool) + var(--s1));
  width: min(20rem, calc(100vw - var(--gutter) * 2 - var(--tool) - var(--s1)));
  padding: var(--s2);
}
#settings-panel .panel-head { margin-bottom: var(--s2); }
#settings-panel fieldset { display: grid; gap: var(--s1); margin: 0; padding: 0; border: 0; }
#settings-panel legend { margin-bottom: var(--s1); color: var(--muted); font-size: var(--step--1); padding: 0; }
#settings-panel label { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
#settings-panel label:has(input:checked) { border-color: var(--accent); }
#settings-panel input { margin: 0.25rem 0 0; accent-color: var(--accent); }
#settings-panel label span { display: grid; gap: 0.125rem; }
#settings-panel label strong { font-size: var(--step--1); font-weight: 600; }
#settings-panel label small { color: var(--muted); font-size: var(--step--1); line-height: 1.4; }



#timeline {
  position: absolute;
  z-index: 25;
  top: calc(var(--s3) + var(--safe-t) + var(--tool) + var(--s1));
  right: calc(var(--gutter) + var(--safe-r));
  bottom: calc(var(--s3) + var(--safe-b));
  width: min(21rem, calc(100vw - var(--gutter) * 2));
  display: flex;
  flex-direction: column;
  padding: var(--s2);
  gap: var(--s2);
}
#calendar-status { font-size: var(--step--1); color: var(--muted); margin-top: 0.25rem; }
#calendar-body { display: flex; flex-direction: column; gap: var(--s2); min-height: 0; flex: 1; padding-top: var(--s2); border-top: 1px solid var(--line); }

.cal-month { display: flex; align-items: center; justify-content: space-between; gap: var(--s1); }
#cal-title { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); color: var(--text); line-height: 1.1; }
.cal-weekdays, #cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; }
.cal-weekdays { margin-bottom: calc(var(--s1) * -1 + 0.25rem); }
.cal-weekdays span { font-size: var(--step--1); color: var(--muted); padding-left: 0.5rem; }

.cal-day {
  height: 2.25rem;
  padding: 0 0 0 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--step--1);
  text-align: left;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.cal-day.has-data { background: var(--line); color: var(--text); font-weight: 600; cursor: pointer; }
.cal-day.has-data[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.cal-blank { height: 2.25rem; }

.cal-jump { display: flex; gap: var(--s1); }
.text-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  height: 2.5rem;
  padding: 0 var(--s2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 500;
}
.text-btn:last-child { justify-content: space-between; flex-direction: row; }
.text-btn:first-child { justify-content: flex-start; }
.text-btn:disabled { color: var(--muted); opacity: 0.4; cursor: default; }
.text-btn .ph { font-size: var(--step-0); }

.list-title { padding-top: var(--s2); border-top: 1px solid var(--line); }
#calendar-dates { display: flex; flex-direction: column; gap: 0.25rem; min-height: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.date-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: var(--s1);
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--step--1);
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.date-row .count { color: var(--muted); }
.date-row .tag { grid-column: 1 / -1; color: var(--muted); }
.date-row[aria-pressed="true"] { border-color: var(--accent); background: var(--line); }
.date-row[aria-pressed="true"] .count, .date-row[aria-pressed="true"] .tag { color: var(--text); }

#calendar-empty { padding: var(--s2) 0; }



#change-legend {
  position: absolute;
  z-index: 10;
  left: calc(var(--gutter) + var(--safe-l));
  bottom: calc(var(--s3) + var(--safe-b));
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 2.5rem;
  padding: 0 var(--s2);
  font-size: var(--step--1);
  font-weight: 500;
}
.change-swatch { flex: none; width: 1rem; height: 1rem; background: var(--accent); border-radius: var(--radius); }
#change-legend.is-empty .change-swatch { background: transparent; border: 1px solid var(--muted); }

#status-bar {
  position: absolute;
  z-index: 12;
  left: calc(var(--gutter) + var(--safe-l));
  bottom: calc(var(--s3) + 2.5rem + var(--s1) + var(--safe-b));
  max-width: 20rem;
  padding: var(--s1) var(--s2);
  font-size: var(--step--1);
  color: var(--muted);
  pointer-events: none;
}



@media (max-width: 40rem) {
  h1 { font-size: var(--step-3); }
  .lede { display: none; }
  #left-rail { width: calc(100% - var(--tool) - var(--s1) - var(--gutter)); padding-right: var(--s1); padding-bottom: calc(var(--s2) + 2.5rem + var(--s1) + var(--safe-b)); gap: var(--s2); }
  #nisar-panel { flex: 1 1 auto; }
  #compare-figure { flex: 1 1 auto; min-height: 10rem; height: auto; }
  #timeline {
    top: auto;
    left: var(--gutter);
    right: var(--gutter);
    bottom: calc(var(--s2) + var(--safe-b));
    width: auto;
    height: auto;
    max-height: 62vh;
    z-index: 40;
  }
  #status-bar { display: none; }
  .list-title, #calendar-dates { display: none; }
  .cal-day, .cal-blank { height: 2rem; }
  #settings-panel { right: var(--gutter); top: calc(var(--s3) + var(--safe-t) + var(--tool) * 2 + var(--s1) * 2); width: calc(100vw - var(--gutter) * 2); }
}


/* Dataset tabs in the comparison header */
/* Tabs get their own full-width row; title and collapse button share the row below */
#nisar-panel .panel-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s2); row-gap: 0.125rem; align-items: center; }
#nisar-panel .panel-heading { display: contents; }
#nisar-panel #panel-title { grid-column: 1; }
#nisar-panel #panel-toggle { grid-column: 2; }
.dataset-tabs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; column-gap: 0.75rem; row-gap: 0.125rem; }
.dataset-tab {
  padding: 0;
  background: transparent;
  border: 0;
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--text);
  text-align: left;
}
.dataset-tab.is-active { color: var(--accent); }

#dataset-placeholder {
  padding: var(--s3) var(--s2);
  background: var(--space);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#dataset-placeholder .ph { font-size: var(--step-2); color: var(--muted); margin-bottom: var(--s1); }

/* Date-pair button: opens the historical imagery card */
.pair-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2rem;
  margin-top: var(--s1);
  padding: 0 0.75rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pair-btn[aria-expanded="true"] { border-color: var(--accent); }

@media (pointer: coarse) {
  .dataset-tab { min-height: 2rem; }
  .pair-btn { height: var(--tool); }
}

/* Historical imagery card: compact on desktop only (mobile layouts are in globe.html) */
@media (min-width: 40.0625rem) and (min-height: 30.0625rem) {
  #timeline {
    top: calc(var(--s3) + var(--safe-t) + var(--tool) + var(--s1));
    bottom: auto;
    width: min(16.5rem, calc(100vw - var(--gutter) * 2));
    max-height: calc(100vh - var(--s3) * 2 - var(--tool) - var(--s1) - var(--safe-t) - var(--safe-b));
    padding: 0.75rem;
    gap: 0.625rem;
  }
  #calendar-title { font-size: var(--step-1); }
  #calendar-status { margin-top: 0.125rem; }
  #calendar-body { gap: 0.625rem; padding-top: 0.625rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  #cal-title { font-size: var(--step-0); }
  #timeline .icon-btn { width: 1.75rem; height: 1.75rem; }
  .cal-weekdays, #cal-grid { gap: 0.125rem; }
  .cal-weekdays span { padding-left: 0.375rem; }
  .cal-day, .cal-blank { height: 1.75rem; }
  .cal-day { padding-left: 0.375rem; }
  .cal-jump .text-btn { height: 2rem; padding: 0 0.75rem; }
  .list-title { padding-top: 0.625rem; }
  #calendar-dates { flex: none; max-height: 9.5rem; }
  .date-row { padding: 0.375rem 0.625rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Keep Historical Imagery as a real, self-contained toolbar button beside Menu. */
#toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s1);
}
#toolbar > #history-btn {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: auto;
  min-width: var(--tool);
  height: var(--tool);
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
#toolbar > #history-btn .ph { display: block; font-size: 1.15rem; }
#toolbar > #history-btn[aria-expanded="true"] { border-color: var(--accent); }
#toolbar > #menu-panel {
  top: calc(var(--tool) + var(--s1));
  right: 0;
}


/* Stack Menu and the icon-only Historical Imagery control vertically. */
#toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
}
#toolbar > #history-btn {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: var(--tool);
  min-width: var(--tool);
  height: var(--tool);
  padding: 0;
  font-size: var(--step-2);
}
#toolbar > #history-btn .ph { font-size: var(--step-2); }
#toolbar > #menu-panel {
  top: 0;
  right: calc(var(--tool) + var(--s1));
}

@media (min-width: 40.0625rem) and (min-height: 30.0625rem) {
  #timeline {
    top: calc(var(--s3) + var(--safe-t) + var(--tool) * 2 + var(--s1) * 2);
    max-height: calc(100vh - var(--s3) * 2 - var(--tool) * 2 - var(--s1) * 2 - var(--safe-t) - var(--safe-b));
  }
}


/* The whole comparison panel slides horizontally; its arrow handle stays reachable. */
#nisar-panel {
  position: relative;
  transform: translateX(0);
  transition: transform 320ms cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}
#nisar-panel.is-collapsed { transform: translateX(-110%); }
#panel-toggle { flex: 0 0 auto; position: relative; z-index: 30; pointer-events: auto; }
.panel-reopen-btn {
  position: fixed; z-index: 1000; left: 0; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: var(--tool); height: var(--tool); padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; pointer-events: auto;
  box-shadow: 0 4px 16px rgb(0 0 0 / 35%); cursor: pointer;
}
.panel-reopen-btn[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  #nisar-panel { transition: none; }
}


/* Supplementary metrics for the GRACE-FO and Landsat datasets. */
.dataset-details {
  display: grid;
  gap: 0.35rem;
  padding-top: var(--s2);
  border-top: 1px solid var(--line);
}
.dataset-details > div {
  display: grid;
  grid-template-columns: minmax(5.5rem, 0.7fr) minmax(0, 1.3fr);
  gap: var(--s1);
  align-items: start;
}
.dataset-details dt { color: var(--muted); }
.dataset-details dd { font-weight: 500; overflow-wrap: anywhere; }




/* Historical imagery change-category filter */
.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s1);
  flex: none;
}
#history-close { order: 0; }
#history-filter { order: 1; }
#history-filter {
  min-width: 7.5rem;
  max-width: 9rem;
  height: 2rem;
  padding: 0 1.7rem 0 0.55rem;
  color: var(--text);
  background: var(--panel, #14181b);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--step--1);
}
#history-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.date-row:disabled, .cal-day.is-filtered-out:disabled {
  opacity: 0.32;
  color: var(--muted);
  cursor: not-allowed;
}
.date-row:disabled { pointer-events: none; }
@media (max-width: 520px) {
  #history-filter { min-width: 6.5rem; max-width: 7.5rem; font-size: 0.72rem; }
  .history-actions {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
  }
  #history-filter { order: 0; }
  #history-close { order: 1; }
}

/* Historical imagery desktop header: a true two-row, two-column layout.
   Row 1: title (left) | close button (right)
   Row 2: date/pair status (left) | category filter (right)
   Mobile layouts remain controlled by the overrides in globe.html. */
@media (min-width: 40.0625rem) and (min-height: 30.0625rem) {
  #timeline > .panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: var(--s2);
    row-gap: 0.35rem;
  }
  #timeline > .panel-head > div:first-child,
  #timeline > .panel-head > .history-actions {
    display: contents;
  }
  #calendar-title {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  #history-close {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  #calendar-status {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    margin: 0;
    align-self: center;
  }
  #history-filter {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: center;
    min-width: 7.5rem;
    max-width: 9rem;
  }
}
