:root {
  color-scheme: light;
  --ink: #213124;
  --muted: #5b665a;
  --line: #d7dfd2;
  --panel: #fffdf8;
  --wash: #eef3ea;
  --surface-alt: #f7f7f0;
  --brand: #2e7d32;
  --brand-dark: #1f5a24;
  --accent: #6b4638;
  --focus: #c3552a;
  --shadow-soft: 0 14px 40px rgba(23, 32, 56, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #d9e4f2;
  --muted: #abc0d7;
  --line: #2c3a52;
  --panel: #111a2b;
  --wash: #101725;
  --surface-alt: #0f1a2e;
  --brand: #7ed2df;
  --brand-dark: #bde7f0;
  --accent: #ffbe86;
  --focus: #ffbe86;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: Manrope, Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 2%, color-mix(in srgb, var(--brand) 18%, transparent) 0%, transparent 38%),
    var(--wash);
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.control-panel {
  z-index: 500;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 120px 236px minmax(220px, 1fr) minmax(260px, 1.35fr) 110px 90px 42px;
  align-items: end;
  gap: 12px;
}

.advanced-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) repeat(7, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.layer-controls {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 13px;
}

.layer-controls legend {
  margin-bottom: 7px;
  font-weight: 700;
}

.layer-controls label {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  font-weight: 400;
}

.layer-controls input {
  width: auto;
  min-height: 0;
  margin: 1px 0 0;
}

.map-trails {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.map-trails button {
  min-height: 0;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 12px;
}

.map-trails button.active {
  border-color: var(--focus);
  background: color-mix(in srgb, var(--focus) 16%, var(--panel));
  color: var(--focus);
}

.trail-status {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--focus) 35%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--focus) 8%, var(--panel));
}

.trail-status[hidden] {
  display: none;
}

.trail-status strong {
  color: var(--focus);
  font-size: 12px;
  line-height: 1.25;
}

.trail-status div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.trail-status a,
.trail-status button {
  min-height: 0;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.archive-tree-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 13px;
}

.archive-tree-field legend {
  margin-bottom: 7px;
  font-weight: 700;
}

.archive-tree {
  display: grid;
  gap: 3px;
  max-height: 185px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  background: var(--panel);
}

.archive-tree-row label {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  padding-left: calc(var(--depth, 0) * 14px);
  line-height: 1.25;
  cursor: pointer;
}

.archive-tree-row input {
  width: auto;
  min-height: 0;
  margin: 1px 0 0;
}

.filter-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.advanced-filters[hidden] {
  display: none;
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--brand-dark);
  text-decoration: none;
}

.surface-link {
  color: var(--brand-dark);
  font: 700 0.78rem Manrope, Arial, sans-serif;
  text-decoration: none;
}

.surface-links {
  display: grid;
  gap: 3px;
}

.surface-link-secondary {
  color: var(--muted);
  font-size: 10px;
}

.surface-link:hover,
.surface-link:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: var(--brand);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-name {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand-title {
  color: var(--brand-dark);
  font-family: Merriweather, Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
}

.local-mode-badge {
  justify-self: start;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--focus) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--focus) 13%, transparent);
  color: var(--focus);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.3;
  text-transform: uppercase;
}

.brand-tagline {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.stats div {
  padding: 9px 10px;
}

.stats div + div {
  border-left: 1px solid var(--line);
}

.stats span {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

.stats label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.timeline-explorer {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.timeline-disclosure {
  min-width: 0;
}

.timeline-disclosure > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.timeline-disclosure[open] {
  align-self: stretch;
}

.timeline-disclosure[open] > summary {
  margin-bottom: 5px;
}

.timeline-heading,
.timeline-actions,
.timeline-lower {
  display: flex;
  align-items: center;
}

.timeline-heading {
  justify-content: space-between;
  gap: 8px;
}

.timeline-heading > div:first-child {
  display: grid;
}

.timeline-kicker,
.timeline-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.timeline-heading strong {
  font-size: 12px;
}

.timeline-actions {
  gap: 4px;
}

.timeline-actions button {
  min-height: 24px;
  padding: 3px 7px;
  font-size: 10px;
}

.timeline-chart {
  display: grid;
  grid-auto-flow: column;
  align-items: end;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.timeline-years {
  grid-auto-columns: minmax(24px, 1fr);
  gap: 2px;
  min-height: 58px;
}

.timeline-months {
  grid-template-columns: repeat(12, minmax(14px, 1fr));
  gap: 1px;
}

.timeline-chart button {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 2px;
  min-height: 50px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.timeline-months button {
  min-height: 32px;
}

.timeline-chart .timeline-bar {
  align-self: end;
  min-height: 3px;
  border-radius: 4px 4px 1px 1px;
  background: color-mix(in srgb, var(--brand) 74%, var(--panel));
}

.timeline-chart .timeline-tick {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.timeline-months .timeline-tick {
  writing-mode: initial;
  transform: none;
}

.timeline-chart button.active .timeline-bar {
  background: var(--focus);
}

.timeline-chart button:disabled {
  opacity: 0.32;
  cursor: default;
}

.timeline-chart button:focus-visible {
  outline-offset: 1px;
}

.timeline-lower {
  align-items: start;
  gap: 8px;
}

.timeline-lower > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.timeline-lower > div:first-child {
  flex: 0 0 38%;
}

.timeline-lower > div:last-child {
  flex: 1;
}

.timeline-collections {
  display: grid;
  gap: 2px;
}

.timeline-collections button {
  display: grid;
  grid-template-columns: minmax(34px, 1fr) minmax(0, 2fr) auto;
  gap: 4px;
  align-items: center;
  min-height: 0;
  padding: 1px 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 8px;
  text-align: left;
  cursor: pointer;
}

.timeline-collections button > span {
  height: 4px;
  background: color-mix(in srgb, var(--line) 65%, transparent);
}

.timeline-collections i {
  display: block;
  height: 100%;
  background: var(--brand);
}

.timeline-collections button.active i {
  background: var(--focus);
}

.timeline-collections strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-collections em {
  color: var(--muted);
  font-style: normal;
}

.timeline-status,
.timeline-empty {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}
.source-trail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0 0;
}

.source-trail-stats span {
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 8%, var(--panel));
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.search-field {
  min-width: 0;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(195, 85, 42, 0.22);
  outline-offset: 1px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button,
.reset,
.filter-toggle {
  min-height: 40px;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button.active {
  background: var(--brand-dark);
  color: #fff;
}
:root[data-theme="dark"] .segmented button.active {
  color: #07111d;
}

.reset {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-count {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--brand-dark);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
}

.reset:hover,
.filter-toggle:hover,
.segmented button:hover {
  background: #edf3f4;
}
:root[data-theme="dark"] .reset:hover,
:root[data-theme="dark"] .filter-toggle:hover,
:root[data-theme="dark"] .segmented button:hover {
  background: #17243a;
}

.segmented button.active:hover {
  background: var(--brand-dark);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--brand-dark);
  cursor: pointer;
}

.theme-toggle .icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.icon-moon,
:root[data-theme="dark"] .icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

.map-panel,
#map {
  min-width: 0;
}

.map-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.map-area-search {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 40px);
  padding: 6px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow-soft);
}

.map-area-search button {
  min-height: 32px;
  white-space: nowrap;
}

.map-area-search span {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.map-panel-tools {
  position: absolute;
  z-index: 225;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 6px;
}

.map-panel-tools button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow-soft);
  font-size: 11px;
}

.map-panel-tools button[aria-expanded="true"] {
  border-color: var(--focus);
  color: var(--focus);
}

.map-panel.evidence-open {
  grid-template-columns: minmax(0, 1fr) minmax(380px, 42vw);
}

#map {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100%;
  background: #e8ecef;
}

.case-rank-panel {
  position: absolute;
  z-index: 220;
  top: 58px;
  right: 14px;
  width: min(340px, calc(100vw - 28px));
  max-height: min(58vh, 520px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.18);
}

.mapping-data-panel {
  position: absolute;
  z-index: 215;
  right: 14px;
  top: 58px;
  width: min(380px, calc(100vw - 28px));
  max-height: min(48vh, 470px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.18);
}

.case-rank-panel[hidden],
.mapping-data-panel[hidden] {
  display: none;
}

.case-rank-header,
.mapping-data-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.panel-close {
  min-height: 0;
  padding: 4px 7px;
  font-size: 10px;
}

.case-rank-header h2 {
  margin: 0;
  font-size: 15px;
}

.mapping-data-header h2 {
  margin: 0;
  font-size: 15px;
}

.source-rich-list {
  display: grid;
  gap: 7px;
  min-height: 0;
  margin-top: 10px;
  overflow: auto;
}

.mapping-data-content {
  display: grid;
  gap: 8px;
  min-height: 0;
  margin-top: 10px;
  overflow: auto;
}

.mapping-downloads {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mapping-downloads a,
.mapping-check-row a,
.mapping-check-row button {
  min-height: 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.mapping-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mapping-stat-grid span {
  min-width: 0;
  padding: 7px 6px;
}

.mapping-stat-grid span + span {
  border-left: 1px solid var(--line);
}

.mapping-stat-grid strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.15;
}

.mapping-stat-grid small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
}

.mapping-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mapping-pill-row span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 7%, var(--panel));
}

.mapping-pill-row strong,
.mapping-source-list strong {
  color: var(--ink);
  font-size: 11px;
}

.mapping-pill-row small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.mapping-source-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mapping-source-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-alt) 86%, transparent);
  font-size: 11px;
}

.mapping-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.mapping-check-list {
  display: grid;
  gap: 6px;
}

.mapping-check-row {
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.mapping-check-row strong {
  color: var(--ink);
  font-size: 12px;
}

.mapping-check-row span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.mapping-check-row div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.source-rich-item {
  display: grid;
  gap: 6px;
  min-height: 0;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}

.source-rich-item button {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.source-rich-item strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.source-rich-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.source-rich-archive-link {
  justify-self: start;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.source-rich-archive-link:hover,
.source-rich-archive-link:focus-visible {
  text-decoration: underline;
}

.popup-title {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.25;
}

.popup-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.popup-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  margin: 0;
}

.popup-meta dt {
  color: var(--muted);
  font-weight: 700;
}

.popup-meta dd {
  margin: 0;
}

.popup-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 700;
}

.primary-source-link {
  color: var(--brand-dark);
}

.popup-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
}

.case-permalink {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.case-permalink {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.dossier-case-link {
  border-color: color-mix(in srgb, var(--focus) 45%, var(--line));
  background: color-mix(in srgb, var(--focus) 10%, var(--panel));
}

.case-citation-button {
  min-height: 0;
  cursor: pointer;
}

.related-cases {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.related-case-list {
  display: grid;
  gap: 6px;
}

.related-case-list a {
  display: grid;
  gap: 2px;
  padding: 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.related-case-list span,
.related-case-list small {
  color: var(--muted);
}

.incident-cluster-members {
  margin-top: 8px;
}

.incident-cluster-members summary {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.incident-cluster-members[open] summary {
  margin-bottom: 7px;
}

.incident-cluster-members .related-case-list {
  max-height: 280px;
  overflow: auto;
}

.map-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
}

.search-shortcut-link {
  margin-top: 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--brand-dark);
  text-decoration: none;
}

.inline-link {
  display: inline;
  width: auto;
  min-height: 0;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.source-label {
  margin: 0 0 6px;
  color: var(--focus);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.source-count {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--focus) 35%, transparent);
  border-radius: 999px;
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
}

.source-detail {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.source-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.source-section-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.source-group {
  display: grid;
  gap: 8px;
}

.source-group + .source-group {
  margin-top: 12px;
}

.source-group-title {
  margin: 0;
  color: var(--focus);
  font-size: 13px;
}

.source-group-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}

.source-group-search {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
}

.source-row {
  padding-left: 8px;
  border-left: 3px solid rgba(195, 85, 42, 0.25);
}

.source-row .source-detail {
  margin: 0;
}

.case-list {
  display: grid;
  gap: 10px;
  max-height: min(54vh, 420px);
  padding-right: 4px;
  overflow: auto;
}

.case-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.case-card .popup-title {
  padding-right: 0;
  font-size: 14px;
}

.case-card .popup-meta {
  font-size: 13px;
}

.ol-popup {
  position: absolute;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 24px));
  max-height: min(72vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.24);
  transform: translate(-50%, -100%);
}

.popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: #edf1f4;
  cursor: pointer;
}

.evidence-panel {
  position: relative;
  z-index: 250;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -8px 0 28px rgba(23, 32, 42, 0.16);
}

.evidence-panel[hidden] {
  display: none;
}

.evidence-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 42px 12px 14px;
  border-bottom: 1px solid var(--line);
}

.evidence-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.evidence-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.evidence-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.evidence-actions .popup-link {
  margin-top: 0;
  white-space: nowrap;
}

.evidence-close {
  top: 8px;
  right: 8px;
}

.evidence-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

.ol-attribution {
  font-size: 12px;
}

@media (max-width: 820px) {
  .control-panel {
    padding: 10px;
    max-height: 42vh;
    overflow: auto;
  }

  .control-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px 74px;
    gap: 10px;
  }

  .advanced-filters {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .brand {
    grid-column: 1;
  }

  .brand p {
    display: none;
  }

  .stats {
    grid-column: 2 / 4;
  }

  .surface-links {
    grid-column: 1;
  }

  .timeline-explorer {
    grid-column: 1 / 4;
  }

  .timeline-years button {
    scroll-snap-align: start;
  }

  .stats div {
    padding: 7px 8px;
  }

  .stats span {
    font-size: 17px;
  }

  .search-field {
    grid-column: 1;
  }

  .reset {
    grid-column: 3;
    align-self: end;
  }

  .filter-toggle {
    grid-column: 2;
  }

  .map-panel,
  #map {
    min-height: 0;
  }

  .map-panel.evidence-open {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(280px, 42vh);
  }

  .case-rank-panel {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    max-height: 30vh;
    padding: 10px;
  }

  .source-rich-list {
    gap: 6px;
  }

  .source-rich-item {
    padding: 7px 8px;
  }

  .evidence-panel {
    grid-column: 1;
    grid-row: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(23, 32, 42, 0.18);
  }
}

@media (max-width: 520px) {
  .control-panel {
    max-height: 38vh;
  }

  .control-bar {
    grid-template-columns: 1fr 94px;
    gap: 8px;
  }

  .brand,
  .stats,
  .search-field,
  .timeline-explorer,
  .surface-links {
    grid-column: 1 / -1;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 16px;
  }

  .brand-tagline {
    display: none;
  }

  .stats span {
    font-size: 15px;
  }

  .stats label {
    font-size: 10px;
  }

  .filter-toggle {
    grid-column: 1;
  }

  .reset {
    grid-column: 2;
  }

  .advanced-filters {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .timeline-lower {
    display: grid;
    grid-template-columns: 1fr;
  }

  .timeline-lower > div:first-child {
    width: 100%;
  }

  .archive-tree {
    max-height: 130px;
  }

  .map-trails button,
  .trail-status a,
  .trail-status button {
    padding: 5px 8px;
  }

  .case-rank-panel {
    max-height: 26vh;
  }

  .case-rank-header h2 {
    font-size: 14px;
  }

  .evidence-panel-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .evidence-actions {
    justify-content: space-between;
  }

  .map-panel.evidence-open {
    grid-template-rows: minmax(0, 1fr) minmax(240px, 44vh);
  }

  .map-panel-tools {
    top: 8px;
    right: 8px;
    left: 8px;
    justify-content: flex-end;
  }

  .map-area-search {
    top: 50px;
    left: 8px;
    transform: none;
    max-width: calc(100% - 16px);
  }

  .map-area-search span {
    display: none;
  }
}
