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

:root {
    color-scheme: light dark;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: white;
    color: #333;
}

/* Dark theme via media query */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        background: #1e1e1e;
    }

    html:not([data-theme="light"]) body {
        background: #1e1e1e;
        color: #e0e0e0;
    }
}

/* Dark theme via explicit attribute */
html[data-theme="dark"] {
    background: #1e1e1e;
}

html[data-theme="dark"] body {
    background: #1e1e1e;
    color: #e0e0e0;
}

/* Light theme via explicit attribute */
html[data-theme="light"] {
    background: white;
}

html[data-theme="light"] body {
    background: white;
    color: #333;
}

#map {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
}

html[data-theme="dark"] #map {
    background: #1a1a1a;
}

.controls {
    position: fixed;
    top: 10px;
    right: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 320px;
    display: none;
}

/* Dark theme via media query */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .controls {
        background: #2d2d2d;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    }
}

/* Dark theme via explicit attribute */
html[data-theme="dark"] .controls {
    background: #2d2d2d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Light theme via explicit attribute */
html[data-theme="light"] .controls {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.controls-header {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

#themeToggle {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #666;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 1000;
}

#themeToggle:hover {
    background: #555;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) #themeToggle {
        background: #555;
    }

    html:not([data-theme="light"]) #themeToggle:hover {
        background: #666;
    }
}

html[data-theme="dark"] #themeToggle {
    background: #555;
}

html[data-theme="dark"] #themeToggle:hover {
    background: #666;
}

#refreshBtn {
    position: fixed;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 1000;
}

#refreshBtn:hover {
    background: #0052a3;
}

#refreshBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) #refreshBtn {
        background: #0066cc;
    }

    html:not([data-theme="light"]) #refreshBtn:hover {
        background: #0052a3;
    }

    html:not([data-theme="light"]) #refreshBtn:disabled {
        background: #555;
    }
}

html[data-theme="dark"] #refreshBtn {
    background: #0066cc;
}

html[data-theme="dark"] #refreshBtn:hover {
    background: #0052a3;
}

html[data-theme="dark"] #refreshBtn:disabled {
    background: #555;
}

.btn-refresh,
.btn-theme {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-theme:hover {
    background: #555;
}

.btn-refresh:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Dark theme button styles via media query */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .btn-refresh {
        background: #0066cc;
    }

    html:not([data-theme="light"]) .btn-refresh:hover {
        background: #0052a3;
    }

    html:not([data-theme="light"]) .btn-refresh:disabled {
        background: #555;
    }

    html:not([data-theme="light"]) .btn-theme {
        background: #555;
    }

    html:not([data-theme="light"]) .btn-theme:hover {
        background: #666;
    }
}

/* Dark theme button styles via explicit attribute */
html[data-theme="dark"] .btn-refresh {
    background: #0066cc;
}

html[data-theme="dark"] .btn-refresh:hover {
    background: #0052a3;
}

html[data-theme="dark"] .btn-refresh:disabled {
    background: #555;
}

html[data-theme="dark"] .btn-theme {
    background: #555;
}

html[data-theme="dark"] .btn-theme:hover {
    background: #666;
}

.status {
    position: fixed;
    bottom: 10px;
    left: 10px;
    max-width: 400px;
    margin-top: 0;
    padding: 10px 12px;
    font-size: 12px;
    color: #666;
    min-height: 40px;
    white-space: pre-wrap;
    word-break: break-word;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
}

html[data-theme="dark"] .status {
    background: rgba(45, 45, 45, 0.95);
}

.status.loading {
    color: #0066cc;
}

.status.error {
    color: #d32f2f;
}

.status.success {
    color: #388e3c;
}

/* Dark theme status styles via media query */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .status {
        color: #aaa;
    }

    html:not([data-theme="light"]) .status.loading {
        color: #4a9eff;
    }

    html:not([data-theme="light"]) .status.error {
        color: #ff6b6b;
    }

    html:not([data-theme="light"]) .status.success {
        color: #69bb6e;
    }
}

/* Dark theme status styles via explicit attribute */
html[data-theme="dark"] .status {
    color: #aaa;
}

html[data-theme="dark"] .status.loading {
    color: #4a9eff;
}

html[data-theme="dark"] .status.error {
    color: #ff6b6b;
}

html[data-theme="dark"] .status.success {
    color: #69bb6e;
}

/* Leaflet attribution adjustment */
.leaflet-bottom.leaflet-right {
    margin-right: 10px;
    margin-bottom: 10px;
}
