:root { --bg: #111418; --fg: #f2f2f2; --muted: #b8bec6; --accent: #ffd34d; --panel: #1d2229; --basemap: #f2f2f2; color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.5 system-ui, sans-serif; }
header, main { padding: 0 16px; max-width: 1400px; margin: 0 auto; }
h1 { margin: .2em 0; }
a { color: var(--accent); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
@media (max-width: 800px) { .layout { grid-template-columns: minmax(0, 1fr); } }
select { max-width: 100%; }
select, input { font: inherit; }
aside details { margin: .8em 0; border-top: 1px solid #3a424c; padding-top: .4em; }
aside summary { cursor: pointer; font-weight: 600; padding: .3em 0; }
aside details[open] > summary { margin-bottom: .2em; }
canvas#map { width: 100%; aspect-ratio: 2 / 1; display: block; background: #000; cursor: crosshair; border-radius: 4px; }
.colorbar { max-width: 320px; width: 100%; background: #fff; margin-top: 8px; }
aside { background: var(--panel); padding: 12px 16px; border-radius: 6px; align-self: start; }
aside h2 { font-size: 1rem; margin: 1em 0 .3em; }
.control { margin: .6em 0; }
.control label { display: block; }
.control.inline { display: flex; gap: .5em; align-items: center; }
.control input[type=range], .control select { width: 100%; }
.hint, #mode-desc, #status { color: var(--muted); font-size: .9em; margin: .2em 0; }
button { font: inherit; padding: .5em 1em; border-radius: 4px; border: 1px solid var(--muted); background: #2b323b; color: var(--fg); cursor: pointer; }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; width: 100%; }
button:disabled { opacity: .7; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 16px; top: 8px; background: var(--bg); padding: 4px 8px; }
.modes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.modes li { background: var(--panel); padding: 12px 16px; border-radius: 6px; }
.modes a { font-size: 1.15em; font-weight: 600; }

/* ---- Mode page (mode.html): the map fills the viewport; controls sit in a slim bar and a "More" drawer. ---- */
body.gt-mode { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; font-size: 16px; }
.gt-mode .gt-switcher { padding: 4px 12px !important; font-size: 14px !important; }
.gt-mode .gt-switcher .gt-demo-desc { display: none; }
.gt-mode header.intro { max-width: none; margin: 0; padding: 4px 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .8em; }
.gt-mode header.intro h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; }
.gt-mode #mode-desc { margin: 0; font-size: .9rem; color: var(--muted); flex: 1 1 30ch; }
.gt-mode #mode-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.gt-mode [hidden] { display: none !important; }
.gt-mode main.stage-wrap { flex: 1 1 auto; min-height: 0; max-width: none; margin: 0; padding: 0 4px; display: flex; }
.gt-mode .stage { flex: 1; min-width: 0; min-height: 0; container-type: size; display: flex; align-items: center; justify-content: center; position: relative; }
/* Largest 2:1 box that fits the stage: full width, or full height when the window is wide. */
.gt-mode .mapbox { position: relative; width: min(100cqw, 200cqh); aspect-ratio: 2 / 1; }
.gt-mode .mapbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.gt-mode canvas.map-image { background: #000; pointer-events: none; }
.gt-mode canvas#map { background: transparent; }
.gt-mode .colorbar { position: absolute; right: 8px; bottom: 8px; width: clamp(120px, 26%, 360px); max-width: none; margin: 0;
  border-radius: 4px; pointer-events: none; }
.gt-mode .colorbar[src^="data:"] { background: #fff; padding: 2px; }
.gt-mode .time-badge { position: absolute; right: 8px; top: 6px; margin: 0; padding: 1px 8px; border-radius: 4px; font-size: .85rem;
  background: rgba(0, 0, 0, .6); color: #fff; pointer-events: none; }
.gt-mode .time-badge:empty { display: none; }
.gt-mode .zoom-reset { position: absolute; left: 8px; top: 6px; padding: 2px 10px; font-size: .85rem; border-radius: 4px;
  background: rgba(0, 0, 0, .7); color: #fff; border: 1px solid rgba(255, 255, 255, .5); cursor: pointer; }
.gt-mode #status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; }
.gt-mode #status:empty { display: none; }
.gt-mode .bar { max-width: 100vw; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 12px; background: var(--panel); border-top: 1px solid #2c333d; }
.gt-mode .bar .control { margin: 0; display: flex; align-items: center; gap: .4em; }
.gt-mode .bar .control label { display: inline; font-size: .85rem; color: var(--muted); }
.gt-mode .bar select { width: auto; max-width: 12em; }
.gt-mode .bar input[type=range] { width: 7em; }
.gt-mode .bar button { padding: .3em .8em; }
.gt-mode .bar button.primary { width: auto; }
.gt-mode .bar-item, .gt-mode .bar-item > div { display: contents; }
.gt-mode .bar-time { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; }
.gt-mode .bar-time .control:has(input[type=range]) { flex: 1; }
.gt-mode .bar-time input[type=range] { width: 100%; }
.gt-mode .bar-time .control:has(input[type=range]) label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.gt-mode .drawer { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(340px, 92vw); overflow-y: auto;
  background: var(--panel); padding: 8px 16px 16px; box-shadow: -4px 0 16px rgba(0, 0, 0, .5); border-radius: 0; }
.gt-mode .drawer[hidden] { display: none; }
.gt-mode .drawer-head { display: flex; justify-content: space-between; align-items: center; }
.gt-mode .drawer-head h2 { margin: 0; font-size: 1rem; }
.gt-mode .drawer-head button { padding: .2em .6em; }
.gt-mode .drawer details { margin: .6em 0; border-top: 1px solid #3a424c; padding-top: .3em; }
.gt-mode .drawer summary { cursor: pointer; font-weight: 600; }
@media (max-width: 640px) {
  .gt-mode #mode-desc { font-size: .8rem; flex-basis: 100%; }
  .gt-mode .bar-time { flex-basis: 100%; }
  .gt-mode .bar select { max-width: 8.5em; }
  .gt-mode .bar .control:has(input[type=range]) label { display: none; }
  .gt-mode .bar { gap: 6px; padding: 6px 8px; }
  .gt-mode .bar-item input[type=range] { width: 4.5em; }
  .gt-mode .bar button { padding: .25em .6em; font-size: .9rem; }
  .gt-mode .time-badge { font-size: .7rem; }
  .gt-mode .stage { align-items: flex-start; padding-top: 8px; }
  .gt-mode .bar .control label { font-size: .75rem; }
  .gt-mode .drawer { top: auto; left: 0; width: auto; max-height: 70dvh; border-radius: 10px 10px 0 0; }
}
/* Portrait phones: a 2:1 map would leave most of the screen empty, so the map fills the free height
   (stretched north-south, at most 3x; clicks and keys still map to the right place). */
@media (max-width: 640px) and (orientation: portrait) {
  .gt-mode .stage { align-items: stretch; padding-top: 4px; }
  .gt-mode .mapbox { width: 100cqw; height: min(100cqh, 150cqw); aspect-ratio: auto; }
}
