* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: #0b1220;
    color: #e2e8f0;
}

.welcome-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 13, 24, 0.65);
    backdrop-filter: blur(2px);
    padding: 20px;
}

.welcome-card {
    width: min(920px, 100%);
    background: #0f1d39;
    border: 1px solid #264a85;
    border-radius: 22px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.welcome-card h2 {
    margin: 0 0 14px;
    font-size: clamp(34px, 4.2vw, 52px);
    line-height: 1.1;
}

.welcome-card p {
    margin: 0 0 10px;
    font-size: clamp(22px, 2.4vw, 44px);
    line-height: 1.25;
    color: #d7e4ff;
}

.stats-modal {
    position: fixed;
    inset: 0;
    z-index: 1900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 13, 24, 0.65);
    backdrop-filter: blur(2px);
    padding: 20px;
}

.stats-card {
    width: min(980px, 100%);
    background: #0f1d39;
    border: 1px solid #264a85;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.stats-header h2 {
    margin: 0;
    font-size: 20px;
}

.stats-subtitle {
    margin: 8px 0 12px;
    color: #bdd0f3;
    font-size: 13px;
}

.stats-chart-wrap {
    width: 100%;
    border: 1px solid #24304a;
    border-radius: 10px;
    background: #0c1528;
    padding: 10px;
}

#statsChartCanvas {
    width: 100%;
    height: 340px;
    display: block;
}

.stats-empty {
    margin: 10px 0 0;
    color: #cbd5e1;
    font-size: 13px;
}

.stats-legend {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stats-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #111b30;
    color: #d8e7ff;
    font-size: 12px;
}

.stats-legend-color {
    width: 8px;
    height: 8px;
    border-radius: 999px;
}

#closeWelcomeBtn {
    margin-top: 18px;
    width: auto;
    min-width: 190px;
    padding: 0 20px;
}

.topbar {
    padding: 18px 20px;
    border-bottom: 1px solid #24304a;
    background: #101a2e;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    margin: 0;
    text-transform: lowercase;
    letter-spacing: 0.4px;
}

.topbar p {
    margin: 4px 0 0;
    color: #9fb0d1;
}

.map-tabs {
    display: flex;
    gap: 8px;
}

.map-tab-btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #35507e;
    background: #1b2a44;
    color: #d8e7ff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.map-tab-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    padding: 16px;
    min-height: calc(100vh - 88px);
}

.panel {
    background: #111b30;
    border: 1px solid #24304a;
    border-radius: 12px;
    padding: 14px;
}

.controls h2 {
    margin: 0 0 8px;
}

.controls h3 {
    margin: 16px 0 8px;
}

.controls p {
    margin: 0 0 12px;
    color: #cbd5e1;
}

.mood-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.mood-btn {
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #334155;
    background: #0c1528;
    color: #d9e5ff;
    cursor: pointer;
    font-weight: 600;
}

.mood-btn.active {
    border-color: #38bdf8;
    background: #163652;
    color: #d9f5ff;
}

label {
    display: block;
    margin: 10px 0 6px;
    font-size: 14px;
}

input {
    width: 100%;
    height: 38px;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0 10px;
    background: #0c1528;
    color: #e2e8f0;
}

#timeRangeFilter {
    width: 100%;
    height: 38px;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0 10px;
    background: #0c1528;
    color: #e2e8f0;
}

.helper-text {
    margin-top: 8px !important;
    font-size: 12px;
    color: #9fb0d1 !important;
}

.note-warning {
    min-height: 18px;
    margin: 8px 0 0;
    color: #fda4af;
    font-size: 12px;
    font-weight: 600;
}

.actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

button {
    height: 40px;
    border: 0;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

button.primary {
    background: #3b82f6;
    color: #ffffff;
}

button.primary:hover {
    background: #2563eb;
}

button.secondary {
    background: #1b2a44;
    color: #d8e7ff;
    border: 1px solid #35507e;
}

button.secondary:hover {
    background: #223557;
}

.legend {
    margin-top: 14px;
    display: grid;
    gap: 8px;
    color: #bdd0f3;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.filter-x {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid #435a86;
    background: #1b2a44;
    color: #d8e7ff;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.filter-x:hover {
    background: #223557;
}

.filter-x.is-filtered {
    background: #5b1f2a;
    border-color: #a83b51;
    color: #ffd5dd;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-right: 8px;
}

.sadness {
    background: #3b82f6;
}

.anger {
    background: #ef4444;
}

.anxiety {
    background: #a855f7;
}

.calm {
    background: #22c55e;
}

.excitement {
    background: #f97316;
}

.loneliness {
    background: #6b7280;
}

.confused {
    background: #14b8a6;
}

.map-panel {
    padding: 0;
    overflow: hidden;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 560px;
}

.emotion-heatmap-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mood-pin {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.mood-pin-wrap {
    position: relative;
    width: 16px;
    height: 16px;
}

.mood-pin-badge {
    position: absolute;
    top: -8px;
    left: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 14px;
    min-width: 22px;
    padding: 0 5px;
    border-radius: 999px;
    background: #2563eb;
    border: 1px solid #ffffff;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.leaflet-control-attribution {
    font-size: 10px !important;
    background: rgba(12, 21, 40, 0.72) !important;
    color: #c4d4f5 !important;
    border-radius: 8px !important;
    padding: 2px 6px !important;
    margin: 8px !important;
}

.leaflet-control-attribution a {
    color: #d9e5ff !important;
}

.popup-delete-btn {
    margin-top: 8px;
    height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    border: 0;
    background: #b91c1c;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.popup-delete-btn:hover {
    background: #991b1b;
}

.me-tag {
    font-size: 11px;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.add-pin-popup .leaflet-popup-content-wrapper {
    background: #111b30;
    color: #e2e8f0;
    border: 1px solid #24304a;
}

.add-pin-popup .leaflet-popup-tip {
    background: #111b30;
}

.pin-composer {
    min-width: 230px;
    display: grid;
    gap: 8px;
}

.pin-composer label {
    margin: 0;
    font-size: 12px;
    color: #cbd5e1;
}

.pin-composer input[type='range'] {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.pin-composer select {
    width: 100%;
    height: 34px;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0 8px;
    background: #0c1528;
    color: #e2e8f0;
}

.sentence-builder {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.sentence-builder span {
    font-size: 12px;
    color: #cbd5e1;
}

.sentence-builder label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 12px;
    color: #cbd5e1;
}

.sentence-builder input[type='checkbox'] {
    width: auto;
    height: auto;
}

.sentence-builder select:disabled {
    opacity: 0.55;
}

.pin-composer small {
    color: #9fb0d1;
    min-height: 16px;
}

.pin-composer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pin-composer-actions button {
    height: 30px;
    border-radius: 6px;
    border: 1px solid #35507e;
    background: #1b2a44;
    color: #d8e7ff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.pin-composer-actions button[data-add-pin-confirm] {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    #map {
        min-height: 440px;
    }

    .actions-row {
        grid-template-columns: 1fr;
    }

    #statsChartCanvas {
        height: 280px;
    }

}
