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

        body {
            font-family: 'EB Garamond', Georgia, serif;
            background: #1a1a2e;
            color: #e0e0e0;
            height: 100vh;
            width: 100vw;
            position: relative;
            overflow: hidden;
        }

        /* ── Full-viewport Map ────────────────────────────────── */

        #explore-map {
            position: absolute;
            inset: 0;
            z-index: 0;
            background: #1a3a5c;
        }

        .leaflet-tile-pane { /* filter managed per-layer by switchEraTiles() */ }
        .leaflet-control-zoom a {
            background: rgba(22,33,62,0.92) !important;
            color: #e0c97f !important;
            border-color: rgba(224,201,127,0.3) !important;
        }
        .leaflet-control-zoom a:hover { background: rgba(22,33,62,1) !important; }
        .leaflet-control-attribution { display: none; }

        .map-marker-tooltip {
            background: rgba(22,33,62,0.95) !important;
            color: #e0e0e0 !important;
            border: 1px solid rgba(224,201,127,0.3) !important;
            border-radius: 6px !important;
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            padding: 4px 10px !important;
            box-shadow: 0 2px 8px rgba(0,0,0,0.4);
        }
        .map-marker-tooltip::before { border-top-color: rgba(22,33,62,0.95) !important; }

        .journey-arrow { background: none !important; border: none !important; font-size: 10px; cursor: pointer; }
        .journey-boat { background: none !important; border: none !important; cursor: pointer; }
        .journey-estimated { background: none !important; border: none !important; cursor: pointer; }
        .journey-life-icon { background: none !important; border: none !important; }
        .life-icon { font-size: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }

        /* ── Era Place Labels (custom city names on map) ──── */
        .era-place-label {
            background: none !important;
            border: none !important;
            white-space: nowrap;
            pointer-events: none;
            font-family: 'EB Garamond', serif;
            color: #2a1a0a;
            text-shadow:
                -1px -1px 0 rgba(255,248,230,0.95),
                 1px -1px 0 rgba(255,248,230,0.95),
                -1px  1px 0 rgba(255,248,230,0.95),
                 1px  1px 0 rgba(255,248,230,0.95),
                 0    0  4px rgba(255,248,230,0.8),
                 0    0  8px rgba(255,248,230,0.5);
            transition: opacity 0.6s ease;
        }
        .era-place-major {
            font-size: 14px;
            font-weight: 700;
            letter-spacing: 0.5px;
        }
        .era-place-mid {
            font-size: 12px;
            font-weight: 600;
        }
        .era-place-minor {
            font-size: 10px;
            font-weight: 500;
            opacity: 0.85;
        }

        /* ── Floating Panel Base ──────────────────────────────── */

        .floating-panel {
            position: absolute;
            background: rgba(22, 33, 62, 0.92);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(224, 201, 127, 0.25);
            border-radius: 12px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.5);
            z-index: 1000;
            transition: opacity 0.3s, transform 0.3s;
        }

        /* ── Title Bar (top-center) ──────────────────────────── */

        #title-bar {
            top: 12px;
            left: 50%;
            transform: translateX(-50%);
            padding: 10px 24px 8px;
            text-align: center;
            z-index: 1000;
        }
        #title-bar h1 {
            font-family: 'Cinzel', serif;
            font-size: 18px;
            font-weight: 700;
            color: #e0c97f;
            letter-spacing: 2px;
            text-transform: uppercase;
            margin: 0;
        }
        #title-bar .subtitle {
            font-family: 'Cinzel', serif;
            font-size: 11px;
            color: #8899aa;
            letter-spacing: 1.5px;
            margin-top: 2px;
        }
        #title-bar a {
            display: inline-block;
            margin-top: 4px;
            font-family: 'Cinzel', serif;
            font-size: 11px;
            color: #8899aa;
            text-decoration: none;
            border: 1px solid rgba(224,201,127,0.2);
            border-radius: 6px;
            padding: 3px 14px;
            transition: all 0.2s;
            letter-spacing: 0.5px;
        }
        #title-bar a:hover {
            color: #e0c97f;
            border-color: #e0c97f;
        }

        /* ── Figures Panel (top-left) ────────────────────────── */

        #figures-panel {
            top: 12px;
            left: 12px;
            width: 230px;
            max-height: calc(100vh - 180px);
            display: flex;
            flex-direction: column;
            padding: 12px;
            overflow: hidden;
        }
        .figures-header {
            font-family: 'Cinzel', serif;
            font-size: 13px;
            font-weight: 600;
            color: #e0c97f;
            letter-spacing: 1px;
            text-transform: uppercase;
            text-align: center;
            margin-bottom: 8px;
            cursor: pointer;
            user-select: none;
        }
        .figures-header .collapse-arrow {
            font-size: 9px;
            margin-left: 6px;
            display: inline-block;
            transition: transform 0.2s;
        }
        #figures-panel.collapsed .figures-body,
        #figures-panel.collapsed .events-body,
        #figures-panel.collapsed .panel-mode-tabs { display: none; }
        #figures-panel.collapsed .collapse-arrow { transform: rotate(180deg); }
        #figures-panel.collapsed { width: auto; }

        .panel-mode-tabs {
            display: flex;
            gap: 0;
            margin-bottom: 8px;
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid rgba(224,201,127,0.2);
        }
        .mode-tab {
            flex: 1;
            font-family: 'Cinzel', serif;
            font-size: 10px;
            letter-spacing: 0.5px;
            padding: 5px 0;
            border: none;
            background: transparent;
            color: #667788;
            cursor: pointer;
            transition: all 0.2s;
        }
        .mode-tab:hover { color: #aabbcc; }
        .mode-tab.active {
            background: rgba(224,201,127,0.15);
            color: #e0c97f;
        }

        .events-list {
            display: flex;
            flex-direction: column;
            gap: 3px;
            overflow-y: auto;
            max-height: 380px;
            padding: 2px 0;
            scrollbar-width: thin;
            scrollbar-color: #333366 transparent;
        }
        .events-list::-webkit-scrollbar { width: 4px; }
        .events-list::-webkit-scrollbar-thumb { background: #333366; border-radius: 2px; }

        .events-figure-filter-header {
            font-family: 'Cinzel', serif;
            font-size: 11px;
            color: #c9a84c;
            padding: 6px 8px;
            margin-bottom: 4px;
            border-bottom: 1px solid rgba(201,168,76,0.2);
            letter-spacing: 0.5px;
        }
        .event-list-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 5px 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.15s;
            border: 1px solid transparent;
        }
        .event-list-item:hover { background: rgba(224,201,127,0.06); }
        .event-list-item.selected {
            background: rgba(224,201,127,0.1);
            border-color: rgba(224,201,127,0.25);
        }
        .event-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex-shrink: 0;
            align-self: flex-start;
            margin-top: 4px;
            border: 1.5px solid rgba(22,33,62,0.8);
        }
        .event-list-text {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 1px;
        }
        .event-list-label {
            font-family: 'EB Garamond', serif;
            font-size: 12px;
            color: #ccd0d8;
            line-height: 1.3;
        }
        .event-list-location {
            font-family: 'EB Garamond', serif;
            font-size: 10px;
            color: #7a8a9a;
            line-height: 1.2;
        }
        .event-list-item.selected .event-list-label { color: #e0c97f; }
        .event-list-item.selected .event-list-location { color: #b0a070; }
        .event-list-year {
            font-family: 'EB Garamond', serif;
            font-size: 10px;
            color: #667788;
            flex-shrink: 0;
            white-space: nowrap;
            align-self: flex-start;
            margin-top: 2px;
        }

        .category-tabs {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin-bottom: 10px;
            justify-content: center;
        }
        .cat-tab {
            font-family: 'Cinzel', serif;
            font-size: 9px;
            padding: 2px 8px;
            border-radius: 10px;
            border: 1px solid rgba(224,201,127,0.2);
            background: transparent;
            color: #8899aa;
            cursor: pointer;
            transition: all 0.2s;
            letter-spacing: 0.5px;
        }
        .cat-tab:hover { border-color: #e0c97f; color: #e0c97f; }
        .cat-tab.active { background: rgba(224,201,127,0.15); border-color: #e0c97f; color: #e0c97f; }

        .figures-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            overflow-y: auto;
            max-height: 380px;
            padding: 4px 2px;
            scrollbar-width: thin;
            scrollbar-color: #333366 transparent;
        }
        .figures-grid::-webkit-scrollbar { width: 4px; }
        .figures-grid::-webkit-scrollbar-thumb { background: #333366; border-radius: 2px; }

        .figure-search-wrap {
            display: flex;
            gap: 4px;
            margin-bottom: 8px;
        }
        .figure-search-wrap input {
            flex: 1;
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 8px;
            padding: 6px 10px;
            color: #e0e0e0;
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            outline: none;
        }
        .figure-search-wrap input:focus { border-color: #e0c97f; }
        .figure-search-wrap input::placeholder { color: #556; }
        .figure-search-wrap button {
            background: rgba(224,201,127,0.12);
            border: 1px solid rgba(224,201,127,0.3);
            border-radius: 8px;
            padding: 4px 12px;
            color: #e0c97f;
            font-family: 'Cinzel', serif;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }
        .figure-search-wrap button:hover {
            background: rgba(224,201,127,0.22);
            border-color: #e0c97f;
        }
        .figure-search-loading {
            text-align: center;
            padding: 8px;
            color: #8899aa;
            font-size: 12px;
            font-family: 'Cinzel', serif;
        }
        .ai-research-progress {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            padding: 12px;
        }
        .ai-research-progress span {
            font-family: 'Cinzel', serif;
            font-size: 12px;
            color: #e0c97f;
        }
        .ai-research-spinner {
            width: 20px; height: 20px;
            border: 2px solid rgba(224,201,127,0.3);
            border-top-color: #e0c97f;
            border-radius: 50%;
            animation: ai-spin 1s linear infinite;
        }
        @keyframes ai-spin { to { transform: rotate(360deg); } }
        .ai-progress-bar {
            width: 100%;
            height: 3px;
            background: rgba(224,201,127,0.15);
            border-radius: 2px;
            overflow: hidden;
        }
        .ai-progress-fill {
            height: 100%;
            background: #e0c97f;
            border-radius: 2px;
            animation: ai-progress-sweep 12s ease-out forwards;
        }
        @keyframes ai-progress-sweep {
            0% { width: 0%; }
            30% { width: 40%; }
            60% { width: 65%; }
            80% { width: 80%; }
            100% { width: 92%; }
        }
        .figure-avatar.ai-generated .avatar-circle {
            border: 2px dashed rgba(224,201,127,0.5) !important;
        }
        .figure-avatar.era-dimmed {
            opacity: 0.3;
        }
        .figure-avatar.era-dimmed .avatar-circle {
            filter: grayscale(90%) brightness(0.4);
        }
        .figure-avatar.loading .avatar-circle {
            animation: avatar-pulse 1.2s ease-in-out infinite;
        }
        @keyframes avatar-pulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(224,201,127,0.6); }
            50% { box-shadow: 0 0 12px 4px rgba(224,201,127,0.3); }
        }

        .figure-avatar {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            cursor: pointer;
            transition: transform 0.15s;
        }
        .figure-avatar:hover { transform: scale(1.08); }

        .avatar-circle {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Cinzel', serif;
            font-weight: 700;
            font-size: 16px;
            color: #fff;
            text-shadow: 0 1px 3px rgba(0,0,0,0.5);
            position: relative;
            border: 3px solid transparent;
            transition: all 0.2s;
            filter: grayscale(70%) brightness(0.6);
        }
        .figure-avatar.selected .avatar-circle {
            border-color: #e0c97f;
            filter: none;
            box-shadow: 0 0 10px rgba(224,201,127,0.4);
        }
        .figure-avatar:hover .avatar-circle {
            filter: grayscale(30%) brightness(0.8);
        }
        .figure-avatar.selected:hover .avatar-circle {
            filter: none;
            box-shadow: 0 0 14px rgba(224,201,127,0.5);
        }

        .figure-avatar.tracked .avatar-circle {
            border-color: #e0c97f;
            filter: none;
            box-shadow: 0 0 12px rgba(224,201,127,0.6);
            animation: tracked-pulse 2s ease-in-out infinite;
        }
        @keyframes tracked-pulse {
            0%, 100% { box-shadow: 0 0 10px rgba(224,201,127,0.4); }
            50% { box-shadow: 0 0 18px rgba(224,201,127,0.7); }
        }

        .avatar-badge {
            position: absolute;
            bottom: -2px;
            right: -2px;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background: rgba(22,33,62,0.95);
            border: 1px solid rgba(224,201,127,0.3);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 9px;
        }

        .avatar-name {
            font-family: 'Cinzel', serif;
            font-size: 9px;
            color: #8899aa;
            text-align: center;
            line-height: 1.1;
            max-width: 64px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .figure-avatar.selected .avatar-name { color: #e0c97f; }

        .figures-actions {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px solid rgba(224,201,127,0.15);
        }
        .figures-actions button {
            font-family: 'Cinzel', serif;
            font-size: 10px;
            padding: 4px 12px;
            border-radius: 6px;
            border: 1px solid rgba(224,201,127,0.3);
            background: transparent;
            color: #8899aa;
            cursor: pointer;
            transition: all 0.2s;
            letter-spacing: 0.5px;
        }
        .figures-actions button:hover {
            color: #e0c97f;
            border-color: #e0c97f;
        }

        /* ── Event Card (top-right) ──────────────────────────── */

        #event-card {
            top: 12px;
            right: 12px;
            width: 340px;
            max-height: 70vh;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: #333366 transparent;
            transform: translateX(120%);
            opacity: 0;
            pointer-events: none;
            z-index: 1200;
        }
        #event-card::-webkit-scrollbar { width: 4px; }
        #event-card::-webkit-scrollbar-thumb { background: #333366; border-radius: 2px; }
        #event-card.open {
            transform: translateX(0);
            opacity: 1;
            pointer-events: auto;
        }

        .card-close {
            position: absolute;
            top: 8px;
            right: 12px;
            background: none;
            border: none;
            color: #8899aa;
            font-size: 20px;
            cursor: pointer;
            z-index: 2;
            transition: color 0.2s;
        }
        .card-close:hover { color: #e0c97f; }

        .card-inner {
            padding: 16px 20px;
        }
        .card-location {
            font-family: 'Cinzel', serif;
            font-size: 18px;
            font-weight: 600;
            color: #e0c97f;
            letter-spacing: 1px;
            margin-bottom: 4px;
            padding-right: 24px;
        }
        .card-divider {
            border: none;
            border-top: 1px solid rgba(224,201,127,0.25);
            margin: 8px 0;
        }
        .card-title {
            font-family: 'Cinzel', serif;
            font-size: 15px;
            font-weight: 600;
            color: #e0e0e0;
            margin-bottom: 4px;
        }
        .card-date {
            font-size: 13px;
            color: #e0c97f;
            opacity: 0.7;
            margin-bottom: 8px;
        }
        .card-description {
            font-size: 14px;
            line-height: 1.6;
            color: #c0c0c0;
            margin-bottom: 10px;
        }
        .card-evidence {
            margin-bottom: 10px;
            padding: 8px 10px;
            background: rgba(224,201,127,0.07);
            border-left: 3px solid #e0c97f;
            border-radius: 0 6px 6px 0;
        }
        .card-evidence:empty { display: none; }
        .card-evidence-ref {
            font-family: 'Cinzel', serif;
            font-size: 12px;
            color: #e0c97f;
            margin-bottom: 4px;
            letter-spacing: 0.3px;
        }
        .card-evidence-ref .ref-icon { margin-right: 4px; }
        .card-evidence-quote {
            font-family: 'EB Garamond', serif;
            font-size: 14px;
            font-style: italic;
            color: #d0d0d0;
            line-height: 1.5;
        }
        .card-evidence-quote .quote-speaker {
            font-style: normal;
            font-size: 11px;
            color: #8899aa;
            display: block;
            margin-top: 2px;
        }
        .card-evidence-sources {
            font-family: 'EB Garamond', serif;
            font-size: 11px;
            color: #8899aa;
            margin-top: 6px;
            padding-top: 5px;
            border-top: 1px solid rgba(224,201,127,0.1);
        }
        .card-evidence-sources .source-tag {
            display: inline-block;
            background: rgba(224,201,127,0.08);
            border: 1px solid rgba(224,201,127,0.15);
            border-radius: 4px;
            padding: 1px 6px;
            margin: 2px 2px 0 0;
            font-size: 10px;
            color: #b0a878;
            cursor: pointer;
            transition: background 0.15s, border-color 0.15s, color 0.15s;
        }
        .card-evidence-sources .source-tag:hover {
            background: rgba(224,201,127,0.18);
            border-color: rgba(224,201,127,0.35);
            color: #e0c97f;
        }

        /* ── Source popover ── */
        .source-popover {
            position: absolute;
            z-index: 9999;
            width: 280px;
            background: rgba(28,32,42,0.97);
            border: 1px solid rgba(224,201,127,0.25);
            border-radius: 8px;
            padding: 14px 16px;
            box-shadow: 0 8px 32px rgba(0,0,0,0.5);
            font-family: 'EB Garamond', serif;
            color: #d0c8a8;
            backdrop-filter: blur(12px);
        }
        .source-popover-close {
            position: absolute;
            top: 6px; right: 10px;
            background: none; border: none;
            color: #8899aa; font-size: 16px;
            cursor: pointer; line-height: 1;
        }
        .source-popover-close:hover { color: #e0c97f; }
        .source-popover-title {
            font-family: 'Cinzel', serif;
            font-size: 13px;
            color: #e0c97f;
            margin-bottom: 4px;
            padding-right: 18px;
            line-height: 1.3;
        }
        .source-popover-meta {
            font-size: 11px;
            color: #8899aa;
            margin-bottom: 8px;
            line-height: 1.3;
        }
        .source-popover-desc {
            font-size: 12px;
            color: #b0a898;
            line-height: 1.4;
            margin-bottom: 12px;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .source-popover-actions {
            display: flex;
            gap: 8px;
        }
        .source-popover-actions button,
        .source-popover-actions a {
            flex: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            padding: 6px 10px;
            border-radius: 5px;
            font-family: 'Cinzel', serif;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            cursor: pointer;
            text-decoration: none;
            transition: background 0.15s, border-color 0.15s;
        }
        .source-popover-ask {
            background: rgba(224,201,127,0.1);
            border: 1px solid rgba(224,201,127,0.25);
            color: #e0c97f;
        }
        .source-popover-ask:hover {
            background: rgba(224,201,127,0.2);
            border-color: rgba(224,201,127,0.4);
        }
        .source-popover-pdf {
            background: rgba(136,153,170,0.1);
            border: 1px solid rgba(136,153,170,0.25);
            color: #8899aa;
        }
        .source-popover-pdf:hover {
            background: rgba(136,153,170,0.2);
            border-color: rgba(136,153,170,0.4);
            color: #b0bec5;
        }
        .card-source-link {
            font-family: 'EB Garamond', serif;
            font-size: 12px;
            color: #e0c97f;
            cursor: pointer;
            padding: 3px 8px;
            margin: 2px 0;
            border-radius: 4px;
            transition: background 0.2s;
        }
        .card-source-link:hover {
            background: rgba(224,201,127,0.12);
            text-decoration: underline;
        }

        /* ── Per-waypoint source display ────────────────────── */
        .wp-source-item {
            margin-bottom: 8px;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(224,201,127,0.08);
        }
        .wp-source-item:last-child {
            margin-bottom: 0;
            padding-bottom: 0;
            border-bottom: none;
        }
        .wp-source-header {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-bottom: 3px;
        }
        .wp-source-type {
            font-family: 'Cinzel', serif;
            font-size: 10px;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            white-space: nowrap;
        }
        .wp-source-why {
            font-size: 12px;
            color: #b0b0b0;
            line-height: 1.5;
            margin: 4px 0;
        }
        .wp-source-ref-row {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .source-pdf-link {
            font-family: 'EB Garamond', serif;
            font-size: 11px;
            color: #e0c97f;
            text-decoration: none;
            white-space: nowrap;
            opacity: 0.8;
            transition: opacity 0.2s;
        }
        .source-pdf-link:hover {
            opacity: 1;
            text-decoration: underline;
        }
        .wp-source-text {
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            font-style: italic;
            color: #d0d0d0;
            line-height: 1.5;
            padding: 6px 10px;
            margin-top: 4px;
            background: rgba(224,201,127,0.05);
            border-left: 2px solid rgba(224,201,127,0.2);
            border-radius: 0 4px 4px 0;
        }

        .card-actions {
            display: flex;
            gap: 8px;
            margin-bottom: 10px;
        }
        .card-chat-btn {
            flex: 1;
            padding: 7px 12px;
            background: rgba(224,201,127,0.12);
            border: 1px solid rgba(224,201,127,0.3);
            border-radius: 6px;
            color: #e0c97f;
            font-family: 'Cinzel', serif;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
            letter-spacing: 0.3px;
        }
        .card-chat-btn:hover {
            background: rgba(224,201,127,0.22);
            border-color: #e0c97f;
        }
        .card-chat-btn .btn-icon { margin-right: 4px; }
        .card-read-more { display: none; }

        .card-people-label {
            font-family: 'Cinzel', serif;
            font-size: 10px;
            color: #8899aa;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 6px;
        }
        .card-figures-row {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            padding-top: 8px;
            border-top: 1px solid rgba(224,201,127,0.15);
        }
        .card-figure-chip {
            display: flex;
            align-items: center;
            gap: 6px;
            background: rgba(26,26,46,0.6);
            border: 1px solid rgba(224,201,127,0.12);
            border-radius: 20px;
            padding: 3px 10px 3px 3px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .card-figure-chip:hover {
            border-color: #e0c97f;
            background: rgba(224,201,127,0.08);
        }
        .card-figure-name {
            font-family: 'EB Garamond', serif;
            font-size: 12px;
            color: #c0c0c0;
            white-space: nowrap;
        }
        .card-figure-chip:hover .card-figure-name { color: #e0c97f; }
        .card-figure-avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Cinzel', serif;
            font-weight: 700;
            font-size: 10px;
            color: #fff;
            text-shadow: 0 1px 2px rgba(0,0,0,0.5);
            border: 2px solid transparent;
            transition: all 0.2s;
            flex-shrink: 0;
        }
        .card-figure-avatar.active {
            border-color: #e0c97f;
        }
        .card-figure-plain {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #333366;
            font-family: 'Cinzel', serif;
            font-weight: 600;
            font-size: 9px;
            color: #8899aa;
            flex-shrink: 0;
        }

        .card-detail-body { display: block; margin-top: 10px; }

        /* ── Detail content shared styles ────────────────────── */

        .source-meta { margin-bottom: 8px; }
        .source-meta-row {
            display: flex;
            justify-content: space-between;
            padding: 4px 0;
            border-bottom: 1px solid rgba(224,201,127,0.08);
            font-size: 13px;
        }
        .meta-label { color: #8899aa; }
        .meta-value { color: #e0e0e0; font-weight: 600; }
        .panel-section-heading {
            color: #e0c97f;
            font-family: 'Cinzel', serif;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin: 14px 0 6px;
            font-weight: 600;
        }
        .event-quote {
            border-left: 3px solid #e0c97f;
            padding: 8px 14px;
            margin: 10px 0;
            font-style: italic;
            color: #c0c0c0;
            font-size: 14px;
            line-height: 1.5;
        }
        .event-quote-speaker {
            color: #e0c97f;
            font-style: normal;
            font-size: 12px;
            margin-top: 4px;
        }
        .event-subevents { list-style: none; padding: 0; }
        .event-subevents li {
            color: #c0c0c0;
            font-size: 13px;
            line-height: 1.5;
            padding: 2px 0 2px 16px;
            position: relative;
        }
        .event-subevents li::before {
            content: '';
            position: absolute;
            left: 0; top: 9px;
            width: 6px; height: 6px;
            border-radius: 50%;
            background: #e0c97f;
        }
        .subevent-link {
            color: #e0c97f;
            text-decoration: none;
            border-bottom: 1px dotted rgba(224,201,127,0.4);
            transition: border-color 0.2s;
        }
        .subevent-link:hover { border-bottom-color: #e0c97f; }
        .subevent-link::after {
            content: ' ↗';
            font-size: 10px;
            opacity: 0.5;
        }
        .event-people, .event-themes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
        .person-chip, .theme-chip {
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 12px;
            padding: 3px 10px;
            font-size: 12px;
            color: #c0c0c0;
        }
        .person-chip.clickable {
            cursor: pointer;
            border-color: #555577;
            transition: all 0.2s;
        }
        .person-chip.clickable:hover {
            background: #222244;
            border-color: #e0c97f;
            color: #e0c97f;
        }
        .theme-chip { border-color: #4a3a6e; color: #c07fe0; }
        .event-location-row {
            display: flex; align-items: center; gap: 6px;
            color: #8899aa; font-size: 13px; margin-bottom: 8px;
        }
        .event-reference-row { color: #c07fe0; font-size: 13px; margin-bottom: 4px; }
        .source-cards { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
        .source-card {
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 8px;
            padding: 8px 12px;
        }
        .source-card-title { color: #e0c97f; font-size: 13px; font-weight: 600; }
        .source-card-meta { color: #8899aa; font-size: 11px; margin-top: 2px; }
        .figure-brief { color: #c0c0c0; font-size: 13px; line-height: 1.5; margin: 6px 0; }
        .figure-journey-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
        .figure-journey-card {
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 8px;
            padding: 6px 10px;
            cursor: pointer;
            transition: border-color 0.2s;
            display: flex; align-items: center; gap: 8px;
        }
        .figure-journey-card:hover { border-color: #e0c97f; }
        .figure-journey-card .journey-line-sample { width: 20px; height: 2px; border-top: 2px dashed; flex-shrink: 0; }
        .figure-journey-card .journey-card-label { color: #e0e0e0; font-size: 13px; flex: 1; }
        .figure-journey-card .journey-card-dates { color: #8899aa; font-size: 11px; flex-shrink: 0; }
        .event-card-mini {
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 8px;
            padding: 6px 10px;
            cursor: pointer;
            transition: border-color 0.2s;
        }
        .event-card-mini:hover { border-color: #e0c97f; }
        .event-card-mini-title { color: #e0e0e0; font-size: 13px; }
        .event-card-mini-meta { color: #8899aa; font-size: 11px; margin-top: 2px; }

        /* ── Era Filters (bottom-center, above nav) ──────────── */

        #era-filters {
            /* Hidden — era selection now done via timeline era bands */
            display: none !important;
        }
        .era-btn {
            border-radius: 8px;
            border: 1px solid #555577;
            background: transparent;
            color: #8899aa;
            font-family: 'Cinzel', serif;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 4px 10px;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .era-btn-label {
            font-size: 10px;
            font-weight: 600;
            letter-spacing: 0.3px;
        }
        .era-btn-range {
            font-size: 8px;
            opacity: 0.7;
            font-family: 'EB Garamond', serif;
        }
        .era-btn:hover { border-color: #e0c97f; color: #e0c97f; }
        .era-btn.active {
            border-color: #e0c97f;
            color: #e0c97f;
            background: rgba(224,201,127,0.12);
        }
        .era-btn:not(.active) { opacity: 0.4; }

        /* ── Timeline Viewer (bottom strip) ─────────────────────── */

        #timeline-viewer {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 110px;
            background: rgba(22,33,62,0.95);
            border-top: 1px solid rgba(224,201,127,0.25);
            z-index: 900;
            display: flex;
            flex-direction: column;
            transition: height 0.3s ease, transform 0.3s ease;
        }
        #timeline-viewer.collapsed {
            height: 28px;
        }
        #timeline-viewer.collapsed .tl-track-wrap,
        #timeline-viewer.collapsed .tl-axis {
            display: none;
        }

        .tl-toolbar {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 3px 12px;
            flex-shrink: 0;
            min-height: 28px;
        }

        /* ── Loading bar (above timeline track) ── */
        .tl-loading-bar {
            display: none;
            align-items: center;
            gap: 10px;
            padding: 6px 16px;
            background: rgba(16,33,62,0.92);
            border-bottom: 1px solid rgba(224,201,127,0.15);
        }
        .tl-loading-bar.active {
            display: flex;
        }
        .tl-loading-text {
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            color: #e0c97f;
            white-space: nowrap;
            letter-spacing: 0.3px;
        }
        .tl-loading-progress {
            flex: 1;
            height: 4px;
            background: rgba(224,201,127,0.12);
            border-radius: 2px;
            overflow: hidden;
        }
        .tl-loading-fill {
            height: 100%;
            width: 30%;
            background: linear-gradient(90deg, #e0c97f, #c09840);
            border-radius: 2px;
            animation: tl-loading-slide 1.4s ease-in-out infinite;
        }
        @keyframes tl-loading-slide {
            0%   { width: 20%; margin-left: 0; }
            50%  { width: 40%; margin-left: 30%; }
            100% { width: 20%; margin-left: 80%; }
        }
        .tl-toolbar-label {
            font-family: 'Cinzel', serif;
            font-size: 10px;
            color: #8899aa;
            letter-spacing: 1.5px;
            text-transform: uppercase;
            white-space: nowrap;
        }
        .tl-btn {
            background: rgba(224,201,127,0.12);
            border: 1px solid rgba(224,201,127,0.3);
            color: #c0a050;
            font-size: 12px;
            width: 22px;
            height: 22px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }
        .tl-btn:hover { background: rgba(224,201,127,0.25); color: #e0c97f; }
        /* ── Event Navigator (inline in toolbar) ── */
        .event-nav {
            display: flex;
            align-items: center;
            gap: 6px;
            margin-left: 12px;
            padding: 0 8px;
            border-left: 1px solid rgba(224,201,127,0.2);
            white-space: nowrap;
            overflow: hidden;
        }
        .event-nav-pip {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }
        .event-nav-name {
            font-family: 'Cinzel', serif;
            font-size: 10px;
            color: #e0c97f;
            letter-spacing: 0.5px;
            flex-shrink: 0;
            max-width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .event-nav-btn {
            font-size: 9px !important;
            width: 18px !important;
            height: 18px !important;
        }
        .event-nav-label {
            font-family: 'EB Garamond', serif;
            font-size: 12px;
            color: #ccc;
            max-width: 220px;
            overflow: hidden;
            text-overflow: ellipsis;
            cursor: pointer;
        }
        .event-nav-label:hover { color: #e0c97f; }
        .event-nav-counter {
            font-family: 'EB Garamond', serif;
            font-size: 10px;
            color: #667788;
            flex-shrink: 0;
        }

        .tl-toggle {
            margin-left: auto;
            background: none;
            border: none;
            color: #667788;
            font-size: 14px;
            cursor: pointer;
            padding: 2px 4px;
        }
        .tl-toggle:hover { color: #e0c97f; }

        .tl-track-wrap {
            flex: 1;
            overflow-x: auto;
            overflow-y: hidden;
            position: relative;
            cursor: grab;
        }
        .tl-track-wrap:active { cursor: grabbing; }
        .tl-track-wrap::-webkit-scrollbar { height: 4px; }
        .tl-track-wrap::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
        .tl-track-wrap::-webkit-scrollbar-thumb { background: rgba(224,201,127,0.3); border-radius: 2px; }

        #tl-center-indicator {
            position: absolute;
            width: 3px;
            top: -2px;
            bottom: -2px;
            background: rgba(224,201,127,0.8);
            pointer-events: none;
            z-index: 8;
            transform: translateX(-50%);
            box-shadow: 0 0 8px rgba(224,201,127,0.5);
        }
        #tl-center-indicator::before {
            content: '';
            position: absolute;
            top: -1px;
            left: 50%;
            transform: translateX(-50%);
            width: 0; height: 0;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-top: 6px solid #e0c97f;
        }
        #tl-center-indicator::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 50%;
            transform: translateX(-50%);
            width: 0; height: 0;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-bottom: 6px solid #e0c97f;
        }
        #tl-center-year {
            position: absolute;
            top: -18px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 9px;
            font-family: 'Cinzel', serif;
            color: #e0c97f;
            white-space: nowrap;
            text-shadow: 0 0 4px rgba(0,0,0,0.8);
            letter-spacing: 0.5px;
        }

        .tl-track {
            position: relative;
            height: 100%;
            min-height: 50px;
        }

        /* Era background bands */
        .tl-era-band {
            position: absolute;
            top: 0;
            bottom: 20px;
            opacity: 0.08;
            border-right: 1px solid rgba(224,201,127,0.15);
            transition: opacity 0.3s ease;
        }
        .tl-era-band.tl-era-active {
            opacity: 0.20;
            border-left: 1px solid rgba(224,201,127,0.3);
            border-right: 1px solid rgba(224,201,127,0.3);
            box-shadow: inset 0 0 20px rgba(224,201,127,0.05);
        }
        .tl-era-band:hover {
            opacity: 0.14;
        }
        .tl-era-label {
            position: absolute;
            bottom: 22px;
            font-family: 'Cinzel', serif;
            font-size: 8px;
            color: rgba(224,201,127,0.4);
            letter-spacing: 0.5px;
            white-space: nowrap;
            text-align: center;
            pointer-events: none;
        }

        /* Dimming for dots/bars outside active era */
        .tl-dot.era-dimmed { opacity: 0.15; }
        .tl-bar.era-dimmed { opacity: 0.15; }
        .tl-dot.tl-future { opacity: 0.25; transition: opacity 0.15s; }
        .tl-bar.tl-future { opacity: 0.35; transition: opacity 0.15s; }

        /* Soft highlight on era button when timeline scrolls to that era */
        .era-btn.tl-scroll-highlight:not(.active) {
            border-color: rgba(224,201,127,0.5);
            color: rgba(224,201,127,0.7);
            opacity: 0.7;
        }

        /* Event dots */
        .tl-dot {
            position: absolute;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            border: 1px solid rgba(22,33,62,0.6);
            cursor: pointer;
            transition: transform 0.15s ease, box-shadow 0.15s ease;
            z-index: 2;
        }
        .tl-dot:hover {
            transform: scale(1.8);
            box-shadow: 0 0 6px currentColor;
            z-index: 5;
        }
        .tl-dot.highlight {
            transform: scale(2);
            box-shadow: 0 0 8px currentColor;
            z-index: 5;
        }
        .tl-dot.dimmed { opacity: 0.2; }
        .tl-dot.tl-hidden, .tl-bar.tl-hidden { display: none; }
        .tl-dot.tl-ghosted { opacity: 0.15; pointer-events: auto; cursor: pointer; }
        .tl-dot.tl-landmark {
            opacity: 0.55;
            border: 1px solid rgba(160,140,100,0.5);
            background: rgba(180,160,110,0.6) !important;
        }
        .tl-dot.tl-revealed {
            transform: scale(2.2);
            box-shadow: 0 0 10px currentColor;
            z-index: 6;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        /* Figure lifespan bars */
        .tl-bar {
            position: absolute;
            height: 14px;
            border-radius: 6px;
            opacity: 0.35;
            cursor: pointer;
            transition: opacity 0.15s;
            z-index: 1;
        }
        .tl-bar:hover { opacity: 0.6; }
        .tl-bar-label {
            position: absolute;
            top: -13px;
            left: 2px;
            font-family: 'Cinzel', serif;
            font-size: 7px;
            color: rgba(224,201,127,0.5);
            white-space: nowrap;
            pointer-events: none;
        }

        /* Year axis labels */
        .tl-axis {
            height: 18px;
            flex-shrink: 0;
            position: relative;
            border-top: 1px solid rgba(224,201,127,0.15);
            overflow: hidden;
            /* Scroll synced with track via JS */
        }
        .tl-axis-inner {
            position: relative;
            height: 100%;
            transition: none;
        }
        .tl-axis-label {
            position: absolute;
            bottom: 2px;
            font-family: 'EB Garamond', serif;
            font-size: 9px;
            color: #667788;
            transform: translateX(-50%);
            white-space: nowrap;
        }

        /* Playback indicator — draggable scrub handle */
        .tl-playback-indicator {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 2px;
            background: #e0c97f;
            z-index: 10;
            box-shadow: 0 0 6px rgba(224,201,127,0.5);
            display: none;
            cursor: ew-resize;
        }
        /* Wide invisible hit area for easier grabbing */
        .tl-playback-indicator::before {
            content: '';
            position: absolute;
            top: 0; bottom: 0;
            left: -8px; right: -8px;
            cursor: ew-resize;
        }
        /* Diamond handle at top */
        .tl-playback-indicator::after {
            content: '';
            position: absolute;
            top: -3px;
            left: 50%;
            transform: translateX(-50%) rotate(45deg);
            width: 8px; height: 8px;
            background: #e0c97f;
            border-radius: 1px;
        }
        .tl-playback-indicator:hover {
            box-shadow: 0 0 12px rgba(224,201,127,0.8);
        }
        .tl-playback-indicator.dragging {
            box-shadow: 0 0 14px rgba(224,201,127,1);
        }

        /* ── Journey Timeline (replaces era timeline during playback) ── */
        .jtl-track-line {
            position: absolute;
            top: 8px;
            height: 2px;
            background: rgba(224,201,127,0.12);
            z-index: 1;
            border-radius: 1px;
        }
        /* Filled progress track — grows as playback advances */
        .jtl-progress-fill {
            position: absolute;
            top: 7px;
            height: 4px;
            background: linear-gradient(90deg, rgba(224,201,127,0.5), rgba(224,201,127,0.35));
            border-radius: 2px;
            z-index: 1;
            transition: width 1s ease-in-out;
        }
        .jtl-progress-fill.jtl-no-transition { transition: none; }
        .jtl-dot {
            position: absolute;
            border-radius: 50%;
            cursor: pointer;
            z-index: 3;
            transition: transform 0.3s ease, opacity 0.6s ease, box-shadow 0.3s ease;
        }
        .jtl-dot.jtl-future {
            opacity: 0.4;
            filter: saturate(0);
        }
        .jtl-dot.jtl-visited {
            opacity: 1;
        }
        .jtl-dot.jtl-current {
            transform: scale(1.8);
            box-shadow: 0 0 10px currentColor;
            z-index: 5;
            animation: jtl-pulse 1.5s ease-in-out infinite;
        }
        @keyframes jtl-pulse {
            0%, 100% { box-shadow: 0 0 6px currentColor; transform: scale(1.6); }
            50% { box-shadow: 0 0 14px currentColor; transform: scale(2); }
        }
        .jtl-dot.jtl-event {
            border: 1px solid rgba(255,255,255,0.25);
        }
        .jtl-dot:hover {
            transform: scale(2.2);
            box-shadow: 0 0 8px currentColor;
            z-index: 5;
            opacity: 1 !important;
            animation: none;
        }
        .jtl-journey-sep {
            position: absolute;
            top: 0;
            bottom: 18px;
            width: 1px;
            background: rgba(224,201,127,0.15);
            z-index: 2;
        }
        .jtl-journey-label {
            position: absolute;
            bottom: 18px;
            transform: translateX(-50%);
            font-family: 'Cinzel', serif;
            font-size: 7px;
            color: rgba(224,201,127,0.4);
            white-space: nowrap;
            pointer-events: none;
            letter-spacing: 0.3px;
        }
        /* Fixed-center playhead (journey mode) */
        .jtl-playhead {
            position: absolute;
            left: 50%;
            top: -2px;
            bottom: -2px;
            width: 3px;
            background: #e0c97f;
            z-index: 10;
            box-shadow: 0 0 10px rgba(224,201,127,0.7);
            pointer-events: none;
            transform: translateX(-50%);
            display: none;
        }
        .jtl-playhead::before {
            content: '';
            position: absolute;
            top: -1px;
            left: 50%;
            transform: translateX(-50%);
            width: 0; height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 7px solid #e0c97f;
        }
        .jtl-playhead::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 50%;
            transform: translateX(-50%);
            width: 0; height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-bottom: 7px solid #e0c97f;
        }

        /* Track sliding transitions for journey mode */
        .jtl-smooth-slide { transition: transform 1.2s ease-in-out; }
        .jtl-no-slide { transition: none !important; }

        /* Tooltip */
        .tl-tooltip {
            position: fixed;
            background: rgba(22,33,62,0.95);
            border: 1px solid rgba(224,201,127,0.3);
            border-radius: 6px;
            padding: 4px 8px;
            font-family: 'EB Garamond', serif;
            font-size: 11px;
            color: #d0d0d0;
            pointer-events: none;
            z-index: 9999;
            max-width: 250px;
            white-space: nowrap;
            display: none;
        }

        /* ── Journey Navigator (bottom-center) ────────────────── */

        #time-navigator {
            bottom: 122px;
            left: 50%;
            transform: translateX(-50%);
            padding: 0;
            z-index: 1000;
            min-width: 420px;
            max-width: 800px;
            width: calc(100vw - 400px);
        }
        .nav-empty {
            display: none;  /* No need for "Select a figure" prompt */
        }
        .nav-journey {
            display: flex;
            flex-direction: column;
            gap: 0;
        }
        .nav-header {
            font-family: 'Cinzel', serif;
            font-size: 11px;
            color: #8899aa;
            text-align: center;
            padding: 6px 16px 2px;
            letter-spacing: 0.5px;
        }
        .nav-header strong { color: #e0c97f; }
        .nav-controls {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 2px 12px 6px;
        }
        .nav-btn {
            background: none;
            border: none;
            color: #e0c97f;
            font-size: 16px;
            cursor: pointer;
            padding: 4px 8px;
            transition: opacity 0.2s;
            flex-shrink: 0;
        }
        .nav-btn:hover { opacity: 0.7; }
        .nav-btn.nav-play {
            font-size: 13px;
            letter-spacing: -2px;
            padding: 4px 6px;
        }
        .nav-waypoint {
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            color: #e0e0e0;
            flex: 1;
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .nav-waypoint strong { font-family: 'Cinzel', serif; font-size: 11px; }
        .nav-counter {
            font-family: 'EB Garamond', serif;
            font-size: 10px;
            color: #667788;
            flex-shrink: 0;
            min-width: 36px;
            text-align: right;
        }
        .nav-progress {
            height: 2px;
            background: rgba(255,255,255,0.08);
            width: 100%;
            border-radius: 0 0 12px 12px;
            overflow: hidden;
        }
        .nav-progress-fill {
            height: 100%;
            background: #e0c97f;
            transition: width 0.4s ease;
            width: 0%;
        }

        /* ── Chat Panel (bottom-left) ────────────────────────── */

        #chat-panel {
            bottom: 16px;
            left: 12px;
            width: 360px;
            height: 420px;
            display: flex;
            flex-direction: column;
            transform: translateY(20px) scale(0.95);
            opacity: 0;
            pointer-events: none;
            z-index: 1100;
        }
        #chat-panel.open {
            transform: translateY(0) scale(1);
            opacity: 1;
            pointer-events: auto;
        }

        .chat-panel-header {
            padding: 10px 16px;
            border-bottom: 1px solid rgba(224,201,127,0.15);
            font-family: 'Cinzel', serif;
            font-size: 13px;
            color: #e0c97f;
            letter-spacing: 1px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .chat-panel-close {
            background: none; border: none;
            color: #8899aa; font-size: 16px;
            cursor: pointer; transition: color 0.2s;
        }
        .chat-panel-close:hover { color: #e0c97f; }

        .explorer-chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
            scrollbar-width: thin;
            scrollbar-color: #333366 transparent;
        }
        .explorer-chat-messages::-webkit-scrollbar { width: 4px; }
        .explorer-chat-messages::-webkit-scrollbar-thumb { background: #333366; border-radius: 2px; }

        .explorer-chat-welcome {
            text-align: center;
            padding: 16px 8px;
            color: #8899aa;
            font-size: 13px;
        }
        .explorer-suggestions {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-top: 12px;
        }
        .suggestion {
            background: rgba(224,201,127,0.08);
            border: 1px solid rgba(224,201,127,0.2);
            border-radius: 8px;
            padding: 8px 12px;
            color: #e0c97f;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .suggestion:hover { background: rgba(224,201,127,0.15); border-color: #e0c97f; }

        .chat-msg { margin-bottom: 10px; }
        .chat-msg.user { text-align: right; }
        .chat-msg.user .chat-bubble {
            background: rgba(224,201,127,0.12);
            border: 1px solid rgba(224,201,127,0.25);
            display: inline-block;
            max-width: 85%;
            text-align: left;
        }
        .chat-msg.assistant .chat-bubble {
            background: rgba(26,26,46,0.6);
            border: 1px solid #333366;
            display: inline-block;
            max-width: 85%;
        }
        .chat-bubble {
            border-radius: 10px;
            padding: 8px 12px;
            font-size: 13px;
            line-height: 1.5;
            color: #e0e0e0;
        }
        .chat-bubble p { margin: 4px 0; }

        .explorer-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
        .explorer-action-btn {
            background: rgba(224,201,127,0.08);
            border: 1px solid rgba(224,201,127,0.3);
            border-radius: 8px;
            padding: 4px 10px;
            color: #e0c97f;
            font-size: 11px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .explorer-action-btn:hover { background: rgba(224,201,127,0.15); }

        .newadvent-link {
            color: #c0965c;
            text-decoration: underline;
            text-decoration-style: dotted;
            word-break: break-all;
        }
        .newadvent-link:hover { color: #e0b06c; }

        .typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
        .typing-indicator span {
            width: 6px; height: 6px;
            background: #8899aa;
            border-radius: 50%;
            animation: typing 1.2s infinite;
        }
        .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
        .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
        @keyframes typing { 0%,60%,100%{opacity:0.3} 30%{opacity:1} }

        .explorer-chat-input {
            display: flex;
            gap: 6px;
            padding: 10px 12px;
            border-top: 1px solid rgba(224,201,127,0.15);
        }
        .explorer-chat-input textarea {
            flex: 1;
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 8px;
            padding: 8px 10px;
            color: #e0e0e0;
            font-family: 'EB Garamond', serif;
            font-size: 13px;
            resize: none;
            outline: none;
        }
        .explorer-chat-input textarea:focus { border-color: #e0c97f; }
        .explorer-chat-input button {
            background: #e0c97f;
            border: none;
            border-radius: 8px;
            padding: 8px 14px;
            color: #16213e;
            font-family: 'Cinzel', serif;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: opacity 0.2s;
        }
        .explorer-chat-input button:hover { opacity: 0.85; }
        .explorer-chat-input button:disabled { opacity: 0.5; cursor: default; }

        /* ── Settings Panel (bottom-right) ───────────────────── */

        #settings-panel {
            bottom: 122px;
            right: 12px;
            padding: 10px 16px;
            z-index: 1000;
        }
        .settings-header {
            font-family: 'Cinzel', serif;
            font-size: 13px;
            color: #8899aa;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: color 0.2s;
        }
        .settings-header:hover { color: #e0c97f; }
        .settings-header .chevron {
            font-size: 10px;
            transition: transform 0.2s;
        }
        #settings-panel.open .chevron { transform: rotate(180deg); }
        .settings-body {
            display: none;
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px solid rgba(224,201,127,0.15);
        }
        #settings-panel.open .settings-body { display: block; }
        .setting-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 0;
            font-size: 12px;
            color: #c0c0c0;
        }
        .setting-row select, .setting-row button {
            background: rgba(26,26,46,0.8);
            border: 1px solid #333366;
            border-radius: 6px;
            padding: 3px 8px;
            color: #e0e0e0;
            font-family: 'EB Garamond', serif;
            font-size: 12px;
            cursor: pointer;
        }
        .route-legend {
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px solid rgba(224,201,127,0.15);
        }
        .route-legend-title {
            font-family: 'Cinzel', serif;
            font-size: 11px;
            color: #8899aa;
            margin-bottom: 6px;
        }
        .route-legend-item {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: #a0a0a0;
            padding: 2px 0;
        }
        .route-legend-line {
            width: 28px;
            height: 0;
            border-top: 2.5px solid #c0c0c0;
            flex-shrink: 0;
        }
        .route-legend-line.sea { border-top-style: dotted; }
        .route-legend-line.estimated { border-top-style: dashed; }

        /* ── Mobile ──────────────────────────────────────────── */

        @media (max-width: 768px) {
            #figures-panel {
                top: auto;
                bottom: 130px;
                left: 8px;
                right: 8px;
                width: auto;
                max-height: none;
                flex-direction: column;
                padding: 8px;
            }
            .figures-grid {
                grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
                max-height: 80px;
                overflow-x: auto;
                overflow-y: hidden;
            }
            .category-tabs { flex-wrap: nowrap; overflow-x: auto; }
            .events-list { max-height: 120px; }

            #event-card {
                top: auto;
                bottom: 0;
                right: 0;
                left: 0;
                width: 100%;
                max-height: 50vh;
                border-radius: 16px 16px 0 0;
                transform: translateY(100%);
            }
            #event-card.open { transform: translateY(0); }

            #timeline-viewer { height: 70px; }
            #timeline-viewer.collapsed { height: 24px; }

            #era-filters { bottom: 140px; padding: 4px 6px; gap: 3px; }
            .era-btn { padding: 3px 6px; }
            .era-btn-label { font-size: 8px; }
            .era-btn-range { font-size: 7px; }
            .figure-search-wrap input { font-size: 12px; padding: 5px 8px; }

            #time-navigator {
                bottom: 82px;
                min-width: auto;
                width: calc(100% - 80px);
                padding: 6px 12px;
            }

            #chat-panel {
                bottom: 76px;
                left: 0;
                right: 0;
                width: 100%;
                height: 50vh;
                border-radius: 16px 16px 0 0;
            }

            #settings-panel { bottom: 78px; right: 8px; padding: 6px 10px; }
        }

/* ── Council Debate Section ───────────────────────────── */

.council-debate {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
}

.debate-issue {
    font-family: 'EB Garamond', serif;
    font-size: 13px;
    color: #c9a84c;
    padding: 8px 12px;
    background: rgba(201, 168, 76, 0.08);
    border-left: 3px solid #c9a84c;
    margin-bottom: 8px;
    border-radius: 4px;
    line-height: 1.5;
}

.debate-issue-label {
    font-weight: 600;
    color: #ddb860;
}

.debate-side {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    border-left: 3px solid;
}

.debate-orthodox {
    background: rgba(80, 176, 128, 0.08);
    border-left-color: #50b080;
}

.debate-heterodox {
    background: rgba(200, 80, 80, 0.08);
    border-left-color: #c85050;
}

.debate-side-header {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.debate-orthodox .debate-side-header {
    color: #50b080;
}

.debate-heterodox .debate-side-header {
    color: #c85050;
}

.debate-side-icon {
    margin-right: 4px;
}

.debate-side-position {
    font-family: 'EB Garamond', serif;
    font-size: 13px;
    color: #ccd0d8;
    line-height: 1.5;
    margin-bottom: 8px;
}

.debate-champions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.debate-champion-chip {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-family: 'EB Garamond', serif;
}

.debate-champion-chip.orthodox {
    background: rgba(80, 176, 128, 0.15);
    color: #70d0a0;
    border: 1px solid rgba(80, 176, 128, 0.25);
}

.debate-champion-chip.heterodox {
    background: rgba(200, 80, 80, 0.15);
    color: #e08080;
    border: 1px solid rgba(200, 80, 80, 0.25);
}
