/* Stage 1 map chrome: scoped to the map application; legacy feature screens stay intact. */
html:has(#app) { background: var(--night); }
body:has(#app) {
    min-width: 320px;
    overflow: hidden;
    background: var(--night);
    color: var(--paper);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
}

#app.app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    background: var(--night);
}

#app .header {
    z-index: 1000;
    flex: 0 0 auto;
    border: 0;
    border-bottom: 1px solid rgba(196, 181, 253, .18);
    background: rgba(18, 10, 28, .96);
    box-shadow: 0 8px 24px rgba(8, 3, 14, .2);
    backdrop-filter: blur(16px);
}

#app .header-content {
    display: flex;
    width: 100%;
    max-width: none;
    min-height: 74px;
    align-items: center;
    gap: clamp(14px, 2.1vw, 34px);
    margin: 0;
    padding: 12px clamp(16px, 2.4vw, 38px);
}

.map-brand {
    display: inline-flex;
    min-width: max-content;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    color: var(--paper);
    text-decoration: none;
}

.map-brand img { width: 40px; height: 40px; object-fit: contain; }
.map-brand span {
    font: 700 25px/.95 var(--display);
    letter-spacing: -.035em;
}
.map-brand:focus-visible { outline: 2px solid var(--lilac); outline-offset: 4px; border-radius: 6px; }

#app .search-section {
    position: relative;
    flex: 1 1 470px;
    min-width: 180px;
    max-width: 700px;
    margin: 0 auto;
}

#app .search-controls { display: flex; flex-direction: row; min-width: 0; align-items: center; gap: 9px; margin: 0; }
#app .search-input-container {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 46px;
    flex: 1 1 auto;
    align-items: center;
    gap: 11px;
    padding: 0 12px 0 15px;
    border: 1px solid rgba(196, 181, 253, .25);
    border-radius: 999px;
    background: #1A0F24;
    box-shadow: inset 0 1px rgba(255,255,255,.025);
    transition: border-color .18s ease, background-color .18s ease;
}

#app .search-input-container:focus-within {
    border-color: rgba(196, 181, 253, .65);
    background: #21152d;
}

#app .search-input {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--paper);
    font: 400 13px/1.3 var(--sans);
}

#app .search-input::placeholder { color: #A99AB8; opacity: 1; }
#app .search-icon, #app .clear-search-button svg, .type-filter-wrap > svg,
.map-quick-filter svg, .header-decoration svg, .avatar-dd-item svg,
.map-phone-tab svg {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#app .search-icon {
    position: static;
    transform: none;
    margin: 0;
    color: var(--lavender);
}
#app .clear-search-button {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
#app .clear-search-button:hover { background: rgba(167,139,250,.14); color: var(--paper); }
#app .clear-search-button[hidden], #app [hidden] { display: none !important; }

.type-filter-wrap {
    position: relative;
    display: flex;
    min-width: 132px;
    min-height: 46px;
    align-items: center;
    gap: 8px;
    padding: 0 34px 0 13px;
    border: 1px solid rgba(196, 181, 253, .25);
    border-radius: 999px;
    background: #1A0F24;
    color: var(--lavender);
}

.type-filter-wrap > svg:first-child { width: 17px; height: 17px; }
.type-filter-wrap .type-chevron {
    position: absolute;
    right: 11px;
    width: 15px;
    height: 15px;
    pointer-events: none;
}
#app .location-filter {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0;
    appearance: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--paper);
    font: 500 12px/1 var(--sans);
    cursor: pointer;
}
#app .location-filter option { background: #1A0F24; color: var(--paper); }
#app .search-results-info { margin: 6px 0 0 17px; color: var(--muted); font-size: 11px; }

#app .header-decoration {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

#app .header-nav-pill, #app .nav-pill-btn {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: #D6CBE3;
    font: 500 12px/1 var(--sans);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
#app .header-nav-pill svg, #app .nav-pill-btn svg { width: 18px; height: 18px; color: var(--lavender); }
#app .header-nav-pill:hover, #app .nav-pill-btn:hover {
    border-color: rgba(167,139,250,.24);
    background: rgba(61,42,77,.55);
    color: var(--paper);
}

#app .header-avatar-wrapper { position: relative; margin-left: 4px; }
#app .header-avatar-btn {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    overflow: hidden;
    padding: 0;
    border: 1px solid rgba(196,181,253,.36);
    border-radius: 50%;
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    color: var(--lilac);
    cursor: pointer;
}
#app .header-avatar-btn:hover { border-color: var(--lilac); background: #3D2A4D; }
#app .header-avatar-btn > i { font-size: 20px; }
#app #header-avatar-initial {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: var(--paper);
    font: 700 16px/1 var(--sans);
}
#app #header-avatar-icon {
    visibility: hidden !important;
    opacity: 0 !important;
}
#app .header-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#app .avatar-dropdown {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 10px);
    right: 0;
    display: grid;
    width: 214px;
    gap: 3px;
    padding: 7px;
    border: 1px solid rgba(167,139,250,.3);
    border-radius: 16px;
    background: #1A0F24;
    box-shadow: 0 18px 45px rgba(5,2,10,.46);
}
#app .avatar-dropdown.hidden { display: none; }
#app .avatar-dd-item {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    gap: 11px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--body);
    font: 500 13px/1 var(--sans);
    text-align: left;
    cursor: pointer;
}
#app .avatar-dd-item:hover { background: rgba(61,42,77,.65); color: var(--paper); }
#app .avatar-dd-item svg { width: 17px; height: 17px; color: var(--lavender); }
#app .avatar-dd-item i { font-size: 17px; color: var(--lavender); }
#app .avatar-dd-logout { border-top: 1px solid rgba(167,139,250,.16); border-radius: 0 0 10px 10px; }

#app .map-login-button { margin-left: 2px; }

#app .main-content {
    position: relative;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    background: #15101c;
}
#app .map-container {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #191421;
    touch-action: pan-x pan-y;
}

.map-quick-filters {
    position: absolute;
    z-index: 125;
    top: 14px;
    left: 16px;
    display: flex;
    max-width: calc(100% - 88px);
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 2px 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
.map-quick-filters::-webkit-scrollbar { display: none; }
.map-quick-filter {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid rgba(196,181,253,.22);
    border-radius: 999px;
    background: rgba(20,11,31,.9);
    color: #E4D9EF;
    font: 500 12px/1 var(--sans);
    white-space: nowrap;
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease;
}
.map-quick-filter:hover { border-color: rgba(196,181,253,.52); background: rgba(45,27,61,.96); }
.map-quick-filter.is-active {
    border-color: rgba(196,181,253,.58);
    background: #8B5CF6;
    color: #fff;
}

#app .most-feared-badge {
    top: 67px;
    left: 18px;
    z-index: 124;
    max-width: min(370px, calc(100% - 36px));
    min-height: 44px;
    padding: 10px 15px;
    border: 1px solid rgba(248,113,142,.42);
    border-radius: 12px;
    background: rgba(35,15,31,.93);
    color: #F5EAF1;
    box-shadow: 0 8px 22px rgba(8,3,14,.28);
}

#app .nearby-locations {
    right: auto;
    bottom: 16px;
    left: 18px;
    width: min(560px, calc(100% - 36px));
    max-width: 560px;
    color: var(--paper);
}
#app #nearby-panel {
    padding: 13px 14px 12px;
    border-color: rgba(167,139,250,.28);
    border-radius: 20px;
    background: rgba(18,10,28,.94);
    box-shadow: 0 15px 38px rgba(8,3,14,.34);
    backdrop-filter: blur(18px);
}
#app .nearby-locations-header { min-height: 42px; padding: 0 1px 8px; }
#app .nearby-locations-heading { color: var(--paper); font: 700 24px/.95 var(--display); letter-spacing: -.02em; }
#app #nearby-collapse, #app #nearby-expand {
    border-color: rgba(196,181,253,.3);
    border-radius: 50%;
    background: #2D1B3D;
    color: var(--lilac);
}
#app #nearby-expand {
    width: auto;
    min-width: 92px;
    padding-inline: 16px;
    border-radius: 999px;
    white-space: nowrap;
}
#app #nearby-list { gap: 8px; padding-bottom: 2px; }
#app #nearby-list .nearby-card {
    width: 224px;
    min-height: 84px;
    gap: 10px;
    padding: 8px;
    border-color: rgba(167,139,250,.2);
    border-radius: 13px;
    background: rgba(45,27,61,.82);
}
#app #nearby-list .nearby-card img { width: 64px; height: 64px; flex-basis: 64px; border-radius: 9px; }
#app .nearby-card-name { color: var(--paper); font: 600 13px/1.3 var(--sans); }
#app .nearby-card-meta { color: #B8A9C6; font: 400 10px/1.3 var(--sans); }

#app #map-location-toast {
    top: 16px;
    z-index: 140;
    padding: 11px 16px;
    border-color: rgba(196,181,253,.32);
    border-radius: 14px;
    background: rgba(20,11,31,.96);
    color: var(--paper);
    box-shadow: 0 12px 30px rgba(8,3,14,.35);
    font: 500 12px/1.45 var(--sans);
}

#app .mapboxgl-ctrl-group {
    overflow: hidden;
    border: 1px solid rgba(196,181,253,.26) !important;
    border-radius: 13px !important;
    background: rgba(20,11,31,.92) !important;
    box-shadow: 0 8px 22px rgba(8,3,14,.28) !important;
}
#app .mapboxgl-ctrl-group button {
    width: 44px;
    height: 44px;
    background: rgba(26,15,36,.94) !important;
    color: #FFFFFF !important;
}
#app .map-location-control.mapboxgl-ctrl-group button#locate-me-button {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9) !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 18px rgba(139,92,246,.35);
}
.hm-location-pin::after {
    position: absolute;
    top: -2px;
    left: -9px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    content: "";
}
#app .map-user-marker, #app .map-user-marker * {
    pointer-events: none !important;
}
#app .mapboxgl-ctrl-group button + button { border-top-color: rgba(196,181,253,.16) !important; }
#app .mapboxgl-ctrl button .mapboxgl-ctrl-icon { filter: invert(.9) sepia(.2) saturate(.7) hue-rotate(220deg); }
#app .mapboxgl-ctrl-attrib {
    margin: 0 5px 5px 0;
    border: 1px solid rgba(196,181,253,.17);
    border-radius: 7px;
    background: rgba(20,11,31,.8) !important;
    color: #D6CBE3 !important;
    font: 10px/1.4 var(--sans);
}
#app .mapboxgl-ctrl-attrib a { color: #D6CBE3 !important; }

.map-phone-tabs { display: none; }

#app #location-denied-banner {
    z-index: 1001;
    border: 0 !important;
    border-bottom: 1px solid rgba(167,139,250,.25) !important;
    background: #1A0F24 !important;
}
#app #location-denied-banner p { color: var(--body) !important; font-family: var(--sans); }
#app #location-denied-banner button { color: var(--lilac) !important; }
#app #migration-notice-banner { z-index: 1002; }

@media (min-width: 768px) and (max-width: 1120px) {
    #app .header-content { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; padding: 9px 22px 12px; }
    #app .map-brand { grid-column: 1; grid-row: 1; }
    #app .header-decoration { grid-column: 2; grid-row: 1; }
    #app .search-section { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; }
    .map-quick-filters { top: 13px; }
}

@media (max-width: 767px) {
    #app .header-content {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 12px;
        min-height: 0;
        padding: max(8px, env(safe-area-inset-top)) 12px 10px;
    }
    .map-brand { grid-column: 1; grid-row: 1; gap: 7px; }
    .map-brand img { width: 36px; height: 36px; }
    .map-brand span { font-size: 23px; }
    #app .header-decoration { display: contents; }
    #app .header-decoration > .header-nav-pill,
    #app .header-decoration > .groups-pill,
    #app .header-decoration > .rank-pill { display: none; }
    #app .header-avatar-wrapper { grid-column: 2; grid-row: 1; }
    #app .header-avatar-btn { width: 44px; height: 44px; }
    #app .map-login-button { grid-column: 2; grid-row: 1; margin: 0; padding-inline: 12px; font-size: 12px; }
    #app .search-section { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; margin: 0; }
    #app .search-controls { gap: 7px; }
    #app .search-input-container { min-height: 44px; gap: 8px; padding-left: 12px; }
    #app .search-input { height: 40px; font-size: 12px; }
    #app .search-input::placeholder { font-size: 11px; }
    .type-filter-wrap { min-width: 106px; min-height: 44px; gap: 5px; padding-left: 10px; padding-right: 28px; }
    .type-filter-wrap > svg:first-child { width: 15px; height: 15px; }
    #app .location-filter { font-size: 11px; }
    .type-filter-wrap .type-chevron { right: 8px; }
    #app .search-results-info { margin-top: 4px; }
    .map-quick-filters {
        top: 10px;
        left: 10px;
        max-width: calc(100% - 84px);
        gap: 6px;
    }
    #app #location-denied-banner { padding: 4px 10px !important; }
    #app #location-denied-banner p {
        padding-right: 44px !important;
        font-size: 13px !important;
        line-height: 1.2 !important;
        text-align: left !important;
    }
    .map-quick-filter { min-height: 44px; padding-inline: 12px; font-size: 11px; }
    #app .most-feared-badge { top: 61px; left: 12px; max-width: calc(100% - 24px); }
    #app .main-content { min-height: 0; }
    #app .nearby-locations {
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    #app #nearby-panel { padding: 9px 10px 9px; border-radius: 17px; }
    #app .nearby-locations-header { min-height: 38px; padding-bottom: 5px; }
    #app .nearby-locations-heading { font-size: 22px; }
    #app #nearby-list .nearby-card { width: min(216px, calc(100vw - 68px)); min-height: 74px; }
    #app #nearby-list .nearby-card img { width: 56px; height: 56px; flex-basis: 56px; }
    #app #map-location-toast { top: 10px; max-width: calc(100% - 24px); }
    .map-phone-tabs {
        position: relative;
        z-index: 1100;
        display: grid;
        height: calc(72px + env(safe-area-inset-bottom));
        flex: 0 0 calc(72px + env(safe-area-inset-bottom));
        grid-template-columns: repeat(4, minmax(0, 1fr));
        padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
        border-top: 1px solid rgba(196,181,253,.18);
        background: rgba(11,6,18,.98);
        box-shadow: 0 -8px 24px rgba(8,3,14,.2);
        backdrop-filter: blur(15px);
    }
    .map-phone-tabs:has(#map-tab-vault[hidden]) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .map-phone-tab {
        display: flex;
        min-width: 44px;
        min-height: 44px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #A99AB8;
        font: 500 10px/1 var(--sans);
        text-decoration: none;
        cursor: pointer;
        touch-action: manipulation;
    }
    .map-phone-tab svg { width: 19px; height: 19px; }
    .map-phone-tab.is-active { background: rgba(109,40,217,.2); color: var(--lilac); }
    .map-phone-tab:focus-visible { outline: 2px solid var(--lilac); outline-offset: -2px; }
}

@media (max-width: 390px) {
    #app .header-content { padding-inline: 10px; }
    #app .search-controls { gap: 5px; }
    .type-filter-wrap { min-width: 98px; padding-left: 8px; padding-right: 26px; }
    #app .search-input::placeholder { font-size: 10px; }
    .map-quick-filters { gap: 5px; }
    .map-quick-filter { padding-inline: 10px; }
}

@media (max-width: 767px) {
    #app .search-input, #app .location-filter { font-size: 16px; }
    #app .search-input::placeholder { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    #app *, #app *::before, #app *::after, .map-quick-filter {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Stage 2 place card: docked desktop inspector and a map-native mobile sheet. */
#place-card-modal.place-card-modal {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: flex;
    width: auto;
    height: auto;
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
    pointer-events: none;
    background: transparent;
}

#place-card-modal .place-card-overlay { display: none; }

#place-card-modal .place-card {
    position: fixed !important;
    top: calc(var(--map-header-bottom, 74px) + 20px) !important;
    right: 20px !important;
    bottom: 20px !important;
    left: auto !important;
    display: flex !important;
    width: 440px !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: calc(100vw - 40px) !important;
    max-height: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: 1px solid rgba(196,181,253,.22) !important;
    border-radius: 24px !important;
    background: #140B1F !important;
    box-shadow: 0 24px 70px rgba(5,2,10,.48), 0 4px 18px rgba(8,3,14,.28) !important;
    pointer-events: auto;
    transform: translateX(calc(100% + 32px)) !important;
    transition: transform .28s cubic-bezier(.2,.72,.22,1) !important;
}

#place-card-modal.show .place-card {
    transform: translateX(0) !important;
}

.map-sheet-handle { display: none; }
#place-card-modal .place-card-topbar {
    display: flex;
    min-height: 56px;
    flex: 0 0 56px;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(167,139,250,.18);
    background: #140B1F;
}
#place-card-modal.hidden, #place-card-modal .hidden {
    display: none !important;
}

#place-card-modal .place-card-content {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 20px 24px;
    overscroll-behavior: contain;
    scrollbar-color: rgba(167,139,250,.45) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

#place-card-modal .place-card-image-container {
    position: relative;
    width: calc(100% + 40px);
    height: 230px;
    flex: 0 0 230px;
    margin: 0 -20px 16px;
    overflow: hidden;
    background: #241832;
}

#place-card-modal .place-card-image {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
    background: linear-gradient(145deg, #2D1B3D, #1A0F24);
}

#place-card-modal .place-card-image > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    object-fit: cover !important;
}
#place-card-modal .place-card-image::after {
    position: absolute;
    inset: 55% 0 0;
    background: linear-gradient(transparent, rgba(20,11,31,.65));
    content: "";
    pointer-events: none;
}

#place-card-modal .image-placeholder {
    border: 0;
    border-radius: 0;
    background: linear-gradient(140deg, #3D2A4D 0%, #241832 54%, #140B1F 100%);
}
#place-card-modal .image-icon { display: none; }
#place-card-modal .image-placeholder p {
    color: #D6CBE3;
    font: 500 12px/1.4 var(--sans);
    font-style: normal;
}

#place-card-modal .place-card-close {
    position: fixed;
    z-index: 12;
    top: 12px;
    right: 12px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(245,240,250,.25);
    border-radius: 50%;
    background: rgba(18,10,28,.78);
    color: var(--paper);
    cursor: pointer;
    backdrop-filter: blur(10px);
}
#place-card-modal .place-card-close:hover {
    border-color: rgba(196,181,253,.62);
    background: rgba(45,27,61,.92);
    color: var(--paper);
    transform: none;
}
#place-card-modal .place-card-close svg,
#place-card-modal .carousel-arrow svg,
#place-card-modal .place-card-action svg,
#place-card-modal .favourites-button svg,
#place-card-modal .toggle-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#place-card-modal .carousel-arrow {
    z-index: 8;
    top: 50%;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(245,240,250,.28);
    border-radius: 50%;
    background: rgba(18,10,28,.72);
    color: var(--paper);
    transform: translateY(-50%);
    backdrop-filter: blur(10px);
}
#place-card-modal .carousel-arrow:hover {
    border-color: rgba(196,181,253,.7);
    background: rgba(45,27,61,.92);
    box-shadow: none;
    transform: translateY(-50%);
}
#place-card-modal .carousel-arrow-left { left: 12px; }
#place-card-modal .carousel-arrow-right { right: 12px; }

#place-card-modal .carousel-indicators {
    bottom: 7px;
    left: 50%;
    gap: 0;
    align-items: center;
    transform: translateX(-50%);
}
#place-card-modal .carousel-indicator {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
}
#place-card-modal .carousel-indicator::after {
    width: 7px;
    height: 7px;
    border: 1px solid rgba(245,240,250,.65);
    border-radius: 999px;
    background: rgba(245,240,250,.48);
    content: "";
    transition: width .18s ease, background-color .18s ease;
}
#place-card-modal .carousel-indicator.active::after {
    width: 19px;
    border-color: var(--lilac);
    background: var(--lilac);
}

#place-card-modal #photo-credit {
    z-index: 6;
    right: auto;
    bottom: 12px;
    left: 12px;
    max-width: calc(100% - 24px);
    padding: 5px 9px;
    border: 1px solid rgba(196,181,253,.22);
    border-radius: 999px;
    background: rgba(18,10,28,.76);
    color: #F5F0FA;
    font: 400 9px/1.35 var(--sans);
    font-style: normal;
    text-align: left;
}

#place-card-modal .place-card-meta {
    display: flex;
    min-height: 30px;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
}
#place-card-modal .place-card-badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    margin: 0;
    padding: 0 10px;
    border: 1px solid rgba(196,181,253,.28);
    border-radius: 999px;
    background: rgba(109,40,217,.2);
    color: #D9CCFA;
    font: 600 9px/1 var(--sans);
    letter-spacing: .1em;
}
#place-card-modal .place-card-distance {
    color: var(--muted);
    font: 500 11px/1.3 var(--sans);
}
#place-card-modal .place-card-distance:empty { display: none; }
#place-card-modal .place-card-town {
    margin: 0 0 3px;
    color: var(--lavender);
    font: 500 11px/1.4 var(--sans);
    letter-spacing: .07em;
    text-transform: uppercase;
}
#place-card-modal .place-card-town:empty { display: none; }
#place-card-modal .place-card-title {
    margin: 0;
    color: var(--paper);
    font: 700 38px/.98 var(--display);
    letter-spacing: -.025em;
    text-shadow: none;
    overflow-wrap: anywhere;
}
#place-card-modal .place-card-description {
    margin: 9px 0 14px;
    color: var(--body);
    font: 400 14px/1.6 var(--sans);
    font-style: normal;
}
#place-card-modal .place-card-submitted-by {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: -5px 0 14px;
    color: var(--lavender);
    font: 400 13px/1.45 var(--sans);
}
#place-card-modal .place-card-submitted-by[hidden] { display: none; }
#place-card-modal .place-card-submitted-by svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#place-card-modal .place-card-actions {
    display: grid;
    grid-template-columns: 1.05fr 1fr .8fr;
    gap: 7px;
    margin: 0 0 17px;
}
#place-card-modal .favourites-button,
#place-card-modal .place-card-action {
    display: inline-flex;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 9px;
    border: 1px solid rgba(196,181,253,.28);
    border-radius: 12px;
    background: #1A0F24;
    color: var(--body);
    font: 600 11px/1.2 var(--sans);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
#place-card-modal .favourites-button {
    border-color: rgba(196,181,253,.42);
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(109,40,217,.18);
}
#place-card-modal .favourites-button:hover,
#place-card-modal .place-card-action:hover {
    border-color: rgba(196,181,253,.64);
    background-color: #2D1B3D;
    color: var(--paper);
    transform: none;
    box-shadow: none;
}
#place-card-modal .favourites-button:hover { background: linear-gradient(135deg, #9569F7, #7737DF); }
#place-card-modal .favourites-button.favourited {
    border-color: rgba(196,181,253,.54);
    background: linear-gradient(135deg, #6D28D9, #4C1D95);
}
#place-card-modal .favourites-button .heart-icon { display: inline-flex; color: inherit; font-size: inherit; }
#place-card-modal .favourites-button .heart-icon svg { width: 17px; height: 17px; }
#place-card-modal .view-public-notes-button { margin: 0; }
#place-card-modal .place-card-action svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--lilac); }

#place-card-modal .fear-rating {
    margin: 0 0 17px;
    padding: 12px 13px;
    border: 1px solid rgba(167,139,250,.2);
    border-radius: 15px;
    background: rgba(26,15,36,.7);
    color: var(--body);
}
#place-card-modal .fear-rating-heading {
    color: var(--lilac);
    font: 600 10px/1.4 var(--sans);
    letter-spacing: .11em;
}
#place-card-modal .fear-rating-prompt { color: var(--muted); font: 400 10px/1.4 var(--sans); }
#place-card-modal .fear-skulls { gap: 3px; }
#place-card-modal .fear-skull {
    display: grid;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    place-items: center;
    padding: 0;
    color: #4A3566;
    filter: none;
    opacity: 1;
}
#place-card-modal .fear-skull.filled { color: #A78BFA; filter: none; }
#place-card-modal .fear-skull:not(:disabled):hover,
#place-card-modal .fear-skull:not(:disabled):focus-visible {
    color: var(--paper);
    filter: none;
    transform: none;
}
#place-card-modal .fear-rating-summary,
#place-card-modal .fear-rating-status { color: #BEB0CC; font: 400 11px/1.4 var(--sans); }

#place-card-modal .place-card-ghost-summary {
    margin: 0 0 15px;
    padding-top: 2px;
}
#place-card-modal .place-card-ghost-summary h3 {
    margin: 0 0 9px;
    color: var(--paper);
    font: 700 24px/.98 var(--display);
}
#place-card-modal .place-card-ghost-type {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: #D6CBE3;
    font: 400 15px/1.6 var(--sans);
}

#place-card-modal .place-card-section {
    margin: 0 0 10px;
    overflow: hidden;
    border: 1px solid rgba(167,139,250,.2);
    border-radius: 15px;
    background: rgba(26,15,36,.55);
}
#place-card-modal .section-toggle {
    display: flex;
    width: 100%;
    min-height: 54px;
    align-items: center;
    gap: 11px;
    padding: 0 15px;
    border: 0;
    background: transparent;
    color: var(--paper);
    font: 700 22px/1 var(--display);
    text-align: left;
    cursor: pointer;
}
#place-card-modal .section-toggle:hover {
    background: rgba(61,42,77,.42);
    color: var(--paper);
}
#place-card-modal .toggle-icon {
    display: inline-grid;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
    color: var(--lavender);
    font-size: 0;
}
#place-card-modal .toggle-icon svg { width: 18px; height: 18px; transition: transform .18s ease; }
#place-card-modal .section-toggle.expanded .toggle-icon svg { transform: rotate(90deg); }
#place-card-modal #visiting-toggle[aria-expanded="true"] .toggle-icon svg { transform: rotate(90deg); }
#place-card-modal .section-content {
    border-top: 1px solid rgba(167,139,250,.14);
    background: rgba(18,10,28,.42);
    color: var(--body);
    font: 400 14px/1.65 var(--sans);
}
#place-card-modal .section-content.show {
    padding: 14px 15px 16px;
    max-height: 1000px;
    opacity: 1;
}
#place-card-modal #place-card-history { margin: 0; color: var(--body); font: 400 14px/1.65 var(--sans); }
#place-card-modal #place-card-history p { margin: 0 0 12px; }
#place-card-modal #place-card-history p:last-child { margin-bottom: 0; }
#place-card-modal .place-card-visitable-line {
    margin: 0;
    padding: 12px 15px 0;
    color: var(--muted);
    font: 400 11px/1.45 var(--sans);
}
#place-card-modal .place-card-visitable-line span { color: var(--body); font-weight: 600; }
#place-card-modal .place-card-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 15px;
    padding: 12px 15px 15px;
    color: var(--body);
}
#place-card-modal .place-card-info-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(167,139,250,.14);
}
#place-card-modal .place-card-info-item .info-label {
    color: var(--muted);
    font: 500 10px/1.35 var(--sans);
    letter-spacing: .05em;
    text-transform: uppercase;
}
#place-card-modal .place-card-info-item .info-value {
    min-width: 0;
    margin: 0;
    color: var(--body);
    font: 400 12px/1.5 var(--sans);
    text-align: left;
    overflow-wrap: anywhere;
}
#place-card-modal .place-card-address-item { grid-column: 1 / -1; }
#place-card-modal #website-row { display: flex !important; }
#place-card-modal #website-row[style*="display: none"] { display: none !important; }
#place-card-modal #place-card-website a {
    color: var(--lilac) !important;
    text-decoration: underline;
    text-decoration-color: rgba(196,181,253,.42);
    text-underline-offset: 3px;
}

#place-card-modal :focus-visible {
    outline: 2px solid var(--lilac);
    outline-offset: 2px;
}

@media (min-width: 768px) {
    body.map-card-open .map-quick-filters {
        max-width: calc(100% - 560px);
    }
    #place-card-modal .place-card-topbar .place-card-close {
        position: static;
    }
    body.map-card-open #app .mapboxgl-ctrl-top-right,
    body.map-card-open #app .mapboxgl-ctrl-bottom-right {
        right: calc(440px + 36px) !important;
    }
}

@media (max-width: 767px) {
    #place-card-modal .place-card-topbar { display: contents; }
    #place-card-modal.place-card-modal {
        align-items: stretch;
        justify-content: center;
    }
    #place-card-modal .place-card {
        top: 45dvh !important;
        right: 0 !important;
        bottom: calc(72px + env(safe-area-inset-bottom)) !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        max-height: none !important;
        border-right: 0 !important;
        border-bottom: 0 !important;
        border-left: 0 !important;
        border-radius: 24px 24px 0 0 !important;
        transform: translateY(100%) !important;
    }
    #place-card-modal.show .place-card { transform: translateY(0) !important; }
    body.map-sheet-expanded #place-card-modal .place-card {
        top: var(--map-header-bottom, 112px) !important;
    }
    #place-card-modal .map-sheet-handle {
        display: grid;
        width: 100%;
        height: 44px;
        min-height: 44px;
        flex: 0 0 44px;
        place-items: center;
        padding: 0;
        border: 0;
        background: #140B1F;
        cursor: grab;
        touch-action: pan-y;
    }
    #place-card-modal .map-sheet-handle:active { cursor: grabbing; }
    #place-card-modal .map-sheet-handle > span {
        display: block;
        width: 42px;
        height: 4px;
        border-radius: 99px;
        background: rgba(196,181,253,.58);
    }
    #place-card-modal .place-card-content { padding: 0 16px 20px; }
    #place-card-modal .place-card-image-container {
        width: calc(100% + 32px);
        height: 150px;
        flex-basis: 150px;
        margin: 0 -16px 13px;
    }
    #place-card-modal .place-card-title { font-size: 28px; line-height: 1; }
    #place-card-modal .place-card-description { margin: 8px 0 12px; font-size: 13px; line-height: 1.6; }
    #place-card-modal .place-card-actions { gap: 6px; margin-bottom: 13px; }
    #place-card-modal .favourites-button,
    #place-card-modal .place-card-action { gap: 5px; padding-inline: 6px; font-size: 10px; }
    #place-card-modal .fear-rating { margin-bottom: 14px; padding: 10px 11px; }
    #place-card-modal .place-card-ghost-summary h3 { font-size: 22px; }
    #place-card-modal .section-toggle { min-height: 52px; font-size: 21px; }
}

@media (max-width: 380px) {
    #place-card-modal .place-card-content { padding-inline: 13px; }
    #place-card-modal .place-card-image-container { width: calc(100% + 26px); margin-inline: -13px; }
    #place-card-modal .place-card-actions { grid-template-columns: 1fr 1fr .8fr; gap: 4px; }
    #place-card-modal .favourites-button,
    #place-card-modal .place-card-action { gap: 4px; padding-inline: 4px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    #place-card-modal .place-card,
    #place-card-modal .carousel-indicator::after,
    #place-card-modal .toggle-icon svg {
        transition: none !important;
    }
}

/* Stage 3 supporting windows: a literary, moonlit system across every /app state. */
.map-auth-back { min-width: 150px; gap: 8px; white-space: nowrap; }
.map-auth-back svg { width: 20px; height: 20px; flex: 0 0 20px; }
body:has(#app) #place-card-modal .section-toggle,
body:has(#app) #place-card-modal .section-toggle span:not(.toggle-icon) {
    font-family: var(--display) !important;
    font-size: 22px !important;
    font-weight: 600 !important;
}
body:has(#app) .map-brand span,
body:has(#app) .auth-main,
body:has(#app) :is(h1, h2, h3, h4, h5, h6),
body:has(#app) :is(h1, h2, h3, h4, h5, h6) > span:not(.hm-icon-wrap) {
    font-family: var(--display) !important;
}
body:has(#app) button {
    min-width: 44px;
    min-height: 44px;
}
body:has(#app) .map-phone-tab span,
body:has(#app) .place-card-actions span,
body:has(#app) .map-brand span {
    color: inherit;
}
body:has(#app) {
    background: #0B0612 !important;
    color: #D6CBE3 !important;
    font-family: var(--sans) !important;
}
body:has(#app) *,
body:has(#app) *::before,
body:has(#app) *::after {
    box-sizing: border-box;
}
body:has(#app) .hidden,
body:has(#app) [hidden],
body:has(#app) .map-phone-tabs[hidden],
body:has(#app) .map-phone-tabs [hidden] {
    display: none !important;
}
body:has(#app) * {
    font-family: var(--sans) !important;
}
body:has(#app) h1,
body:has(#app) h2,
body:has(#app) h3,
body:has(#app) .profile-title-main,
body:has(#app) .profile-title-subtitle,
body:has(#app) .section-title,
body:has(#app) .form-title,
body:has(#app) .auth-title,
body:has(#app) .leaderboard-title,
body:has(#app) .notes-modal-title,
body:has(#app) .modal-title,
body:has(#app) .story-form-title,
body:has(#app) .success-title,
body:has(#app) #welcome-popup-inner h2,
body:has(#app) #welcome-popup-overlay h2,
body:has(#app) #detailed-error-overlay h1 {
    color: #F5F0FA !important;
    font-family: var(--display) !important;
    font-weight: 700 !important;
    letter-spacing: -.025em;
    text-shadow: none !important;
}
body:has(#app) p,
body:has(#app) label,
body:has(#app) span,
body:has(#app) li,
body:has(#app) small,
body:has(#app) .auth-footer,
body:has(#app) .auth-switch,
body:has(#app) .notes-modal-subtitle {
    color: #D6CBE3;
}
body:has(#app) button,
body:has(#app) a,
body:has(#app) input,
body:has(#app) textarea,
body:has(#app) select {
    font-family: var(--sans) !important;
}
body:has(#app) button,
body:has(#app) a,
body:has(#app) input,
body:has(#app) textarea,
body:has(#app) select,
body:has(#app) [tabindex] {
    -webkit-tap-highlight-color: transparent;
}
body:has(#app) :focus-visible {
    outline: 2px solid #C4B5FD !important;
    outline-offset: 3px !important;
}

/* Main application keeps a map-sized canvas above the fixed mobile navigation. */
#app.app { background: #0B0612 !important; }
@media (min-width: 768px) {
    #app.app { padding: 0 !important; }
    body:has(#app) .map-phone-tabs { display: none !important; }
}
@media (max-width: 767px) {
    #app.app {
        padding: 0 0 calc(72px + env(safe-area-inset-bottom)) !important;
        box-sizing: border-box;
    }
    body:has(#app) .map-phone-tabs {
        position: fixed !important;
        z-index: 12000 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        display: grid !important;
        width: 100% !important;
        height: calc(72px + env(safe-area-inset-bottom)) !important;
        min-height: calc(72px + env(safe-area-inset-bottom)) !important;
        padding: 4px 8px calc(4px + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid rgba(196,181,253,.2) !important;
        background: rgba(11,6,18,.98) !important;
        box-shadow: 0 -10px 32px rgba(5,2,10,.38) !important;
        backdrop-filter: blur(18px);
    }
    body:has(#app) .map-phone-tabs[hidden],
    body:has(#app) .map-phone-tabs [hidden] { display: none !important; }
}

/* Restored profile lives beside #app so its former hide-app behavior remains usable. */
body.map-profile-active { overflow: hidden !important; }
body:has(#profile-page) #profile-page.profile-page:not(.hidden) {
    position: fixed !important;
    z-index: 11500 !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: max(26px, env(safe-area-inset-top)) clamp(18px, 4vw, 56px) 40px !important;
    background:
        radial-gradient(ellipse at 50% -15%, rgba(109,40,217,.18), transparent 48%),
        #0B0612 !important;
    color: #D6CBE3 !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
body:has(#profile-page) #profile-page .profile-header {
    max-width: 1120px;
    margin: 0 auto;
    padding: 22px 0 14px;
    border-bottom: 1px solid rgba(196,181,253,.2);
    background: transparent !important;
}
body:has(#profile-page) #profile-page .profile-title-main {
    display: block;
    font-size: clamp(38px, 6vw, 58px) !important;
    line-height: .95;
}
body:has(#profile-page) #profile-page .profile-title-subtitle {
    display: block;
    margin-top: 8px;
    color: #A78BFA !important;
    font: 500 12px/1.4 var(--sans) !important;
    letter-spacing: .14em;
    text-transform: uppercase;
}
body:has(#profile-page) #profile-page .profile-decoration { display: none !important; }
body:has(#profile-page) #profile-page .back-button-container,
body:has(#profile-page) #profile-page .profile-content {
    width: min(100%, 1120px);
    margin-right: auto;
    margin-left: auto;
}
body:has(#profile-page) #profile-page .back-button-container { padding: 16px 0; }
body:has(#profile-page) #profile-page .back-button,
body:has(#profile-page) #profile-page .change-photo-btn,
body:has(#profile-page) #profile-page .my-groups-browse-link {
    min-height: 44px !important;
    border: 1px solid rgba(196,181,253,.25) !important;
    border-radius: 999px !important;
    background: #1A0F24 !important;
    color: #E8DFF0 !important;
    box-shadow: none !important;
    font: 600 12px/1.2 var(--sans) !important;
}
body:has(#profile-page) #profile-page .profile-content { display: grid; gap: 18px; }
body:has(#profile-page) #profile-page .profile-content > section {
    padding: clamp(18px, 3vw, 28px) !important;
    border: 1px solid rgba(167,139,250,.22) !important;
    border-radius: 20px !important;
    background: #140B1F !important;
    color: #D6CBE3 !important;
    box-shadow: 0 16px 40px rgba(5,2,10,.2) !important;
}
body:has(#profile-page) #profile-page .section-title {
    margin: 0 0 18px !important;
    font-size: clamp(26px, 3vw, 34px) !important;
}
body:has(#profile-page) #profile-page .user-info-section {
    display: grid;
    grid-template-columns: auto minmax(0,1fr);
    align-items: center;
    gap: 14px 24px;
}
body:has(#profile-page) #profile-page .user-avatar {
    border: 1px solid rgba(196,181,253,.35) !important;
    background: #241832 !important;
}
body:has(#profile-page) #profile-page input,
body:has(#profile-page) #profile-page textarea,
body:has(#app) .auth-screen input,
body:has(#app) .notes-modal textarea,
body:has(#app) .modal input,
body:has(#app) .story-form-modal input,
body:has(#app) .story-form-modal textarea {
    min-height: 46px;
    border: 1px solid rgba(196,181,253,.25) !important;
    border-radius: 12px !important;
    background: #0F0917 !important;
    color: #F5F0FA !important;
    box-shadow: none !important;
    font: 400 14px/1.5 var(--sans) !important;
}
body:has(#app) input::placeholder,
body:has(#app) textarea::placeholder { color: #9A8AAD !important; opacity: 1; }
body:has(#app) .user-stats,
body:has(#app) .rank-card,
body:has(#app) .my-groups-grid,
body:has(#app) .favourites-grid { color: #D6CBE3 !important; }
body:has(#profile-page) .rank-card,
body:has(#profile-page) .my-groups-grid > *,
body:has(#profile-page) .favourites-grid > * {
    border-color: rgba(167,139,250,.2) !important;
    background-color: #1A0F24 !important;
    color: #D6CBE3 !important;
}
@media (max-width: 767px) {
    body:has(#profile-page) #profile-page.profile-page:not(.hidden) {
        padding: max(18px, env(safe-area-inset-top)) 14px calc(72px + env(safe-area-inset-bottom) + 24px) !important;
    }
    body:has(#profile-page) #profile-page .user-info-section { grid-template-columns: 1fr; }
}

/* Login, verification and signup screens. */
body.map-auth-active { overflow: hidden !important; }
body:has(#app) .auth-screen:not(.hidden) {
    position: fixed !important;
    z-index: 11000 !important;
    inset: 0 !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: max(28px, env(safe-area-inset-top)) 18px 32px !important;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(109,40,217,.2), transparent 46%),
        #0B0612 !important;
    color: #D6CBE3 !important;
}
body:has(#app) .auth-content {
    width: min(100%, 520px) !important;
    margin: auto !important;
    padding: clamp(22px, 5vw, 42px) !important;
    border: 1px solid rgba(167,139,250,.27) !important;
    border-radius: 24px !important;
    background: rgba(20,11,31,.98) !important;
    box-shadow: 0 28px 90px rgba(0,0,0,.44) !important;
}
body:has(#app) .auth-header { margin-bottom: 24px; }
body:has(#app) .auth-title { margin: 0 !important; }
body:has(#app) .auth-main { display: block; font-size: clamp(36px, 8vw, 52px) !important; line-height: .95; }
body:has(#app) .auth-subtitle {
    display: block;
    margin-top: 8px;
    color: #A78BFA !important;
    font: 500 12px/1.4 var(--sans) !important;
    letter-spacing: .14em;
}
body:has(#app) .auth-ghost { display: none !important; }
body:has(#app) .auth-form {
    padding: 22px !important;
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 17px !important;
    background: #1A0F24 !important;
    box-shadow: none !important;
}
body:has(#app) .form-title { margin: 0 0 18px !important; font-size: 30px !important; }
body:has(#app) .auth-screen .input-group { margin-bottom: 15px !important; }
body:has(#app) .auth-screen label { display: block; margin-bottom: 7px; color: #D6CBE3 !important; font-size: 12px !important; font-weight: 600; }
body:has(#app) .auth-screen input { width: 100% !important; padding: 0 14px !important; }
body:has(#app) .auth-screen .password-wrapper { position: relative; }
body:has(#app) .auth-screen .password-wrapper input { padding-right: 54px !important; }
body:has(#app) .password-toggle {
    position: absolute !important;
    top: 50% !important;
    right: 4px !important;
    display: grid !important;
    width: 44px !important;
    height: 44px !important;
    place-items: center !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: #C4B5FD !important;
    transform: translateY(-50%);
}
body:has(#app) .password-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body:has(#app) .auth-btn,
body:has(#app) .notification-btn,
body:has(#app) #welcome-explore-btn,
body:has(#app) #welcome-dismiss-btn,
body:has(#app) .story-form-modal .form-submit-btn,
body:has(#app) .story-form-modal .success-close-btn,
body:has(#app) .story-form-modal .error-retry-btn,
body:has(#app) .notes-save-button,
body:has(#app) .modal .delete-button,
body:has(#app) #detailed-error-overlay button {
    display: inline-flex !important;
    min-width: 120px !important;
    min-height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 22px !important;
    border: 1px solid rgba(196,181,253,.36) !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%) !important;
    color: #F5F0FA !important;
    box-shadow: 0 8px 22px rgba(109,40,217,.22) !important;
    font: 600 13px/1.2 var(--sans) !important;
    letter-spacing: 0 !important;
    text-shadow: none !important;
    cursor: pointer;
}
body:has(#app) .auth-switch { margin: 18px 0 0 !important; color: #B7A9C5 !important; text-align: center; font-size: 12px !important; }
body:has(#app) .switch-btn,
body:has(#app) .auth-screen a {
    min-height: 44px;
    padding: 0 4px;
    border: 0 !important;
    background: transparent !important;
    color: #C4B5FD !important;
    font: 600 12px/1.2 var(--sans) !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
}
body:has(#app) .auth-footer { margin-top: 21px; color: #9A8AAD !important; text-align: center; font-size: 11px !important; }
body:has(#app) .auth-footer p { color: #9A8AAD !important; }
body:has(#app) .auth-footer a { color: #C4B5FD !important; }
@media (max-width: 767px) {
    body:has(#app) .auth-screen input,
    body:has(#app) .auth-screen textarea,
    body:has(#app) .notes-modal textarea,
    body:has(#app) .modal input,
    body:has(#app) .story-form-modal input,
    body:has(#app) .story-form-modal textarea { font-size: 16px !important; }
}

/* Shared modal shell, notes, public notes, ranking and story/account workflows. */
body:has(#app) .notes-modal,
body:has(#app) .leaderboard-overlay,
body:has(#app) .story-form-modal,
body:has(#app) #delete-account-modal,
body:has(#app) .notification-modal,
body:has(#app) #welcome-popup,
body:has(#app) #welcome-popup-overlay {
    z-index: 13000 !important;
}
body:has(#app) .notes-modal:not(.hidden),
body:has(#app) .leaderboard-overlay:not(.hidden),
body:has(#app) .story-form-modal:not(.hidden),
body:has(#app) #delete-account-modal:not(.hidden),
body:has(#app) .notification-modal:not(.hidden),
body:has(#app) #welcome-popup:not(.hidden) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    background: rgba(5,2,10,.78) !important;
    backdrop-filter: blur(8px);
}
body:has(#app) .notes-modal-overlay,
body:has(#app) .leaderboard-backdrop,
body:has(#app) .story-form-overlay,
body:has(#app) .modal-overlay {
    background: rgba(5,2,10,.78) !important;
    backdrop-filter: blur(5px);
}
body:has(#app) .notes-modal-card,
body:has(#app) .leaderboard-panel,
body:has(#app) .story-form-container,
body:has(#app) .modal-content,
body:has(#app) .notification-content,
body:has(#app) #welcome-popup-inner,
body:has(#app) #welcome-popup-overlay > div {
    width: min(100%, 620px) !important;
    max-height: min(82dvh, 780px) !important;
    overflow: auto !important;
    padding: clamp(20px, 4vw, 32px) !important;
    border: 1px solid rgba(167,139,250,.3) !important;
    border-radius: 22px !important;
    background: #140B1F !important;
    color: #D6CBE3 !important;
    box-shadow: 0 28px 80px rgba(0,0,0,.52) !important;
    text-align: left;
    backdrop-filter: blur(18px);
}
body:has(#app) .notes-modal-card,
body:has(#app) .leaderboard-panel,
body:has(#app) .modal-content { position: relative; }
body:has(#app) .notes-modal-title,
body:has(#app) .leaderboard-title,
body:has(#app) .modal-title,
body:has(#app) .story-form-title { font-size: clamp(27px, 5vw, 36px) !important; line-height: 1 !important; }
body:has(#app) .notes-modal-subtitle,
body:has(#app) .leaderboard-subtitle { color: #9A8AAD !important; font-size: 12px !important; line-height: 1.55; }
body:has(#app) .notes-modal-header,
body:has(#app) .leaderboard-panel > .leaderboard-title,
body:has(#app) .story-form-header,
body:has(#app) .modal-header {
    border-bottom: 1px solid rgba(167,139,250,.2) !important;
    background: transparent !important;
}
body:has(#app) .notes-modal-close,
body:has(#app) .leaderboard-close,
body:has(#app) .modal-close,
body:has(#app) .story-form-close {
    display: grid !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    place-items: center !important;
    border: 1px solid rgba(196,181,253,.25) !important;
    border-radius: 50% !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
    font: 400 22px/1 var(--sans) !important;
    box-shadow: none !important;
}
body:has(#app) .notes-modal-footer,
body:has(#app) .modal-footer,
body:has(#app) .story-form-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; border-top: 1px solid rgba(167,139,250,.18) !important; }
body:has(#app) .notes-modal-footer button,
body:has(#app) .modal-footer button,
body:has(#app) .story-form-footer button {
    min-width: 100px !important;
    min-height: 44px !important;
    padding: 0 18px !important;
    border: 1px solid rgba(196,181,253,.24) !important;
    border-radius: 999px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
    font: 600 12px/1.2 var(--sans) !important;
    box-shadow: none !important;
}
body:has(#app) .notes-save-button,
body:has(#app) .form-submit-btn { background: linear-gradient(135deg,#8B5CF6,#6D28D9) !important; color: #F5F0FA !important; }
body:has(#app) .notes-textarea { width: 100%; min-height: 180px; padding: 14px !important; resize: vertical; }
body:has(#app) .public-notes-list,
body:has(#app) .public-note-view-body,
body:has(#app) .leaderboard-content { color: #D6CBE3 !important; }
body:has(#app) .public-notes-loading,
body:has(#app) .public-notes-empty,
body:has(#app) .leaderboard-loading,
body:has(#app) .leaderboard-empty { color: #9A8AAD !important; }
body:has(#app) .leaderboard-row,
body:has(#app) .public-note-card,
body:has(#app) .public-notes-item,
body:has(#app) .note-card {
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 14px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
}
body:has(#app) .story-form-body { background: transparent !important; }
body:has(#app) .story-form-modal .form-label { color: #D6CBE3 !important; font-size: 12px !important; font-weight: 600; }
body:has(#app) .story-form-modal .form-help,
body:has(#app) .story-form-modal .char-count { color: #9A8AAD !important; }
body:has(#app) .file-upload-area {
    min-height: 90px !important;
    border: 1px dashed rgba(196,181,253,.35) !important;
    border-radius: 14px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
}
body:has(#app) .danger-zone {
    padding: 18px !important;
    border: 1px solid rgba(167,139,250,.28) !important;
    border-radius: 16px !important;
    background: rgba(109,40,217,.08) !important;
}
body:has(#app) .delete-account-button {
    min-height: 44px !important;
    border: 1px solid rgba(196,181,253,.28) !important;
    border-radius: 999px !important;
    background: #241832 !important;
    color: #E8DFF0 !important;
}
body:has(#app) .warning-text,
body:has(#app) .confirmation-text { color: #D6CBE3 !important; }
body:has(#app) .notification-icon,
body:has(#app) .error-msg-icon { color: #C4B5FD !important; }

/* Both welcome experiences and graceful loading/error states. */
body:has(#app) #welcome-popup-overlay[style*="display: flex"] {
    display: flex !important;
    z-index: 14000 !important;
    background: rgba(5,2,10,.8) !important;
    backdrop-filter: blur(8px);
}
body:has(#app) #welcome-popup-inner,
body:has(#app) #welcome-popup-overlay > div {
    text-align: center !important;
}
body:has(#app) #welcome-popup-inner h2,
body:has(#app) #welcome-popup-overlay h2 {
    margin: 0 0 12px !important;
    color: #F5F0FA !important;
    font-size: 34px !important;
    line-height: 1 !important;
}
body:has(#app) #welcome-popup-inner p,
body:has(#app) #welcome-popup-overlay p { margin: 0 0 22px !important; color: #D6CBE3 !important; font-size: 14px !important; line-height: 1.6; }
body:has(#app) #welcome-popup-inner .welcome-ghost,
body:has(#app) #welcome-popup-overlay > div > div:first-child { color: #A78BFA !important; }
body:has(#app) .loading-screen,
body:has(#app) .error-screen {
    position: fixed !important;
    z-index: 15000 !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(109,40,217,.14), transparent 46%),
        #0B0612 !important;
    color: #D6CBE3 !important;
}
body:has(#app) .loading-screen.hidden,
body:has(#app) .error-screen.hidden { display: none !important; }
body:has(#app) .loading-content,
body:has(#app) .error-content {
    width: min(100%, 520px) !important;
    padding: clamp(24px, 5vw, 42px) !important;
    border: 1px solid rgba(167,139,250,.25) !important;
    border-radius: 24px !important;
    background: #140B1F !important;
    text-align: center !important;
    box-shadow: 0 24px 70px rgba(0,0,0,.4);
}
body:has(#app) .loading-spinner {
    width: 34px !important;
    height: 34px !important;
    margin: 0 auto 20px !important;
    border: 2px solid rgba(196,181,253,.18) !important;
    border-top-color: #A78BFA !important;
    border-radius: 50% !important;
}
body:has(#app) .loading-text,
body:has(#app) .error-title { color: #F5F0FA !important; font: 700 34px/1 var(--display) !important; }
body:has(#app) .error-message { color: #D6CBE3 !important; font-size: 14px !important; line-height: 1.6; }
body:has(#app) .retry-button {
    min-height: 44px !important;
    padding: 0 22px !important;
    border: 1px solid rgba(196,181,253,.35) !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg,#8B5CF6,#6D28D9) !important;
    color: #F5F0FA !important;
    font: 600 13px/1.2 var(--sans) !important;
}
body:has(#app) #detailed-error-overlay {
    background: #0B0612 !important;
    padding: 20px !important;
}
body:has(#app) #detailed-error-overlay > div {
    width: min(100%, 520px) !important;
    max-width: 520px !important;
    padding: clamp(24px, 5vw, 40px) !important;
    border: 1px solid rgba(167,139,250,.3) !important;
    border-radius: 22px !important;
    background: #140B1F !important;
    box-shadow: 0 28px 80px rgba(0,0,0,.5) !important;
}
body:has(#app) #detailed-error-overlay h1 {
    margin: 0 0 12px !important;
    color: #F5F0FA !important;
    font: 700 38px/.98 var(--display) !important;
}
body:has(#app) #detailed-error-overlay p {
    margin: 0 0 22px !important;
    color: #D6CBE3 !important;
    font: 400 14px/1.65 var(--sans) !important;
}
body:has(#app) #detailed-error-overlay button { width: auto !important; }

/* Mapbox's fullscreen badge uses its built-in dark raster icon; replace only its artwork. */
#app .mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon,
#app .mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon {
    filter: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23F5F0FA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H5a2 2 0 0 0-2 2v3m13-5h3a2 2 0 0 1 2 2v3M3 16v3a2 2 0 0 0 2 2h3m13-5v3a2 2 0 0 1-2 2h-3'/%3E%3C/svg%3E") !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 20px 20px !important;
}
#app .mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23F5F0FA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3v5H3m13-5v5h5M3 16h5v5m13-5h-5v5'/%3E%3C/svg%3E") !important;
}

@media (max-width: 767px) {
    body:has(#app) .notes-modal:not(.hidden),
    body:has(#app) .leaderboard-overlay:not(.hidden),
    body:has(#app) .story-form-modal:not(.hidden),
    body:has(#app) #delete-account-modal:not(.hidden),
    body:has(#app) .notification-modal:not(.hidden),
    body:has(#app) #welcome-popup:not(.hidden) {
        padding: 12px 12px calc(84px + env(safe-area-inset-bottom)) !important;
    }
    body:has(#app) .notes-modal-card,
    body:has(#app) .leaderboard-panel,
    body:has(#app) .story-form-container,
    body:has(#app) .modal-content,
    body:has(#app) .notification-content,
    body:has(#app) #welcome-popup-inner,
    body:has(#app) #welcome-popup-overlay > div {
        width: 100% !important;
        max-height: min(78dvh, 700px) !important;
        padding: 20px !important;
    }
}

/* Reduced motion applies to app windows even while #app itself is hidden. */
@media (prefers-reduced-motion: reduce) {
    body:has(#app) *,
    body:has(#app) *::before,
    body:has(#app) *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Dynamic guest gates: keep inline legacy markup, handlers and copy; restyle by stable IDs. */
body:has(#app) #guest-login-prompt,
body:has(#app) #notes-login-prompt {
    position: fixed !important;
    z-index: 14000 !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-y: auto !important;
    padding: 18px !important;
    background: rgba(5,2,10,.82) !important;
    backdrop-filter: blur(9px);
    -webkit-overflow-scrolling: touch;
}
body:has(#app) #guest-login-prompt > div,
body:has(#app) #notes-login-prompt > div {
    position: relative !important;
    width: min(100%, 460px) !important;
    max-width: 460px !important;
    max-height: calc(100dvh - 36px) !important;
    overflow-y: auto !important;
    padding: clamp(24px, 5vw, 36px) !important;
    border: 1px solid rgba(196,181,253,.28) !important;
    border-radius: 22px !important;
    background: #140B1F !important;
    color: #D6CBE3 !important;
    text-align: center !important;
    box-shadow: 0 28px 90px rgba(0,0,0,.52) !important;
}
body:has(#app) #guest-login-prompt h2,
body:has(#app) #notes-login-prompt h2 {
    margin: 0 0 12px !important;
    color: #F5F0FA !important;
    font: 700 clamp(29px, 6vw, 38px)/.98 var(--display) !important;
    letter-spacing: -.025em !important;
}
body:has(#app) #guest-login-prompt p,
body:has(#app) #notes-login-prompt p {
    margin: 0 0 22px !important;
    color: #D6CBE3 !important;
    font: 400 14px/1.65 var(--sans) !important;
}
body:has(#app) #guest-login-prompt > div > div:first-child,
body:has(#app) #notes-login-prompt > div > div:not(.hm-icon-wrap):first-of-type {
    display: flex !important;
    min-height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 0 14px !important;
    color: #C4B5FD !important;
    font-size: 22px !important;
}
body:has(#app) #guest-login-prompt .hm-icon-wrap,
body:has(#app) #notes-login-prompt .hm-icon-wrap {
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    color: #C4B5FD;
}
body:has(#app) #guest-login-prompt .hm-icon-wrap svg,
body:has(#app) #notes-login-prompt .hm-icon-wrap svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
body:has(#app) #guest-signup-btn,
body:has(#app) #notes-prompt-signup {
    display: inline-flex !important;
    width: 100% !important;
    min-height: 48px !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 0 9px !important;
    padding: 0 18px !important;
    border: 1px solid rgba(196,181,253,.35) !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg,#8B5CF6,#6D28D9) !important;
    color: #F5F0FA !important;
    box-shadow: 0 8px 22px rgba(109,40,217,.22) !important;
    font: 600 13px/1.2 var(--sans) !important;
}
body:has(#app) #guest-login-btn,
body:has(#app) #notes-prompt-login {
    display: inline-flex !important;
    width: 100% !important;
    min-height: 48px !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 0 8px !important;
    padding: 0 18px !important;
    border: 1px solid rgba(196,181,253,.23) !important;
    border-radius: 999px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
    box-shadow: none !important;
    font: 600 12px/1.3 var(--sans) !important;
    white-space: normal;
}
body:has(#app) #guest-dismiss-btn {
    display: inline-flex !important;
    min-width: 44px !important;
    min-height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 12px !important;
    border: 1px solid transparent !important;
    border-radius: 999px !important;
    background: transparent !important;
    color: #AFA0BE !important;
    font: 500 12px/1.2 var(--sans) !important;
}
body:has(#app) #notes-prompt-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    display: grid !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    place-items: center !important;
    padding: 0 !important;
    border: 1px solid rgba(196,181,253,.25) !important;
    border-radius: 50% !important;
    background: #1A0F24 !important;
    color: #C4B5FD !important;
    font-size: 0 !important;
}
body:has(#app) #notes-prompt-close .hm-icon-wrap {
    width: 20px;
    height: 20px;
}

/* Small temporary nudge sits in open map space, clear of the phone bar and nearby sheet. */
body:has(#app) #guest-nudge-banner {
    position: fixed !important;
    z-index: 8000 !important;
    top: calc(var(--map-header-bottom, 74px) + 82px) !important;
    right: 16px !important;
    bottom: auto !important;
    left: auto !important;
    width: max-content !important;
    max-width: min(390px, calc(100vw - 32px)) !important;
    padding: 12px 16px !important;
    border: 1px solid rgba(196,181,253,.25) !important;
    border-radius: 14px !important;
    background: rgba(20,11,31,.96) !important;
    color: #D6CBE3 !important;
    font: 500 12px/1.5 var(--sans) !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-shadow: 0 12px 30px rgba(5,2,10,.38) !important;
    transform: none !important;
    backdrop-filter: blur(14px);
}
@media (max-width: 767px) {
    body:has(#app) #guest-nudge-banner {
        top: calc(var(--map-header-bottom, 112px) + 76px) !important;
        right: 12px !important;
        max-width: min(340px, calc(100vw - 24px)) !important;
    }
}

/* Keep account menus above in-flow notices and map filter chips. */
#app .header { z-index: 1500; }
/* Migration notice is a calm in-flow alert, not an alarm-colored banner. */
body:has(#app) #app #migration-notice-banner {
    position: relative !important;
    inset: auto !important;
    flex: 0 0 auto !important;
    width: auto !important;
    z-index: 1002 !important;
    margin: 0 !important;
    padding: 10px 54px 10px 16px !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(196,181,253,.22) !important;
    background: #140B1F !important;
    color: #D6CBE3 !important;
    box-shadow: none !important;
}
body:has(#app) #migration-notice-banner .migration-notice-text {
    margin: 0 !important;
    color: #D6CBE3 !important;
    font: 400 12px/1.55 var(--sans) !important;
}
body:has(#app) #migration-notice-banner .migration-notice-close {
    display: grid !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    place-items: center !important;
    padding: 0 !important;
    border: 1px solid rgba(196,181,253,.22) !important;
    border-radius: 50% !important;
    background: #1A0F24 !important;
    color: #C4B5FD !important;
}

/* Shared public investigation rows and read-only note detail. */
body:has(#app) .public-note-row {
    display: flex !important;
    min-width: 0 !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 12px !important;
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 14px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
}
body:has(#app) .public-note-row-info {
    display: flex !important;
    min-width: 0 !important;
    flex: 1 1 180px !important;
    flex-direction: column !important;
    gap: 4px !important;
}
body:has(#app) .public-note-row-username,
body:has(#app) .public-note-view-author {
    min-width: 0;
    color: #F5F0FA !important;
    font: 600 14px/1.4 var(--sans) !important;
    white-space: normal !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
}
body:has(#app) .public-note-row-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 4px 8px !important;
    color: #9A8AAD !important;
    font: 400 11px/1.45 var(--sans) !important;
}
body:has(#app) .public-note-row-rank,
body:has(#app) .public-note-view-rank { color: #C4B5FD !important; font-weight: 600; }
body:has(#app) .public-note-row-date,
body:has(#app) .public-note-view-date { color: #9A8AAD !important; }
body:has(#app) .public-note-row-actions {
    display: flex !important;
    min-width: 0;
    flex: 0 0 auto;
    align-items: center !important;
    gap: 8px !important;
}
body:has(#app) .public-note-view-button,
body:has(#app) .public-note-report-button {
    display: inline-flex !important;
    min-width: 44px !important;
    min-height: 44px !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 14px !important;
    border: 1px solid rgba(196,181,253,.24) !important;
    border-radius: 999px !important;
    background: #241832 !important;
    color: #E8DFF0 !important;
    font: 600 11px/1.3 var(--sans) !important;
    text-align: center;
    white-space: normal !important;
    overflow-wrap: anywhere;
    box-shadow: none !important;
}
body:has(#app) .public-note-view-button {
    flex: 0 1 auto !important;
    border-color: rgba(196,181,253,.34) !important;
    background: linear-gradient(135deg,#8B5CF6,#6D28D9) !important;
    color: #F5F0FA !important;
}
body:has(#app) .public-note-report-button {
    flex: 0 0 44px !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    color: #C4B5FD !important;
}
body:has(#app) .public-note-report-button svg,
body:has(#app) .public-note-view-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
body:has(#app) .public-note-report-label { display: none !important; }
body:has(#app) .public-note-view-body {
    width: 100%;
    max-width: 100%;
    max-height: min(58dvh, 620px) !important;
    overflow: auto !important;
    padding: 0 !important;
    color: #D6CBE3 !important;
    overflow-wrap: anywhere;
    overscroll-behavior: contain;
}
body:has(#app) .public-note-view-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 5px 10px !important;
    min-width: 0;
    padding: 12px !important;
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 12px !important;
    background: #1A0F24 !important;
    color: #9A8AAD !important;
    font: 400 11px/1.45 var(--sans) !important;
    overflow-wrap: anywhere;
}
body:has(#app) .public-note-view-content {
    max-width: 100%;
    padding: 15px !important;
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 14px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
    font: 400 14px/1.7 var(--sans) !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word;
}
body:has(#app) .public-note-view-content :is(p, div, span, li) {
    max-width: 100%;
    color: inherit !important;
    overflow-wrap: anywhere;
}
@media (max-width: 767px) {
    body:has(#app) .public-note-row {
        align-items: stretch !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    body:has(#app) .public-note-row-actions { width: 100%; }
    body:has(#app) .public-note-view-button { flex: 1 1 auto !important; }
    body:has(#app) .public-note-report-button { flex: 0 0 44px !important; }
}

/* Favourite collection and profile fields remain usable at narrow tablet/phone widths. */
body:has(#profile-page) #profile-page .favourites-grid {
    display: grid !important;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)) !important;
    gap: 14px !important;
}
body:has(#profile-page) #profile-page .favourite-card {
    min-width: 0 !important;
    max-width: 100%;
    padding: clamp(14px, 2.5vw, 22px) !important;
    border: 1px solid rgba(167,139,250,.2) !important;
    border-radius: 16px !important;
    background: #1A0F24 !important;
    color: #D6CBE3 !important;
    overflow-wrap: anywhere;
}
body:has(#profile-page) #profile-page .favourite-name {
    min-width: 0;
    color: #F5F0FA !important;
    font: 600 17px/1.2 var(--sans) !important;
    overflow-wrap: anywhere;
}
body:has(#profile-page) #profile-page .favourite-card :is(p, span, a, button, input) {
    max-width: 100%;
    overflow-wrap: anywhere;
}
body:has(#profile-page) #profile-page .name-input-container,
body:has(#profile-page) #profile-page .user-details,
body:has(#profile-page) #profile-page .name-input {
    width: 100%;
    min-width: 0;
}
@media (max-width: 767px) {
    body:has(#profile-page) #profile-page .favourites-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* Line icons are rendered only by the UI that owns them, never from user text. */
body:has(#app) .hm-icon { vertical-align: middle; }
.map-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}
body:has(#app) :is(.welcome-ghost, .map-dialog-icon, .notification-icon, .verification-icon) {
    color: var(--lilac);
}
body:has(#app) :is(.welcome-ghost, .map-dialog-icon, .notification-icon, .verification-icon) .hm-icon {
    width: 34px;
    height: 34px;
}
body:has(#app) #welcome-popup-overlay .welcome-ghost { margin-bottom: 12px; }
body:has(#app) :is(.title-icon, .rank-badge-icon, .upload-icon, .file-upload-icon, .cta-icon, .empty-icon) .hm-icon {
    width: 26px;
    height: 26px;
    color: var(--lavender);
}
body:has(#app) :is(.migration-notice-text, .detail-label, .error-message, .notes-button) .hm-icon {
    width: 16px;
    height: 16px;
}
