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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: white;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

.header {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    text-align: center;
    background: rgba(10, 14, 39, 0.9);
    padding: 20px 40px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.header h1 {
    font-size: 28px;
    margin-bottom: 5px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.theme-day .header h1 {
    background: linear-gradient(90deg, #111111 0%, #333333 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

body.theme-day .header p {
    color: rgba(0, 0, 0, 0.65);
}

.controls {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
}

.theme-toggle {
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(10, 14, 39, 0.92);
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    border-color: rgba(79, 172, 254, 0.8);
    background: rgba(79, 172, 254, 0.2);
}

.search-box select {
    width: 100%;
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(10, 14, 39, 0.9);
    color: white;
    font-size: 14px;
    backdrop-filter: blur(10px);
    appearance: none;
    cursor: pointer;
    outline: none;
}

.search-box select option {
    color: #0a0e27;
}

.timeline-control {
    background: rgba(10, 14, 39, 0.9);
    border-radius: 15px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.timeline-control label {
    font-size: 14px;
    font-weight: 600;
    color: #4facfe;
}

body.theme-day .timeline-control label {
    color: #111111;
}

.timeline-control input[type="range"] {
    width: 100%;
    accent-color: #4facfe;
    cursor: pointer;
}

body.theme-day .timeline-control input[type="range"] {
    accent-color: #666666;
}

.timeline-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.timeline-info button {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(79, 172, 254, 0.6);
    background: rgba(79, 172, 254, 0.15);
    color: #4facfe;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-info button:hover {
    background: rgba(79, 172, 254, 0.3);
}

.menu-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(10, 14, 39, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
    opacity: 0.7;
}

.menu-toggle:hover {
    opacity: 1;
    background: rgba(79, 172, 254, 0.2);
    border-color: rgba(79, 172, 254, 0.4);
}

body.theme-day .menu-toggle {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #111111;
}

body.theme-day .menu-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar {
    position: absolute;
    left: 20px;
    top: 120px;
    width: 280px;
    max-height: calc(100vh - 140px);
    background: rgba(10, 14, 39, 0.95);
    border-radius: 15px;
    padding: 20px;
    z-index: 1000;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.controls {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.controls.collapsed {
    transform: translateX(calc(100% + 20px));
}

.sidebar h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #4facfe;
}

.category {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.category:hover,
.category.active {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: #4facfe;
}

.category-title {
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-count {
    background: rgba(79, 172, 254, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.category-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.marker {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    user-select: none;
    z-index: 2;
}

.marker:hover {
    transform: scale(1.18);
    box-shadow: 0 6px 25px rgba(79, 172, 254, 0.7);
}

.marker-elements { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.marker-organic { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.marker-physical { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.marker-analytical { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.marker-biochemistry { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.marker-industrial { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

.marker.dim {
    opacity: 0.35;
    filter: saturate(0.6) blur(0.2px);
    z-index: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

.mapboxgl-popup-content {
    background: rgba(10, 14, 39, 0.98);
    border-radius: 15px;
    padding: 20px;
    min-width: 320px;
    max-width: 400px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.mapboxgl-popup-close-button {
    color: white;
    font-size: 20px;
    padding: 5px 10px;
}

.mapboxgl-popup { z-index: 10000; }

.popup-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #4facfe;
}

.popup-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.popup-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.popup-description {
    line-height: 1.6;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
}

.popup-impact {
    background: rgba(79, 172, 254, 0.2);
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
}

.popup-impact-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #4facfe;
}

.popup-scientist {
    font-style: italic;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
}

.popup-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(79, 172, 254, 0.2);
    color: #4facfe;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(79, 172, 254, 0.4);
    transition: all 0.2s ease;
}

.popup-link::after {
    content: "↗";
    font-size: 12px;
}

.popup-link:hover {
    background: rgba(79, 172, 254, 0.35);
}

.footer-credit {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-radius: 20px;
    background: rgba(10, 14, 39, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.footer-credit a {
    color: #4facfe;
    text-decoration: none;
}

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

.app-error {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 53, 69, 0.92);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 999px;
    z-index: 15000;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

body.theme-day {
    background: linear-gradient(135deg, #fefefe 0%, #f5f5f5 100%);
    color: #111111;
}

body.theme-day .header {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

body.theme-day .header p {
    color: rgba(0, 0, 0, 0.65);
}

body.theme-day .controls .search-box select,
body.theme-day .timeline-control,
body.theme-day .theme-toggle {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #111111;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body.theme-day .theme-toggle {
    color: #111111;
}

body.theme-day .theme-toggle:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.25);
}

body.theme-day .timeline-info {
    color: rgba(0, 0, 0, 0.7);
}

body.theme-day .timeline-info button {
    border-color: rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.05);
    color: #111111;
}

body.theme-day .timeline-info button:hover {
    background: rgba(0, 0, 0, 0.1);
}

body.theme-day .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

body.theme-day .sidebar h3 {
    color: #222;
}

body.theme-day .category {
    background: rgba(0, 0, 0, 0.04);
    border-left-color: transparent;
}

body.theme-day .category:hover,
body.theme-day .category.active {
    background: rgba(0, 0, 0, 0.08);
    border-left-color: #111;
}

body.theme-day .category-count {
    background: rgba(0, 0, 0, 0.12);
    color: #111;
}

body.theme-day .category-desc {
    color: rgba(0, 0, 0, 0.55);
}

body.theme-day .marker {
    background: #ffffff;
    border: 2px solid rgba(0, 0, 0, 0.8);
    color: #111111;
    filter: grayscale(100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
}

body.theme-day .marker.dim {
    opacity: 0.2;
}

body.theme-day .mapboxgl-popup-content {
    background: rgba(255, 255, 255, 0.97);
    color: #111;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.theme-day .mapboxgl-popup-close-button {
    color: #111;
}

body.theme-day .popup-title {
    color: #111111;
}

body.theme-day .popup-meta {
    color: rgba(0, 0, 0, 0.7);
}

body.theme-day .popup-description {
    color: rgba(0, 0, 0, 0.9);
}

body.theme-day .popup-impact {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.9);
}

body.theme-day .popup-impact-title {
    color: #111;
}

body.theme-day .popup-scientist {
    color: rgba(0, 0, 0, 0.7);
}

body.theme-day .popup-link {
    background: rgba(0, 0, 0, 0.05);
    color: #111;
    border: 1px solid rgba(0, 0, 0, 0.4);
}

body.theme-day .popup-link:hover {
    background: rgba(0, 0, 0, 0.1);
}

body.theme-day .footer-credit {
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

body.theme-day .footer-credit a {
    color: #111;
}

body.theme-day .app-error {
    background: rgba(200, 30, 49, 0.92);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(79, 172, 254, 0.5);
    border-radius: 10px;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: rgba(10, 14, 39, 0.98);
    backdrop-filter: blur(20px);
    z-index: 1999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    display: none;
}

body.theme-day .mobile-menu {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.mobile-menu.open {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-day .mobile-menu-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.mobile-menu-header h3 {
    margin: 0;
    font-size: 18px;
    color: #4facfe;
}

body.theme-day .mobile-menu-header h3 {
    color: #111;
}

.mobile-menu-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

body.theme-day .mobile-menu-close {
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
    color: #111;
}

.mobile-menu-close:hover {
    background: rgba(79, 172, 254, 0.2);
    border-color: rgba(79, 172, 254, 0.4);
}

body.theme-day .mobile-menu-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.mobile-menu-content {
    padding: 20px;
}

.mobile-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-day .mobile-controls {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.mobile-categories h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #4facfe;
}

body.theme-day .mobile-categories h3 {
    color: #111;
}

@media (max-width: 1100px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        display: none;
    }

    .controls {
        display: none;
    }

    .mobile-menu {
        display: block;
    }
}

@media (min-width: 1101px) {
    .mobile-menu {
        display: none;
    }

    .mobile-menu-overlay {
        display: none;
    }
}

@media (max-width: 1100px) {
    .header {
        font-size: 20px;
        padding: 12px 24px;
        max-width: calc(100% - 100px);
    }

    .header h1 {
        font-size: 20px;
    }

    .header p {
        font-size: 12px;
    }

    .footer-credit {
        bottom: 10px;
        right: 10px;
        font-size: 11px;
        padding: 8px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .search-box select,
    .timeline-control,
    .theme-toggle {
        font-size: 13px;
        padding: 10px 16px;
    }

    .mapboxgl-popup-content {
        min-width: 280px;
        max-width: calc(100vw - 40px);
        padding: 16px;
    }

    .popup-title {
        font-size: 18px;
    }

    .popup-description {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .header {
        top: 10px;
        padding: 10px 16px;
        max-width: calc(100% - 80px);
    }

    .header h1 {
        font-size: 16px;
    }

    .header p {
        display: none;
    }

    .menu-toggle {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .controls {
        top: 60px;
        right: 10px;
        left: 10px;
        width: calc(100% - 20px);
    }

    .sidebar {
        top: 60px;
        left: 10px;
        width: calc(100% - 20px);
        max-width: 280px;
    }

    .footer-credit {
        bottom: 5px;
        right: 5px;
        font-size: 10px;
        padding: 6px 10px;
    }

    .footer-credit span {
        display: none;
    }
}
