:root {
    color-scheme: light;
    --bg-gradient: linear-gradient(180deg,
            #1D1135 0%,
            #4A2D7A 25%,
            #7E57C2 50%,
            #B39DDB 75%,
            #EDE7F6 100%);
    --md-sys-color-background: #EDE7F6;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-primary: #6750A4;
    --md-sys-color-primary-dark: #381E72;
    --md-sys-color-primary-light: #D0BCFF;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-secondary: #EADDFF;
    --md-sys-color-on-surface: #1D1B20;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.1);
    --md-elevation-3: 0 8px 16px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--md-sys-color-on-surface);
}

button {
    font: inherit;
}

#app-shell {
    position: relative;
    width: 100%;
    height: 100%;
}

.top-app-bar {
    position: absolute;
    top: 18px;
    right: 18px;
    left: 18px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 76px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(103, 80, 164, 0.88), rgba(56, 30, 114, 0.86));
    border: 1px solid rgba(234, 221, 255, 0.32);
    border-radius: 28px;
    box-shadow: var(--md-elevation-3);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: var(--md-sys-color-primary-dark);
    background: var(--md-sys-color-secondary);
    border-radius: 16px;
    box-shadow: var(--md-elevation-1);
}

.brand-mark .material-symbols-rounded {
    font-size: 28px;
}

.eyebrow,
.top-app-bar h1 {
    margin: 0;
}

.eyebrow {
    color: rgba(234, 221, 255, 0.9);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.top-app-bar h1 {
    margin-top: 2px;
    color: #FFFBFE;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
}

.style-switcher {
    display: grid;
    gap: 6px;
    min-width: 180px;
}

.style-switcher label {
    color: rgba(234, 221, 255, 0.9);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.style-switcher select {
    min-height: 44px;
    padding: 0 44px 0 16px;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, var(--md-sys-color-primary) 50%) calc(100% - 22px) 18px / 7px 7px no-repeat,
        linear-gradient(135deg, var(--md-sys-color-primary) 50%, transparent 50%) calc(100% - 16px) 18px / 7px 7px no-repeat,
        rgba(255, 251, 254, 0.94);
    border: 1px solid rgba(234, 221, 255, 0.62);
    border-radius: 14px;
    outline: none;
}

.style-switcher select:focus {
    border-color: var(--md-sys-color-primary-light);
    box-shadow: 0 0 0 3px rgba(208, 188, 255, 0.32);
}

.map-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-gradient);
}

#map {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.map-stage::after {
    position: absolute;
    inset: 0;
    pointer-events: none;
    content: "";
    background:
        linear-gradient(180deg, rgba(29, 17, 53, 0.28) 0%, rgba(29, 17, 53, 0) 34%),
        linear-gradient(0deg, rgba(29, 17, 53, 0.22) 0%, rgba(29, 17, 53, 0) 28%);
    z-index: 1;
}

.fab {
    position: absolute;
    right: 28px;
    bottom: 28px;
    z-index: 4;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    color: var(--md-sys-color-on-primary);
    cursor: pointer;
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-primary-dark));
    border: 0;
    border-radius: 20px;
    box-shadow: var(--md-elevation-3);
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.fab:hover {
    transform: translateY(-2px);
}

.fab:active {
    transform: translateY(0) scale(0.98);
}

.fab:disabled {
    cursor: wait;
    opacity: 0.72;
}

.fab .material-symbols-rounded {
    font-size: 30px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.snackbar {
    position: absolute;
    right: 24px;
    bottom: 108px;
    max-width: min(420px, calc(100% - 48px));
    padding: 14px 18px;
    color: var(--md-sys-color-on-surface);
    pointer-events: none;
    visibility: hidden;
    background: rgba(255, 251, 254, 0.96);
    border: 1px solid rgba(202, 196, 208, 0.64);
    border-radius: 16px;
    box-shadow: var(--md-elevation-3);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.snackbar.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.user-marker {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--md-sys-color-on-primary);
    background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-primary-dark));
    border: 3px solid #FFFBFE;
    border-radius: 50%;
    box-shadow: 0 8px 22px rgba(56, 30, 114, 0.38);
}

.user-marker .material-symbols-rounded {
    font-size: 24px;
}

.accuracy-circle {
    width: 12px;
    height: 12px;
    background: rgba(208, 188, 255, 0.28);
    border: 2px solid var(--md-sys-color-primary);
    border-radius: 999px;
}

@media (max-width: 640px) {
    .top-app-bar {
        top: 12px;
        right: 12px;
        left: 12px;
        align-items: stretch;
        flex-direction: column;
        min-height: 72px;
        padding: 12px 16px;
        border-radius: 24px;
    }

    .style-switcher {
        min-width: 100%;
    }

    .brand-mark {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .fab {
        right: 18px;
        bottom: 28px;
        width: 58px;
        height: 58px;
        border-radius: 18px;
    }

    .snackbar {
        right: 16px;
        bottom: 100px;
        max-width: calc(100% - 32px);
    }

    .location-widget {
        right: 18px;
        bottom: 96px;
    }

    .location-panel {
        width: calc(100vw - 24px);
        max-width: 360px;
        padding: 14px 16px;
        border-radius: 20px;
    }
}

/* Location widget: collapsed = circular FAB, expanded = panel */
.location-widget {
    position: absolute;
    right: 28px;
    bottom: 104px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

.location-widget > * {
    pointer-events: auto;
}

.location-fab {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    color: var(--md-sys-color-on-primary, #fff);
    background: linear-gradient(135deg, var(--md-sys-color-primary, #6750A4), var(--md-sys-color-primary-dark, #381E72));
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--md-elevation-3, 0 4px 12px rgba(0, 0, 0, 0.22));
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.location-fab:hover {
    transform: translateY(-2px);
}

.location-fab:active {
    transform: translateY(0) scale(0.96);
}

.location-fab .material-symbols-rounded {
    font-size: 28px;
}

.location-widget.is-expanded .location-fab {
    transform: scale(0.85);
    opacity: 0.85;
}

.location-panel {
    width: min(86vw, 360px);
    padding: 16px 20px 14px;
    background: var(--md-sys-color-surface, #FFFBFE);
    color: var(--md-sys-color-on-surface, #1D1B20);
    border-radius: 24px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.18),
        0 4px 16px rgba(0, 0, 0, 0.16);
    transform-origin: bottom right;
    animation: location-panel-in 180ms ease;
}

@keyframes location-panel-in {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.location-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.location-panel-header .material-symbols-rounded {
    color: var(--md-sys-color-primary, #6750A4);
    font-size: 20px;
}

.location-panel-header h2 {
    flex: 1;
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--md-sys-color-on-surface, #1D1B20);
}

.location-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin: -4px -8px -4px 0;
    color: var(--md-sys-color-on-surface-variant, #49454F);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.location-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.location-close .material-symbols-rounded {
    font-size: 20px;
}

.location-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin: 0 0 10px;
}

.location-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.location-field dt {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}

.location-field dd {
    margin: 2px 0 0;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface, #1D1B20);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-status {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.78rem;
    color: var(--md-sys-color-on-surface-variant, #49454F);
}
