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

:root {
    color-scheme: light only;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #f1f5f9;
    color: #0f172a;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    z-index: 20;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.search-section {
    display: flex;
    gap: 20px;
    align-items: center;
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    width: 280px;
    padding: 8px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 30px;
    font-size: 0.9rem;
    background: #ffffff;
    transition: all 0.15s;
}

.search-box input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.search-box button {
    background: #0f172a;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.search-box button:hover {
    background: #1e293b;
}

.coords-box {
    display: flex;
    gap: 6px;
}

.coords-box input {
    width: 100px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 30px;
    font-size: 0.9rem;
}

.coords-box input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.coords-box button {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    padding: 8px 16px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

.coords-box button:hover {
    background: #e2e8f0;
}

.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.info-panel h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.info-row .label {
    color: #64748b;
}

.info-row .value {
    font-weight: 500;
    color: #0f172a;
}

.bounds-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin: 16px 0;
}

.bounds-row {
    display: flex;
    justify-content: space-between;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.bounds-row span:first-child {
    color: #64748b;
}

.error-message {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 8px;
    font-size: 0.8rem;
    border-left: 3px solid #dc2626;
    display: none;
}

.nav-panel button {
    width: 100%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    padding: 10px;
    border-radius: 30px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-panel button:hover:not(:disabled) {
    background: #e2e8f0;
}

.nav-panel button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.legend {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid #eef2f6;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #475569;
}

.color-current {
    display: inline-block;
    width: 14px;
    height: 3px;
    background: #d32f2f;
    border-radius: 2px;
}

.color-grid {
    display: inline-block;
    width: 14px;
    height: 3px;
    background: #1976d2;
    border-radius: 2px;
}

.copyright {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eef2f6;
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
}

#map {
    flex: 1;
    position: relative;
    background: #e2e8f0;
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1000;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background-color: #d32f2f;
    box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

.crosshair::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

.crosshair::after {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

.floating-scale-panel {
    position: absolute;
    bottom: 30px;
    left: 300px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border: 1px solid #e2e8f0;
    padding: 16px;
    z-index: 1000;
    min-width: 240px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    color: #0f172a;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
    padding: 0 4px;
}

.close-btn:hover {
    color: #0f172a;
}

.scale-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scale-buttons button {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #0f172a;
    cursor: pointer;
    flex: 1 0 calc(50% - 8px);
    transition: all 0.1s;
}

.scale-buttons button:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.export-btn {
    width: 100%;
    margin-top: 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    padding: 10px;
    border-radius: 30px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.export-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #3b82f6;
}

.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(2px);
    z-index: 2000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    z-index: 2001;
    min-width: 320px;
    border: 1px solid #eef2f6;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 1.2rem;
    text-align: center;
}

.modal-content p {
    color: #475569;
    margin-bottom: 20px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s;
    min-width: 120px;
}

#select-option1,
#select-option2 {
    background: #0f172a;
    color: white;
}

#select-option1:hover,
#select-option2:hover {
    background: #1e293b;
}

.sheet-label {
    color: #1e293b;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    line-height: 1.2;
}

.leaflet-interactive {
    stroke: #1976d2;
}

@media (max-width: 1024px) {
    .top-bar {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
    }
    .search-section {
        flex-wrap: wrap;
        gap: 12px;
        width: 100%;
    }
    .search-box {
        flex: 1;
    }
    .search-box input {
        width: 100%;
    }
    .coords-box {
        width: 100%;
    }
    .coords-box input {
        flex: 1;
        width: auto;
    }
    .sidebar {
        width: 260px;
    }
    .floating-scale-panel {
        left: 280px;
    }
}

@media (max-width: 768px) {
    .export-btn {
            display: none;
    }
    body {
        overflow: auto;
        height: auto;
    }
    #app {
        height: auto;
        min-height: 100vh;
    }
    .main-area {
        flex-direction: column;
        overflow: visible;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 16px;
        order: 2;
    }
    #map {
        height: 70vh;
        min-height: 350px;
        order: 1;
    }
    .top-bar {
        padding: 12px;
    }
    .logo {
        width: 100%;
        justify-content: space-between;
    }
    .search-section {
        margin-top: 8px;
    }
    .search-box {
        flex-wrap: wrap;
    }
    .search-box input {
        width: 100%;
    }
    .search-box button {
        width: 100%;
    }
    .coords-box {
        flex-wrap: wrap;
    }
    .coords-box input {
        width: calc(50% - 4px);
    }
    .coords-box button {
        width: 100%;
        margin-top: 6px;
    }
    .floating-scale-panel {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        width: auto;
        max-width: 400px;
        margin: 0 auto;
    }
    .modal {
        width: 90%;
        min-width: auto;
        max-width: 360px;
    }
}

@media (max-width: 480px) {
    .export-btn {
            display: none;
    }
    .logo h1 {
        font-size: 1.2rem;
    }
    .badge {
        font-size: 0.6rem;
    }
    .info-panel h3 {
        font-size: 0.75rem;
    }
    .bounds-box {
        padding: 8px;
    }
    .floating-scale-panel {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
    .scale-buttons button {
        flex: 1 0 100%;
    }

    .copyright {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    }
    .github-link {
        margin-left: 0;
        border-left: none;
        padding-left: 0;
    }
}

.leaflet-overlay-pane path.leaflet-interactive[stroke="#d32f2f"],
.leaflet-overlay-pane path.leaflet-interactive[stroke="#D32F2F"] {
    stroke: #d32f2f !important;
}
.leaflet-overlay-pane path.leaflet-interactive[stroke="#1976d2"],
.leaflet-overlay-pane path.leaflet-interactive[stroke="#1976D2"] {
    stroke: #1976d2 !important;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.15s;
    border-left: 1px solid #e2e8f0;
    padding-left: 8px;
}

.github-link:hover {
    color: #0f172a;
}

.github-link svg {
    opacity: 0.7;
}

.github-link:hover svg {
    opacity: 1;
}