* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background: #000; color: #fff;
    overflow: hidden;
    -webkit-user-select: none; user-select: none;
}

#map { position: fixed; inset: 0; z-index: 0; }

/* Top bar */
.top-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.top-row { display: flex; align-items: center; gap: 10px; }
.app-icon { width: 36px; height: 36px; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.app-icon img { width: 100%; height: 100%; }
.btn-x {
    width: 32px; height: 32px; background: rgba(255,255,255,0.1);
    color: #999; border: none; border-radius: 50%; font-size: 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.btn-x:active { opacity: 0.8; }

/* Search bar */
.search-wrap { position: relative; flex: 1; max-width: 260px; }
.search-input {
    width: 100%; padding: 10px 12px 10px 32px;
    background: rgba(44, 44, 46, 0.9); border: none;
    border-radius: 10px; color: #fff; font-size: 15px;
    font-family: inherit; backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.search-input::placeholder { color: #888; }
.search-input:focus { outline: none; border: 1px solid #007AFF; }
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: #888; font-size: 14px; pointer-events: none;
}
.search-clear {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: #555; color: #fff; border: none; border-radius: 50%;
    width: 20px; height: 20px; font-size: 12px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    line-height: 1;
}
.search-results {
    position: absolute; top: 100%; left: 0; right: 0;
    margin-top: 6px; background: rgba(28, 28, 30, 0.95);
    border-radius: 12px; overflow: hidden;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    display: none; max-height: 280px; overflow-y: auto;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 12px 14px; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:active { background: rgba(255,255,255,0.08); }
.search-result-name { font-size: 15px; font-weight: 500; }
.search-result-addr { font-size: 12px; color: #888; margin-top: 2px; }
.search-loading {
    padding: 12px 14px; font-size: 14px; color: #888;
    display: flex; align-items: center; gap: 8px;
}
.search-loading::before {
    content: ''; width: 12px; height: 12px;
    border: 2px solid #444; border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Top-bar buttons */
.btn-icon {
    width: 40px; height: 40px;
    background: rgba(44, 44, 46, 0.9); color: #fff;
    border: none; border-radius: 10px;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.btn-icon:active { opacity: 0.8; }
.btn-share {
    padding: 10px 20px; background: #007AFF; color: #fff;
    border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.btn-share:active { opacity: 0.8; }
.btn-share:disabled { background: #333; color: #666; cursor: default; }

/* First-visit welcome card */
.welcome-card {
    display: none;
    position: fixed; left: 50%; bottom: 72px;
    transform: translateX(-50%);
    z-index: 1500;
    max-width: 320px; width: calc(100% - 32px);
    background: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.welcome-card.show { display: block; }
.welcome-close {
    position: absolute; top: 4px; right: 4px;
    width: 28px; height: 28px;
    background: transparent; color: #888; border: none;
    font-size: 20px; cursor: pointer; line-height: 1;
}
.welcome-close:active { color: #fff; }
.welcome-title {
    color: #fff; font-size: 15px; font-weight: 600;
    margin-bottom: 4px; padding-right: 24px;
}
.welcome-body { color: #aaa; font-size: 13px; line-height: 1.45; }
.welcome-body a { color: #007AFF; text-decoration: none; }

/* Bottom hint */
.bottom-hint {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    text-align: center;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}
.hint-text { color: #888; font-size: 14px; }
.hint-text a { color: #007AFF; text-decoration: none; pointer-events: auto; }

/* === Bottom sheet === */
.sheet-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0, 0, 0, 0);
    transition: background 0.25s ease;
    display: flex; align-items: flex-end; justify-content: center;
    pointer-events: none;
}
.sheet-overlay.show {
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
}
.sheet {
    width: 100%;
    max-width: 560px;
    background: #1c1c1e;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(.32, .72, 0, 1);
    display: flex; flex-direction: column;
    overflow: hidden;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.sheet-overlay.show .sheet { transform: translateY(0); }
.sheet-snap-peek { max-height: 240px; }
.sheet-snap-half { max-height: min(70vh, 600px); }
.sheet-snap-full { height: 90vh; }
.sheet-handle {
    width: 36px; height: 5px; background: #555; border-radius: 3px;
    margin: 8px auto 8px;
    cursor: grab;
}
.sheet-handle:active { cursor: grabbing; }
.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 20px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sheet-title { font-size: 17px; font-weight: 600; color: #fff; }
.sheet-header-actions { display: flex; gap: 8px; align-items: center; }
.sheet-body {
    padding: 16px 20px 4px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* === Pin form (inside sheet) === */
.pin-form-content { display: flex; flex-direction: column; }
.emoji-picker {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}
.emoji-option {
    width: 44px; height: 44px; font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    background: #2c2c2e; border: 2px solid transparent;
    border-radius: 10px; cursor: pointer;
}
.emoji-option.selected { border-color: #007AFF; background: rgba(0,122,255,0.15); }
.pin-input {
    width: 100%; padding: 12px 14px; background: #2c2c2e; border: none;
    border-radius: 10px; color: #fff; font-size: 16px; margin-bottom: 10px;
    font-family: inherit;
}
.pin-input::placeholder { color: #666; }
.pin-input:focus { outline: none; border: 1px solid #007AFF; }
.pin-notes { resize: vertical; min-height: 72px; line-height: 1.4; }
.pin-form-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn-cancel {
    flex: 1; padding: 12px; background: #2c2c2e; color: #fff;
    border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer;
}
.btn-save {
    flex: 1; padding: 12px; background: #007AFF; color: #fff;
    border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer;
}
.btn-save:active, .btn-cancel:active { opacity: 0.8; }
.btn-delete {
    width: 100%; padding: 12px; background: transparent; color: #ff453a;
    border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
    cursor: pointer; margin-top: 12px;
}
.btn-delete:active { opacity: 0.7; }

.pin-expiry-row { margin-bottom: 10px; }
.pin-expiry-add {
    background: transparent; border: none; padding: 8px 0;
    color: #888; font-size: 14px; font-family: inherit;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.pin-expiry-add:active { color: #aaa; }
.pin-expiry-active { display: flex; gap: 8px; align-items: center; }
.pin-expiry-date { flex: 1; margin-bottom: 0; color-scheme: dark; }
.pin-expiry-clear {
    background: transparent; border: none; color: #888;
    font-size: 22px; cursor: pointer; padding: 4px 8px; line-height: 1;
}
.pin-expiry-clear:active { color: #fff; }

/* === Share result modal === */
.share-result {
    display: none; position: fixed; inset: 0; z-index: 3000;
    background: rgba(0,0,0,0.7);
    align-items: center; justify-content: center;
}
.share-result.show { display: flex; }
.share-card {
    background: #1c1c1e; border-radius: 16px; padding: 28px 24px;
    text-align: center; max-width: 340px; width: 90%;
}
.share-card h2 { font-size: 20px; margin-bottom: 8px; }
.share-card p { color: #999; font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.share-url-box { display: flex; gap: 8px; margin-bottom: 16px; }
.share-url {
    flex: 1; padding: 10px 12px; background: #2c2c2e; border: none;
    border-radius: 8px; color: #fff; font-size: 14px; font-family: monospace;
}
.btn-copy {
    padding: 10px 16px; background: #007AFF; color: #fff; border: none;
    border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    white-space: nowrap;
}
.btn-copy:active { opacity: 0.8; }
.share-card .btn-done {
    display: block; width: 100%; padding: 12px; background: #007AFF;
    color: #fff; border: none; border-radius: 10px; font-size: 15px;
    font-weight: 600; cursor: pointer; margin-top: 8px;
}
.share-card .btn-cancel-share {
    display: block; width: 100%; padding: 12px; background: #2c2c2e;
    color: #fff; border: none; border-radius: 10px; font-size: 15px;
    font-weight: 600; cursor: pointer; margin-top: 8px;
}
.share-nemo-link {
    display: block; color: #007AFF; font-size: 13px;
    text-decoration: none; margin-top: 12px;
}

/* === Emoji markers === */
.emoji-marker {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; font-size: 20px;
    background: rgba(30, 30, 30, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    position: relative;
}
.emoji-marker.draft {
    border-color: rgba(0, 122, 255, 0.5);
    box-shadow: 0 0 8px rgba(0, 122, 255, 0.3);
}
/* Time-bound pin: orange border + white clock badge in bottom-right.
   Mirrors the iOS app's "expiring" treatment. */
.emoji-marker.expiring { border: 2px solid #FF9500; }
.emoji-marker .expiry-badge {
    position: absolute;
    bottom: -4px; right: -4px;
    width: 14px; height: 14px;
    background: #FF9500;
    border: 1.5px solid white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.emoji-marker .expiry-badge svg { width: 8px; height: 8px; }

/* === My-location button === */
/* Lifts both the bottom-right (locate) and bottom-left (zoom) controls above
   the home-indicator inset and the bottom hint gradient. */
.leaflet-bottom.leaflet-right,
.leaflet-bottom.leaflet-left {
    margin-bottom: max(60px, calc(50px + env(safe-area-inset-bottom)));
}
.nemo-locate-btn {
    width: 44px; height: 44px;
    background: rgba(28, 28, 30, 0.9);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    padding: 0;
}
.nemo-locate-btn:active { opacity: 0.8; }
.nemo-locate-btn.active { color: #007AFF; }
.nemo-locate-btn.denied { color: #666; }
.nemo-locate-btn.locating { cursor: progress; }
.nemo-locate-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: #007AFF;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* === User-location dot (mirrors iOS Maps "blue dot") === */
.user-location-dot {
    width: 18px; height: 18px;
    background: #007AFF;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4), 0 1px 3px rgba(0,0,0,0.4);
    animation: user-location-pulse 2.2s ease-out infinite;
}
@keyframes user-location-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.45), 0 1px 3px rgba(0,0,0,0.4); }
    80%  { box-shadow: 0 0 0 18px rgba(0, 122, 255, 0),    0 1px 3px rgba(0,0,0,0.4); }
    100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0),       0 1px 3px rgba(0,0,0,0.4); }
}

/* === Cluster (override leaflet.markercluster defaults) === */
/* Override all 3 size tiers — the iOS app doesn't size-tier, just shows count. */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large,
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: transparent !important;
    box-shadow: none !important;
}
.nemo-cluster {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #007AFF;
    border: 2px solid white;
    color: white;
    font-weight: 700;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* === Leaflet popup overrides (kept for any rare popup, e.g. attribution) === */
.leaflet-popup-content-wrapper {
    background: #1c1c1e !important; color: #fff !important;
    border-radius: 12px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-content {
    margin: 12px 14px !important;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 14px !important; line-height: 1.4 !important;
}
.leaflet-popup-tip { background: #1c1c1e !important; }
.leaflet-control-attribution { font-size: 10px !important; opacity: 0.6; }

/* === List view === */
.list-view { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; }
.list-empty { color: #888; font-size: 14px; text-align: center; padding: 32px 16px; }
.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 4px;
    cursor: pointer;
    border-radius: 8px;
}
.list-row:active { background: rgba(255,255,255,0.06); }
.list-row.expired { opacity: 0.55; }
.list-row-emoji {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.list-row-text { flex: 1; min-width: 0; }
.list-row-title {
    font-size: 15px; color: #fff; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-row-title.untitled { color: #888; font-style: italic; }
.list-row-notes {
    font-size: 12px; color: #888; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-row-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px;
    background: #FF9500;
    color: white;
    font-size: 11px; font-weight: 600;
    border-radius: 999px;
    flex-shrink: 0;
}
.list-row-pill.expired {
    background: rgba(255,255,255,0.08);
    color: #888;
}

/* === Sort menu === */
.sort-menu { position: relative; }
.sort-menu-btn {
    background: transparent; border: none; color: #fff; cursor: pointer;
    padding: 6px 8px; border-radius: 6px;
}
.sort-menu-btn:active { background: rgba(255,255,255,0.08); }
.sort-menu-list {
    position: absolute; top: 100%; right: 0; margin-top: 6px;
    background: #2c2c2e; border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    min-width: 140px; padding: 4px;
    z-index: 100;
}
.sort-menu-item {
    display: block; width: 100%;
    background: transparent; border: none; color: #fff;
    padding: 10px 12px; text-align: left;
    font-size: 14px; cursor: pointer; border-radius: 6px;
    font-family: inherit;
}
.sort-menu-item:active { background: rgba(255,255,255,0.08); }
.sort-menu-item.selected { color: #007AFF; font-weight: 600; }

/* === Options sheet === */
.options-content { display: flex; flex-direction: column; gap: 20px; }
.options-section { display: flex; flex-direction: column; gap: 8px; }
.options-heading {
    font-size: 12px; font-weight: 600;
    color: #888; text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}
.emoji-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
}
.emoji-filter-cell {
    position: relative;
    aspect-ratio: 1;
    background: #2c2c2e;
    border: none; border-radius: 10px;
    font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: #fff;
}
.emoji-filter-cell:active { background: #333; }
.emoji-filter-glyph { line-height: 1; }
.emoji-filter-overlay {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    background: rgba(28, 28, 30, 0.7);
    border-radius: 10px;
    color: #888;
}
.emoji-filter-cell.hidden .emoji-filter-overlay { display: flex; }
.emoji-filter-cell.hidden .emoji-filter-glyph { opacity: 0.35; }

.options-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 4px;
    cursor: pointer;
}
.options-toggle-label { font-size: 15px; color: #fff; }
.options-toggle-input {
    width: 48px; height: 28px;
    -webkit-appearance: none; appearance: none;
    background: #3a3a3c; border-radius: 999px;
    position: relative; cursor: pointer;
    transition: background 0.18s;
}
.options-toggle-input::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 24px; height: 24px;
    background: white; border-radius: 50%;
    transition: transform 0.18s;
}
.options-toggle-input:checked { background: #34C759; }
.options-toggle-input:checked::after { transform: translateX(20px); }

.options-action {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: #2c2c2e; color: #fff;
    border: none; border-radius: 10px;
    font-size: 15px; font-weight: 500;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.options-action:active { background: #333; }
.options-action.danger { color: #ff453a; }
.options-action-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    color: #007AFF;
    flex-shrink: 0;
}
.options-action.danger .options-action-icon { color: #ff453a; }
.options-action-label { flex: 1; }
