@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;1,400&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

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

:root {
    --bg: #f5f5f0;
    --bg-card: #fafaf7;
    --bg-sidebar: #f0f0eb;
    --bg-input: #fff;
    --text: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #999;
    --border: #d5d5d0;
    --border-light: #e8e8e3;
    --accent: #333;
    --accent-hover: #111;
    --accent-light: rgba(0,0,0,0.05);
    --error-bg: #f5eded;
    --error-text: #6b2020;
    --error-border: #d4b0b0;
    --success-bg: #edf5ed;
    --success-text: #1a4a1a;
    --success-border: #b0c8b0;
    --warning-bg: #f5f0e0;
    --warning-text: #5a4a10;
    --warning-border: #d4c880;
    --info-bg: #edf2f5;
    --info-text: #1a3a4a;
    --info-border: #a0c0d0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.03);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 3px;
    --radius-lg: 6px;
    --font-body: 'Libre Baskerville', 'Georgia', 'Times New Roman', serif;
    --font-heading: 'Playfair Display', 'Georgia', serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --max-width: 1100px;
    --header-height: 56px;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --bg-card: #222;
    --bg-sidebar: #1e1e1e;
    --bg-input: #2a2a2a;
    --text: #d4d4d4;
    --text-secondary: #999;
    --text-muted: #666;
    --border: #3a3a3a;
    --border-light: #2e2e2e;
    --accent: #bbb;
    --accent-hover: #ddd;
    --accent-light: rgba(255,255,255,0.06);
    --error-bg: #2e1a1a;
    --error-text: #d48888;
    --error-border: #4a2a2a;
    --success-bg: #1a2e1a;
    --success-text: #88c888;
    --success-border: #2a4a2a;
    --warning-bg: #2e2a1a;
    --warning-text: #c8b868;
    --warning-border: #4a4020;
    --info-bg: #1a2030;
    --info-text: #88b0d0;
    --info-border: #2a3a50;
    --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.3);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 0.75rem;
}
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; margin-top: 2rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 600; }

p { margin-bottom: 1rem; }
em { font-style: italic; }
img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* Header */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.5px;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
}
.logo:hover { color: var(--accent-hover); text-decoration: none; }
.logo-icon { font-size: 20px; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}
.main-nav a {
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.main-nav a:hover {
    color: var(--text);
    background: var(--accent-light);
    text-decoration: none;
}

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span {
    display: block; width: 20px; height: 2px; background: var(--text);
    margin: 4px 0; transition: 0.2s;
}

.nav-dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }
.caret { font-size: 0.65em; opacity: 0.5; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1001;
    padding: 4px 0;
}
.dropdown-menu a {
    display: block;
    padding: 6px 14px;
    font-size: 13px;
}
.nav-dropdown:hover .dropdown-menu { display: block; }

/* Main */
.site-main {
    min-height: calc(100vh - var(--header-height) - 200px);
    padding: 32px 0;
}

/* Page header */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 6px; }
.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 12px;
    transition: all 0.2s;
}
.card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}
.card h3 { margin-bottom: 4px; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card h4 { margin-bottom: 4px; }
.card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Species grid */
.species-grid,
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.species-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
}
.species-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}
.species-card-img {
    height: 140px;
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-light);
}
.species-card-img .placeholder {
    font-size: 3.5rem;
    opacity: 0.15;
}
.species-card-body { padding: 16px; }
.species-card-body h3 {
    font-size: 14px;
    margin-bottom: 2px;
}
.species-card-body h3 a { color: var(--text); text-decoration: none; }
.species-card-body h3 a:hover { text-decoration: underline; }
.species-card-body .common-name {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}
.species-card-body .date-range {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-weight: 500;
}
.species-card-body .stats {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

/* Callout boxes */
.callout {
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0;
    font-size: 14px;
}
.callout-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}
.callout-content p { margin-bottom: 0.5rem; font-size: 13px; }
.callout-content p:last-child { margin-bottom: 0; }
.callout-debated {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-left: 3px solid var(--warning-border);
}
.callout-debated .callout-title { color: var(--warning-text); }
.callout-hypothesis {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-left: 3px solid var(--info-border);
}
.callout-hypothesis .callout-title { color: var(--info-text); }
.callout-unknown {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
}
.callout-unknown .callout-title { color: var(--text-muted); }
.callout-info {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-left: 3px solid var(--info-border);
}
.callout-info .callout-title { color: var(--info-text); }

/* Detail sections */
.detail-section { margin-bottom: 32px; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-sidebar);
}
.data-table tr:hover td { background: var(--accent-light); }
.data-table a { text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* Brain region chart */
.brain-chart { margin: 16px 0; }
.brain-bar {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 10px;
}
.brain-bar-label {
    width: 110px;
    font-size: 12px;
    text-align: right;
    color: var(--text-secondary);
    font-weight: 500;
}
.brain-bar-track {
    flex: 1;
    height: 18px;
    background: var(--bg-sidebar);
    border-radius: 2px;
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.brain-bar-fill {
    height: 100%;
    border-radius: 1px;
    background: var(--accent);
    transition: width 0.5s ease;
}
.brain-bar-value {
    width: 50px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* References list */
.ref-list { list-style: decimal; padding-left: 2rem; }
.ref-list li {
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.ref-title { font-weight: 700; color: var(--text); }
.ref-authors { color: var(--text-muted); }

/* Timeline / chart containers */
.timeline-container {
    width: 100%;
    overflow: visible;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 12px 0;
}
.timeline-container svg text { fill: var(--text-muted); }
.timeline-container svg line.grid { stroke: var(--border-light); }

/* Map container */
.map-container {
    width: 100%;
    height: 550px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    margin: 12px 0;
    box-shadow: var(--shadow);
}
.map-container .leaflet-tile-pane {
    filter: sepia(0.15) saturate(0.85);
}

/* Map layer controls */
.map-layer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
    padding: 10px 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 0.88rem;
    font-family: 'Libre Baskerville', serif;
}
.map-layer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 3px 0;
    color: var(--text-secondary);
    transition: color 0.15s;
}
.map-layer-toggle:hover { color: var(--text); }
.map-layer-toggle input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}
.map-toggle-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Map data sources bar */
.map-sources-bar {
    margin-top: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--bg-card);
}
.map-sources-bar a { color: var(--text-secondary); }

/* Curated site markers */
.map-curated-marker {
    background: none !important;
    border: none !important;
}
.map-curated-pin {
    width: 16px;
    height: 16px;
    background: #8b6914;
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Map cluster styling */
.map-cluster {
    background: none !important;
}
.map-cluster div {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.map-cluster span { line-height: 1; }
.map-cluster-small div { width: 30px; height: 30px; font-size: 11px; background: rgba(139,105,20,0.8); }
.map-cluster-medium div { width: 38px; height: 38px; font-size: 12px; background: rgba(139,105,20,0.85); }
.map-cluster-large div { width: 46px; height: 46px; font-size: 13px; background: rgba(100,70,10,0.9); }
.map-cluster-pbdb.map-cluster-small div { background: rgba(100,80,200,0.75); }
.map-cluster-pbdb.map-cluster-medium div { background: rgba(100,80,200,0.82); }
.map-cluster-pbdb.map-cluster-large div { background: rgba(80,60,180,0.88); }
.map-cluster-oc div { width: 30px; height: 30px; font-size: 11px; background: rgba(200,80,60,0.78); }

/* On-map legend */
.map-onmap-legend {
    background: rgba(250,250,247,0.92);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 0.78rem;
    font-family: 'Libre Baskerville', serif;
    color: var(--text-secondary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    line-height: 1.6;
    max-width: 140px;
}
.map-legend-title {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 5px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
}
.map-legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.map-legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.6);
}

/* Map popup styling */
.map-styled-popup .leaflet-popup-content-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 3px 14px rgba(0,0,0,0.12);
    padding: 0;
}
.map-styled-popup .leaflet-popup-content {
    margin: 12px 14px;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.map-styled-popup .leaflet-popup-tip {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-top: none;
    border-left: none;
}
.map-popup-site {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 4px;
}
.map-popup-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-family: -apple-system, sans-serif;
    color: #fff;
    padding: 1px 7px;
    border-radius: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-right: 5px;
    vertical-align: middle;
}
.map-popup-age {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}
.map-popup-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.map-popup-desc {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}
.map-popup-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.map-popup-link:hover { text-decoration: underline; }
.map-popup-source {
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.stat-item { text-align: center; }
.stat-value {
    font-size: 28px;
    font-family: var(--font-heading);
    font-weight: 800;
    color: var(--text);
    display: block;
    line-height: 1.2;
}
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Hero section */
.hero {
    text-align: center;
    padding: 48px 0 32px;
    margin-bottom: 24px;
}
.hero h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text);
    font-style: italic;
}
.hero p {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto 20px;
    line-height: 1.7;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    background: var(--bg-card);
    color: var(--text);
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
    border-color: var(--accent-hover);
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}
.btn-danger {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}
.btn-danger:hover { background: var(--error-text); color: #fff; border-color: var(--error-text); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 14px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-error { background: var(--error-bg); color: var(--error-text); border: 1px solid var(--error-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.alert-info { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }

/* Filter bar */
.filter-bar {
    margin-bottom: 20px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.filter-bar .form-control { width: auto; flex: 1; min-width: 140px; }

/* Grid layouts */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Sidebar layout */
.sidebar-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    align-self: start;
}
.sidebar .card { margin-bottom: 12px; }

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 32px 0 20px;
    margin-top: 48px;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.footer-col h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 4px; }
.footer-col a { color: var(--text-secondary); font-size: 13px; text-decoration: none; }
.footer-col a:hover { color: var(--text); text-decoration: underline; }
.footer-col p { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}
.footer-bottom p { margin-bottom: 2px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 4px; margin: 24px 0; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
}
.pagination a {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; font-weight: 700; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    padding: 8px 16px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 3D model embed */
.model-3d-container {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    margin: 12px 0;
}
.model-3d-container iframe { width: 100%; height: 100%; border: none; }

/* D3 tooltip */
.d3-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    max-width: 300px;
    font-family: var(--font-body);
    line-height: 1.5;
}

/* Details/summary for admin forms */
details { margin-bottom: 16px; }
details summary { cursor: pointer; display: inline-block; }
details summary::-webkit-details-marker { display: none; }

/* Responsive */
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .main-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        padding: 12px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .main-nav.open { display: flex; }
    .nav-dropdown:hover .dropdown-menu { display: none; }
    .nav-dropdown.open .dropdown-menu { display: block; position: static; box-shadow: none; }

    .hero h1 { font-size: 24px; }
    .species-grid,
    .card-grid { grid-template-columns: 1fr; }
    .two-col, .three-col { grid-template-columns: 1fr; }
    .sidebar-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .stats-bar { justify-content: center; }
    .filter-bar { flex-direction: column; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 6px 8px; }
    .map-container { height: 350px; }
    .map-layer-controls { gap: 4px 10px; font-size: 0.82rem; padding: 8px 12px; }
    .map-onmap-legend { max-width: 120px; font-size: 0.72rem; padding: 8px 10px; }
}

/* Tour of Humanity */
.tour-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent);
    z-index: 1100;
    transition: width 0.15s;
}
.tour-hero {
    text-align: center;
    padding: 48px 0 36px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 32px;
}
.tour-hero h1 { font-size: 2.4rem; margin-bottom: 12px; }
.tour-hero .subtitle { max-width: 680px; margin: 0 auto; font-size: 1.05rem; line-height: 1.7; }
.tour-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 40px;
    align-items: start;
}
.tour-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 16px);
    font-size: 0.82rem;
    border-right: 1px solid var(--border-light);
    padding-right: 16px;
}
.tour-sidebar-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.tour-nav-link {
    display: block;
    padding: 5px 0;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: 10px;
    margin-left: -1px;
    transition: color 0.15s, border-color 0.15s;
    line-height: 1.35;
}
.tour-nav-link:hover { color: var(--text); }
.tour-nav-link.active {
    color: var(--text);
    border-left-color: var(--accent);
    font-weight: 600;
}
.tour-chapter {
    padding: 36px 0;
    border-bottom: 1px solid var(--border-light);
}
.tour-chapter:last-child { border-bottom: none; }
.tour-chapter-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}
.tour-chapter-num {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.tour-chapter h2 {
    font-size: 1.55rem;
    margin-bottom: 0;
}
.tour-date-range {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 16px;
}
.tour-prose {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.tour-species-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin: 16px 0;
}
.tour-species-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px 14px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}
.tour-species-card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
}
.tour-species-card .species-name {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.tour-species-card .species-common {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.tour-species-card .species-range {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.tour-milestone {
    background: var(--info-bg);
    border: 1px solid var(--info-border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.88rem;
    line-height: 1.55;
}
.tour-milestone-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--info-text);
    margin-bottom: 4px;
}
.tour-discovery {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.88rem;
    line-height: 1.55;
}
.tour-discovery-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--warning-text);
    margin-bottom: 4px;
}
.tour-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.tour-links a {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: background 0.15s;
}
.tour-links a:hover { background: var(--accent-light); }

/* Dating Methods page */
.dating-method-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.dating-method-card h3 { margin-bottom: 4px; font-size: 1.15rem; }
.dating-method-principle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 10px;
}
.dating-method-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    font-size: 0.88rem;
    margin-bottom: 10px;
}
.dating-method-grid dt {
    font-weight: 600;
    color: var(--text-secondary);
}
.dating-method-grid dd {
    color: var(--text-secondary);
    margin: 0;
}
.dating-method-db {
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
    margin-top: 8px;
}
.dating-category-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin: 32px 0 16px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

@media (max-width: 768px) {
    .tour-layout { grid-template-columns: 1fr; gap: 0; }
    .tour-sidebar {
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 0 0 12px 0;
        margin-bottom: 20px;
        display: flex;
        flex-wrap: wrap;
        gap: 4px 12px;
    }
    .tour-sidebar-title { width: 100%; }
    .tour-nav-link { border-left: none; padding-left: 0; font-size: 0.78rem; }
    .tour-hero h1 { font-size: 1.8rem; }
    .tour-species-row { grid-template-columns: 1fr; }
    .dating-method-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    .container { padding: 0 16px; }
}
