:root {
  --atlas-ink: #091f3b;
  --atlas-slate: #475569;
  --atlas-blue: #005fed;
  --atlas-deep: #0145c8;
  --atlas-edge: #d5dde7;
  --atlas-rule: #e0e7ef;
  --atlas-tone: #a57316;
  background: white;
}

html, body.theme-explorer {
  margin: 0;
  min-height: 0;
}

body.theme-explorer {
  padding: 0;
  display: block;
  background: white;
  color: var(--atlas-ink);
  font: 400 14px/1.45 Inter, system-ui, sans-serif;
}

.theme-explorer *, .theme-explorer *::before, .theme-explorer *::after {
  box-sizing: border-box;
}

.theme-explorer [hidden] { display: none !important; }
.theme-explorer :is(h1, h2, p, ul, figure) { margin: 0; }
.theme-explorer :is(input, button, summary) { font: inherit; }
.theme-explorer button { color: inherit; cursor: pointer; }
.theme-explorer button:disabled { cursor: default; }

.atlas-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-explorer #main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border: 1px solid var(--atlas-edge);
  border-radius: 10px;
}

.atlas-workspace { padding: 16px 19px 13px; }
.load-status { display: flex; align-items: center; gap: 12px; min-height: 96px; }
.load-status p, .atlas-method p { color: var(--atlas-slate); font-size: 13px; }

.atlas-intro, .theme-heading, .atlas-transport, .map-legend, .history-summary {
  display: flex;
  align-items: center;
}

.atlas-intro { flex-wrap: wrap; justify-content: space-between; gap: 7px 14px; }
.atlas-intro .date-heading {
  color: var(--atlas-ink);
  font-weight: 720;
  font-size: clamp(21px, 2.25vw, 25px);
  line-height: 1.17;
  letter-spacing: -.035em;
}

.date-jump {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  white-space: nowrap;
}

.date-jump:hover time { text-decoration: underline; text-decoration-color: #adbfda; text-underline-offset: 3px; }
#main .date-jump input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  background: white;
  cursor: pointer;
}

.date-jump input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  cursor: pointer;
}

#main .date-jump input:focus-visible {
  opacity: 1;
  color: var(--atlas-ink);
  font-size: .78em;
}

.theme-explorer .day-count, .theme-explorer .window-note {
  color: var(--atlas-slate);
  font-size: 12px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.theme-explorer .day-count { margin-top: 3px; }
.atlas-segment {
  display: inline-flex;
  align-items: stretch;
  padding: 2px;
  border: 1px solid var(--atlas-edge);
  border-radius: 8px;
  background: white;
  white-space: nowrap;
}

:is(#main, #theme-picker) .atlas-segment button {
  min-height: 0;
  padding: 5px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--atlas-ink);
  font-size: 12px;
  font-weight: 550;
  line-height: 1.4;
}

:is(#main, #theme-picker) .atlas-segment button[aria-pressed="true"] {
  background: #e7efff;
  color: var(--atlas-deep);
  box-shadow: inset 0 0 0 1px #adcaff;
}

.atlas-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 13px 0 16px;
  padding: 9px 0;
  border-block: 1px solid var(--atlas-rule);
}

.atlas-transport { gap: 5px; }
:is(#main, #theme-picker) .atlas-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #c7d3e1;
  border-radius: 7px;
  background: white;
  color: var(--atlas-ink);
  font-size: 12px;
  font-weight: 620;
  line-height: 1;
  white-space: nowrap;
}

:is(#main, #theme-picker) .atlas-control:disabled { color: #8390a1; background: #f5f7fa; }
#main .play-control { min-width: 71px; background: var(--atlas-blue); border-color: var(--atlas-blue); color: white; }
.play-control svg { width: 12px; height: 12px; fill: currentColor; }
#main .step-control, #theme-picker .picker-close { width: 30px; padding: 0; }
.step-control svg, .picker-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#main .mobile-themes, #main .picker-close { display: none; }
.atlas-history { min-width: 0; color: var(--atlas-slate); font-variant-numeric: tabular-nums; }
.history-summary { justify-content: space-between; gap: 8px; font-size: 11px; }
.history-theme { display: inline-flex; align-items: center; gap: 6px; color: var(--atlas-ink); font-weight: 660; }
.theme-dot, .legend-day, .legend-trail {
  display: inline-block;
  height: 8px;
  width: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--tone, var(--atlas-tone));
}

.history-track { position: relative; height: 29px; }
.history-track:has(input:focus-visible) { outline: 3px solid #84b4ff; outline-offset: 2px; border-radius: 3px; }
.history-track svg { display: block; width: 100%; height: 100%; overflow: visible; }
.history-track path, .history-cursor { fill: none; vector-effect: non-scaling-stroke; }
.history-baseline { stroke: #ccd5dd; stroke-width: 1px; }
.history-line { stroke: var(--atlas-tone); stroke-width: 1.3px; stroke-linejoin: round; }
.history-cursor { stroke: var(--atlas-ink); stroke-width: 1.3px; }
#main .history-track input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  appearance: none;
  opacity: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  cursor: ew-resize;
}

.history-track input::-webkit-slider-runnable-track { height: 100%; background: transparent; }
.history-track input::-moz-range-track { height: 100%; background: transparent; }
.history-track input::-webkit-slider-thumb { width: 1px; height: 100%; appearance: none; background: transparent; }
.history-track input::-moz-range-thumb { width: 1px; height: 100%; border: 0; background: transparent; }
.history-years { position: relative; height: 15px; margin-top: 2px; font-size: 10px; line-height: 15px; }
.history-years span { position: absolute; white-space: nowrap; transform: translateX(-50%); }
.history-years span:first-child { transform: none; }
.history-years span:last-child { transform: translateX(-100%); }

.atlas-map-layout { display: grid; grid-template-columns: minmax(0,1.75fr) minmax(278px,1fr); gap: 22px; align-items: start; }
.map-figure { min-width: 0; }
.map-paper { position: relative; height: 350px; overflow: hidden; border: 1px solid var(--atlas-edge); border-radius: 9px; background: #f4f7fa; }
.map-paper canvas { display: block; width: 100%; height: 100%; }
.theme-explorer .map-empty {
  position: absolute;
  bottom: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  padding: 4px 8px;
  border: 1px solid var(--atlas-edge);
  border-radius: 5px;
  background: rgb(255 255 255 / 94%);
  color: var(--atlas-slate);
  font-size: 12px;
}

.map-legend { flex-wrap: wrap; gap: 8px 15px; margin-top: 8px; color: var(--atlas-slate); font-size: 12px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-trail { border: 1.3px solid #8797a8; background: transparent; }
.theme-heading { justify-content: space-between; gap: 8px; }
.theme-heading h2 { color: var(--atlas-ink); font-size: 17px; font-weight: 700; line-height: 1.25; letter-spacing: -.025em; }
:is(#main, #theme-picker) .window-segment button { padding: 3px 6px; font-size: 11px; }
.theme-explorer .window-note { margin: 5px 0 8px; }
.theme-list { padding: 0; border-top: 1px solid var(--atlas-edge); list-style: none; }
.theme-list li { margin: 0; padding: 0; border-bottom: 1px solid var(--atlas-rule); }
:is(#main, #theme-picker) .theme-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 24px;
  padding: 3px 7px 5px;
  border: 0;
  border-radius: 0;
  background: white;
  color: var(--atlas-ink);
  text-align: start;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
}

:is(#main, #theme-picker) .theme-choice[aria-pressed="true"] { background: #eaf1fc; box-shadow: inset 3px 0 var(--atlas-blue); }
.theme-choice .theme-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.theme-bar {
  position: absolute;
  bottom: 2px;
  left: 20px;
  width: calc(100% - 30px);
  height: 2px;
  border-radius: 2px;
  background: var(--tone);
  transform: scaleX(var(--share, 0));
  transform-origin: left center;
}

:is(#main, #theme-picker) .clear-selection {
  min-height: 26px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--atlas-deep);
  font-size: 12px;
  font-weight: 550;
}

.atlas-method { margin-top: 11px; border-top: 1px solid var(--atlas-rule); }
.atlas-method summary { width: fit-content; max-width: 100%; padding: 9px 0 3px; color: var(--atlas-deep); cursor: pointer; font-size: 13px; font-weight: 620; }
.atlas-method p { max-width: 84ch; margin: 8px 0; }
.theme-picker { width: min(400px,calc(100% - 20px)); max-height: min(92dvh,620px); padding: 14px; border: 1px solid var(--atlas-edge); border-radius: 10px; background: white; color: var(--atlas-ink); box-shadow: 0 12px 42px rgb(9 31 59 / 18%); }
.theme-picker::backdrop { background: rgb(9 31 59 / 30%); }
.theme-picker[open] {
  position: fixed;
  inset: var(--picker-top, 10px) 0 auto;
  display: grid;
  grid-template-rows: minmax(0,1fr);
  height: min(620px, var(--picker-height, 92dvh));
  max-height: var(--picker-height, 92dvh);
  margin: 0 auto;
  overflow: hidden;
}
.theme-picker .theme-panel { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; min-height: 0; }
.theme-picker .theme-list { overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.theme-picker .theme-heading h2 { margin-right: auto; }
#theme-picker .picker-close { display: inline-flex; }
.theme-picker .window-note { margin-top: 8px; }
#theme-picker .theme-choice { min-height: 42px; }
#theme-picker .clear-selection { min-height: 38px; justify-self: start; }

@media (hover: hover) {
  :is(#main, #theme-picker) .atlas-control:not(:disabled):hover, :is(#main, #theme-picker) .atlas-segment button:not([aria-pressed="true"]):hover { background: #f0f5fc; }
  #main .play-control:not(:disabled):hover { background: var(--atlas-deep); }
  :is(#main, #theme-picker) .theme-choice:hover { background: #edf3fa; }
  .clear-selection:hover, .atlas-method summary:hover { text-decoration: underline; }
}

@media (max-width: 760px) {
  .atlas-workspace { padding: 12px; }
  .atlas-intro { align-items: start; }
  .atlas-intro .date-heading { font-size: 21px; }
  :is(#main, #theme-picker) .atlas-segment button { padding: 5px 6px; font-size: 11px; }
  .atlas-player { grid-template-columns: minmax(0,1fr) auto auto; gap: 7px 5px; margin: 10px 0 12px; padding: 9px 0; }
  #main .mobile-themes { display: inline-flex; border-color: #b3cdf9; background: #f1f6ff; color: var(--atlas-deep); }
  .atlas-history { grid-column: 1 / -1; grid-row: 2; }
  .history-summary { display: grid; gap: 1px; font-size: 10px; }
  .history-theme { font-size: 11px; }
  .history-track { height: 27px; }
  .atlas-map-layout { grid-template-columns: minmax(0,1fr); gap: 0; }
  .desktop-themes { display: none; }
  .map-paper { height: clamp(195px,65vw,340px); }
  .map-legend { gap: 8px 12px; font-size: 10px; }
}

@media (max-width: 270px) {
  .atlas-player { grid-template-columns: auto 1fr; }
  .speed-control { justify-self: start; }
  #main .mobile-themes { grid-row: 2; justify-self: start; }
  .atlas-history { grid-row: 3; }
}
