:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #333;
  --text: #ccc;
  --text-muted: #999;
  --accent: #d4af37;
  --accent-soft: rgba(212, 175, 55, 0.15);
  --quote-border: #d4af37;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --sidebar-width: 320px;
  --header-height: 56px;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: var(--header-height) 1fr auto;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.header {
  grid-area: header;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-main {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.6rem 0;
}

.header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.header-title {
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.mobile-filter-btn {
  display: none;
}

.mobile-filter-drawer {
  display: none;
}

.toggle-map-btn {
  display: none;
}

.mobile-play-btn {
  display: none;
}

.sidebar-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.header-right {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: flex-end;
  text-align: right;
  gap: 0;
  max-width: none;
  justify-content: center;
}

.tagline {
  margin: 0;
  font-style: italic;
  font-family: var(--font-serif);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: normal;
  line-height: 1.3;
  max-width: 100%;
}

.admin-link {
  text-decoration: none;
  color: inherit;
  cursor: default;
}

.admin-link:hover,
.admin-link:focus-visible,
.admin-link:active {
  color: inherit;
  text-decoration: none;
}

.admin-link-strong {
  transition: color 0.15s ease;
}

.admin-link-strong:hover,
.admin-link-strong:focus-visible {
  color: var(--accent);
}

.top-timeline {
  display: none;
}

.top-timeline input[type="range"] {
  width: 100%;
  margin: 0;
  height: 10px;
  accent-color: var(--accent);
}

.top-timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.top-timeline-labels span:nth-child(2) {
  color: var(--accent);
  font-weight: 500;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 180px;
  max-width: 600px;
  overflow: hidden;
}

.nav-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.sidebar .panel {
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.sidebar-expand-btn {
  display: none;
}

.resize-handle {
  background: transparent;
  user-select: none;
  z-index: 50;
}

.resize-handle--v {
  display: none;
}

.resize-handle--h {
  position: absolute;
  top: var(--row-split, 55%);
  left: 0;
  right: 0;
  height: 8px;
  cursor: row-resize;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  z-index: 50;
  transform: translateY(-4px);
}

.resize-handle--h:hover {
  background: var(--accent-soft);
}

.resize-handle--v-bottom {
  position: absolute;
  left: var(--bottom-col-split, 320px);
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: background 0.15s;
  z-index: 50;
  transform: translateX(-4px);
}

.resize-handle--v-bottom:hover {
  background: var(--accent-soft);
}

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  border: none;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  background: rgba(88, 166, 255, 0.08);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.field {
  margin-bottom: 0.75rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.9;
}

select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 2.25rem;
}

select[multiple] {
  min-height: 6rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

input[type="range"] {
  width: 100%;
  margin: 0.25rem 0;
  accent-color: var(--accent);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.checkbox-label input {
  margin: 0;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:hover {
  background: var(--border);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.filters-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.filters-actions .btn-primary {
  flex: 2;
}

.filters-actions .btn-ghost {
  flex: 1;
}

.btn-icon {
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.playback-controls .btn-icon {
  flex-shrink: 0;
}

.playback-controls select {
  width: auto;
  min-width: 7rem;
}

.current-date {
  font-family: var(--font-serif);
  font-size: 1rem;
  margin-top: 0.25rem;
  color: var(--accent);
}

.quote-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.quote-banner {
  flex: 1;
  min-height: 120px;
  padding: 1rem;
  border-left: 4px solid var(--quote-border);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  overflow-y: auto;
}

.quote-banner .quote-text {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}

.quote-banner .quote-icon {
  margin-right: 0.4rem;
  font-style: normal;
}

.quote-banner .quote-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quote-banner .quote-meta strong {
  color: var(--text);
}

.quote-source-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  margin-top: 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.quote-doc-link {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.quote-doc-label {
  font-weight: 500;
}

.quote-doc-title {
  color: var(--accent);
  text-decoration: none;
}

.quote-doc-title:hover {
  text-decoration: underline;
}

.quote-doc-url {
  opacity: 0.9;
}

.quote-source-url {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.main {
  grid-area: main;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--row-split, 55%) 1fr;
  grid-template-areas: "map" "bottom-row";
  min-height: 0;
  position: relative;
}

.bottom-row {
  grid-area: bottom-row;
  display: grid;
  grid-template-columns: var(--bottom-col-split, 50%) 1fr;
  min-height: 0;
  position: relative;
}

.time-slider-footer {
  grid-area: footer;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 0;
  overflow-y: auto;
}

.time-slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.time-slider-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
  min-width: 120px;
}

.time-slider-info label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.time-slider-wrapper {
  position: relative;
  flex: 1;
  min-width: 0;
}

.time-slider {
  flex: 1;
  min-width: 0;
  height: 6px;
  cursor: pointer;
}

.date-display {
  position: absolute;
  top: -1.6rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0c14b;
  font-family: var(--font-sans);
  letter-spacing: 0.05em;
  min-height: 1.3rem;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.date-display.visible {
  opacity: 1;
}

.date-jump-input {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.date-jump-field {
  background: transparent;
  color: transparent;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  min-width: 100px;
  text-align: center;
  letter-spacing: 0.05em;
  pointer-events: all;
  cursor: text;
  outline: none;
  caret-color: #f0c14b;
}

.date-jump-field:focus {
  outline: 1px solid rgba(240, 193, 75, 0.3);
}

.date-jump-field::placeholder {
  color: rgba(240, 193, 75, 0.4);
}

.quadrant {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.quadrant--map {
  grid-area: map;
  min-height: 0;
}

.quadrant--info {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 120px;
  min-width: 180px;
  overflow-y: auto;
}

.quadrant--doc {
  background: var(--surface);
  border-top: 1px solid var(--border);
  min-height: 120px;
  flex: 1;
  min-width: 180px;
}

.nav-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.info-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.info-content h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.doc-viewer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
  overflow: auto;
  background: var(--bg);
}

.doc-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  cursor: zoom-in;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}


.map {
  width: 100%;
  height: 100%;
  min-height: 0;
  z-index: 0;
}

.quote-overlay {
  display: none;
}

.quote-overlay-compact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
}

.dumbarton-oaks-panel {
  --dumbarton-aspect-ratio: 4 / 3;
  position: absolute;
  bottom: 0;
  left: var(--sidebar-width);
  width: 22%;
  height: auto;
  aspect-ratio: var(--dumbarton-aspect-ratio);
  min-width: 160px;
  max-height: 45vh;
  z-index: 100;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  background: rgba(5, 10, 20, 0.95);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease, left 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s ease, aspect-ratio 0.25s ease, transform 0.25s ease;
  display: flex;
  flex-direction: column;
  transform-origin: bottom left;
}

.dumbarton-oaks-panel.visible {
  opacity: 1;
  visibility: visible;
}

.dumbarton-oaks-panel.dumbarton-oaks-panel--enlarged {
  width: 39.6%;
  height: auto;
  min-width: 288px;
  max-height: 100%;
  max-width: 100%;
}

.app--sidebar-hidden {
  grid-template-columns: 1fr;
  grid-template-areas:
    "header"
    "main"
    "footer";
}

.app--sidebar-hidden .sidebar {
  display: none;
}

.app--sidebar-hidden .dumbarton-oaks-panel {
  left: 48px;
}

.dumbarton-oaks-panel .dumbarton-oaks-img {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: auto;
  cursor: pointer;
  vertical-align: top;
}

.dumbarton-oaks-panel.dumbarton-oaks-panel--enlarged .dumbarton-oaks-img {
  cursor: zoom-out;
}

.dumbarton-oaks-panel .dumbarton-oaks-link {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.75);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dumbarton-oaks-panel .dumbarton-oaks-link:hover {
  color: #79c0ff;
  text-decoration: underline;
}

.quote-overlay-text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-style: italic;
  line-height: 1.3;
  text-align: center;
  color: #f9fafb;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.quote-nav {
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #f9fafb;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.quote-nav:hover {
  background: rgba(37, 99, 235, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

.quote-nav:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  z-index: 10;
  transition: opacity 0.3s;
}

.loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Google Maps info window overrides */
.gm-style .gm-style-iw-c {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  max-width: 320px;
}

.gm-style .gm-style-iw-d {
  overflow: auto !important;
}

.info-window h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.info-window p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: #333;
}

.info-window .meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "header"
      "main"
      "footer";
  }

  .sidebar {
    display: none;
  }

  .mobile-filter-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
  }

  .mobile-filter-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .mobile-filter-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  .mobile-filter-drawer {
    display: flex !important;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    flex-direction: column;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .mobile-filter-drawer.open {
    opacity: 1;
    visibility: visible;
  }

  .mobile-filter-drawer.open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }

  .mobile-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-top: var(--header-height);
  }

  .mobile-filter-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text);
  }

  .mobile-filter-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
  }

  .mobile-filter-close:hover {
    background: var(--accent-soft);
  }

  .mobile-filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-filter-content .field {
    margin-bottom: 0;
  }

  .mobile-filter-content .field label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
  }

  .mobile-filter-content input[type="text"],
  .mobile-filter-content input[type="range"],
  .mobile-filter-content select {
    width: 100%;
  }

  .mobile-filter-content select {
    padding: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
  }

  .header {
    padding: 0.75rem 1rem;
  }

  .header-main {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .header-title {
    order: 1;
    flex: 0 0 auto;
  }

  .header h1 {
    font-size: 1rem;
  }

  .sidebar-toggle {
    order: 0;
    width: 32px;
    height: 32px;
  }

  .header-right {
    order: 2;
    flex-basis: 100%;
    text-align: left;
    align-items: flex-start;
  }

  .tagline {
    font-size: 0.8rem;
    line-height: 1.3;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-muted);
  }

  .top-timeline {
    display: none;
  }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "info" "doc" "map";
  }

  .bottom-row {
    grid-template-columns: 1fr;
    order: -1;
    display: contents;
  }

  .quadrant--info {
    grid-area: info;
    order: 1;
    border-top: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
  }

  .quadrant--doc {
    grid-area: doc;
    order: 2;
    border-top: none;
    max-height: none;
  }

  .quadrant--map {
    order: 3;
  }

  .resize-handle {
    display: none !important;
  }

  .resize-handle--h,
  .resize-handle--v-bottom {
    display: none !important;
  }

  .quadrant--info {
    border-top: 1px solid var(--border);
    border-right: none;
    min-height: auto;
    max-height: 40vh;
    overflow-y: auto;
  }

  .quadrant--doc {
    border-top: 1px solid var(--border);
    min-height: auto;
    max-height: 40vh;
  }

  .map {
    min-height: 200px;
  }

  .quote-overlay {
    top: 306px;
    width: 92%;
    min-width: 92%;
    padding: 0.4rem 0.75rem;
  }

  .quote-overlay-compact {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }

  .quote-overlay-text {
    font-size: 1rem;
    line-height: 1.4;
    padding: 0.5rem 0;
    flex: 1;
  }

  .quote-nav {
    align-self: center;
    width: auto;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  .quote-nav-left {
    order: 1;
  }

  .quote-nav-right {
    order: 4;
  }

  .mobile-play-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    order: 2;
    transition: background 0.2s ease, transform 0.2s ease;
  }

  .mobile-play-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
  }

  .mobile-play-btn:active {
    transform: scale(0.95);
  }

  .quote-banner {
    padding: 0.75rem;
    min-height: auto;
    flex: 0 1 auto;
    overflow: visible;
  }

  .quote-text {
    font-size: 0.95rem;
    line-height: 1.4;
    display: block;
  }

  .main.no-image .quote-banner {
    padding: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
  }

  .main.no-image .quote-overlay-compact {
    margin-bottom: 0.5rem;
  }

  .info-content {
    padding: 0.5rem 0.5rem 0.25rem;
    flex-direction: column;
    gap: 0.3rem;
  }

  .quote-overlay-compact {
    margin-top: 0;
    margin-bottom: 0.5rem;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .quote-overlay-text {
    font-size: 0.85rem;
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
  }

  .quote-icon {
    display: none;
  }

  .doc-viewer-content {
    padding: 0.5rem;
  }

  .doc-viewer-img {
    max-width: 95%;
    max-height: 95%;
  }
}

/* ============================================================
   Brand button + "Six Chapters" modal
   ============================================================ */
.brand-btn {
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  color: inherit; font: inherit; display: inline-flex; align-items: center;
  gap: 0.5rem; transition: opacity 0.15s ease;
}
.brand-btn::after {
  content: "\203A"; font-size: 1.1em; opacity: 0.45; transform: translateY(-1px);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.brand-btn:hover { opacity: 0.9; }
.brand-btn:hover::after { opacity: 0.85; transform: translate(3px, -1px); }
.brand-btn h1 { margin: 0; }

.chapters-modal { position: fixed; inset: 0; z-index: 1000; display: none; }
.chapters-modal.open { display: block; }
.chapters-backdrop {
  position: absolute; inset: 0; background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(3px); animation: chaptersFade 0.2s ease;
}

.image-modal .chapters-backdrop {
  backdrop-filter: none;
  background: rgba(0, 0, 0, 0.3);
}
.chapters-dialog {
  position: relative; max-width: 960px; margin: 4vh auto; max-height: 92vh;
  overflow-y: auto; background: #12161f; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  padding: 2rem 2.25rem 2.5rem; animation: chaptersRise 0.25s ease;
}
@keyframes chaptersFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes chaptersRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.chapters-close {
  position: absolute; top: 0.9rem; right: 1.1rem; width: 2rem; height: 2rem;
  border: 0; border-radius: 50%; background: rgba(255,255,255,0.06); color: #cfd8e6;
  font-size: 1.4rem; line-height: 1; cursor: pointer; transition: background 0.15s ease;
}
.chapters-close:hover { background: rgba(255,255,255,0.14); }
.chapters-head { text-align: center; margin-bottom: 1.6rem; padding-right: 1.5rem; }
.chapters-head h2 {
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 2rem;
  margin: 0 0 0.35rem; color: #f2f5fa;
}
.chapters-head p { margin: 0; color: #93a0b4; font-size: 0.95rem; }
.chapters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chapter-card {
  background: #171d28; border: 1px solid rgba(255,255,255,0.06);
  border-left: 4px solid var(--chapter-color, #5c6bc0); border-radius: 12px;
  padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column;
}
.chapter-chip {
  display: inline-block; align-self: flex-start; font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase; color: #fff;
  background: var(--chapter-color, #5c6bc0); padding: 0.22rem 0.6rem;
  border-radius: 20px; margin-bottom: 0.6rem;
}
.chapter-title {
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.35rem;
  margin: 0 0 0.15rem; color: #eef2f8;
}
.chapter-years { font-size: 0.8rem; color: #7f8da0; margin-bottom: 0.55rem; }
.chapter-blurb { font-size: 0.92rem; color: #c3cdda; margin: 0 0 0.7rem; line-height: 1.5; }
.chapter-count { font-size: 0.78rem; color: #8b97a8; margin-bottom: 0.6rem; }
.chapter-count b { color: #cdd6e3; }
.chapter-quote {
  font-family: "Cormorant Garamond", Georgia, serif; font-style: italic;
  font-size: 1.02rem; color: #d8e0ec; border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 0.7rem; margin-top: auto; line-height: 1.45;
}
.chapter-cite {
  display: block; font-family: "DM Sans", sans-serif; font-style: normal;
  font-size: 0.75rem; color: #7f8da0; margin-top: 0.4rem;
}
@media (max-width: 720px) {
  .chapters-grid { grid-template-columns: 1fr; }
  .chapters-dialog { margin: 2vh auto; padding: 1.5rem 1.25rem 2rem; }
}

/* ----- Life-chapter (era) filter ----- */
.era-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.era-filter-actions { display: flex; gap: 0.35rem; }
.era-mini-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted, #93a0b4);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 5px;
  cursor: pointer;
}
.era-mini-btn:hover { color: var(--text); border-color: var(--accent); }

.era-filter {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.35rem;
}
.era-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.15rem 0;
}
.era-option input { margin: 0; flex: 0 0 auto; }
.era-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--chapter-color, #5c6bc0);
}
.era-text { display: flex; flex-direction: column; line-height: 1.2; }
.era-name { font-size: 0.85rem; }
.era-years { font-size: 0.7rem; color: var(--text-muted, #93a0b4); }

/* Chapter chip inside the map info window (popup) */
.info-window .info-chapter { margin: 0 0 0.5rem; }
.info-chapter-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
  padding: 0.16rem 0.55rem;
  border-radius: 20px;
}

/* ---- Trace mode controls ---- */
.trace-field .trace-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
  opacity: 0.95;
}

.trace-field .trace-count-row label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.trace-field input[type="number"] {
  width: 4.2rem;
  padding: 0.3rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  text-align: center;
}

.trace-field input[type="number"]:disabled {
  opacity: 0.4;
}

.trace-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.trace-legend-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  /* GBIV: green -> blue -> indigo -> violet (oldest -> newest) */
  background: linear-gradient(90deg,
    rgb(46, 204, 64) 0%,
    rgb(0, 116, 217) 40%,
    rgb(75, 0, 130) 72%,
    rgb(148, 0, 211) 100%);
}

/* ---- Miles-traveled HUD (upper-right of map) ---- */
.miles-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  padding: 0.5rem 0.8rem;
  background: rgba(5, 10, 20, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  user-select: none;
  transition: opacity 0.3s ease;
}

.miles-hud-value {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.miles-hud-number {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.miles-hud-unit {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
}

.miles-hud-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* Image lightbox modal */
.image-modal-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100vw;
  height: 100vh;
  padding: 2rem;
  gap: 1.5rem;
  overflow-y: auto;
  background: #0d1117;
}

.image-modal-img {
  max-width: 90vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  flex-shrink: 0;
}

.image-modal-caption {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex-shrink: 0;
  padding: 0 1rem;
}

.image-modal-caption .modal-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text);
  font-weight: 500;
}

.image-modal-caption .modal-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Image Picker Modal */
.image-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: none;
}

.image-picker-modal.open {
  display: flex;
}

.image-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

.image-picker-dialog {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 1200px;
  height: 90vh;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  margin: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.image-picker-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.image-picker-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.2s ease;
}

.image-picker-close:hover {
  color: var(--accent);
}

.image-picker-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.image-picker-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s ease;
  background: var(--bg);
}

.image-picker-item:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.image-picker-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.image-picker-img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.image-picker-name {
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border);
}

.image-picker-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.image-picker-footer .btn {
  padding: 0.75rem 2rem;
}

/* Improve resize handle visibility */
.resize-handle--h::before,
.resize-handle--v-bottom::before {
  content: '';
  position: absolute;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.resize-handle--h::before {
  width: 40px;
  height: 3px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 1.5px;
}

.resize-handle--v-bottom::before {
  width: 3px;
  height: 40px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 1.5px;
}

.resize-handle--h:hover::before,
.resize-handle--v-bottom:hover::before {
  opacity: 0.6;
}

.resize-handle--h:active::before,
.resize-handle--v-bottom:active::before {
  opacity: 0.8;
}

.resize-handle--h:hover,
.resize-handle--v-bottom:hover {
  background: var(--accent-soft);
}

.resize-handle--h:active,
.resize-handle--v-bottom:active {
  background: rgba(88, 166, 255, 0.25);
}

/* Adjust quote overlay spacing */
.quote-overlay-compact {
  margin-bottom: 0.75rem;
  margin-top: 0;
}

@media (max-width: 640px) {
  :root {
    --header-height: 44px;
  }

  .app {
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .miles-hud { top: 10px; right: 10px; padding: 0.4rem 0.6rem; }
  .miles-hud-number { font-size: 1.25rem; }

  input[type="text"],
  input[type="number"],
  input[type="range"],
  select,
  textarea {
    font-size: 16px;
  }

  #textSearch,
  #dateJumpField,
  #traceCount {
    font-size: 16px;
  }

  .header {
    padding: 0.4rem 0.75rem;
  }

  .header-main {
    padding: 0.3rem 0;
    gap: 0.5rem;
  }

  .header h1 {
    font-size: 0.85rem;
  }

  .tagline {
    font-size: 0.6rem;
    display: none;
  }

  .sidebar-toggle {
    width: 28px;
    height: 28px;
  }

  .mobile-filter-btn {
    width: 28px;
    height: 28px;
  }

  .main {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "info"
      "doc";
    min-height: 0;
  }

  /* Hide map and footer on mobile */
  .quadrant--map {
    display: none !important;
  }

  .time-slider-footer {
    display: none !important;
  }

  .toggle-map-btn {
    display: none !important;
  }

  .resize-handle {
    display: none !important;
  }

  .bottom-row {
    display: flex;
    flex-direction: column;
    order: unset;
    grid-column: unset;
    grid-row: unset;
    grid-template-columns: unset;
    max-height: 100%;
    min-height: 0;
    flex: 1;
  }

  .quadrant--info {
    order: 1;
    padding: 0.5rem 0.5rem 0.3rem;
    border-top: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: auto;
    max-height: auto;
    flex: 0 0 auto;
  }

  .info-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
  }

  .quote-banner {
    display: none;
  }

  .quote-text {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .quote-overlay-compact {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0.3rem 0;
  }

  .quote-overlay-text {
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 0;
    flex: 1;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .quote-nav {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 0.8rem;
  }

  .mobile-play-btn {
    display: inline-flex !important;
    width: 40px;
    height: 40px;
    order: 2;
  }

  .quadrant--doc {
    order: 2;
    border-top: 1px solid var(--border);
    min-height: auto;
    max-height: 60vh;
    flex: 1;
    min-width: 0;
  }

  .quadrant--doc:empty,
  .quadrant--doc:has(> .doc-viewer-content:empty),
  .doc-viewer-content:empty {
    display: none;
  }

  .doc-viewer-content {
    padding: 0.75rem;
    height: 100%;
  }

  .doc-viewer-img {
    max-width: 100%;
    max-height: 100%;
  }

  .time-slider-info {
    min-width: auto;
  }

  .time-slider-info label {
    font-size: 0.75rem;
  }

  .current-date {
    font-size: 0.9rem;
  }
}
