/* The atlas workspace: one map, one time navigator, details when needed. */
:root { --footer-space: calc(60px + env(safe-area-inset-bottom, 0px)); --workspace-paper: #faf8f4; --workspace-ink: #302b27; --workspace-line: #e3ddd4; --workspace-accent: #b94e32; }
html { height: 100%; overflow-x: hidden; overflow-y: auto; background: var(--workspace-paper); }
body { height: auto; min-height: 100%; overflow: visible; background: var(--workspace-paper); }
.app { --population-space: 42px; display: grid; height: calc(100dvh - var(--footer-space)); min-height: 0; grid-template-columns: minmax(0, 1fr) clamp(360px, 28.5vw, 410px); grid-template-rows: 70px minmax(0, 1fr) calc(132px + var(--population-space)); grid-template-areas: 'head head' 'stage side' 'time side'; background: var(--workspace-paper); }
.app > header { display: flex; min-width: 0; padding: 0 28px; gap: 42px; flex-wrap: nowrap; border-bottom: 1px solid var(--workspace-line); background: var(--workspace-paper); }
.brand { gap: 10px; flex: none; }
.brand h1 { font-size: 22px; }
.app > header .brand-kicker, .app > header .brand > span { display: none; }
.brand > svg circle:first-child { fill: var(--workspace-accent); }
.workspace-nav { display: flex; align-self: stretch; gap: 22px; }
.workspace-nav button { padding: 0 3px; border: 0; border-bottom: 2px solid transparent; background: none; font: 15px var(--display); color: #736c65; cursor: pointer; }
.workspace-nav button[aria-pressed='true'] { color: var(--workspace-accent); border-bottom-color: var(--workspace-accent); }
.app > header .head-tools { display: flex; margin-left: auto; min-width: 0; }
.app > header .history-search-trigger { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: clamp(210px, 23vw, 320px); min-height: 42px; padding: 8px 14px; border-radius: 9px; background: #f3f0eb; color: #706960; font-size: 13px; }
.history-search-trigger > span:first-child { font: 24px/1 var(--body); }
.app > .stage { grid-area: stage; height: auto; min-height: 0; border: 0; border-radius: 0; background: #f2eee6; }
.stage .readout { top: 24px; left: 28px; padding: 0; background: transparent; border: 0; max-width: calc(100% - 185px); }
.stage .readout::before { content: 'EXPLORING THE WORLD'; font-size: 10px; color: #71695f; letter-spacing: .16em; }
.stage .readout .yr { font-size: clamp(36px, 3.6vw, 52px); color: var(--workspace-ink); line-height: 1.1; }
.stage .readout .yr small { font-size: 20px; }
.readout-era { display: block; margin-top: 6px; font: 13px var(--display); color: #756c60; }
#mapToolsToggle { display: flex; position: absolute; z-index: 8; top: 24px; right: 24px; gap: 9px; background: #faf8f4ed; border-color: #d6d2c8; min-height: 44px; padding: 9px 14px; font-size: 13px; box-shadow: 0 2px 8px #30302005; }
.stage .zoom { bottom: 20px; right: 24px; }
.stage .map-context { left: 28px; bottom: 20px; }
.stage-hint { right: 85px; bottom: 22px; font-size: 10px; }
.stage.comparing #mapToolsToggle { top: 52px; }
.time, .stage.comparing + .time { grid-area: time; display: grid; grid-template-columns: auto minmax(100px, 1fr) auto; grid-template-rows: max-content 40px 42px 16px; grid-template-areas: 'population population population' 'play date actions' 'ruler ruler ruler' 'summary summary navigation'; padding: 12px 24px 8px; gap: 2px 16px; background: var(--workspace-paper); border: 0; border-top: 1px solid var(--workspace-line); border-radius: 0; min-width: 0; z-index: 9; }
.time .controls { grid-area: play; display: flex; align-items: center; gap: 6px; }
.time .controls .lbl { display: none; }
.time .controls .iconbtn { width: 38px; min-height: 38px; height: 38px; border: 1px solid var(--workspace-line); border-radius: 50%; background: transparent; color: var(--workspace-ink); font-size: 20px; }
.time .controls .play { width: 40px; min-width: 0; flex: none; justify-content: center; padding: 0; gap: 0; font: 0/1 var(--body); background: var(--workspace-accent); border-color: var(--workspace-accent); color: #fff; border-radius: 50%; }
.time .controls .iconbtn:disabled { opacity: .35; cursor: default; }
.time .controls .play::before { content: '▶'; display: block; font: 17px/1 var(--body); }
.time .controls .play[aria-label='Pause']::before { content: 'Ⅱ'; }
.time .controls .play[aria-label^='Replay']::before { content: '↻'; }
.timeline-date { grid-area: date; display: flex; align-items: center; justify-content: center; min-width: 0; }
.time .timeline-date .year-step { flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #756c60; font-size: 21px; cursor: pointer; }
.time .timeline-date .year-step:hover { background: #eee9e0; }
.timeline-date .goto { width: auto; flex: none; align-items: center; gap: 3px; }
.timeline-date .goto > div { flex: none; }
.timeline-date .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* Four-digit years must fit even with wider fallback fonts and compact widths. */
.timeline-date .goto input { width: 133px; min-width: calc(4ch + 14px); height: 40px; font: 500 21px var(--display); text-align: center; padding: 4px 6px; border: 1px solid transparent; background: transparent; border-radius: 5px; }
.timeline-date .goto input:hover, .timeline-date .goto input:focus { border-color: #d6cabb; background: #fff; }
.time .timeline-date .goto input.is-wide-date { width: 16ch; }
.timeline-date .goto .iconbtn { display: none; width: 28px !important; height: 36px !important; min-height: 36px; background: transparent !important; color: var(--workspace-accent) !important; }
.timeline-date .goto:focus-within .iconbtn { display: grid; }
.dock-actions { grid-area: actions; display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 8px; align-items: center; }
.dock-actions .atlas-menu-trigger { border: 0; background: transparent; padding: 6px; font-size: 12px; }
.timeline-scope { border: 0; background: transparent; color: var(--workspace-accent); cursor: pointer; padding: 7px 0; font: 12px var(--body); min-height: 40px; white-space: nowrap; }
.time .ruler { grid-area: ruler; height: 50px; margin: 0 5px; }
.time .eras { display: none; }
.time .marks { top: 10px; height: 15px; border-color: #bab5ac; }
.time .marks b { width: 3px; height: 3px !important; border-radius: 50%; background: #a8a297; opacity: .7; box-shadow: none; }
.time .ticks { top: 32px; height: 18px; }
.time .ticks span { font-size: 10px; color: #736c63; }
.time .needle { top: 7px; height: 20px; border-color: var(--workspace-accent); }
.time .needle::before { top: 2px; left: -5px; width: 8px; height: 8px; border: 0; background: var(--workspace-accent); border-radius: 50%; }
.time .win { top: 9px; height: 17px; border: 0; background: #b94e3217; }
.time .ruler input[type='range']::-webkit-slider-thumb { height: 50px; }
.time .ruler input[type='range']::-moz-range-thumb { height: 50px; }
.time-summary { grid-area: summary; gap: 5px; font-size: 10px; line-height: 20px; overflow: hidden; white-space: nowrap; }
.time-summary > .era { display: none; }
.event-navigation { grid-area: navigation; justify-content: flex-end; }
.timeline-help { margin: 0; }
.timeline-help summary { min-height: 20px; padding: 0; font-size: 10px; }
.timeline-help p { bottom: 100%; right: 0; left: auto; }
.time .discovery-status { position: absolute; bottom: 100%; left: 28px; right: 80px; height: auto; min-height: 0; block-size: auto; padding: 6px 10px; background: #faf8f4ed; font-size: 11px; border-radius: 4px; }
.time .discovery-status.is-empty { display: none; }
.side { grid-area: side; min-height: 0; min-width: 0; padding: 0; background: var(--workspace-paper); border-left: 1px solid var(--workspace-line); overflow: auto; overscroll-behavior: contain; }
.side-intro { position: sticky; top: 0; padding: 24px 22px 0; z-index: 4; background: var(--workspace-paper); border: 0; }
.side-intro .kicker { display: none; }
.side h2 { font: 500 27px/1.2 var(--display); color: var(--workspace-ink); }
.side .sub { font-size: 12px; }
.sidebar-scope { font-size: 11px; line-height: 1.5; margin-top: 5px; }
.context-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--workspace-line); margin-top: 14px; }
.context-tabs button { border: 0; border-bottom: 2px solid transparent; padding: 9px 2px; min-height: 44px; background: none; font: 13px var(--body); cursor: pointer; color: #746d64; }
.context-tabs button[aria-pressed='true'] { color: var(--workspace-accent); border-color: var(--workspace-accent); }
.side-content { padding: 14px 22px 24px; background: var(--workspace-paper); }
.side .detail { background: #fffdfa; border: 1px solid var(--workspace-line); border-top: 1px solid var(--workspace-line); border-radius: 6px; padding: 16px; box-shadow: none; }
.side .detail h3 { font-size: 22px; line-height: 1.3; padding-right: 10px; margin-block: 9px; }
.side .detail p { font-size: 14px; line-height: 1.7; }
.side .detail > .kicker { padding-right: 26px; font-size: 10px; }
.side .detail .close { width: 44px; height: 44px; min-height: 44px; top: 4px; right: 4px; font-size: 16px; background: transparent; border: 0; }
.side .detail h3 .event-emoji { font-size: 18px; }
.story-sources { margin-top: 12px; }
.story-sources > summary { min-height: 28px; cursor: pointer; font-size: 12px; color: #716659; }
.story-sources a { font-size: 12px; }
.side .detail > .discovery-action { display: block; min-height: 34px; margin-top: 10px; padding: 4px 0; font: 500 14px var(--display); color: var(--workspace-accent); background: transparent; border: 0; }
.story-context { padding-top: 4px; }
.story-context > summary { min-height: 32px; cursor: pointer; font-size: 11px; color: #827365; }
.story-context .near { border: 0; padding-top: 8px; }
.story-context .near > b { display: block; font-size: 11px; margin-bottom: 8px; }
.story-context .near > p { font: 12px/1.6 var(--body); color: #756c65; }
.story-context .story-card { padding: 10px; border: 1px solid var(--workspace-line); border-radius: 4px; background: #fffdfa; color: var(--workspace-ink); cursor: pointer; font: inherit; }
.story-context .story-card:hover { border-color: var(--workspace-accent); }
.story-context a { display: inline-block; min-height: 24px; color: var(--workspace-accent); font: 12px/1.6 var(--body); }
.settings-dialog .view-tool { padding-bottom: 6px; border-bottom: 1px solid var(--workspace-line); }
.settings-dialog .dock-options > summary { display: list-item; border: 0; border-radius: 0; background: transparent; justify-content: flex-start; padding: 10px 0; font-size: 13px; }
.event-list-disclosure > summary { cursor: pointer; color: var(--workspace-accent); font-size: 12px; padding: 10px 0; }
.event-list-disclosure:not(.has-selection) > summary { display: none; }
.detail .near summary { cursor: pointer; font-size: 12px; font-weight: 500; padding: 8px 0; }
.side .region h4 { font-size: 10px; padding-bottom: 7px; text-transform: uppercase; letter-spacing: .08em; }
.side .item { border: 0; border-bottom: 1px solid var(--workspace-line); border-radius: 0; background: transparent; padding: 12px 0; margin: 0; grid-template-columns: 48px minmax(0, 1fr); gap: 9px; }
.side .item .t { font: 500 18px/1.4 var(--display); }
.side .item .b { font-size: 14px; line-height: 1.55; margin-top: 4px; }
.side .item .y { font-size: 11px; }
.side .item[aria-current='true'] { box-shadow: none; background: #eee9df; padding-left: 8px; }
.side .item:hover { background: #f0ece5; }
.side .people { gap: 7px; }
.journey-shortcuts { border-top: 1px solid var(--workspace-line); padding-top: 20px; margin-top: 20px; }
.journey-shortcuts h3 { font: 500 22px var(--display); margin: 0 0 12px; }
.journey-shortcuts button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 0; background: none; border: 0; border-bottom: 1px solid var(--workspace-line); font: 13px var(--body); text-align: left; cursor: pointer; }
.journey-shortcuts button:hover { color: var(--workspace-accent); }
.journey-shortcuts button small { display: block; margin-top: 4px; color: #756c65; font: 11px/1.5 var(--body); }
.journey-time-filter { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.journey-time-filter select { max-width: 50%; min-height: 40px; padding: 5px; border: 1px solid #c8bdaf; border-radius: 4px; background: #fffdf9; color: inherit; font: 12px var(--body); }
.journey-time-filter > label { gap: 8px; }
.workspace-coverage { font-size: 10px; color: #7b746b; margin: 28px 0 0; }
.side .sidebar-extras { margin: 0; padding: 0; border: 0; }
.sidebar-extras-intro { margin-bottom: 12px; }
.sidebar-extras-intro h3 { display: none; }
.sidebar-extras-intro p { font-size: 12px; color: #756b62; margin: 0; }
#journeyTopics { display: grid; gap: 10px; margin-bottom: 24px; }
.journey-topic { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 88px; padding: 16px; text-align: left; background: #f0eee6; border: 1px solid #ded8cb; border-radius: 7px; cursor: pointer; }
.journey-topic:first-child { background: #f5e9e6; border-color: #e6d4ce; }
.journey-topic:nth-child(2) { background: #eaf0ed; border-color: #d5dfd6; }
.journey-topic strong { display: block; font: 500 21px var(--display); }
.journey-topic small { display: block; margin-top: 6px; font: 12px/1.6 var(--body); color: #766b60; }
.journey-topic:hover { border-color: var(--workspace-accent); }
.journey-topic > img { object-fit: contain; }
.journey-collections > section { margin: 20px 0; border: 1px solid var(--workspace-line); background: transparent; box-shadow: none; }
.journey-collections .fact { margin: 22px 0; }
.side.journey-panel-open #journeyTopics, .side.journey-panel-open .journey-collections, .side.journey-panel-open .sidebar-extras-intro { display: none; }
#journeyPanels .atlas-menu-panel { position: static; width: 100%; max-width: none; height: calc(100dvh - 198px); max-height: none; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
#journeyPanels .rights-heading h2, #journeyPanels .migrations-heading h2 { font-size: 24px; }
#journeyPanels .rights-heading h2 > span { display: none; }
[data-workspace='journeys'] .side-content > .discovery-panel { display: none; }
[data-sidebar-context='people'] .side-content > .discovery-panel { display: none; }
[data-workspace='journeys'] .story-trail { display: none; }
.sheet-toggle { display: none; }
.workspace-dialog { position: fixed; inset: 86px 20px auto auto; margin: 0; width: min(420px, calc(100vw - 40px)); height: auto; max-height: calc(100dvh - 106px); max-width: 100vw; padding: 24px; border: 1px solid var(--workspace-line); border-radius: 10px; background: var(--workspace-paper); color: var(--workspace-ink); box-shadow: -20px 0 80px #30271e22; overflow: auto; overscroll-behavior: contain; }
.workspace-dialog:not([open]) { display: none; }
.workspace-dialog::backdrop { background: #272b283b; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.dialog-heading h2 { margin: 0; font: 500 30px var(--display); }
.dialog-heading p { margin: 6px 0 0; color: #766d63; font-size: 13px; }
.dialog-heading button { flex: none; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; cursor: pointer; }
.settings-dialog .view-tool { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 18px; }
.settings-dialog .tool-label { font: 13px var(--body); letter-spacing: 0; text-transform: none; color: inherit; }
.settings-dialog .seg { display: flex; width: 100%; border-radius: 6px; background: #f0ede7; border-color: var(--workspace-line); }
.settings-dialog .seg button { flex: 1; padding: 8px; min-height: 40px; font: 12px var(--body); }
.settings-dialog .seg button[aria-pressed='true'] { background: var(--workspace-accent); color: #fff; border-radius: 4px; }
.settings-dialog #layersPanel, .settings-dialog #filtersPanel { display: block; position: static; width: 100%; max-width: none; max-height: none; padding: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.settings-dialog .borders-control { position: static; border: 0; padding: 0; background: none; box-shadow: none; border-radius: 0; backdrop-filter: none; }
.settings-dialog .borders-control > .tool-label { margin: 0 0 8px; }
.settings-dialog .bseg { position: static; backdrop-filter: none; }
.settings-dialog .border-confidence, .settings-dialog .water-key { font-size: 11px; }
.settings-dialog .border-confidence p { font-size: 12px; }
.settings-dialog .thematic-layers { margin-top: 22px; padding-top: 18px; }
.settings-dialog .thematic-layers h3 { font-size: 18px; }
.settings-section { border-top: 1px solid var(--workspace-line); margin-top: 10px; padding-top: 0; }
.settings-section > summary { display: list-item; min-height: 44px; align-content: center; font: 13px/1.6 var(--body); cursor: pointer; padding: 10px 0; color: inherit; list-style: revert; }
#categoryStatus { font-size: 11px; color: #786c60; margin-left: 8px; }
.settings-dialog #legend { position: static; display: flex; max-width: none; gap: 7px; margin-top: 12px; }
.settings-dialog #legend .chip { background: #f0ede7; border-color: #d9d1c5; color: var(--workspace-ink); font-size: 12px; min-height: 40px; }
.settings-dialog #legend .chip i { box-shadow: none; }
.settings-dialog #legend .chip[aria-pressed='false'] { opacity: .55; }
.settings-dialog .comparison-controls { margin-top: 16px; display: grid; }
.settings-dialog .comparison-controls #compareYears { grid-template-columns: 1fr 1fr; }
.settings-dialog .comparison-controls #compareYears button { grid-column: 1 / -1; }
.settings-dialog .dock-options-content { position: static; width: 100%; max-width: none; max-height: none; padding: 0; border: 0; box-shadow: none; overflow: visible; }
.settings-dialog .discovery-tools { display: grid; grid-template-columns: 1fr; padding: 0; gap: 8px; background: transparent; }
.settings-dialog .discovery-tools > button { width: 100%; font-size: 13px; }
/* Population stays beside the timeline, including on phones and in comparison. */
.time > .population-strip { position: relative; grid-area: population; align-items: center; gap: 4px 14px; padding: 6px 10px; }
.time .population-heading details { position: static; margin-left: auto; }
.time .population-values { align-items: center; }
.time .population-value { align-items: baseline; }
.time .population-method { left: 0; right: auto; bottom: calc(100% + 8px); width: min(620px, calc(100vw - 48px)); max-width: 100%; max-height: min(50dvh, var(--population-note-space, 400px)); }
.time:has(.population-heading details[open]) { z-index: 40; }
.workspace-primary { width: 100%; min-height: 46px; margin-top: 28px; border: 0; border-radius: 6px; background: var(--workspace-accent); color: #fff; cursor: pointer; font: 14px var(--body); }
.app:has(.deep-time-only) .journey-collections :is(.curated-discoveries, .daily-challenge-card, .comparison-stories, #fact) { display: block; }
[hidden] { display: none !important; }
@media (min-width: 861px) and (max-width: 1180px) {
  .app > header { gap: 20px; padding-inline: 20px; }
  .brand h1 { font-size: 20px; }
  .time, .stage.comparing + .time { padding-inline: 18px; column-gap: 7px; }
  .timeline-date .goto input { width: 105px; font-size: 18px; }
  .dock-actions { gap: 4px; }
  .dock-actions .atlas-menu-trigger, .timeline-scope { font-size: 11px; }
  .time .controls .iconbtn { width: 32px; }
  .time .controls .play { width: 38px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 62px minmax(0, 1fr) calc(132px + var(--population-space)) 82px 60px; grid-template-areas: 'head' 'stage' 'time' 'side' 'nav'; height: calc(100dvh - var(--footer-space)); display: grid; }
  .app:has(.side.sheet-open) { grid-template-rows: 62px minmax(0, 1fr) calc(132px + var(--population-space)) 0 60px; }
  .app > header { grid-area: head; padding: 0 16px; gap: 10px; }
  .brand h1 { font-size: 19px; }
  .brand > svg { width: 24px; height: 24px; }
  .workspace-nav { display: none; }
  .app > header .head-tools { display: block; width: 44px; flex: 0 0 44px; }
  .app > header .history-search-trigger { width: 44px; height: 44px; min-height: 44px; padding: 7px; justify-content: center; background: transparent; border: 0; }
  .history-search-trigger .search-label { display: none; }
  .app > .stage { grid-area: stage; order: initial; min-height: 0; height: auto; scroll-margin-top: 0; }
  .stage .readout { top: 16px; left: 18px; padding: 0; max-width: calc(100% - 160px); }
  .stage .readout::before { font-size: 8px; letter-spacing: .1em; margin-bottom: 4px; }
  .stage .readout .yr { font-size: 36px; }
  .stage .readout .yr small { font-size: 15px; }
  #mapToolsToggle { top: 16px; right: 16px; padding: 7px 10px; min-height: 40px; font-size: 11px; }
  .stage .map-context { left: 16px; bottom: 12px; }
  .map-context summary { font-size: 9px; min-height: 20px; }
  .map-context p { width: 260px; }
  .stage .zoom { right: 16px; bottom: 12px; }
  .stage .zoom .iconbtn { width: 34px; height: 34px; }
  .time, .stage.comparing + .time { order: initial; grid-area: time; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: max-content 40px 42px 18px; grid-template-areas: 'population population population' 'play date actions' 'ruler ruler ruler' 'summary summary navigation'; padding: 10px 16px 8px; column-gap: 5px; row-gap: 2px; }
  .time .controls { gap: 3px; }
  .time .controls .iconbtn { width: 30px; min-height: 36px; height: 36px; }
  .time .controls .play { width: 36px; padding: 0; font-size: 0; }
  .time .controls .lbl { display: none; }
  .timeline-date .goto input { width: 80px; height: 36px; font-size: 18px; }
  .time .timeline-date .year-step { width: 36px; }
  .timeline-date .goto .iconbtn, .timeline-date .goto:focus-within .iconbtn { display: none; }
  .dock-actions { gap: 4px; flex-wrap: nowrap; }
  .dock-actions .atlas-menu-trigger { min-height: 40px; padding: 4px 0; font-size: 11px; }
  .timeline-scope { font-size: 11px; }
  #currentEraLabel { display: none; }
  .time .ruler { height: 42px; }
  .time .ticks { top: 26px; }
  .time .ticks span { font-size: 11px; }
  .time-summary { font-size: 11px; }
  .time-summary .browse-dinosaurs { display: none; }
  .timeline-help summary { font-size: 11px; min-height: 20px; }
  .era-panel { position: fixed; bottom: calc(282px + var(--footer-space)); top: auto; left: 12px; right: 12px; width: auto; max-width: none; max-height: calc(100dvh - 340px - var(--footer-space)); }
  .app > .side { grid-area: side; order: initial; border: 0; border-top: 1px solid var(--workspace-line); border-radius: 14px 14px 0 0; background: var(--workspace-paper); min-height: 0; overflow: hidden; z-index: 20; }
  .sheet-toggle { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; height: 81px; min-height: 81px; padding: 8px 20px 10px; text-align: left; gap: 3px; border: 0; background: var(--workspace-paper); cursor: pointer; }
  .sheet-handle { display: block; justify-self: center; width: 32px; height: 4px; border-radius: 6px; background: #b9b1a7; }
  .sheet-toggle > span:nth-child(2) { font: 500 17px var(--display); }
  #sheetPreview { font: 11px var(--body); color: #7c6b5d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side:not(.sheet-open) #sideBody { visibility: hidden; }
  .app > .side.sheet-open { position: fixed; left: 0; right: 0; top: 72px; bottom: calc(192px + var(--footer-space) + var(--population-space)); height: auto; border-top: 1px solid #d4c8b9; box-shadow: 0 -15px 50px #30271e24; overflow: auto; }
  .side.sheet-open .sheet-toggle { position: sticky; top: 0; z-index: 6; height: 70px; min-height: 70px; border-bottom: 1px solid var(--workspace-line); }
  .side.sheet-open .side-intro { top: 70px; }
  .side-intro { padding: 18px 20px 0; }
  .side h2 { font-size: 26px; }
  .side-content { padding: 16px 20px 24px; }
  #journeyPanels .atlas-menu-panel { height: max(300px, calc(100dvh - 425px)); }
  .mobile-atlas-nav { position: static; grid-area: nav; order: initial; display: flex; justify-content: space-around; align-items: stretch; gap: 0; padding: 4px 12px 4px; width: 100%; border: 0; border-top: 1px solid var(--workspace-line); background: var(--workspace-paper); z-index: 30; }
  .mobile-atlas-nav button { display: grid; place-content: center; gap: 0; flex: 1; border: 0; background: transparent; padding: 0; color: #796f63; font-size: 20px; }
  .mobile-atlas-nav button span { font: 10px var(--body); }
  .mobile-atlas-nav button[aria-pressed='true'] { color: var(--workspace-accent); }
  .workspace-dialog { inset: 12px 12px auto auto; width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 22px; }
  .settings-dialog input, .settings-dialog select { font-size: 16px; }
  .history-search { max-height: calc(100dvh - 24px); }
}
@media (max-width: 370px) {
  .brand h1 { font-size: 17px; }
  .time, .stage.comparing + .time { padding-inline: 12px; }
  .timeline-date .goto input { width: 52px; font-size: 16px; }
  .time { column-gap: 3px; }
  .time .controls, .time .dock-actions { gap: 2px; }
  .stage .readout .yr { font-size: 30px; }
  #mapToolsToggle { right: 12px; }
}
@media (max-width: 860px) and (max-height: 550px) {
  .app { grid-template-rows: 48px minmax(0, 1fr) calc(100px + var(--population-space)) 54px 48px; }
  .app:has(.side.sheet-open) { grid-template-rows: 48px minmax(0, 1fr) calc(100px + var(--population-space)) 0 48px; }
  .time, .stage.comparing + .time { grid-template-rows: max-content 36px 38px; padding-block: 8px; }
  .time-summary, .event-navigation { display: none; }
  .sheet-toggle { height: 54px; min-height: 54px; padding-block: 4px; }
  .sheet-toggle > span:nth-child(2) { display: none; }
  .app > .side.sheet-open { top: 52px; bottom: calc(148px + var(--footer-space) + var(--population-space)); }
  .time:has(#eraPanel:not([hidden])) { z-index: 40; }
  .era-panel { top: 60px; bottom: auto; max-height: calc(100dvh - 120px); }
  .time > .population-strip { flex-wrap: nowrap; gap: 4px 8px; padding: 3px 6px; }
  .time .population-heading > b { font-size: 9px; }
  .time .population-heading details { order: 2; }
  .time .population-heading summary { font-size: 0; }
  .time .population-heading summary::after { content: 'ⓘ'; font-size: 14px; }
  .time .population-values { flex-basis: auto; order: 1; gap: 8px; }
  .time .population-value strong { font-size: 16px; }
  .time .population-value small { flex-basis: 100%; font-size: 9px; line-height: 1.1; }
}
@media (max-height: 720px) {
  #journeyPanels .atlas-menu-panel { position: fixed; inset: 12px; width: auto; height: calc(100dvh - 24px); padding: 12px 16px; background: var(--workspace-paper); border: 1px solid var(--workspace-line); border-radius: 10px; z-index: 60; }
}
@media (max-width: 860px) {
  #journeyPanels .atlas-menu-panel { position: fixed; inset: 12px 12px calc(72px + var(--footer-space)) 12px; width: auto; height: auto; padding: 12px 16px; background: var(--workspace-paper); border: 1px solid var(--workspace-line); border-radius: 10px; box-shadow: 0 12px 40px #30271e24; z-index: 60; }
}
@media (max-width: 860px) and (max-height: 550px) {
  .app > .side.journey-panel-open { z-index: 40; }
  #journeyPanels .atlas-menu-panel { inset: 12px; height: calc(100dvh - 24px); }
}
/* Long dates get their own row when the normal date column is too narrow. */
@media (max-width: 1180px) {
  .app:has(#gotoInput.is-wide-date) { grid-template-rows: 70px minmax(0, 1fr) calc(172px + var(--population-space)); }
  .time:has(#gotoInput.is-wide-date) { grid-template-rows: max-content 40px 40px 42px 16px; grid-template-areas: 'population population population' 'play actions actions' 'date date date' 'ruler ruler ruler' 'summary summary navigation'; }
}
@media (max-width: 860px) {
  .app:has(#gotoInput.is-wide-date) { grid-template-rows: 62px minmax(0, 1fr) calc(172px + var(--population-space)) 82px 60px; }
  .app:has(#gotoInput.is-wide-date):has(.side.sheet-open) { grid-template-rows: 62px minmax(0, 1fr) calc(172px + var(--population-space)) 0 60px; }
  .app:has(#gotoInput.is-wide-date) > .side.sheet-open { bottom: calc(232px + var(--footer-space) + var(--population-space)); }
}
@media (max-width: 860px) and (max-height: 550px) {
  .app:has(#gotoInput.is-wide-date) { grid-template-rows: 48px minmax(0, 1fr) calc(140px + var(--population-space)) 54px 48px; }
  .app:has(#gotoInput.is-wide-date):has(.side.sheet-open) { grid-template-rows: 48px minmax(0, 1fr) calc(140px + var(--population-space)) 0 48px; }
  .time:has(#gotoInput.is-wide-date) { grid-template-rows: max-content 36px 36px 38px; }
  .app:has(#gotoInput.is-wide-date) > .side.sheet-open { bottom: calc(188px + var(--footer-space) + var(--population-space)); }
}
@media (min-width: 550px) and (max-width: 860px) and (max-height: 550px) {
  .app:has(#gotoInput.is-wide-date) { grid-template-rows: 48px minmax(0, 1fr) calc(100px + var(--population-space)) 54px 48px; }
  .app:has(#gotoInput.is-wide-date):has(.side.sheet-open) { grid-template-rows: 48px minmax(0, 1fr) calc(100px + var(--population-space)) 0 48px; }
  .time:has(#gotoInput.is-wide-date) { grid-template-rows: max-content 36px 38px; grid-template-areas: 'population population population' 'play date actions' 'ruler ruler ruler' 'summary summary navigation'; }
  .app:has(#gotoInput.is-wide-date) > .side.sheet-open { bottom: calc(148px + var(--footer-space) + var(--population-space)); }
}

/* Reserve the compact footer row so credits and support stay visible after load. */
body > .atlas-footer { padding: 8px max(24px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); background: var(--workspace-paper); }
.atlas-footer-main { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; }
.atlas-footer-identity { margin-right: auto; }
.atlas-footer-sources { margin: 0; }
.atlas-footer-sources[open] { flex-basis: 100%; }
.atlas-footer-note { display: block; margin: 12px 0; }
.atlas-footer-support > span { display: inline; }
.atlas-footer-source-grid p { font-size: 12px; }
.footer-shortcut, .atlas-footer-return { min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--workspace-accent); font: 12px var(--body); cursor: pointer; }
.atlas-footer-return { display: none; margin-top: 12px; }
.atlas-footer:has(.atlas-footer-sources[open]) .atlas-footer-return { display: inline-block; }
.footer-shortcut:focus-visible, .atlas-footer-return:focus-visible { outline: 2px solid var(--workspace-accent); outline-offset: 3px; }
@media (max-width: 860px) {
  body > .atlas-footer { padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .atlas-footer-main { flex-wrap: nowrap; gap: 6px; }
  .atlas-footer-main:has(.atlas-footer-sources[open]) { flex-wrap: wrap; }
  .atlas-footer-identity { flex: 1; min-width: 0; }
  .atlas-footer .atlas-footer-name { font-size: 12px; }
  .atlas-footer-support { margin: 0; }
  .atlas-footer-support > span { display: none; }
  .atlas-footer .atlas-support-link { font-size: 12px; padding: 0 8px; gap: 4px; }
  .atlas-support-link > span { font-size: 16px; }
  .atlas-footer-sources:not([open]) summary { font-size: 0; }
  .atlas-footer-sources:not([open]) summary::after { content: 'Sources'; font-size: 11px; }
}
@media (max-width: 860px) and (max-height: 720px) {
  .app > .side.sheet-open, .app:has(#gotoInput.is-wide-date) > .side.sheet-open { bottom: calc(60px + var(--footer-space)); }
}
@media (max-width: 860px) and (max-height: 550px) {
  .app > .side.sheet-open, .app:has(#gotoInput.is-wide-date) > .side.sheet-open { bottom: calc(48px + var(--footer-space)); }
  .side.sheet-open .sheet-toggle { height: 40px; min-height: 40px; }
  .side.sheet-open .side-intro { top: 40px; padding-top: 8px; }
  .side.sheet-open .side-intro :is(h2, .sub, .sidebar-scope) { display: none; }
  .side.sheet-open .context-tabs { margin-top: 0; }
}

/* In short windows, a side dock leaves room for the map and the footer. */
@media (max-height: 360px) and (min-width: 550px) {
  .app, .app:has(.side.sheet-open), .app:has(#gotoInput.is-wide-date), .app:has(#gotoInput.is-wide-date):has(.side.sheet-open) {
    grid-template-columns: minmax(0, 1fr) 280px minmax(280px, 30vw);
    grid-template-rows: 44px minmax(0, 1fr);
    grid-template-areas: 'head head head' 'stage time side';
    height: calc(100dvh - var(--footer-space));
  }
  .time, .stage.comparing + .time, .time:has(#gotoInput.is-wide-date) {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 40px max-content 40px minmax(36px, 1fr);
    grid-template-areas: 'date date date' 'population population population' 'play play actions' 'ruler ruler ruler';
    padding: 6px 8px; gap: 2px 4px; overflow-y: auto;
  }
  .time .timeline-date .goto input { font-size: 16px; }
  .time .timeline-date .year-step { width: 40px; }
  .time .ruler { height: 40px; }
  .time .ticks { top: 23px; }
  .time .ticks span { font-size: 11px; }
  .app > header { min-height: 0; }
  .time-summary, .event-navigation { display: none; }
  .time:has(#eraPanel:not([hidden])) { z-index: 40; }
  .era-panel { position: fixed; top: 12px; bottom: auto; left: auto; right: 12px; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
}
@media (max-height: 360px) and (min-width: 550px) and (max-width: 860px) {
  .app, .app:has(.side.sheet-open), .app:has(#gotoInput.is-wide-date), .app:has(#gotoInput.is-wide-date):has(.side.sheet-open) {
    grid-template-columns: minmax(0, 1fr) 256px;
    grid-template-rows: 44px minmax(0, 1fr) 44px;
    grid-template-areas: 'head head' 'stage time' 'nav nav';
  }
  .app > .side:not(.sheet-open) { grid-area: stage; position: relative; align-self: end; justify-self: start; width: calc(100% - 60px); margin: 0 0 8px 8px; height: 44px; border: 1px solid var(--workspace-line); border-radius: 6px; }
  .side:not(.sheet-open) .sheet-toggle { height: 44px; min-height: 44px; padding: 4px 8px; }
  .side:not(.sheet-open) .sheet-handle { display: none; }
  .side:not(.sheet-open) #sheetPreview { white-space: normal; line-height: 1.4; }
  .time .timeline-date .goto input { width: 100px; }
}
