:root {
  --bg: #f1efe9;
  --ink: #13100f;
  --muted: #6f665f;
  --panel: #fffdf7;
  --border: #d8d1c8;
  --accent: #bf3b18;
  --accent-soft: #f0d8ce;
  --focus: #8f2609;
  --shadow: 0 14px 38px rgba(31, 20, 13, 0.12);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, #fff4e8 0%, rgba(255, 244, 232, 0) 35%),
    radial-gradient(circle at 87% 2%, #f7ece4 0%, rgba(247, 236, 228, 0) 25%),
    linear-gradient(180deg, #faf7f2 0%, var(--bg) 70%);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(#000 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

.hero {
  position: relative;
  z-index: 1;
  padding: clamp(1.2rem, 2vw, 2rem) clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(120deg, #fffaf2 0%, #f7efe4 100%);
  text-align: center;
}

.kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font: 600 0.72rem var(--mono);
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.05;
}

.subhead {
  max-width: 70ch;
  margin: 0;
  color: var(--muted);
}

.hero-tagline {
  margin: 0.5rem auto 0;
  font: 700 clamp(1.08rem, 2vw, 1.95rem) var(--sans);
  letter-spacing: 0.015em;
  color: #b68d39;
}

.intro-pdf {
  margin: 0.75rem auto 0;
  max-width: 900px;
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid #3f352d;
  box-shadow:
    0 12px 34px rgba(38, 24, 16, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.intro-pdf-toolbar {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.44rem;
  padding: 0.42rem 0.62rem;
  background: linear-gradient(180deg, #3f342f 0%, #2b241f 100%);
  border-bottom: 1px solid #1d1714;
  color: #d8c8b2;
  font: 600 0.68rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.intro-pdf-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.intro-pdf-dot.dot-red {
  background: #d66c4c;
}

.intro-pdf-dot.dot-amber {
  background: #d2a24a;
}

.intro-pdf-dot.dot-green {
  background: #71a674;
}

.intro-pdf-filename {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.intro-pdf-pages {
  color: #b7a693;
  white-space: nowrap;
}

.intro-pdf-page {
  position: relative;
  text-align: left;
  padding: clamp(0.95rem, 2.2vw, 1.5rem) clamp(0.95rem, 2.8vw, 1.7rem);
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 30px,
      rgba(27, 58, 87, 0.075) 30px,
      rgba(27, 58, 87, 0.075) 31px
    ),
    linear-gradient(180deg, #fffdf8 0%, #f9f3e9 100%);
  color: #211914;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

/* Slight left margin line to sell the "document page" look. */
.intro-pdf-page::before {
  content: "";
  position: absolute;
  left: clamp(0.85rem, 2.4vw, 1.35rem);
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(164, 46, 30, 0.22);
  pointer-events: none;
}

.intro-pdf-page p {
  margin: 0;
  padding-left: clamp(0.48rem, 1.2vw, 0.62rem);
  font-size: clamp(0.95rem, 1.42vw, 1.1rem);
  line-height: 1.72;
  color: #231a14;
  text-wrap: pretty;
}

.intro-pdf-page p + p {
  margin-top: 0.6rem;
}

.intro-pdf-lead {
  font-weight: 500;
}

.intro-pdf-emph {
  color: #a43b1b;
}

.intro-pdf-stamp {
  position: absolute;
  top: 0.85rem;
  right: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.6rem;
  padding: 0.08rem 0.58rem;
  border: 2px solid rgba(170, 49, 29, 0.5);
  color: rgba(164, 49, 31, 0.7);
  border-radius: 0.2rem;
  font: 700 0.64rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-7deg);
  pointer-events: none;
}

.intro-pdf-quote {
  font-style: italic;
  color: #63574d;
}

.intro-pdf-foot {
  font-weight: 500;
}

.intro-pdf-cta {
  margin-top: 0.78rem;
}

.intro-pdf-link {
  color: #8e2f16;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 700;
}

.intro-pdf-link:visited,
.intro-pdf-link:hover,
.intro-pdf-link:active {
  color: #8e2f16;
}

.hero-summary {
  margin: 0.65rem auto 0;
  max-width: 1260px;
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  background: linear-gradient(145deg, #fffef9 0%, #f8f0e8 100%);
  padding: 0.44rem;
}

.hero-summary-head {
  margin: 0 0 0.35rem;
  text-align: left;
  font: 700 0.67rem var(--mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6f665f;
}

.stat-cards.compact-stats {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 0.32rem;
}

.hero-summary .stat-card {
  padding: 0.32rem 0.45rem;
  border-radius: 0.52rem;
  box-shadow: none;
  background: linear-gradient(145deg, #ffffff 0%, #fffaf3 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-height: 2rem;
}

.hero-summary .stat-card .label {
  font-size: 0.55rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
  margin: 0;
  text-align: left;
}

.hero-summary .stat-card .value {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1;
  white-space: nowrap;
  text-align: right;
}

.hero-divider {
  height: 1px;
  max-width: 1260px;
  margin: 0.75rem auto 0;
  background: linear-gradient(90deg, rgba(216, 209, 200, 0), rgba(216, 209, 200, 1), rgba(216, 209, 200, 0));
}

.hero-meta {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  color: var(--muted);
  font: 500 0.78rem var(--mono);
}

.hero-search {
  margin: 0.75rem auto 0;
  max-width: 860px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
}

.hero-search input[type="search"] {
  min-width: 0;
  border-radius: 0.9rem;
  padding: 0.7rem 0.8rem;
}

.hero-search .action-btn,
.hero-search .ghost-btn {
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.map-cta {
  margin: 0.7rem auto 0;
  max-width: 860px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.62rem 1rem;
  border-radius: 0.7rem;
  border: 1px solid #6f56a0;
  background: linear-gradient(125deg, #5d3d90 0%, #3d2864 100%);
  color: #fff;
  text-decoration: none;
  font: 700 0.76rem var(--mono);
  letter-spacing: 0.025em;
  box-shadow: 0 6px 18px rgba(72, 45, 110, 0.32);
}

.map-cta:visited,
.map-cta:hover,
.map-cta:active {
  color: #fff;
  text-decoration: none;
}

.map-cta:hover {
  transform: translateY(-1px);
  filter: saturate(1.05) brightness(1.03);
}

.hero-nav {
  margin: 0.75rem auto 0;
  max-width: 1260px;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.nav-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.nav-group-label {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0.1rem;
  padding: 0.45rem 0.8rem;
  font: 700 0.82rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2a1d10;
  background: linear-gradient(135deg, #e8dfd4 0%, #ddd2c4 100%);
  border-radius: 0.5rem;
  border: 1px solid rgba(0,0,0,0.08);
  text-align: center;
  font-size: 0.85rem;
}

.hero-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.45rem 0.68rem;
  border-radius: 0.5rem;
  color: #fff;
  text-decoration: none;
  font: 600 0.72rem var(--mono);
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.hero-nav-btn:visited,
.hero-nav-btn:hover,
.hero-nav-btn:active {
  color: #fff;
  text-decoration: none;
}

.hero-nav-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.06) brightness(1.02);
}

.hero-nav-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 1rem clamp(1rem, 3vw, 2.5rem) 2rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
  padding: 0.9rem;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.mindmap-panel,
.datasets-panel,
.explorer-panel,
.timeline-panel,
.characters-panel,
.detail-panel,
.viewer-panel {
  grid-column: 1 / -1;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 0.72rem;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.ds-card {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.65rem;
  background: linear-gradient(160deg, #fffefb 0%, #fff8ef 100%);
  height: 100%;
}

.ds-card.clickable {
  cursor: pointer;
}

.ds-card.clickable:hover {
  border-color: #cfb5a6;
  box-shadow: 0 8px 22px rgba(56, 34, 24, 0.09);
}

.ds-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.7rem;
}

.ds-title-wrap {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.ds-title-link {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
  color: inherit;
  text-decoration: none;
}

.ds-title-link:visited,
.ds-title-link:hover,
.ds-title-link:active {
  color: inherit;
  text-decoration: none;
}

.ds-title-link:hover .ds-name {
  text-decoration: underline;
}

.ds-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ds-official-name {
  color: var(--muted);
  font: 500 0.7rem var(--mono);
  letter-spacing: 0.015em;
}

.ds-badge {
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font: 600 0.68rem var(--mono);
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: #fff8ef;
  color: #6a4f42;
}

.ds-badge.extracted {
  border-color: #c6d5b9;
  background: #edf7e7;
  color: #2d5b31;
}

.ds-badge.downloading {
  border-color: #d9c8a5;
  background: #fff7e3;
  color: #8b5b10;
}

.ds-badge.combined {
  border-color: #b8c7da;
  background: #ebf2fb;
  color: #274f7f;
}

.ds-row {
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.ds-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  color: #3f342f;
  font-size: 0.88rem;
}

.ds-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.ds-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.ds-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddb3a2;
  border-radius: 999px;
  background: #fff4eb;
  color: #8f2f15;
  text-decoration: none;
  font: 600 0.68rem var(--mono);
  letter-spacing: 0.02em;
  padding: 0.18rem 0.52rem;
}

.ds-link-btn:visited,
.ds-link-btn:hover,
.ds-link-btn:active {
  color: #8f2f15;
  text-decoration: none;
}

.ds-link-btn:hover {
  background: #ffe9db;
}

.ds-open-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 999px;
  border: 1px solid #ddb3a2;
  background: #fff4eb;
  color: #a83214;
  font: 700 0.9rem/1 var(--mono);
  text-decoration: none;
}

.ds-open-icon:visited,
.ds-open-icon:hover,
.ds-open-icon:active {
  color: #a83214;
  text-decoration: none;
}

.ds-open-icon:hover {
  background: #ffe9db;
  transform: translateY(-1px);
}

.dataset-page-nav {
  max-width: 980px;
}

.dataset-page-shell {
  max-width: 980px;
  margin: 0 auto;
}

.dataset-page-card {
  margin-top: 0.5rem;
}

.dataset-site-links {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.dataset-ref-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.58rem;
  border-radius: 999px;
  border: 1px solid #d7c7b8;
  background: #fff9f1;
  color: #5c4c3f;
  text-decoration: none;
  font: 600 0.68rem var(--mono);
  letter-spacing: 0.02em;
}

.dataset-ref-pill:visited,
.dataset-ref-pill:hover,
.dataset-ref-pill:active {
  color: #5c4c3f;
  text-decoration: none;
}

.dataset-ref-pill:hover {
  background: #fff2e5;
  border-color: #d1b6a4;
}

.dataset-empty {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.65rem;
  background: linear-gradient(145deg, #ffffff, #fff8ef);
}

.stat-card .label {
  color: var(--muted);
  font: 600 0.72rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  margin-top: 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.progress-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.progress-rate {
  color: var(--muted);
  font: 500 0.84rem var(--mono);
}

.progress-track {
  margin: 0.65rem 0 0.8rem;
  height: 0.72rem;
  border-radius: 100px;
  background: #e9e2da;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #da5f28 0%, #bf3b18 80%);
}

.kv-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.kv-list > div {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.kv-list dt {
  color: var(--muted);
  font: 600 0.75rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kv-list dd {
  margin: 0;
  word-break: break-word;
}

.table-wrap {
  overflow: auto;
  max-height: 340px;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
}

.mindmap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.mindmap-wrap {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, #fff7f1 0%, rgba(255, 247, 241, 0) 36%),
    radial-gradient(circle at 85% 90%, #f7efe7 0%, rgba(247, 239, 231, 0) 30%),
    linear-gradient(180deg, #fffdf8 0%, #f6f1ea 100%);
  flex: 1 1 auto;
  min-width: 0;
}

/* Side-by-side layout: map + sidebar */
.mindmap-and-sidebar {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
  align-items: stretch;
}

.map-sidebar {
  flex: 0 0 320px;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: linear-gradient(180deg, #faf7f3 0%, #f0ebe4 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-sidebar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  color: #9a8e82;
  font-size: 0.85rem;
  line-height: 1.5;
}

.map-sidebar-header {
  padding: 0.7rem 0.9rem 0.5rem;
  background: linear-gradient(135deg, #3a2a1a, #2a1d10);
  color: #f5e6d0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.map-sidebar-header .sidebar-node-name {
  display: block;
  font-size: 0.95rem;
  color: #e8b93c;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 0.2rem;
}

.map-sidebar-header .sidebar-stats {
  display: block;
  font-size: 0.7rem;
  color: #bba98e;
  margin-top: 0.3rem;
  font-weight: 400;
}

.map-sidebar-section {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.map-sidebar-section h4 {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a7e72;
  margin: 0 0 0.4rem;
}

.map-sidebar-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.map-sidebar-node-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 1rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  background: #e8e0d6;
  color: #4a3f36;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.map-sidebar-node-chip:hover {
  background: #d4c8b8;
  border-color: #c4b8a8;
}

.map-sidebar-items {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.4rem 0;
  max-height: min(50vw, 380px);
}

.map-sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.8rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #4a3f36;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
  line-height: 1.35;
}

.map-sidebar-item:hover {
  background: rgba(0,0,0,0.04);
}

.map-sidebar-item .sidebar-item-label {
  display: block;
  font-weight: 600;
  color: #2a1d10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-sidebar-item .sidebar-item-path {
  display: block;
  color: #8a7e72;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}

.map-sidebar-item .sidebar-item-collection {
  display: inline-block;
  background: #e8e0d6;
  color: #6a5f54;
  padding: 0.1rem 0.4rem;
  border-radius: 0.6rem;
  font-size: 0.6rem;
  margin-top: 0.15rem;
}

@media (max-width: 900px) {
  .mindmap-and-sidebar {
    flex-direction: column;
  }
  .map-sidebar {
    flex: none;
    max-width: 100%;
    max-height: 300px;
  }
}

#mindmapSvg {
  width: 100%;
  height: min(56vw, 500px);
  min-height: 300px;
  display: block;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.timeline-filters {
  min-width: 100%;
  width: 100%;
  grid-template-columns: 1fr;
}

.explorer-panel .filters {
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(120px, 1fr));
  width: 100%;
}

.timeline-list {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #fffcf7;
}

.timeline-item {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  display: grid;
  gap: 0.35rem;
  cursor: pointer;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item:hover {
  background: #fff3e9;
}

.timeline-item:focus-visible {
  outline: 2px solid #a73a1a;
  outline-offset: -2px;
}

.timeline-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.7rem;
}

.timeline-title strong {
  font-size: 0.95rem;
}

.timeline-date {
  font: 600 0.72rem var(--mono);
  color: #8f2f15;
  border: 1px solid #dfb7a8;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  white-space: nowrap;
}

.timeline-summary {
  color: #3f342f;
  font-size: 0.84rem;
}

.timeline-significance {
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.34rem 0.55rem;
  background: #fff;
  color: #3b2f2b;
  font: 600 0.72rem var(--mono);
  cursor: pointer;
}

.mini-btn:hover {
  background: #fff3e9;
}

.map-link {
  stroke: #b8b1a9;
  stroke-width: 1.2;
  stroke-opacity: 0.8;
}

.map-link.active {
  stroke: #bf3b18;
  stroke-width: 2.2;
  stroke-opacity: 1;
}

.map-link.dimmed {
  stroke-opacity: 0.18;
}

.map-node {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.map-node .map-label {
  fill: #2c241f;
  font: 600 12px var(--sans);
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 4px;
}

.map-node.selected circle {
  stroke-width: 3;
  stroke: #1a120f;
}

.map-node.dimmed {
  opacity: 0.22;
}

.ghost-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffaf2;
  padding: 0.4rem 0.72rem;
  cursor: pointer;
  color: #7a3a22;
  font: 600 0.76rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.ghost-btn:hover {
  background: #f7e9dc;
}

.ghost-btn:visited,
.ghost-btn:hover,
.ghost-btn:active {
  color: #7a3a22;
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  top: 0;
  background: #faf4ed;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.explorer-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(130px, 1fr) minmax(110px, 1fr);
  gap: 0.45rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--border);
  background: #fffdfa;
  border-radius: 0.55rem;
  padding: 0.5rem 0.58rem;
}

input:focus-visible,
select:focus-visible,
.artifact-item:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.result-meta {
  margin: 0.6rem 0 0.7rem;
  color: var(--muted);
  font: 500 0.78rem var(--mono);
}

.artifact-list {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fffcf8;
}

.artifact-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  padding: 0.6rem;
  cursor: pointer;
  display: grid;
  gap: 0.28rem;
}

.artifact-item:hover {
  background: #fff2e9;
}

.artifact-item.active {
  background: var(--accent-soft);
}

.artifact-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.artifact-label {
  font-weight: 600;
}

.artifact-chip {
  border: 1px solid #dfb7a8;
  color: #8f2f15;
  border-radius: 100px;
  padding: 0.05rem 0.42rem;
  font: 600 0.7rem var(--mono);
  white-space: nowrap;
}

.artifact-path {
  font: 0.75rem var(--mono);
  color: var(--muted);
  word-break: break-word;
}

.artifact-note {
  color: #5f4e46;
  font-size: 0.8rem;
}

.detail-kv > div {
  grid-template-columns: 6.2rem 1fr;
}

.hint {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.action-btn {
  border: 0;
  border-radius: 0.55rem;
  padding: 0.55rem 0.75rem;
  background: linear-gradient(125deg, #ca4c22 0%, #a12e11 100%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background: linear-gradient(125deg, #786d66 0%, #574e48 100%);
}

.detail-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.viewer-text,
.viewer-markdown {
  margin: 0;
  max-height: 560px;
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fffaf3;
}

.viewer-text {
  color: #231d19;
  font: 0.78rem/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.viewer-markdown {
  font-size: 0.92rem;
  line-height: 1.55;
}

.viewer-markdown h1,
.viewer-markdown h2,
.viewer-markdown h3,
.viewer-markdown h4 {
  margin: 1rem 0 0.5rem;
}

.viewer-markdown p {
  margin: 0.55rem 0;
}

.viewer-markdown blockquote {
  margin: 0.7rem 0;
  border-left: 3px solid var(--accent);
  background: #f7eee4;
  border-radius: 0.45rem;
  padding: 0.45rem 0.7rem;
  color: #4b3e39;
}

.viewer-markdown code {
  font: 0.78rem var(--mono);
  background: #f3ece4;
  border-radius: 0.4rem;
  padding: 0.08rem 0.28rem;
}

.viewer-markdown pre {
  margin: 0.7rem 0;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.65rem;
  background: #f7efe6;
  overflow: auto;
  font: 0.76rem/1.45 var(--mono);
}

.viewer-markdown ul,
.viewer-markdown ol {
  margin: 0.5rem 0 0.6rem 1.3rem;
}

.viewer-image {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 720px;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
}

.viewer-frame {
  width: 100%;
  min-height: 700px;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
}

.notes-list {
  margin: 0;
  padding-left: 1.2rem;
}

.notes-list li + li {
  margin-top: 0.4rem;
}

@media (max-width: 1200px) {
  .datasets-panel,
  .timeline-panel,
  .characters-panel,
  .explorer-panel,
  .viewer-panel,
  .detail-panel {
    grid-column: span 12;
  }

  .stat-cards.compact-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dataset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ds-actions {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .explorer-panel .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .explorer-panel .filters input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .hero-tagline {
    margin-top: 0.45rem;
    font-size: clamp(0.98rem, 5vw, 1.22rem);
  }

  .intro-pdf {
    margin-top: 0.6rem;
    border-radius: 0.65rem;
  }

  .intro-pdf-toolbar {
    grid-template-columns: auto auto auto minmax(0, 1fr);
    gap: 0.34rem;
    padding: 0.38rem 0.46rem;
  }

  .intro-pdf-pages {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: 0.08rem;
    font-size: 0.62rem;
  }

  .intro-pdf-page {
    padding: 0.84rem 0.74rem 0.92rem;
    background-size: 100% 27px, 100% 100%;
  }

  .intro-pdf-page::before {
    left: 0.72rem;
  }

  .intro-pdf-page p {
    padding-left: 0.42rem;
    font-size: 0.93rem;
    line-height: 1.62;
  }

  .intro-pdf-stamp {
    top: 0.58rem;
    right: 0.56rem;
    min-height: 1.28rem;
    font-size: 0.56rem;
    border-width: 1px;
  }

  .hero-summary {
    padding: 0.38rem;
  }

  .stat-cards.compact-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.28rem;
  }

  .hero-summary .stat-card {
    padding: 0.3rem 0.36rem;
    min-height: 1.9rem;
  }

  .hero-summary .stat-card .label {
    font-size: 0.52rem;
  }

  .hero-summary .stat-card .value {
    font-size: 0.8rem;
  }

  .hero-search {
    grid-template-columns: 1fr;
  }

  .hero-search .action-btn,
  .hero-search .ghost-btn {
    min-height: 2.4rem;
  }

  .map-cta {
    width: 100%;
    max-width: none;
  }

  .hero-nav {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .hero-nav-btn {
    width: 100%;
    max-width: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .panel {
    grid-column: span 1 !important;
  }

  .filters {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .kv-list > div,
  .detail-kv > div {
    grid-template-columns: 1fr;
  }

  .dataset-grid {
    grid-template-columns: 1fr;
  }

  .ds-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .ds-actions {
    width: 100%;
    justify-content: space-between;
  }

  .explorer-panel .filters {
    grid-template-columns: 1fr;
  }

  .explorer-panel .filters input {
    grid-column: span 1;
  }

  .nav-group {
    grid-template-columns: 1fr;
  }

  .mindmap-and-sidebar {
    flex-direction: column;
  }

  .map-sidebar {
    flex: none;
    max-width: 100%;
    max-height: 300px;
  }

  .table-wrap {
    max-width: 100%;
  }

  .viewer-frame {
    min-height: 400px;
  }

  #mindmapSvg {
    min-height: 220px;
    height: 60vw;
  }

  .hero {
    padding: 1rem 0.75rem;
  }

  .explorer-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Site Footer ── */
.site-footer {
  position: relative;
  z-index: 1;
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer p {
  margin: 0.25rem 0;
}

/* ── Collaboration banner ────────────────────────── */
.collab-banner {
  margin: 1.5rem auto;
  max-width: 720px;
  background: linear-gradient(135deg, #1a2a1a 0%, #0f1a0f 100%);
  border: 2px solid #2e7d32;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.collab-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(46,125,50,0.15), transparent 70%);
  pointer-events: none;
}
.collab-banner-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}
.collab-banner h3 {
  color: #66bb6a;
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  letter-spacing: 0.03em;
}
.collab-banner p {
  color: #c8e6c9;
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0.4rem 0;
}
.collab-banner .collab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}
.collab-banner .collab-btn {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.collab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.collab-btn-primary {
  background: #2e7d32;
  color: #fff;
}
.collab-btn-secondary {
  background: #1b5e20;
  color: #c8e6c9;
}
.collab-btn-outline {
  background: transparent;
  color: #66bb6a;
  border: 1px solid #2e7d32;
}
