/* ==========================================================================
   HISTORICAL ATLAS
   PROFESSIONAL DEFENSE / INTELLIGENCE UI
   ==========================================================================
   Design direction:
   - Cartographic
   - Defense / intelligence workstation
   - Historical reference atlas
   - Dark operational interface
   - Restrained brass / olive accent system
   - Desktop + genuine mobile redesign

   Existing JS/HTML selectors intentionally preserved.
   ========================================================================== */


/* ==========================================================================
   01. DESIGN TOKENS
   ========================================================================== */

:root {

  /* ------------------------------------------------------------------------
     Foundation
     ------------------------------------------------------------------------ */

  --black: #050706;
  --black-1: #070908;
  --black-2: #0a0d0b;
  --black-3: #0e1210;

  --white: #ffffff;

  --gray-50:  #f4f5f2;
  --gray-100: #e7e9e4;
  --gray-200: #d3d7d0;
  --gray-300: #b9beb6;
  --gray-400: #979e95;
  --gray-500: #747c73;
  --gray-600: #5a625b;
  --gray-700: #424943;
  --gray-800: #2d332f;
  --gray-900: #1b201d;
  --gray-950: #0c100e;


  /* ------------------------------------------------------------------------
     Application surfaces
     ------------------------------------------------------------------------ */

  --background: #080b09;
  --background-subtle: #0b0f0d;

  --surface: #0d120f;
  --surface-raised: #111713;
  --surface-elevated: #151b17;
  --surface-hover: #1a211c;
  --surface-active: #202920;

  --surface-glass: rgba(13, 18, 15, 0.86);
  --surface-glass-heavy: rgba(9, 13, 11, 0.94);


  /* ------------------------------------------------------------------------
     Text
     ------------------------------------------------------------------------ */

  --foreground: #dfe3dd;
  --foreground-strong: #f4f5f1;
  --foreground-muted: #a5aca4;
  --foreground-subtle: #737b73;
  --foreground-faint: #505850;
  --foreground-disabled: #383f39;


  /* ------------------------------------------------------------------------
     Borders
     ------------------------------------------------------------------------ */

  --border: rgba(221, 229, 219, 0.10);
  --border-subtle: rgba(221, 229, 219, 0.055);
  --border-strong: rgba(221, 229, 219, 0.17);

  --border-accent: rgba(196, 162, 87, 0.32);


  /* ------------------------------------------------------------------------
     Atlas brass / khaki
     ------------------------------------------------------------------------ */

  --atlas-accent: #c7a35b;
  --atlas-accent-hover: #d9b66c;
  --atlas-accent-bright: #e3c47b;

  --atlas-accent-muted: rgba(199, 163, 91, 0.10);
  --atlas-accent-soft: rgba(199, 163, 91, 0.055);
  --atlas-accent-border: rgba(199, 163, 91, 0.28);

  --atlas-khaki: #989177;
  --atlas-khaki-light: #b5ad8e;
  --atlas-khaki-dark: #6e6957;


  /* ------------------------------------------------------------------------
     Cartographic colors
     ------------------------------------------------------------------------ */

  --map-land: #777565;
  --map-land-light: #8f8c77;
  --map-land-dark: #5c5b50;

  --map-border: rgba(10, 13, 11, 0.74);
  --map-border-light: rgba(222, 218, 193, 0.32);

  --map-grid: rgba(198, 184, 135, 0.055);
  --map-grid-strong: rgba(198, 184, 135, 0.10);


  /* ------------------------------------------------------------------------
     Semantic
     ------------------------------------------------------------------------ */

  --success: #61a875;
  --success-muted: rgba(97, 168, 117, 0.12);

  --warning: #c99a3d;
  --warning-muted: rgba(201, 154, 61, 0.12);

  --danger: #c95c5c;
  --danger-muted: rgba(201, 92, 92, 0.12);

  --info: #668cae;
  --info-muted: rgba(102, 140, 174, 0.12);


  /* ------------------------------------------------------------------------
     Typography
     ------------------------------------------------------------------------ */

  --font-sans:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  --font-mono:
    "SFMono-Regular",
    "SF Mono",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace;

  --font-serif:
    "Iowan Old Style",
    "Palatino Linotype",
    Palatino,
    Georgia,
    serif;


  --text-2xs: 9px;
  --text-xs: 10px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 19px;
  --text-2xl: 23px;
  --text-3xl: 28px;
  --text-4xl: 34px;


  --line-tight: 1.15;
  --line-normal: 1.45;
  --line-relaxed: 1.7;


  /* ------------------------------------------------------------------------
     Spacing
     ------------------------------------------------------------------------ */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;


  /* ------------------------------------------------------------------------
     Radius
     ------------------------------------------------------------------------ */

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 18px;
  --radius-full: 9999px;


  /* ------------------------------------------------------------------------
     Shadows
     ------------------------------------------------------------------------ */

  --shadow-xs:
    0 1px 2px rgba(0, 0, 0, 0.28);

  --shadow-sm:
    0 3px 10px rgba(0, 0, 0, 0.30);

  --shadow-md:
    0 10px 30px rgba(0, 0, 0, 0.38);

  --shadow-lg:
    0 20px 60px rgba(0, 0, 0, 0.48);

  --shadow-map:
    0 12px 36px rgba(0, 0, 0, 0.28);


  /* ------------------------------------------------------------------------
     Layout
     ------------------------------------------------------------------------ */

  --header-height: 60px;
  --sidebar-width: 310px;
  --timeline-height: 190px;

  --mobile-header-height: 58px;
  --mobile-sidebar-height: 204px;


  /* ------------------------------------------------------------------------
     Motion
     ------------------------------------------------------------------------ */

  --duration-fast: 110ms;
  --duration-normal: 170ms;
  --duration-slow: 260ms;

  --ease-out:
    cubic-bezier(0.16, 1, 0.3, 1);

  --ease-in-out:
    cubic-bezier(0.65, 0, 0.35, 1);


  /* ------------------------------------------------------------------------
     Layering
     ------------------------------------------------------------------------ */

  --z-base: 0;
  --z-map: 1;
  --z-map-overlay: 5;
  --z-map-controls: 10;
  --z-sidebar: 20;
  --z-timeline: 30;
  --z-header: 40;
  --z-popover: 50;
  --z-modal: 100;
  --z-loading: 800;
  --z-toast: 900;
  --z-tooltip: 1000;
}


/* ==========================================================================
   02. GLOBAL RESET
   ========================================================================== */

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

html {
  width: 100%;
  height: 100%;

  background: var(--background);

  color-scheme: dark;

  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;

  font-synthesis: none;

  scrollbar-gutter: stable;
}

body {
  width: 100%;
  height: 100%;
  min-height: 100%;

  margin: 0;

  background:
    radial-gradient(
      circle at 50% -20%,
      rgba(199, 163, 91, 0.035),
      transparent 40%
    ),
    var(--background);

  color: var(--foreground);

  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--line-normal);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  text-rendering: optimizeLegibility;

  overflow: hidden;
}

button,
input,
select,
textarea {
  margin: 0;
  font: inherit;
}

button {
  color: inherit;
  border: 0;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}


/* ==========================================================================
   03. ACCESSIBILITY
   ========================================================================== */

:focus {
  outline: none;
}

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

::selection {
  color: var(--foreground-strong);
  background: rgba(199, 163, 91, 0.24);
}


/* ==========================================================================
   04. SCROLLBARS
   ========================================================================== */

* {
  scrollbar-width: thin;
  scrollbar-color:
    rgba(205, 211, 202, 0.16)
    transparent;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(205, 211, 202, 0.12);

  border:
    2px solid transparent;

  border-radius:
    var(--radius-full);

  background-clip:
    padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background:
    rgba(205, 211, 202, 0.20);

  background-clip:
    padding-box;
}


/* ==========================================================================
   05. APPLICATION SHELL
   ========================================================================== */

.atlas-app {
  position: relative;

  width: 100%;
  height: 100dvh;
  min-height: 0;

  display: grid;

  grid-template-rows:
    var(--header-height)
    minmax(0, 1fr);

  overflow: hidden;

  background:
    var(--background);
}


/* ==========================================================================
   06. HEADER
   ========================================================================== */

.atlas-header {
  position: relative;
  z-index: var(--z-header);

  width: 100%;
  height: var(--header-height);

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding:
    0
    var(--space-5);

  background:
    linear-gradient(
      180deg,
      rgba(18, 23, 20, 0.97),
      rgba(10, 14, 12, 0.96)
    );

  border-bottom:
    1px solid var(--border-strong);

  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.18);

  backdrop-filter:
    blur(18px);

  -webkit-backdrop-filter:
    blur(18px);
}


/* --------------------------------------------------------------------------
   Header top highlight
   -------------------------------------------------------------------------- */

.atlas-header::after {
  content: "";

  position: absolute;

  left: 0;
  right: 0;
  bottom: -1px;

  height: 1px;

  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(199, 163, 91, 0.22) 22%,
      rgba(199, 163, 91, 0.08) 50%,
      transparent 78%
    );

  pointer-events: none;
}


/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */

.brand {
  min-width: 260px;

  display: flex;
  align-items: center;

  gap: var(--space-3);

  user-select: none;
}

.brand-mark {
  position: relative;

  width: 32px;
  height: 32px;

  flex: 0 0 32px;

  display: grid;
  place-items: center;

  color: var(--background);

  background:
    linear-gradient(
      145deg,
      #e2d9b9,
      #b6a87e
    );

  border:
    1px solid rgba(255, 255, 255, 0.34);

  border-radius:
    var(--radius-sm);

  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.34),
    0 4px 12px rgba(0, 0, 0, 0.24);

  font-size: 14px;

  overflow: hidden;
}

.brand-mark::after {
  content: "";

  position: absolute;

  inset: 3px;

  border:
    1px solid rgba(20, 22, 18, 0.22);

  border-radius:
    3px;

  pointer-events: none;
}

.brand h1 {
  margin: 0;

  color: var(--foreground-strong);

  font-size: 14px;
  font-weight: 650;

  letter-spacing: -0.015em;

  line-height: 1;
}

.brand-text p {
  display: block;

  margin:
    5px 0
    0;

  color: var(--foreground-subtle);

  font-size: 9px;
  font-weight: 500;

  letter-spacing: 0.075em;

  line-height: 1;

  text-transform: uppercase;
}


/* --------------------------------------------------------------------------
   Current year
   -------------------------------------------------------------------------- */

.header-center {
  position: absolute;

  left: 50%;
  top: 50%;

  transform:
    translate(-50%, -50%);
}

.current-year {
  display: inline-flex;
  align-items: center;

  gap: 8px;

  color: var(--foreground-strong);

  font-family: var(--font-serif);

  font-size: var(--text-xl);
  font-weight: 500;

  letter-spacing: -0.015em;

  white-space: nowrap;
}

.current-year::before {
  content: "";

  width: 5px;
  height: 5px;

  flex: 0 0 5px;

  background:
    var(--atlas-accent);

  border-radius:
    50%;

  box-shadow:
    0 0 0 3px rgba(199, 163, 91, 0.08);
}


/* --------------------------------------------------------------------------
   Header actions
   -------------------------------------------------------------------------- */

.header-actions {
  min-width: 260px;

  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: var(--space-2);
}


/* ==========================================================================
   07. VIEW SWITCH
   ========================================================================== */

.view-switch {
  display: flex;
  align-items: center;

  gap: 2px;

  padding: 3px;

  margin-right: var(--space-1);

  background:
    rgba(255, 255, 255, 0.035);

  border:
    1px solid var(--border);

  border-radius:
    var(--radius-md);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.view-button {
  height: 29px;

  padding:
    0
    11px;

  color:
    var(--foreground-subtle);

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-sm);

  font-size:
    var(--text-xs);

  font-weight:
    550;

  letter-spacing:
    0.025em;

  cursor:
    pointer;

  transition:
    color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.view-button:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.055);
}

.view-button.active {
  color:
    var(--atlas-accent-bright);

  background:
    linear-gradient(
      180deg,
      rgba(199, 163, 91, 0.16),
      rgba(199, 163, 91, 0.075)
    );

  border-color:
    var(--atlas-accent-border);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}


/* ==========================================================================
   08. BUTTON SYSTEM
   ========================================================================== */

.header-button,
.map-button,
.map-control,
.timeline-button,
.timeline-play,
.icon-button {
  position: relative;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 34px;
  height: 34px;

  padding:
    0
    var(--space-3);

  color:
    var(--foreground-muted);

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.055),
      rgba(255, 255, 255, 0.025)
    );

  border:
    1px solid var(--border);

  border-radius:
    var(--radius-md);

  cursor:
    pointer;

  transition:
    color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) ease;
}

.header-button:hover,
.map-button:hover,
.map-control:hover,
.timeline-button:hover,
.timeline-play:hover,
.icon-button:hover {
  color:
    var(--foreground-strong);

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.085),
      rgba(255, 255, 255, 0.040)
    );

  border-color:
    var(--border-strong);

  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.18);
}

.header-button:active,
.map-button:active,
.map-control:active,
.timeline-button:active,
.timeline-play:active,
.icon-button:active {
  transform:
    translateY(1px);
}

.header-button:disabled,
.map-button:disabled,
.map-control:disabled,
.timeline-button:disabled,
.timeline-play:disabled,
.icon-button:disabled {
  color:
    var(--foreground-disabled);

  background:
    rgba(255, 255, 255, 0.018);

  border-color:
    var(--border-subtle);

  opacity:
    0.55;
}


/* --------------------------------------------------------------------------
   Header button
   -------------------------------------------------------------------------- */

.header-button {
  min-width: 34px;
  height: 34px;

  font-size:
    var(--text-sm);

  font-weight:
    500;
}


/* --------------------------------------------------------------------------
   Generic icon button
   -------------------------------------------------------------------------- */

.icon-button {
  width: 34px;
  padding: 0;
}


/* ==========================================================================
   09. PRIMARY / SECONDARY BUTTONS
   ========================================================================== */

.button-primary,
.button-secondary,
.button-ghost,
.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap:
    var(--space-2);

  min-height:
    38px;

  padding:
    0
    var(--space-4);

  border-radius:
    var(--radius-md);

  font-size:
    var(--text-sm);

  font-weight:
    600;

  cursor:
    pointer;

  transition:
    color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) ease;
}

.button-primary {
  color:
    #15130d;

  background:
    linear-gradient(
      180deg,
      #e1c985,
      #c4a25d
    );

  border:
    1px solid rgba(255, 255, 255, 0.20);

  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.25);
}

.button-primary:hover {
  background:
    linear-gradient(
      180deg,
      #ead494,
      #d0ae68
    );

  box-shadow:
    0 5px 16px rgba(0, 0, 0, 0.34);
}

.button-primary:active {
  transform:
    translateY(1px);
}

.button-secondary {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.045);

  border:
    1px solid var(--border);
}

.button-secondary:hover {
  background:
    rgba(255, 255, 255, 0.075);

  border-color:
    var(--border-strong);
}

.button-ghost {
  color:
    var(--foreground-muted);

  background:
    transparent;

  border:
    1px solid transparent;
}

.button-ghost:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.045);

  border-color:
    var(--border);
}

.button-danger {
  color:
    #e7aaaa;

  background:
    var(--danger-muted);

  border:
    1px solid rgba(201, 92, 92, 0.25);
}

.button-danger:hover {
  background:
    rgba(201, 92, 92, 0.18);

  border-color:
    rgba(201, 92, 92, 0.38);
}


/* ==========================================================================
   10. MAIN APPLICATION AREA
   ========================================================================== */

.atlas-main {
  position: relative;

  min-width: 0;
  min-height: 0;

  display: grid;

  grid-template-columns:
    var(--sidebar-width)
    minmax(0, 1fr);

  overflow: hidden;

  background:
    var(--background);
}


/* ==========================================================================
   11. SIDEBAR
   ========================================================================== */

#sidebar {
  position: relative;
  z-index: var(--z-sidebar);

  min-width: 0;
  min-height: 0;

  display: flex;
  flex-direction: column;

  background:
    linear-gradient(
      180deg,
      #101510 0%,
      #0c110e 100%
    );

  border-right:
    1px solid var(--border-strong);

  overflow: hidden;

  box-shadow:
    8px 0 28px rgba(0, 0, 0, 0.14);
}


/* --------------------------------------------------------------------------
   Sidebar top accent
   -------------------------------------------------------------------------- */

#sidebar::before {
  content: "";

  position: absolute;

  top: 0;
  left: 0;

  width: 2px;
  height: 100%;

  background:
    linear-gradient(
      180deg,
      rgba(199, 163, 91, 0.55),
      rgba(199, 163, 91, 0.04) 35%,
      transparent 70%
    );

  pointer-events: none;
}


/* --------------------------------------------------------------------------
   Sidebar sections
   -------------------------------------------------------------------------- */

.sidebar-section {
  flex: 0 0 auto;

  padding:
    var(--space-4);

  border-bottom:
    1px solid var(--border);
}

.section-label {
  display: block;

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-2xs);

  font-weight:
    650;

  letter-spacing:
    0.13em;

  text-transform:
    uppercase;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding:
    0
    var(--space-1);

  margin-bottom:
    var(--space-2);
}

.section-count {
  color:
    var(--foreground-faint);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);
}

.entities-section {
  flex: 1 1 auto;

  min-height: 0;

  display: flex;
  flex-direction: column;

  padding:
    var(--space-2)
    0;
}

.date-heading {
  margin-bottom:
    var(--space-3);
}

.date-display {
  display: flex;
  align-items: baseline;

  gap:
    var(--space-2);
}

.sidebar-year {
  color:
    var(--foreground-strong);

  font-family:
    var(--font-serif);

  font-size:
    var(--text-2xl);

  font-weight:
    500;

  line-height:
    var(--line-tight);

  letter-spacing:
    -0.02em;
}

.date-context {
  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}

.empty-state {
  padding:
    var(--space-6)
    var(--space-4);

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);

  line-height:
    var(--line-relaxed);

  text-align:
    center;
}


/* ==========================================================================
   12. SEARCH
   ========================================================================== */

.search-box {
  position: relative;

  width: 100%;

  margin-top:
    var(--space-3);
}

.search-box::before {
  content: "";

  position: absolute;

  left: 13px;
  top: 50%;

  width: 13px;
  height: 13px;

  transform:
    translateY(-50%);

  border:
    1.5px solid var(--foreground-subtle);

  border-radius:
    50%;

  pointer-events:
    none;
}

.search-box::after {
  content: "";

  position: absolute;

  left: 24px;
  top: calc(50% + 5px);

  width: 5px;
  height: 1.5px;

  transform:
    rotate(45deg);

  transform-origin:
    left center;

  background:
    var(--foreground-subtle);

  pointer-events:
    none;
}

.search-box .search-icon {
  display:
    none;
}

#search {
  width: 100%;
  height: 39px;

  padding:
    0
    38px;

  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.035);

  border:
    1px solid var(--border);

  border-radius:
    var(--radius-md);

  outline:
    none;

  font-size:
    var(--text-sm);

  transition:
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

#search::placeholder {
  color:
    var(--foreground-faint);
}

#search:hover {
  border-color:
    var(--border-strong);
}

#search:focus {
  background:
    rgba(255, 255, 255, 0.055);

  border-color:
    rgba(199, 163, 91, 0.42);

  box-shadow:
    0 0 0 3px rgba(199, 163, 91, 0.07);
}


/* ==========================================================================
   13. SIDEBAR META
   ========================================================================== */

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;

  margin-top:
    var(--space-3);

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}

#sidebarYear {
  color:
    var(--foreground-faint);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);
}


/* ==========================================================================
   14. ENTITY LIST
   ========================================================================== */

#entityList {
  flex: 1 1 auto;

  min-height: 0;

  padding:
    var(--space-2);

  overflow-x:
    hidden;

  overflow-y:
    auto;

  overscroll-behavior:
    contain;

  scrollbar-gutter:
    stable;
}

.entity-item {
  position: relative;

  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: flex-start;

  padding:
    11px
    12px;

  margin:
    2px 0;

  color:
    var(--foreground-muted);

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-md);

  text-align:
    left;

  cursor:
    pointer;

  transition:
    color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) ease;
}

.entity-item:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.045);

  border-color:
    rgba(255, 255, 255, 0.055);
}

.entity-item:active {
  transform:
    scale(0.995);

  background:
    rgba(255, 255, 255, 0.065);
}

.entity-item.active {
  color:
    var(--foreground-strong);

  background:
    linear-gradient(
      90deg,
      rgba(199, 163, 91, 0.13),
      rgba(199, 163, 91, 0.045)
    );

  border-color:
    rgba(199, 163, 91, 0.20);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.entity-item.active::before {
  content: "";

  position: absolute;

  left: -1px;
  top: 9px;
  bottom: 9px;

  width: 3px;

  background:
    var(--atlas-accent);

  border-radius:
    0
    3px
    3px
    0;

  box-shadow:
    0 0 10px rgba(199, 163, 91, 0.20);
}

.entity-name {
  width: 100%;

  overflow:
    hidden;

  color:
    inherit;

  font-family:
    var(--font-serif);

  font-size:
    var(--text-sm);

  font-weight:
    500;

  line-height:
    var(--line-tight);

  text-overflow:
    ellipsis;

  white-space:
    nowrap;
}

.entity-meta {
  margin-top:
    5px;

  color:
    var(--foreground-faint);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  line-height:
    1.35;
}


/* ==========================================================================
   15. SIDEBAR LEGEND
   ========================================================================== */

.border-legend {
  flex:
    0 0 auto;

  padding:
    var(--space-4);

  background:
    rgba(255, 255, 255, 0.012);

  border-top:
    1px solid var(--border);
}

.border-legend-title {
  margin-bottom:
    var(--space-3);

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-2xs);

  font-weight:
    650;

  letter-spacing:
    0.12em;

  text-transform:
    uppercase;
}

.legend-row {
  display: flex;
  align-items: center;

  gap:
    var(--space-2);

  margin:
    7px 0;

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}

.legend-line {
  width: 28px;
  height: 1px;

  flex:
    0 0 28px;

  background:
    var(--foreground-muted);
}

.legend-line.precision-low,
.legend-line.low {
  opacity:
    0.28;
}

.legend-line.precision-medium,
.legend-line.medium {
  opacity:
    0.60;
}

.legend-line.precision-high,
.legend-line.high {
  opacity:
    1;
}

.legend {
  margin-top:
    var(--space-2);
}

.legend-item {
  display: flex;
  align-items: center;

  gap:
    var(--space-2);

  margin:
    6px 0;

  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}


/* ==========================================================================
   16. MAP VIEW STACK
   ========================================================================== */

.map-view-stack {
  position: relative;

  min-width: 0;
  min-height: 0;

  overflow:
    hidden;

  background:
    #101512;
}

.map-view {
  position: absolute;

  inset: 0;

  display: none;

  overflow:
    hidden;

  background:
    #101512;
}

.map-view.active {
  display:
    block;
}

#map {
  position: relative;

  min-width: 0;
  min-height: 0;

  overflow:
    hidden;

  background:
    radial-gradient(
      circle at 50% 48%,
      rgba(199, 163, 91, 0.045),
      transparent 52%
    ),
    #111613;
}


/* ==========================================================================
   17. CARTOGRAPHIC GRID
   ========================================================================== */

#map::before {
  content: "";

  position: absolute;

  inset: 0;

  z-index: 0;

  pointer-events: none;

  opacity:
    0.8;

  background-image:
    linear-gradient(
      var(--map-grid) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      var(--map-grid) 1px,
      transparent 1px
    );

  background-size:
    90px
    90px;

  mask-image:
    linear-gradient(
      to bottom,
      black,
      transparent 95%
    );
}


/* --------------------------------------------------------------------------
   Secondary coordinate texture
   -------------------------------------------------------------------------- */

#map::after {
  content: "";

  position: absolute;

  inset: 0;

  z-index: 0;

  pointer-events: none;

  background:
    radial-gradient(
      circle at 50% 50%,
      transparent 0%,
      transparent 55%,
      rgba(0, 0, 0, 0.18) 100%
    );
}


/* ==========================================================================
   18. MAP SVG
   ========================================================================== */

#map svg {
  position: relative;

  z-index:
    var(--z-map);

  display:
    block;

  width:
    100%;

  height:
    100%;
}


/* ==========================================================================
   19. D3 MAP FEATURES
   ========================================================================== */

.historical-region {
  fill:
    var(--map-land);

  fill-opacity:
    0.90;

  stroke:
    var(--map-border);

  stroke-width:
    0.72px;

  vector-effect:
    non-scaling-stroke;

  cursor:
    pointer;

  transition:
    fill 140ms var(--ease-out),
    fill-opacity 140ms var(--ease-out),
    stroke 140ms var(--ease-out),
    filter 140ms var(--ease-out);
}

.historical-region:hover,
.historical-region.hovered {
  fill:
    var(--map-land-light);

  fill-opacity:
    1;

  stroke:
    rgba(15, 18, 15, 0.88);

  filter:
    brightness(1.08);
}

.historical-region.selected {
  fill:
    var(--atlas-accent);

  fill-opacity:
    0.94;

  stroke:
    var(--atlas-accent-bright);

  stroke-width:
    1.45px;

  filter:
    drop-shadow(
      0 0 4px
      rgba(199, 163, 91, 0.20)
    );
}

.historical-region.search-match {
  stroke:
    var(--atlas-accent);

  stroke-width:
    1.25px;

  filter:
    brightness(1.08);
}

.historical-region.precision-1 {
  fill-opacity:
    0.48;

  stroke-dasharray:
    4 4;
}

.historical-region.precision-2 {
  fill-opacity:
    0.72;
}

.historical-region.precision-3 {
  fill-opacity:
    0.94;
}


/* --------------------------------------------------------------------------
   Historical border overlay
   -------------------------------------------------------------------------- */

.historical-border {
  fill:
    none;

  stroke:
    var(--map-border-light);

  stroke-width:
    0.5px;

  vector-effect:
    non-scaling-stroke;

  pointer-events:
    none;
}


/* --------------------------------------------------------------------------
   Historical settlements
   -------------------------------------------------------------------------- */

.historical-place {
  fill:
    var(--atlas-accent-hover);

  fill-opacity:
    0.92;

  stroke:
    rgba(8, 11, 9, 0.85);

  stroke-width:
    0.75px;

  vector-effect:
    non-scaling-stroke;

  cursor:
    pointer;

  transition:
    fill-opacity 120ms ease,
    transform 120ms ease;
}

.historical-place:hover {
  fill-opacity:
    1;
}


/* ==========================================================================
   20. MAP CONTROLS
   ========================================================================== */

.map-controls {
  position: absolute;

  z-index:
    var(--z-map-controls);

  top:
    var(--space-4);

  right:
    var(--space-4);

  display:
    flex;

  flex-direction:
    column;

  gap:
    3px;

  padding:
    4px;

  background:
    rgba(10, 14, 12, 0.86);

  border:
    1px solid var(--border-strong);

  border-radius:
    var(--radius-lg);

  box-shadow:
    var(--shadow-md);

  backdrop-filter:
    blur(14px);

  -webkit-backdrop-filter:
    blur(14px);
}

.map-button,
.map-control {
  width:
    34px;

  height:
    34px;

  min-width:
    34px;

  padding:
    0;

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-md);

  font-size:
    15px;
}

.map-button:hover,
.map-control:hover {
  background:
    rgba(255, 255, 255, 0.065);

  border-color:
    rgba(255, 255, 255, 0.065);
}

.map-button.reset,
.map-control:last-child {
  margin-top:
    3px;

  font-size:
    12px;

  border-top:
    1px solid var(--border);
}


/* ==========================================================================
   21. MAP INFORMATION PANEL
   ========================================================================== */

#mapInfo {
  position: absolute;

  z-index:
    var(--z-map-controls);

  left:
    var(--space-5);

  bottom:
    var(--space-5);

  width:
    min(430px, calc(100% - 40px));

  padding:
    var(--space-5);

  background:
    linear-gradient(
      145deg,
      rgba(20, 26, 22, 0.96),
      rgba(10, 14, 12, 0.95)
    );

  border:
    1px solid var(--border-strong);

  border-radius:
    var(--radius-xl);

  box-shadow:
    var(--shadow-lg);

  backdrop-filter:
    blur(18px);

  -webkit-backdrop-filter:
    blur(18px);

  animation:
    atlas-panel-enter
    var(--duration-slow)
    var(--ease-out);
}

#mapInfo::before {
  content: "";

  position: absolute;

  top: 0;
  left: var(--space-5);

  width: 48px;
  height: 1px;

  background:
    linear-gradient(
      90deg,
      var(--atlas-accent),
      transparent
    );

  opacity:
    0.8;
}

#mapInfo[hidden],
#mapInfo:not(.visible) {
  display:
    none;
}

.map-info-header {
  display:
    flex;

  align-items:
    flex-start;

  justify-content:
    space-between;

  margin-bottom:
    var(--space-2);
}

.info-kicker {
  display:
    block;

  margin-bottom:
    5px;

  color:
    var(--atlas-accent);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  font-weight:
    600;

  letter-spacing:
    0.14em;

  text-transform:
    uppercase;
}

#mapInfoTitle {
  margin:
    0
    30px
    8px
    0;

  color:
    var(--foreground-strong);

  font-family:
    var(--font-serif);

  font-size:
    var(--text-xl);

  font-weight:
    500;

  line-height:
    var(--line-tight);

  letter-spacing:
    -0.015em;
}

#mapInfoContent {
  color:
    var(--foreground-muted);

  font-size:
    var(--text-sm);

  line-height:
    var(--line-relaxed);
}

#mapInfoContent strong {
  color:
    var(--foreground);

  font-weight:
    600;
}

#mapInfoContent code {
  color:
    var(--atlas-accent-hover);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-xs);
}

#closeMapInfo {
  position:
    absolute;

  top:
    11px;

  right:
    11px;

  width:
    32px;

  height:
    32px;

  display:
    grid;

  place-items:
    center;

  color:
    var(--foreground-subtle);

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-sm);

  cursor:
    pointer;

  transition:
    color 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

#closeMapInfo:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.06);

  border-color:
    var(--border);
}


/* ==========================================================================
   22. LOADING STATE
   ========================================================================== */

#loading {
  position:
    absolute;

  inset:
    0;

  z-index:
    var(--z-loading);

  display:
    flex;

  align-items:
    center;

  justify-content:
    center;

  background:
    rgba(8, 11, 9, 0.88);

  backdrop-filter:
    blur(7px);

  -webkit-backdrop-filter:
    blur(7px);
}

#loading[hidden] {
  display:
    none;
}

.loading-inner {
  width:
    min(360px, calc(100% - 40px));

  padding:
    var(--space-6);

  text-align:
    center;
}

.loading-spinner {
  width:
    28px;

  height:
    28px;

  margin:
    0 auto
    var(--space-5);

  border:
    2px solid
    rgba(255, 255, 255, 0.08);

  border-top-color:
    var(--atlas-accent);

  border-right-color:
    rgba(199, 163, 91, 0.42);

  border-radius:
    50%;

  animation:
    atlas-spin
    750ms
    linear
    infinite;
}

.loading-title {
  margin-bottom:
    var(--space-1);

  color:
    var(--foreground);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-sm);

  font-weight:
    600;

  letter-spacing:
    0.04em;

  text-transform:
    uppercase;
}

.loading-text {
  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}


/* ==========================================================================
   23. ERROR STATE
   ========================================================================== */

#error {
  position:
    absolute;

  inset:
    0;

  z-index:
    var(--z-loading);

  display:
    flex;

  align-items:
    center;

  justify-content:
    center;

  background:
    rgba(8, 11, 9, 0.94);
}

#error[hidden] {
  display:
    none;
}

.error-inner {
  width:
    min(480px, calc(100% - 40px));

  padding:
    var(--space-8);

  text-align:
    center;
}

.error-title {
  margin-bottom:
    var(--space-2);

  color:
    var(--foreground-strong);

  font-size:
    var(--text-lg);

  font-weight:
    650;
}

.error-text {
  color:
    var(--foreground-subtle);

  font-size:
    var(--text-sm);

  line-height:
    var(--line-relaxed);
}


/* ==========================================================================
   24. TIMELINE
   ========================================================================== */

#timelinePanel {
  position:
    relative;

  z-index:
    var(--z-timeline);

  height:
    var(--timeline-height);

  padding:
    var(--space-5)
    var(--space-8)
    var(--space-6);

  background:
    linear-gradient(
      180deg,
      #101510,
      #0c110e
    );

  border-top:
    1px solid var(--border-strong);

  box-shadow:
    0 -10px 32px rgba(0, 0, 0, 0.18);
}

#timelinePanel::before {
  content: "";

  position:
    absolute;

  top:
    -1px;

  left:
    15%;

  right:
    15%;

  height:
    1px;

  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(199, 163, 91, 0.20),
      transparent
    );
}


/* --------------------------------------------------------------------------
   Timeline header
   -------------------------------------------------------------------------- */

.timeline-header {
  display:
    flex;

  align-items:
    center;

  justify-content:
    space-between;

  min-height:
    30px;

  margin-bottom:
    var(--space-4);
}

.timeline-title {
  display:
    flex;

  align-items:
    baseline;

  gap:
    var(--space-3);
}

.timeline-title h2,
.timeline-title strong {
  margin:
    0;

  color:
    var(--foreground);

  font-size:
    var(--text-sm);

  font-weight:
    650;

  letter-spacing:
    -0.005em;
}

.timeline-kicker {
  color:
    var(--foreground-subtle);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  font-weight:
    600;

  letter-spacing:
    0.10em;

  text-transform:
    uppercase;
}

#timelineYearLabel,
.timeline-current-year {
  color:
    var(--atlas-accent);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-xs);

  font-weight:
    600;
}


/* --------------------------------------------------------------------------
   Timeline actions
   -------------------------------------------------------------------------- */

.timeline-actions {
  display:
    flex;

  align-items:
    center;

  gap:
    4px;
}

.timeline-button {
  min-width:
    34px;

  height:
    32px;

  padding:
    0
    10px;

  font-size:
    var(--text-sm);
}

#playButton,
.timeline-play {
  min-width:
    72px;

  color:
    var(--foreground);

  background:
    linear-gradient(
      180deg,
      rgba(199, 163, 91, 0.14),
      rgba(199, 163, 91, 0.06)
    );

  border-color:
    var(--atlas-accent-border);
}

#playButton:hover,
.timeline-play:hover {
  background:
    linear-gradient(
      180deg,
      rgba(199, 163, 91, 0.20),
      rgba(199, 163, 91, 0.09)
    );
}


/* ==========================================================================
   25. TIMELINE TRACK
   ========================================================================== */

.timeline-track,
.timeline-rail {
  position:
    relative;

  width:
    100%;

  padding:
    6px
    0;
}

#timeline {
  display:
    block;

  width:
    100%;

  height:
    24px;

  margin:
    0;

  appearance:
    none;

  -webkit-appearance:
    none;

  background:
    transparent;

  cursor:
    pointer;
}

#timeline:focus-visible {
  outline:
    none;
}


/* --------------------------------------------------------------------------
   WebKit track
   -------------------------------------------------------------------------- */

#timeline::-webkit-slider-runnable-track {
  width:
    100%;

  height:
    4px;

  background:
    linear-gradient(
      90deg,
      rgba(199, 163, 91, 0.32),
      rgba(255, 255, 255, 0.13)
    );

  border-radius:
    var(--radius-full);
}


/* --------------------------------------------------------------------------
   WebKit thumb
   -------------------------------------------------------------------------- */

#timeline::-webkit-slider-thumb {
  appearance:
    none;

  -webkit-appearance:
    none;

  width:
    16px;

  height:
    16px;

  margin-top:
    -6px;

  background:
    var(--foreground-strong);

  border:
    3px solid
    var(--surface);

  border-radius:
    50%;

  box-shadow:
    0 0 0 1px rgba(199, 163, 91, 0.45),
    0 3px 10px rgba(0, 0, 0, 0.44);

  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

#timeline:hover::-webkit-slider-thumb {
  transform:
    scale(1.14);

  box-shadow:
    0 0 0 1px rgba(199, 163, 91, 0.75),
    0 3px 12px rgba(0, 0, 0, 0.52);
}


/* --------------------------------------------------------------------------
   Firefox
   -------------------------------------------------------------------------- */

#timeline::-moz-range-track {
  width:
    100%;

  height:
    4px;

  background:
    rgba(255, 255, 255, 0.12);

  border-radius:
    var(--radius-full);
}

#timeline::-moz-range-progress {
  height:
    4px;

  background:
    var(--atlas-accent);

  border-radius:
    var(--radius-full);
}

#timeline::-moz-range-thumb {
  width:
    12px;

  height:
    12px;

  background:
    var(--foreground-strong);

  border:
    3px solid
    var(--surface);

  border-radius:
    50%;

  box-shadow:
    0 0 0 1px rgba(199, 163, 91, 0.55);
}


/* ==========================================================================
   26. TIMELINE TICKS
   ========================================================================== */

#timelineTicks {
  position:
    relative;

  width:
    100%;

  height:
    24px;

  margin-top:
    -1px;
}

.timeline-tick {
  position:
    absolute;

  top:
    0;

  width:
    1px;

  height:
    6px;

  background:
    rgba(255, 255, 255, 0.13);
}

.timeline-tick.major {
  height:
    10px;

  background:
    var(--atlas-accent-border);
}

.timeline-tick-label {
  position:
    absolute;

  top:
    12px;

  transform:
    translateX(-50%);

  color:
    var(--foreground-faint);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  white-space:
    nowrap;
}


/* ==========================================================================
   27. TIMELINE LABELS
   ========================================================================== */

#timelineLabels {
  display:
    flex;

  align-items:
    center;

  justify-content:
    space-between;

  gap:
    var(--space-2);

  margin-top:
    var(--space-2);
}

#timelineLabels span {
  color:
    var(--foreground-faint);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);
}

#timelineCurrent {
  color:
    var(--atlas-accent);
}


/* ==========================================================================
   28. TIMELINE PERIODS
   ========================================================================== */

.timeline-periods {
  display:
    flex;

  align-items:
    center;

  gap:
    5px;

  margin-top:
    var(--space-3);

  overflow-x:
    auto;

  scrollbar-width:
    none;
}

.timeline-periods::-webkit-scrollbar {
  display:
    none;
}

.timeline-period,
.period-button {
  flex:
    0 0 auto;

  height:
    31px;

  padding:
    0
    11px;

  color:
    var(--foreground-subtle);

  background:
    rgba(255, 255, 255, 0.025);

  border:
    1px solid var(--border-subtle);

  border-radius:
    var(--radius-md);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  font-weight:
    550;

  cursor:
    pointer;

  transition:
    color var(--duration-normal) var(--ease-out),
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.timeline-period:hover,
.period-button:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.055);

  border-color:
    var(--border);
}

.timeline-period:active,
.period-button:active {
  background:
    rgba(255, 255, 255, 0.08);
}

.timeline-period.active,
.period-button.active {
  color:
    var(--atlas-accent-bright);

  background:
    linear-gradient(
      180deg,
      rgba(199, 163, 91, 0.15),
      rgba(199, 163, 91, 0.06)
    );

  border-color:
    var(--atlas-accent-border);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}


/* ==========================================================================
   29. FOOTER / MAP STATUS
   ========================================================================== */

.atlas-footer {
  position:
    fixed;

  right:
    var(--space-4);

  bottom:
    calc(
      var(--timeline-height)
      +
      var(--space-3)
    );

  z-index:
    var(--z-timeline);

  display:
    flex;

  align-items:
    center;

  gap:
    7px;

  padding:
    5px
    9px;

  color:
    rgba(223, 227, 221, 0.38);

  background:
    rgba(7, 10, 8, 0.60);

  border:
    1px solid rgba(255, 255, 255, 0.055);

  border-radius:
    var(--radius-full);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  pointer-events:
    none;

  user-select:
    none;

  backdrop-filter:
    blur(8px);
}

.footer-divider {
  opacity:
    0.5;
}


/* ==========================================================================
   30. ABOUT MODAL
   ========================================================================== */

#aboutModal {
  position:
    fixed;

  inset:
    0;

  z-index:
    var(--z-modal);

  display:
    flex;

  align-items:
    center;

  justify-content:
    center;

  padding:
    var(--space-6);

  background:
    rgba(0, 0, 0, 0.74);

  backdrop-filter:
    blur(10px);

  -webkit-backdrop-filter:
    blur(10px);

  animation:
    atlas-fade-in
    var(--duration-normal)
    var(--ease-out);
}

#aboutModal[hidden] {
  display:
    none;
}


/* --------------------------------------------------------------------------
   About card
   -------------------------------------------------------------------------- */

.about-card {
  position:
    relative;

  width:
    min(640px, 100%);

  max-height:
    min(
      760px,
      calc(100dvh - 48px)
    );

  padding:
    var(--space-8);

  overflow-y:
    auto;

  background:
    linear-gradient(
      145deg,
      #161c18,
      #0d120f
    );

  border:
    1px solid var(--border-strong);

  border-radius:
    var(--radius-xl);

  box-shadow:
    var(--shadow-lg);

  animation:
    atlas-modal-enter
    var(--duration-slow)
    var(--ease-out);
}

.about-card::before {
  content: "";

  position:
    absolute;

  top:
    0;

  left:
    var(--space-8);

  width:
    70px;

  height:
    1px;

  background:
    linear-gradient(
      90deg,
      var(--atlas-accent),
      transparent
    );
}

.about-card h2 {
  margin:
    0
    0
    var(--space-2);

  color:
    var(--foreground-strong);

  font-family:
    var(--font-serif);

  font-size:
    var(--text-3xl);

  font-weight:
    500;

  line-height:
    var(--line-tight);

  letter-spacing:
    -0.025em;
}

.about-card .subtitle {
  margin-bottom:
    var(--space-6);

  color:
    var(--atlas-accent);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  font-weight:
    600;

  letter-spacing:
    0.12em;

  text-transform:
    uppercase;
}

.about-card p {
  margin:
    0
    0
    var(--space-4);

  color:
    var(--foreground-muted);

  font-size:
    var(--text-sm);

  line-height:
    1.8;
}

.about-card p:last-child {
  margin-bottom:
    0;
}

.about-close {
  position:
    absolute;

  top:
    var(--space-4);

  right:
    var(--space-4);

  width:
    34px;

  height:
    34px;

  display:
    grid;

  place-items:
    center;

  color:
    var(--foreground-subtle);

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-md);

  cursor:
    pointer;
}

.about-close:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.06);

  border-color:
    var(--border);
}


/* ==========================================================================
   31. MODAL MARKUP VARIANTS
   ========================================================================== */

.modal-dialog {
  position:
    relative;

  width:
    min(640px, 100%);

  max-height:
    min(
      760px,
      calc(100dvh - 48px)
    );

  padding:
    var(--space-7);

  overflow-y:
    auto;

  background:
    linear-gradient(
      145deg,
      #161c18,
      #0d120f
    );

  border:
    1px solid var(--border-strong);

  border-radius:
    var(--radius-xl);

  box-shadow:
    var(--shadow-lg);

  animation:
    atlas-modal-enter
    var(--duration-slow)
    var(--ease-out);
}

.modal-backdrop {
  position:
    absolute;

  inset:
    0;
}

.modal-header {
  display:
    flex;

  align-items:
    flex-start;

  justify-content:
    space-between;

  margin-bottom:
    var(--space-5);
}

.modal-header h2 {
  margin:
    0;

  color:
    var(--foreground-strong);

  font-family:
    var(--font-serif);

  font-size:
    var(--text-3xl);

  font-weight:
    500;

  letter-spacing:
    -0.02em;
}

.modal-content p {
  margin:
    0
    0
    var(--space-3);

  color:
    var(--foreground-muted);

  font-size:
    var(--text-sm);

  line-height:
    var(--line-relaxed);
}

.panel-close {
  width:
    34px;

  height:
    34px;

  flex:
    0 0 34px;

  display:
    grid;

  place-items:
    center;

  color:
    var(--foreground-subtle);

  background:
    transparent;

  border:
    1px solid transparent;

  border-radius:
    var(--radius-md);

  cursor:
    pointer;
}

.panel-close:hover {
  color:
    var(--foreground);

  background:
    rgba(255, 255, 255, 0.06);

  border-color:
    var(--border);
}

.about-grid {
  display:
    grid;

  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );

  gap:
    var(--space-3);

  margin-top:
    var(--space-5);
}

.about-stat {
  padding:
    var(--space-4);

  background:
    rgba(255, 255, 255, 0.028);

  border:
    1px solid var(--border-subtle);

  border-radius:
    var(--radius-md);
}

.about-stat strong {
  display:
    block;

  color:
    var(--foreground-strong);

  font-size:
    var(--text-sm);

  font-weight:
    650;
}

.about-stat span {
  color:
    var(--foreground-subtle);

  font-size:
    var(--text-xs);
}


/* ==========================================================================
   32. TOOLTIP
   ========================================================================== */

.atlas-tooltip {
  position:
    fixed;

  z-index:
    var(--z-tooltip);

  max-width:
    280px;

  padding:
    9px
    12px;

  color:
    var(--foreground);

  background:
    rgba(11, 15, 13, 0.96);

  border:
    1px solid var(--border-strong);

  border-radius:
    var(--radius-md);

  box-shadow:
    var(--shadow-md);

  font-size:
    var(--text-xs);

  line-height:
    1.5;

  pointer-events:
    none;

  transition:
    opacity var(--duration-fast) ease;

  backdrop-filter:
    blur(10px);
}

.atlas-tooltip strong {
  display:
    block;

  margin-bottom:
    2px;

  color:
    var(--foreground-strong);

  font-family:
    var(--font-serif);

  font-size:
    var(--text-md);

  font-weight:
    550;
}

.atlas-tooltip span {
  color:
    var(--foreground-muted);
}


/* ==========================================================================
   33. LEAFLET VIEW
   ========================================================================== */

.leaflet-view {
  background:
    #0c1210;
}

.leaflet-view.leaflet-container {
  background:
    #0c1210;

  font:
    inherit;
}

.leaflet-view .leaflet-control-zoom {
  border:
    1px solid var(--border-strong) !important;

  border-radius:
    var(--radius-lg) !important;

  overflow:
    hidden;

  box-shadow:
    var(--shadow-md);
}

.leaflet-view .leaflet-control-zoom a {
  width:
    34px !important;

  height:
    34px !important;

  color:
    var(--foreground-muted) !important;

  background:
    rgba(11, 15, 13, 0.93) !important;

  border-bottom:
    1px solid var(--border) !important;

  line-height:
    34px !important;

  transition:
    color 120ms ease,
    background 120ms ease;
}

.leaflet-view .leaflet-control-zoom a:hover {
  color:
    var(--foreground-strong) !important;

  background:
    rgba(27, 34, 29, 0.98) !important;
}

.leaflet-entity-tooltip {
  color:
    var(--foreground) !important;

  background:
    rgba(11, 15, 13, 0.96) !important;

  border:
    1px solid var(--border-strong) !important;

  border-radius:
    var(--radius-md) !important;

  box-shadow:
    var(--shadow-md) !important;

  font-family:
    var(--font-serif) !important;

  font-size:
    var(--text-sm) !important;
}

.leaflet-entity-tooltip::before {
  display:
    none !important;
}


/* ==========================================================================
   34. GLOBE VIEW
   ========================================================================== */

.globe-view {
  background:
    radial-gradient(
      circle at 50% 45%,
      rgba(199, 163, 91, 0.055),
      transparent 46%
    ),
    radial-gradient(
      circle at 50% 50%,
      #101915,
      #050806 72%
    );
}

.globe-svg {
  display:
    block;

  cursor:
    grab;
}

.globe-svg:active {
  cursor:
    grabbing;
}

.globe-sphere {
  fill:
    #101b16;

  stroke:
    rgba(199, 163, 91, 0.42);

  stroke-width:
    1px;

  filter:
    drop-shadow(
      0 15px 30px
      rgba(0, 0, 0, 0.38)
    );
}

.globe-graticule {
  fill:
    none;

  stroke:
    rgba(255, 255, 255, 0.075);

  stroke-width:
    0.5px;

  vector-effect:
    non-scaling-stroke;

  pointer-events:
    none;
}

.globe-region-layer .historical-region {
  stroke:
    rgba(5, 8, 6, 0.70);
}

.globe-place-layer .historical-place {
  pointer-events:
    none;
}

.globe-hint {
  position:
    absolute;

  z-index:
    var(--z-map-controls);

  bottom:
    var(--space-4);

  left:
    50%;

  transform:
    translateX(-50%);

  padding:
    6px
    12px;

  color:
    var(--foreground-subtle);

  background:
    rgba(10, 14, 12, 0.76);

  border:
    1px solid var(--border);

  border-radius:
    var(--radius-full);

  font-family:
    var(--font-mono);

  font-size:
    var(--text-2xs);

  letter-spacing:
    0.05em;

  pointer-events:
    none;

  backdrop-filter:
    blur(8px);
}

.globe-hint[hidden] {
  display:
    none;
}


/* ==========================================================================
   35. DATA / CODE TYPOGRAPHY
   ========================================================================== */

code,
pre,
.mono {
  font-family:
    var(--font-mono);
}

pre {
  overflow-x:
    auto;

  padding:
    var(--space-4);

  color:
    var(--foreground-muted);

  background:
    rgba(255, 255, 255, 0.028);

  border:
    1px solid var(--border);

  border-radius:
    var(--radius-md);

  line-height:
    1.65;
}


/* ==========================================================================
   36. UTILITY STATES
   ========================================================================== */

.is-hidden,
[hidden] {
  display:
    none !important;
}

.is-disabled {
  pointer-events:
    none;

  opacity:
    0.5;
}

.is-loading {
  pointer-events:
    none;
}


/* ==========================================================================
   37. TOUCH FOUNDATION
   ========================================================================== */

@media (pointer: coarse) {

  .header-button,
  .map-button,
  .map-control,
  .timeline-button,
  .icon-button {
    min-width:
      44px;

    min-height:
      44px;
  }

  .entity-item {
    min-height:
      48px;
  }

  .timeline-period,
  .period-button {
    min-height:
      40px;
  }

  #timeline {
    height:
      32px;
  }
}


/* ==========================================================================
   38. LARGE DESKTOP
   ========================================================================== */

@media (min-width: 1440px) {

  :root {
    --sidebar-width:
      330px;

    --timeline-height:
      200px;
  }

  .atlas-header {
    padding-left:
      var(--space-6);

    padding-right:
      var(--space-6);
  }

  #timelinePanel {
    padding-left:
      var(--space-10);

    padding-right:
      var(--space-10);
  }

  #mapInfo {
    width:
      min(460px, calc(100% - 48px));
  }
}


/* ==========================================================================
   39. TABLET
   ========================================================================== */

@media (max-width: 1100px) {

  :root {
    --sidebar-width:
      275px;
  }

  .brand {
    min-width:
      210px;
  }

  .header-actions {
    min-width:
      210px;
  }

  #timelinePanel {
    padding-left:
      var(--space-5);

    padding-right:
      var(--space-5);
  }
}


/* ==========================================================================
   40. SMALL TABLET
   ========================================================================== */

@media (max-width: 820px) {

  :root {
    --sidebar-width:
      240px;

    --timeline-height:
      178px;
  }

  .brand {
    min-width:
      auto;
  }

  .brand-text p {
    display:
      none;
  }

  .header-actions {
    min-width:
      auto;
  }

  .view-button {
    padding-left:
      9px;

    padding-right:
      9px;
  }

  .current-year {
    font-size:
      var(--text-lg);
  }

  .sidebar-section {
    padding:
      var(--space-3);
  }

  .border-legend {
    padding:
      var(--space-3);
  }
}


/* ==========================================================================
   41. MOBILE — COMPLETE LAYOUT REDESIGN
   ========================================================================== */

@media (max-width: 640px) {

  :root {
    --mobile-header-height:
      58px;

    --mobile-sidebar-height:
      198px;
  }


  /* ------------------------------------------------------------------------
     Root
     ------------------------------------------------------------------------ */

  html,
  body {
    width:
      100%;

    height:
      100%;

    overflow:
      hidden;

    overscroll-behavior:
      none;
  }

  .atlas-app {
    height:
      100dvh;

    grid-template-rows:
      var(--mobile-header-height)
      minmax(0, 1fr);
  }


  /* ------------------------------------------------------------------------
     MOBILE HEADER
     ------------------------------------------------------------------------ */

  .atlas-header {
    height:
      var(--mobile-header-height);

    padding:
      0
      12px;

    background:
      linear-gradient(
        180deg,
        rgba(16, 21, 18, 0.98),
        rgba(9, 13, 11, 0.98)
      );
  }

  .brand {
    gap:
      9px;

    min-width:
      0;

    flex:
      1 1 auto;
  }

  .brand-mark {
    width:
      30px;

    height:
      30px;

    flex-basis:
      30px;
  }

  .brand h1 {
    max-width:
      145px;

    overflow:
      hidden;

    font-size:
      13px;

    text-overflow:
      ellipsis;

    white-space:
      nowrap;
  }

  .brand-text p {
    display:
      none;
  }


  /* ------------------------------------------------------------------------
     Mobile year
     ------------------------------------------------------------------------ */

  .header-center {
    position:
      static;

    flex:
      0 0 auto;

    transform:
      none;

    margin:
      0
      8px;
  }

  .current-year {
    font-size:
      15px;
  }

  .current-year::before {
    width:
      4px;

    height:
      4px;

    flex-basis:
      4px;
  }


  /* ------------------------------------------------------------------------
     Mobile header actions
     ------------------------------------------------------------------------ */

  .header-actions {
    flex:
      0 0 auto;

    gap:
      4px;

    min-width:
      auto;
  }

  .view-switch {
    display:
      none;
  }

  .header-button {
    width:
      40px;

    min-width:
      40px;

    height:
      40px;

    padding:
      0;

    font-size:
      0;
  }

  .header-button::after {
    content:
      "•••";

    display:
      block;

    color:
      var(--foreground-muted);

    font-size:
      11px;

    letter-spacing:
      2px;

    line-height:
      1;
  }


  /* ------------------------------------------------------------------------
     MOBILE MAIN
     ------------------------------------------------------------------------ */

  .atlas-main {
    min-height:
      0;

    display:
      flex;

    flex-direction:
      column;

    overflow:
      hidden;
  }


  /* ------------------------------------------------------------------------
     MOBILE MAP
     ------------------------------------------------------------------------ */

  .map-view-stack {
    order:
      1;

    flex:
      1 1 auto;

    min-height:
      0;

    width:
      100%;
  }


  /* ------------------------------------------------------------------------
     Mobile map controls
     ------------------------------------------------------------------------ */

  .map-controls {
    top:
      12px;

    right:
      12px;

    gap:
      3px;

    padding:
      4px;

    border-radius:
      10px;
  }

  .map-button,
  .map-control {
    width:
      40px;

    height:
      40px;

    min-width:
      40px;

    font-size:
      16px;
  }


  /* ------------------------------------------------------------------------
     Mobile map info becomes bottom sheet
     ------------------------------------------------------------------------ */

  #mapInfo {
    left:
      10px;

    right:
      10px;

    bottom:
      10px;

    width:
      auto;

    max-height:
      min(
        42dvh,
        360px
      );

    padding:
      18px;

    border-radius:
      14px;

    box-shadow:
      0 18px 50px
      rgba(0, 0, 0, 0.50);
  }

  #mapInfo::before {
    left:
      50%;

    transform:
      translateX(-50%);

    width:
      42px;
  }

  #mapInfoTitle {
    margin-right:
      38px;

    font-size:
      18px;
  }

  #mapInfoContent {
    font-size:
      13px;
  }

  #closeMapInfo {
    width:
      38px;

    height:
      38px;
  }


  /* ------------------------------------------------------------------------
     MOBILE SIDEBAR
     ------------------------------------------------------------------------ */

  #sidebar {
    order:
      2;

    flex:
      0 0 var(--mobile-sidebar-height);

    width:
      100%;

    height:
      var(--mobile-sidebar-height);

    min-height:
      var(--mobile-sidebar-height);

    border:
      0;

    border-top:
      1px solid var(--border-strong);

    box-shadow:
      0 -12px 30px
      rgba(0, 0, 0, 0.22);
  }

  #sidebar::before {
    display:
      none;
  }

  .sidebar-section {
    padding:
      10px
      12px;
  }

  .section-heading {
    margin-bottom:
      7px;
  }

  .section-label {
    font-size:
      8px;
  }

  .sidebar-year {
    font-size:
      20px;
  }

  .date-context {
    font-size:
      10px;
  }

  #search {
    height:
      40px;

    border-radius:
      9px;
  }

  .sidebar-meta {
    display:
      none;
  }


  /* ------------------------------------------------------------------------
     Mobile entity list
     ------------------------------------------------------------------------ */

  #entityList {
    display:
      grid;

    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      );

    align-content:
      start;

    gap:
      4px;

    padding:
      7px
      8px;

    overflow-y:
      auto;

    scrollbar-gutter:
      stable;
  }

  .entity-item {
    min-width:
      0;

    min-height:
      48px;

    padding:
      9px;

    margin:
      0;

    border-radius:
      8px;
  }

  .entity-item.active::before {
    left:
      -1px;

    top:
      8px;

    bottom:
      8px;

    width:
      3px;
  }

  .entity-name {
    font-size:
      11px;
  }

  .entity-meta {
    margin-top:
      3px;

    font-size:
      8px;
  }

  .border-legend,
  .legend-section {
    display:
      none;
  }


  /* ------------------------------------------------------------------------
     MOBILE TIMELINE
     ------------------------------------------------------------------------ */

  #timelinePanel {
    order:
      3;

    position:
      relative;

    height:
      auto;

    min-height:
      176px;

    padding:
      12px;

    border-top:
      1px solid var(--border-strong);

    box-shadow:
      0 -8px 24px
      rgba(0, 0, 0, 0.18);
  }

  #timelinePanel::before {
    display:
      none;
  }

  .timeline-header {
    min-height:
      36px;

    margin-bottom:
      8px;
  }

  .timeline-title {
    gap:
      7px;
  }

  .timeline-title h2,
  .timeline-title strong {
    font-size:
      12px;
  }

  .timeline-kicker {
    display:
      none;
  }

  #timelineYearLabel,
  .timeline-current-year {
    font-size:
      9px;
  }

  .timeline-actions {
    gap:
      3px;
  }

  .timeline-button {
    min-width:
      40px;

    height:
      40px;

    padding:
      0
      8px;
  }

  #playButton,
  .timeline-play {
    min-width:
      62px;

    height:
      40px;
  }

  .timeline-track,
  .timeline-rail {
    padding:
      7px
      0;
  }

  #timeline {
    height:
      32px;
  }

  #timelineLabels {
    margin-top:
      4px;

    padding-bottom:
      0;
  }

  #timelineLabels span {
    font-size:
      8px;
  }

  .timeline-periods {
    margin-top:
      7px;

    justify-content:
      flex-start;

    gap:
      4px;

    padding-bottom:
      2px;
  }

  .timeline-period,
  .period-button {
    height:
      36px;

    min-height:
      36px;

    padding:
      0
      10px;

    border-radius:
      8px;

    font-size:
      8px;
  }

  .timeline-tick-label {
    display:
      none;
  }

  .atlas-footer {
    display:
      none;
  }
}


/* ==========================================================================
   42. VERY SMALL PHONES
   ========================================================================== */

@media (max-width: 420px) {

  :root {
    --mobile-header-height:
      54px;

    --mobile-sidebar-height:
      182px;
  }

  .atlas-header {
    padding:
      0
      9px;
  }

  .brand {
    gap:
      7px;
  }

  .brand-mark {
    width:
      28px;

    height:
      28px;

    flex-basis:
      28px;
  }

  .brand h1 {
    max-width:
      115px;

    font-size:
      12px;
  }

  .current-year {
    font-size:
      13px;
  }

  .header-button {
    width:
      38px;

    min-width:
      38px;

    height:
      38px;
  }

  .map-controls {
    top:
      9px;

    right:
      9px;
  }

  .map-button,
  .map-control {
    width:
      38px;

    height:
      38px;

    min-width:
      38px;
  }

  #sidebar {
    flex-basis:
      var(--mobile-sidebar-height);

    height:
      var(--mobile-sidebar-height);

    min-height:
      var(--mobile-sidebar-height);
  }

  .sidebar-section {
    padding:
      8px
      10px;
  }

  #search {
    height:
      38px;
  }

  .entity-item {
    min-height:
      44px;

    padding:
      8px;
  }

  .entity-name {
    font-size:
      10px;
  }

  .entity-meta {
    display:
      none;
  }

  #timelinePanel {
    min-height:
      164px;

    padding:
      10px;
  }

  .timeline-title h2,
  .timeline-title strong {
    font-size:
      11px;
  }

  #playButton,
  .timeline-play {
    min-width:
      58px;
  }

  .timeline-period,
  .period-button {
    height:
      34px;

    min-height:
      34px;

    padding:
      0
      8px;
  }
}


/* ==========================================================================
   43. LANDSCAPE MOBILE
   ========================================================================== */

@media (max-width: 760px) and (orientation: landscape) {

  :root {
    --mobile-header-height:
      50px;

    --mobile-sidebar-height:
      124px;
  }

  .atlas-header {
    height:
      var(--mobile-header-height);
  }

  .brand-mark {
    width:
      27px;

    height:
      27px;

    flex-basis:
      27px;
  }

  .brand h1 {
    font-size:
      11px;
  }

  .current-year {
    font-size:
      13px;
  }

  .header-button {
    width:
      38px;

    min-width:
      38px;

    height:
      38px;
  }

  #sidebar {
    flex-basis:
      var(--mobile-sidebar-height);

    height:
      var(--mobile-sidebar-height);

    min-height:
      var(--mobile-sidebar-height);
  }

  .sidebar-section {
    padding:
      6px
      10px;
  }

  .section-heading {
    display:
      none;
  }

  #search {
    height:
      32px;
  }

  #entityList {
    grid-template-columns:
      repeat(
        4,
        minmax(0, 1fr)
      );

    gap:
      3px;
  }

  .entity-item {
    min-height:
      38px;

    padding:
      6px;
  }

  .entity-meta {
    display:
      none;
  }

  .entity-name {
    font-size:
      9px;
  }

  #timelinePanel {
    min-height:
      112px;

    padding:
      8px
      10px;
  }

  .timeline-header {
    min-height:
      28px;

    margin-bottom:
      2px;
  }

  .timeline-button {
    min-width:
      34px;

    height:
      34px;
  }

  #playButton,
  .timeline-play {
    min-width:
      54px;

    height:
      34px;
  }

  .timeline-period,
  .period-button {
    height:
      30px;

    min-height:
      30px;
  }
}


/* ==========================================================================
   44. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior:
      auto !important;

    animation-duration:
      0.01ms !important;

    animation-iteration-count:
      1 !important;

    transition-duration:
      0.01ms !important;
  }
}


/* ==========================================================================
   45. ANIMATIONS
   ========================================================================== */

@keyframes atlas-spin {

  from {
    transform:
      rotate(0deg);
  }

  to {
    transform:
      rotate(360deg);
  }
}

@keyframes atlas-fade-in {

  from {
    opacity:
      0;
  }

  to {
    opacity:
      1;
  }
}

@keyframes atlas-panel-enter {

  from {
    opacity:
      0;

    transform:
      translateY(7px)
      scale(0.995);
  }

  to {
    opacity:
      1;

    transform:
      translateY(0)
      scale(1);
  }
}

@keyframes atlas-modal-enter {

  from {
    opacity:
      0;

    transform:
      translateY(12px)
      scale(0.985);
  }

  to {
    opacity:
      1;

    transform:
      translateY(0)
      scale(1);
  }
}


/* ==========================================================================
   END — PROFESSIONAL DEFENSE ATLAS UI
   ========================================================================== */
