/* The shared shell keeps page navigation separate from the chosen world time. */
html { scroll-padding-top: 190px; }
.site-header.history-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.history-header .header-masthead {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  min-height: 74px;
}
.history-header .brand { margin-right: auto; }
.history-header .brand img { width: 62px; height: 62px; }
.history-header .brand strong { font-size: 31px; }
.history-header .brand small { font-size: 6px; letter-spacing: 1.8px; }
.history-header .simulation-status { font-size: 11px; }
.history-header #site-navigation {
  display: flex;
  justify-content: flex-start;
  gap: clamp(24px, 3vw, 44px);
  width: 100%;
  max-height: none;
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.history-header #site-navigation a {
  min-height: 44px;
  padding: 10px 1px;
  border-bottom-width: 2px;
  font-size: 13px;
  white-space: nowrap;
}
.site-header .world-context.history-navigation {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  align-items: center;
  gap: 0 28px;
  min-width: 0;
  margin: 0;
  padding: 10px 0;
  border: 0;
}
.history-dateline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 16px;
  min-width: 0;
}
.history-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.history-context::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}
.history-video { color: var(--accent); font-size: 12px; white-space: nowrap; }
.history-navigation[data-mode="archive"] .history-context { color: var(--accent); }
.history-navigation[data-mode="archive"] .history-context::before {
  width: 6px;
  height: 6px;
  border: 1px solid currentColor;
  border-radius: 1px;
  background: transparent;
}
.history-header .snapshot-caption {
  min-height: 0;
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
}
.history-controls, .history-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.history-selector {
  display: grid;
  grid-template-columns: 44px minmax(100px, 260px) 44px;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}
.history-header .history-selector select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px 22px 7px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 0;
  font-size: 13px;
  text-overflow: ellipsis;
}
.history-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}
.history-controls button svg { flex: 0 0 auto; }
.history-controls button:hover:not(:disabled) { color: var(--accent); background: var(--raised); }
.history-controls .history-step { min-height: 42px; padding: 8px; }
.history-controls .history-present { color: var(--accent); }
.history-controls .history-copy { color: var(--muted); }
.history-controls button:disabled, .history-selector select:disabled { opacity: .38; }
.history-controls button:focus-visible, .history-selector select:focus-visible { outline-offset: 2px; }
.history-note {
  grid-column: 1 / -1;
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.history-header ~ main section,
.history-header ~ main #people-count,
.history-header ~ main #logs-count,
.history-header ~ main #literature-count { scroll-margin-top: 190px; }

@media (max-width: 1100px) {
  .history-header .header-masthead { min-height: 66px; gap: 15px; }
  .history-header .brand img { width: 56px; height: 56px; }
  .history-header .brand strong { font-size: 29px; }
  .history-header.navigation-ready .navigation-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    background: transparent;
  }
  .history-header #site-navigation {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 20px;
    max-height: min(220px, 40dvh);
    padding: 6px 0;
    overflow-y: auto;
    border-bottom: 0;
  }
  .history-header.navigation-ready #site-navigation { display: none; }
  .history-header.navigation-ready.navigation-open #site-navigation { display: grid; }
  .history-header #site-navigation a { justify-content: flex-start; padding: 10px 8px; }
  .site-header .world-context.history-navigation {
    gap: 8px 20px;
    border-top: 1px solid var(--line);
  }
  .history-dateline { display: block; }
  .history-header .snapshot-caption { margin-top: 2px; }
  .history-controls, .history-actions { gap: 6px; }
  .history-selector { grid-template-columns: 44px minmax(100px, 220px) 44px; }
  .history-controls .history-copy { padding: 8px; }
  .history-copy > span { display: none; }
}

@media (max-width: 720px) {
  .history-header .header-masthead { gap: 12px; }
  .history-header .simulation-status { display: none; }
  .site-header .world-context.history-navigation { grid-template-columns: minmax(0, 1fr); padding: 8px 0; }
  .history-dateline { display: flex; justify-content: space-between; gap: 4px 10px; }
  .history-header .snapshot-caption { margin: 0; font-size: 11px; }
  .history-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .history-selector { grid-template-columns: 42px minmax(0, 1fr) 42px; }
  .history-header .history-selector select { font-size: 16px; }
  .history-controls .history-step { min-width: 42px; }
  .history-controls .history-present { padding: 8px 6px; font-size: 11px; }
  .history-present svg { display: none; }
  .history-actions { gap: 0; }
  .history-controls .history-copy { min-width: 36px; padding: 8px 6px; }
}

@media (max-width: 480px) {
  .history-header .brand img { width: 48px; height: 48px; }
  .history-header .brand strong { font-size: 26px; }
  .history-header .brand small { font-size: 5px; letter-spacing: 1.35px; }
  .history-header .header-masthead { min-height: 62px; }
  .history-header.navigation-ready .navigation-toggle { gap: 5px; padding: 8px 9px; font-size: 12px; }
  .history-controls { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .history-selector { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .history-actions { justify-content: space-between; }
  .history-actions:has(.history-present[hidden]) { justify-content: flex-end; }
  .history-controls .history-present { padding-left: 0; font-size: 12px; }
  .history-present svg { display: block; }
  .history-controls .history-copy { min-width: 44px; padding-right: 0; }
  .history-copy > span { display: inline; }
}

@media (max-height: 560px) {
  .site-header.history-header { position: relative; }
  html { scroll-padding-top: 16px; }
  .history-header ~ main section,
  .history-header ~ main #people-count,
  .history-header ~ main #logs-count,
  .history-header ~ main #literature-count { scroll-margin-top: 16px; }
}
