* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #0d1117;
    color: #c9d1d9;
}

/* Sidebar */
#sidebar {
    width: 360px;
    min-width: 360px;
    background: #161b22;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #30363d;
    z-index: 1000;
}

#sidebar-header {
    padding: 12px 20px 8px;
    background: #0d1117;
    border-bottom: 2px solid #e6443680;
    flex-shrink: 0;
}

#sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: #f0f6fc;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 2px;
}

/* Stats */
#stats-bar {
    padding: 5px 20px;
    font-size: 12px;
    color: #8b949e;
    border-bottom: 1px solid #30363d;
    background: #0d1117;
    flex-shrink: 0;
}

#stats-bar span {
    font-weight: 600;
    color: #58a6ff;
}

/* View toggles */
#view-toggles {
    padding: 6px 20px;
    display: flex;
    gap: 6px;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.view-btn {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background: #0d1117;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s;
}

.view-btn:hover {
    border-color: #58a6ff;
    color: #c9d1d9;
}

.view-btn.active {
    background: #1f6feb;
    border-color: #1f6feb;
    color: #ffffff;
}

/* Toolbar */
#toolbar {
    padding: 6px 20px;
    display: flex;
    gap: 6px;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

#search-box {
    flex: 2;
    padding: 5px 10px;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 12px;
    background: #0d1117;
    color: #c9d1d9;
}

#search-box:focus {
    outline: none;
    border-color: #58a6ff;
}

#search-box::placeholder {
    color: #484f58;
}

#toolbar select {
    flex: 1;
    padding: 5px 6px;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 11px;
    background: #0d1117;
    color: #c9d1d9;
    cursor: pointer;
    min-width: 0;
}

#toolbar select:focus {
    outline: none;
    border-color: #58a6ff;
}

/* Filter presets */
#presets-bar {
    padding: 5px 20px;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #30363d;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.preset-btn {
    padding: 3px 10px;
    border: 1px solid #30363d;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    background: #0d1117;
    color: #8b949e;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preset-btn:hover {
    border-color: #58a6ff;
    color: #c9d1d9;
}

.preset-btn.active {
    background: #1f6feb;
    border-color: #1f6feb;
    color: #ffffff;
}

/* Concept panel */
#concept-panel {
    border-bottom: 1px solid #30363d;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

#concept-panel::-webkit-scrollbar {
    width: 5px;
}

#concept-panel::-webkit-scrollbar-track {
    background: #161b22;
}

#concept-panel::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

#concept-header {
    padding: 8px 20px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #161b22;
    z-index: 1;
}

.concept-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.concept-hint {
    font-size: 9px;
    color: #484f58;
    flex: 1;
    text-align: center;
}

.concept-clear-btn {
    font-size: 10px;
    color: #58a6ff;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
}

.concept-clear-btn:hover {
    color: #79c0ff;
}

#concept-chips {
    padding: 4px 16px 8px;
}

.concept-domain {
    margin-bottom: 4px;
}

.concept-domain-label {
    font-size: 10px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 6px 4px 3px;
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.concept-domain-label:hover {
    opacity: 0.85;
}
.concept-domain-label.domain-active {
    color: #fff !important;
    border-radius: 4px;
    padding: 1px 6px;
}
.concept-domain-label.domain-excluded {
    text-decoration: line-through;
    opacity: 0.4;
}

.concept-chip {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 3px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    user-select: none;
}

.concept-chip.inactive {
    background: #21262d;
    color: #8b949e;
    border-color: #30363d;
}

.concept-chip.inactive:hover {
    border-color: #58a6ff;
    color: #c9d1d9;
}

.concept-chip.active {
    color: #ffffff;
    border-color: transparent;
}

.concept-chip .chip-count {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 3px;
}

.concept-chip.excluded {
    background: #21262d;
    color: #f85149;
    border-color: #f8514930;
    text-decoration: line-through;
}

/* Story list */
#story-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

#story-list::-webkit-scrollbar {
    width: 5px;
}

#story-list::-webkit-scrollbar-track {
    background: #161b22;
}

#story-list::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.story-item {
    padding: 10px 20px;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}

.story-item:hover {
    background: #1c2128;
}

.story-item.active {
    background: #1c2128;
    border-left-color: #58a6ff;
}

.story-item.fresh {
    border-left-color: #3fb950;
}

.story-title {
    font-size: 13px;
    font-weight: 500;
    color: #c9d1d9;
    line-height: 1.35;
    margin-bottom: 4px;
}

.story-meta {
    font-size: 11px;
    color: #8b949e;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.story-source {
    font-weight: 600;
    color: #58a6ff;
}

.story-concept-tag {
    padding: 0px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: #fff;
    opacity: 0.85;
}

.story-location {
    color: #8b949e;
}

.story-time {
    color: #484f58;
}

/* Expanded story detail */
.story-detail {
    display: none;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #21262d;
}

.story-item.expanded .story-detail {
    display: block;
}

.story-summary {
    font-size: 12px;
    color: #8b949e;
    line-height: 1.45;
    margin-bottom: 6px;
}

.story-link {
    font-size: 11px;
    color: #58a6ff;
    text-decoration: none;
    font-weight: 500;
}

.story-link:hover {
    text-decoration: underline;
}

.loading {
    padding: 40px 20px;
    text-align: center;
    color: #484f58;
    font-size: 13px;
}

/* Map */
#map {
    flex: 1;
    z-index: 1;
    background: #000;
}

/* MapLibre popup */
.maplibregl-popup-content {
    background: #161b22 !important;
    color: #c9d1d9;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
    padding: 14px 18px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 340px;
    border: 1px solid #30363d;
}

.maplibregl-popup-tip {
    border-top-color: #161b22 !important;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: #161b22 !important;
}

.maplibregl-popup-anchor-top .maplibregl-popup-tip {
    border-bottom-color: #161b22 !important;
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: #161b22 !important;
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: #161b22 !important;
}

.maplibregl-popup-close-button {
    color: #8b949e;
    font-size: 18px;
    padding: 4px 8px;
}

.maplibregl-popup-close-button:hover {
    color: #f0f6fc;
    background: transparent;
}

.popup-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #f0f6fc;
}

.popup-summary {
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 8px;
}

.popup-meta {
    font-size: 11px;
    color: #484f58;
    margin-bottom: 6px;
}

.popup-concepts {
    margin-bottom: 6px;
}

.popup-link {
    display: inline-block;
    margin-top: 4px;
    color: #58a6ff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
}

.popup-link:hover {
    text-decoration: underline;
}

/* Sidebar toggle */
#sidebar-toggle {
    position: absolute;
    left: 360px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    width: 20px;
    height: 48px;
    background: #161b22;
    border: 1px solid #30363d;
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: #8b949e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.3s;
}

#sidebar-toggle:hover {
    color: #f0f6fc;
    background: #1c2128;
}

body.sidebar-collapsed #sidebar {
    margin-left: -360px;
}

body.sidebar-collapsed #sidebar-toggle {
    left: 0;
}

#sidebar {
    transition: margin-left 0.3s ease;
}

/* New stories badge */
#new-badge {
    display: none;
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: #1f6feb;
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(31, 111, 235, 0.4);
    animation: slideDown 0.3s ease;
}

#new-badge:hover {
    background: #388bfd;
}

#new-badge.visible {
    display: block;
}

@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Trending bar */
#trending-bar {
    display: none;
    padding: 5px 20px;
    border-bottom: 1px solid #30363d;
    background: #0d1117;
    font-size: 11px;
    overflow-x: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

#trending-bar.visible {
    display: flex;
    align-items: center;
    gap: 6px;
}

#trending-bar::-webkit-scrollbar {
    height: 0;
}

/* removed duplicate scrollbar rules - hidden via height: 0 above */

.trending-label {
    color: #f85149;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.trending-chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
    transition: all 0.15s;
    flex-shrink: 0;
}

.trending-chip:hover {
    background: rgba(248, 81, 73, 0.25);
    border-color: rgba(248, 81, 73, 0.5);
}

.trending-spike {
    font-size: 9px;
    opacity: 0.7;
    margin-left: 2px;
}

/* Keyboard shortcuts overlay */
#shortcuts-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

#shortcuts-overlay.visible {
    display: flex;
}

.shortcuts-panel {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 24px 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.shortcuts-panel h2 {
    font-size: 16px;
    font-weight: 600;
    color: #f0f6fc;
    margin-bottom: 16px;
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.shortcut-key {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    padding: 2px 8px;
    font-family: monospace;
    font-size: 12px;
    color: #c9d1d9;
    min-width: 24px;
    text-align: center;
}

.shortcut-desc {
    color: #8b949e;
    flex: 1;
    margin-left: 12px;
}

.shortcuts-close {
    margin-top: 16px;
    text-align: center;
    font-size: 11px;
    color: #484f58;
}

/* Hover tooltip for cloud heatmap */
#hover-tooltip {
    display: none;
    position: fixed;
    z-index: 2000;
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px 12px;
    max-width: 320px;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.hover-story {
    font-size: 12px;
    color: #c9d1d9;
    padding: 2px 0;
    line-height: 1.35;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.hover-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}

.hover-more {
    font-size: 11px;
    color: #8b949e;
    padding-top: 2px;
}

/* Info panel */
#info-panel {
    display: none;
    position: fixed;
    right: 16px;
    top: 16px;
    bottom: 16px;
    width: 340px;
    background: rgba(22, 27, 34, 0.96);
    border: 1px solid #30363d;
    border-radius: 12px;
    z-index: 1500;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    flex-direction: column;
}

#info-panel.visible {
    display: flex;
}

#info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

#info-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #f0f6fc;
}

#info-panel-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#info-panel-close:hover {
    color: #f0f6fc;
}

#info-panel-stories {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

#info-panel-stories::-webkit-scrollbar {
    width: 5px;
}

#info-panel-stories::-webkit-scrollbar-track {
    background: transparent;
}

#info-panel-stories::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.info-card {
    padding: 10px 18px;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    transition: background 0.12s;
}

.info-card:hover {
    background: rgba(255,255,255,0.04);
}

.info-card-title {
    font-size: 13px;
    font-weight: 500;
    color: #c9d1d9;
    line-height: 1.35;
    margin-bottom: 4px;
}

.info-card-meta {
    font-size: 11px;
    color: #8b949e;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.info-card-summary {
    font-size: 12px;
    color: #8b949e;
    line-height: 1.4;
    margin-bottom: 6px;
}

.info-card-link {
    font-size: 11px;
    color: #58a6ff;
    text-decoration: none;
    font-weight: 500;
}

.info-card-link:hover {
    text-decoration: underline;
}

/* World overview bar */
#world-overview-bar {
    display: none;
    padding: 8px 20px;
    border-bottom: 1px solid #30363d;
    background: #0d1117;
    flex-shrink: 0;
}

#world-overview-bar.visible {
    display: block;
}

.world-overview-text {
    font-size: 12px;
    color: #8b949e;
    line-height: 1.5;
}

.world-overview-label {
    font-size: 10px;
    font-weight: 700;
    color: #58a6ff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    display: block;
}

.world-overview-time {
    font-size: 10px;
    color: #484f58;
    margin-top: 4px;
    display: block;
}

/* Event list */
#event-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

#event-list::-webkit-scrollbar {
    width: 5px;
}

#event-list::-webkit-scrollbar-track {
    background: #161b22;
}

#event-list::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.event-item {
    padding: 10px 20px;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}

.event-item:hover {
    background: #1c2128;
}

.event-item.active {
    background: #1c2128;
    border-left-color: #58a6ff;
}

.event-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.event-status {
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.event-status.emerging {
    background: rgba(63, 185, 80, 0.15);
    color: #3fb950;
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.event-status.ongoing {
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.event-status.escalating {
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.event-status.de-escalating {
    background: rgba(163, 113, 247, 0.15);
    color: #a371f7;
    border: 1px solid rgba(163, 113, 247, 0.3);
}

.event-status.resolved {
    background: rgba(139, 148, 158, 0.15);
    color: #8b949e;
    border: 1px solid rgba(139, 148, 158, 0.3);
}

.event-title {
    font-size: 13px;
    font-weight: 600;
    color: #f0f6fc;
    line-height: 1.35;
    flex: 1;
}

.event-story-count {
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: #21262d;
    color: #8b949e;
    border: 1px solid #30363d;
    flex-shrink: 0;
}

.event-meta {
    font-size: 11px;
    color: #8b949e;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.event-actor {
    padding: 0px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.event-description {
    display: none;
    font-size: 12px;
    color: #8b949e;
    line-height: 1.45;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #21262d;
}

.event-item.expanded .event-description {
    display: block;
}

.event-sample-stories {
    display: none;
    margin-top: 6px;
}

.event-item.expanded .event-sample-stories {
    display: block;
}

.event-sample-story {
    font-size: 11px;
    color: #8b949e;
    padding: 3px 0;
    border-left: 2px solid #30363d;
    padding-left: 8px;
    margin: 3px 0;
}

.event-sample-story a {
    color: #58a6ff;
    text-decoration: none;
}

.event-sample-story a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    #sidebar {
        width: 100%;
        min-width: unset;
        max-height: 45vh;
    }
    #map {
        height: 55vh;
    }
    #sidebar-toggle {
        display: none;
    }
}
