* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    color: #111;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}

.contacts-panel {
    width: min(390px, 40vw);
    min-width: 300px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e7e7e7;
    display: flex;
    flex-direction: column;
    z-index: 20;
    color: #111;
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
}

body.panel-closed .contacts-panel {
    width: 0;
    min-width: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
    overflow: hidden;
}

body.panel-open .contacts-panel {
    opacity: 1;
    pointer-events: auto;
}

.contacts-header {
    position: relative;
    padding: max(14px, env(safe-area-inset-top)) 40px 10px 10px;
    border-bottom: 1px solid #efefef;
}
.contacts-close {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #f0f0f5;
    color: #555;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.contacts-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #2481cc;
}
.contacts-city {
    margin-top: 2px;
    font-size: 13px;
    color: #8e8e93;
}

.contacts-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 12px;
    padding: 0 12px;
    height: 40px;
    border-radius: 10px;
    background: #f0f0f5;
    color: #8e8e93;
}
.contacts-search {
    flex: 1;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: #111;
    outline: none;
}
.contacts-search::placeholder { color: #a0a0a8; }

.contacts-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.contact-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: none;
    background: #fff;
    text-align: left;
    cursor: pointer;
    border-bottom: 1px solid #f2f2f2;
}
.contact-row:hover { background: #f7f9fc; }
.contact-row.is-active { background: #eaf4fd; }
.contact-row__avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #ddd;
}
.contact-row__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.contact-row__name {
    font-size: 16px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-row__status {
    font-size: 14px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-row__status .online { color: #6ab2f2; font-weight: 500; }
.contact-row__status .muted { color: #8e8e93; }
.tg-theme .contact-row__status .online { color: #6ab2f2; }
.contact-row.is-online { background: rgba(106, 178, 242, 0.06); }

.contacts-bottom-tabs {
    display: flex;
    border-top: 1px solid #e7e7e7;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fafafa;
}
.contacts-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #8e8e93;
    cursor: pointer;
}
.contacts-tab svg { stroke: #8e8e93; }
.contacts-tab.active {
    color: #2481cc;
}
.contacts-tab.active svg { stroke: #2481cc; }

.map-pane {
    flex: 1;
    position: relative;
    min-width: 0;
    background: #aad3df;
}
.map-pane #map {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #aad3df;
}

.map-member-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 480;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(30, 27, 46, 0.92), rgba(22, 20, 34, 0.98));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 14px;
    font-weight: 600;
}
.map-member-bar a {
    color: #e8e4ff;
    text-decoration: none;
}
.map-member-bar a:hover { color: #fff; }
.map-member-bar__dot { color: #6b6580; }
.map-member-bar__user { color: #d4cfe8; font-weight: 600; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.map-pane .leaflet-bottom {
    bottom: calc(44px + env(safe-area-inset-bottom));
}

.map-open-list {
    position: absolute;
    z-index: 500;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: #2481cc;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}
body.panel-open .map-open-list {
    display: none;
}

.app-top,
.bottom-nav,
.map-tools { display: none !important; }

@media (max-width: 820px) {
    body.panel-open .contacts-panel {
        width: min(85vw, 300px);
        min-width: 240px;
    }
    .contact-row__name { font-size: 14px; }
    .contact-row__status { font-size: 12px; }
    .contact-row__avatar { width: 44px; height: 44px; }
    .contacts-header h1 { font-size: 18px; }
}

/* Snap Map pastel ton */
.leaflet-tile-pane {
    filter: saturate(1.08) contrast(0.98) brightness(1.02);
}

.leaflet-control-attribution {
    font-size: 9px !important;
    background: rgba(255,255,255,.65) !important;
    border-radius: 6px 0 0 0;
}

/* Isı noktaları */
.heat-layer { pointer-events: none; }

/* Üst bar */
.app-top {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 500;
    padding: max(10px, env(safe-area-inset-top)) 12px 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.app-top > * { pointer-events: auto; }

.story-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 3px;
    flex-shrink: 0;
    box-sizing: border-box;
    background: linear-gradient(160deg, #ff5c8a 0%, #ffd07a 50%, #ff5c8a 100%);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}
.story-avatar--top { width: 40px; height: 40px; padding: 2px; }
.story-avatar--rail { width: 62px; height: 62px; margin: 0 auto; }
.story-avatar--map { width: 52px; height: 52px; margin: 0 auto; }
.story-avatar__inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #141414;
    border: 2px solid #141414;
}
.story-avatar__inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}
.nf-marker-wrap .story-avatar__inner {
    display: block;
    flex: none;
}
.nf-marker-wrap .story-avatar__map-photo,
.leaflet-div-icon.nf-marker-wrap img.story-avatar__map-photo {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
    object-position: center 22%;
    display: block;
}
.story-avatar-label {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.15;
    color: #fff;
    text-align: center;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95), 0 2px 10px rgba(0, 0, 0, 0.55);
    white-space: nowrap;
    max-width: 76px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-pill {
    flex: 1;
    background: rgba(255,255,255,.94);
    color: #222;
    border-radius: 999px;
    padding: 11px 16px;
    font-weight: 600;
    font-size: 15px;
    box-shadow: 0 4px 18px rgba(0,0,0,.12);
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-pill svg { opacity: .45; flex-shrink: 0; }

.icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: none; background: rgba(255,255,255,.92);
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    display: grid; place-items: center; cursor: pointer;
    color: #333;
}

/* Sağ araç çubuğu */
.map-tools {
    display: none !important;
}
.tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 2px solid transparent;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,.14);
    cursor: pointer;
    color: #1a1a1a;
    display: grid;
    place-items: center;
    padding: 0;
}
.tool-btn.active {
    border-color: #ff4d8d;
    box-shadow: 0 4px 16px rgba(255,77,141,.35);
}

/* Alt navigasyon */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 600;
    padding: 0 10px calc(8px + env(safe-area-inset-bottom));
    pointer-events: none;
}
.bottom-nav-inner {
    pointer-events: auto;
    background: rgba(18,18,18,.88);
    backdrop-filter: blur(12px);
    border-radius: 22px 22px 0 0;
    border: 1px solid rgba(255,255,255,.08);
    border-bottom: none;
    padding: 10px 12px 12px;
}
.avatar-rail {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px 2px 10px;
}
.avatar-rail::-webkit-scrollbar { display: none; }
.rail-item {
    flex: 0 0 auto;
    width: 72px;
    text-align: center;
    cursor: pointer;
}
.rail-item .story-avatar-label {
    max-width: 72px;
    font-size: 11px;
}

.nav-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.nav-tab {
    flex: 1;
    max-width: 140px;
    padding: 10px;
    border-radius: 14px;
    border: none;
    background: rgba(255,255,255,.08);
    color: #ccc;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.nav-tab.active {
    background: rgba(255,255,255,.16);
    color: #fff;
}

/* Harita marker (Leaflet) */
.leaflet-marker-icon.nf-marker-wrap {
    background: transparent !important;
    border: none !important;
    width: 58px !important;
    height: 58px !important;
    overflow: visible !important;
}
.leaflet-div-icon.nf-marker-wrap img {
    max-width: none !important;
    max-height: none !important;
}
.nf-marker {
    text-align: center;
    width: 58px;
    margin-left: -29px;
    margin-top: -29px;
    transition: transform .18s ease;
}
.nf-marker .story-avatar--map {
    margin: 0;
}
.nf-marker.is-active {
    transform: scale(1.06);
}
.nf-marker.is-active .story-avatar--map {
    box-shadow: 0 4px 16px rgba(255, 92, 138, 0.45);
}
.nf-marker .story-avatar-label {
    display: none;
}

/* Story */
.story-preview {
    position: fixed; inset: 0; z-index: 850;
    display: none;
    background: #111 center/cover no-repeat;
    cursor: pointer;
}
.story-preview.open { display: block; }
.story-preview,
.story-preview .story-ui,
.story-preview .story-ui h3,
.story-preview .story-ui li {
    color: #fff;
}
.story-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}
.story-bars {
    position: absolute; top: max(8px, env(safe-area-inset-top));
    z-index: 2;
    left: 10px; right: 10px;
    display: flex; gap: 4px; height: 3px;
}
.story-bars span {
    flex: 1;
    height: 100%;
    border-radius: 2px;
    background: rgba(255,255,255,.35);
    transition: background .2s;
}
.story-bars span.done,
.story-bars span.active {
    background: #fff;
}
.story-bars span.pending {
    background: rgba(255,255,255,.35);
}
.story-ui {
    position: absolute; inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.35) 0%,
        transparent 22%,
        transparent 45%,
        rgba(0, 0, 0, 0.55) 72%,
        rgba(0, 0, 0, 0.88) 100%
    );
    padding: max(36px, calc(env(safe-area-inset-top) + 24px)) 20px calc(100px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; justify-content: flex-end;
    pointer-events: none;
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
.story-ui h3,
.story-ui ul,
.story-open-profile {
    pointer-events: auto;
}
.story-tap-zones {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
}
.story-tap-zones button {
    flex: 1;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.story-ui h3 {
    font-size: clamp(26px, 7vw, 34px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 12px;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65), 0 1px 2px rgba(0, 0, 0, 0.8);
}
.story-ui ul {
    list-style: none;
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.story-ui li {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.96);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.85);
}
.close-x {
    position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(0,0,0,.45); color: #fff; border: none;
    font-size: 22px; cursor: pointer; z-index: 3;
    pointer-events: auto;
}
.story-open-profile {
    align-self: center;
    text-align: center;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}
.story-open-profile .circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Profil sheet */
.overlay {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0,0,0,.55);
    display: none; align-items: flex-end; justify-content: center;
}
.overlay.open { display: flex; }
.sheet {
    width: 100%; max-width: 480px; max-height: 92vh;
    background: #fff; color: #111;
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform .28s ease;
}
.overlay.open .sheet { transform: translateY(0); }
.sheet-cover {
    height: 40vh; min-height: 200px;
    background: #222 center/cover no-repeat;
    position: relative;
}
.sheet-body { padding: 18px 18px 24px; overflow-y: auto; max-height: 52vh; }
.sheet-body h2 { color: #c41e3a; font-size: 26px; margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 13px; color: #666; margin-bottom: 14px; }
.bio {
    font-size: 14px; line-height: 1.55; color: #333; white-space: pre-wrap;
    border-left: 3px solid #c41e3a; padding-left: 12px; margin-bottom: 18px;
}
.sheet-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.sheet-gallery img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 8px;
    background: #eee;
}
.wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #25d366;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    line-height: 1;
    text-decoration: none;
    border: none;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    -webkit-tap-highlight-color: transparent;
}
.wa-btn:active {
    transform: scale(0.99);
    background: #20bd5a;
}
.wa-btn__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}
.wa-btn__icon img {
    display: block;
    width: 24px;
    height: 24px;
}
.wa-btn__text {
    display: block;
    letter-spacing: 0.01em;
}

.empty-toast {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    z-index: 400; background: rgba(0,0,0,.75); padding: 14px 18px;
    border-radius: 12px; font-size: 14px; text-align: center;
    max-width: 85%; display: none;
}
.empty-toast.show { display: block; }

.leaflet-control-zoom { display: none !important; }
