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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

#controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    width: 300px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

#controls h2 {
    font-size: 1.3em;
    margin-bottom: 4px;
    color: #1a1a2e;
}

.hint {
    font-size: 0.8em;
    color: #666;
    margin-bottom: 16px;
}

.control-group {
    margin-bottom: 14px;
}

.control-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

input[type="datetime-local"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s;
}

input[type="datetime-local"]:focus {
    border-color: #4a90d9;
}

.toggle-group {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.toggle {
    flex: 1;
    padding: 8px;
    border: none;
    background: #f5f5f5;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.toggle.active {
    background: #4a90d9;
    color: white;
}

.toggle:hover:not(.active) {
    background: #e8e8e8;
}

input[type="range"] {
    width: 100%;
    margin: 4px 0;
    accent-color: #4a90d9;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7em;
    color: #999;
}

#calculate-btn {
    width: 100%;
    padding: 12px;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

#calculate-btn:hover:not(:disabled) {
    background: #3a7bc8;
    transform: translateY(-1px);
}

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

#loading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 8px;
    font-size: 0.85em;
    color: #4a90d9;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#error-msg {
    margin-top: 12px;
    padding: 10px;
    background: #fff0f0;
    border: 1px solid #ffcccc;
    border-radius: 8px;
    font-size: 0.85em;
    color: #cc3333;
}

#results {
    margin-top: 16px;
}

.result-card {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.result-card.shaded {
    background: linear-gradient(135deg, #e8f4fd, #dceefb);
    border-left: 3px solid #4a90d9;
}

.result-card.shortest {
    background: #f5f5f5;
    border-left: 3px solid #e74c3c;
}

.result-card h3 {
    font-size: 0.9em;
    margin-bottom: 8px;
    color: #333;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 0.82em;
}

.stat-label {
    color: #666;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

.stat-value.highlight {
    color: #2d7a2d;
    font-size: 1.05em;
}

#sun-info {
    text-align: center;
    font-size: 0.78em;
    color: #888;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

#legend {
    position: absolute;
    bottom: 24px;
    left: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.8em;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
    color: #444;
}

.legend-line {
    display: inline-block;
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.shaded-line {
    background: #2563eb;
}

.legend-line.shortest-line {
    background: #e74c3c;
    border-top: 2px dashed #e74c3c;
    height: 0;
}

.legend-swatch {
    display: inline-block;
    width: 16px;
    height: 12px;
    background: rgba(50, 50, 80, 0.35);
    border-radius: 2px;
}

.locate-control a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #333;
    text-decoration: none;
}

.locate-control a:hover {
    background: #f4f4f4;
}

.locate-control.locating a {
    color: #4a90d9;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hidden {
    display: none !important;
}
