/* =========================================
   Map Alerts — Demo (1:1 with iOS app)
   Color palette translated directly from
   Map Alerts/Assets.xcassets/Colors/*.colorset
   ========================================= */
:root {
    /* iOS asset colors (light mode, sRGB) */
    --c-bottom-menu: #FFFFFF;     /* bottomMenuBg */
    --c-cell:        #FEFFFF;     /* cell */
    --c-deselected:  #667085;     /* deselected */
    --c-divider:     #F6F6F6;     /* divider */
    --c-link:        #007AFF;     /* link (iOS system blue) */
    --c-list:        #F6F6F6;     /* list — page background */
    --c-text:        #1E1E1E;     /* text */
    --c-secondary:   #6B6B6E;     /* iOS secondaryLabel */
    --c-tertiary:    #C7C7CC;     /* iOS tertiaryLabel */
    --c-telegram:    #0088CC;     /* telegramColor */

    /* Pin tint colors — match iOS PinColor enum */
    --pin-red:        #FF3B30;
    --pin-orange:     #FF9500;
    --pin-yellow:     #FFCC00;
    --pin-green:      #34C759;
    --pin-light-blue: #5AC8FA;
    --pin-blue:       #007AFF;
    --pin-purple:     #AF52DE;
    --pin-black:      #1E1E1E;

    /* Phone metrics (iPhone 15 Pro logical dimensions) */
    --phone-width: 390px;
    --phone-height: 844px;
    --phone-radius: 54px;
    --status-h: 54px;
    --tabbar-h: 84px;

    --sf: -apple-system, BlinkMacSystemFont, "SF Pro Text",
          "SF Pro Display", system-ui, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--sf);
    color: var(--c-text);
    background: #1d1f23;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Phone frame (desktop) ===== */
.stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(80% 60% at 50% 0%,  rgba(255, 122, 0, 0.10), transparent 60%),
        radial-gradient(80% 60% at 50% 100%, rgba(0, 122, 255, 0.10), transparent 60%),
        #14161a;
}

.phone {
    position: relative;
    width: var(--phone-width);
    height: var(--phone-height);
    border-radius: var(--phone-radius);
    background: #0b0c0e;
    padding: 14px;
    box-shadow:
        0 0 0 2px #2a2c30,
        0 30px 80px rgba(0,0,0,0.55),
        0 12px 28px rgba(0,0,0,0.4);
}

.phone::before,
.phone::after {
    content: "";
    position: absolute;
    background: #2a2c30;
}
.phone::before { /* volume up rocker */
    left: -3px; top: 130px; width: 3px; height: 64px; border-radius: 2px;
}
.phone::after  { /* power button */
    right: -3px; top: 200px; width: 3px; height: 88px; border-radius: 2px;
}

.phone-screen {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--c-list);
    border-radius: calc(var(--phone-radius) - 12px);
    overflow: hidden;
}

/* ===== Status bar ===== */
.status-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: var(--status-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 30px 0;
    z-index: 70;
    pointer-events: none;
    color: #000;
}
.status-time {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    width: 80px;
    text-align: center;
    margin-left: -8px;
}
.status-island {
    width: 110px;
    height: 36px;
    background: #000;
    border-radius: 22px;
    margin-top: 4px;
}
.status-icons {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 80px;
    justify-content: flex-end;
}
.icon-signal { width: 18px; height: 12px; fill: #000; }
.icon-wifi   { width: 17px; height: 12px; fill: #000; }
.icon-battery {
    display: flex; align-items: center;
    margin-left: 1px;
}
.icon-battery .battery-body {
    width: 26px; height: 12px;
    border: 1.2px solid rgba(0,0,0,0.4);
    border-radius: 3px;
    padding: 1px;
    position: relative;
}
.icon-battery .battery-fill {
    height: 100%;
    width: 88%;
    background: #000;
    border-radius: 1.5px;
}
.icon-battery .battery-cap {
    width: 2px; height: 4px;
    background: rgba(0,0,0,0.4);
    border-radius: 0 1px 1px 0;
    margin-left: 1px;
}

/* ===== Screens ===== */
.screen-content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.screen-content.active { display: flex; }

/* ====== MAP SCREEN ====== */
.map-screen { background: var(--c-list); }
.map-screen.active { display: block; }
.map-area {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
}
#leaflet-map {
    position: absolute;
    inset: 0;
    z-index: 1;
}
.leaflet-control-container { display: none; }
.leaflet-container {
    background: #f5f5f5 !important;
    font-family: var(--sf) !important;
}

/* Map overlay buttons */
.map-overlay-left {
    position: absolute;
    top: calc(var(--status-h) + 4px);
    left: 16px;
    right: 16px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    pointer-events: none;
}
.map-overlay-left > * { pointer-events: auto; }
.location-btn {
    position: absolute;
    top: calc(var(--status-h) + 4px);
    right: 16px;
    z-index: 20;
}
.round-btn {
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 16px;
    background: var(--c-list);
    color: var(--c-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 25px rgba(0,0,0,0.30);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
}
.round-btn:active { transform: scale(0.96); }
.round-btn.expanded {
    box-shadow: 0 4px 25px rgba(0,0,0,0.30),
                inset 0 0 0 4px var(--c-link);
}
.round-btn.time-btn { position: relative; }
.round-btn .time-btn-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    font-size: 15px;
    font-weight: 700;
    color: var(--c-text);
    pointer-events: none;
}

/* Filter popovers — channel = full width, time = fixed 180px (matches iOS
   `fixedSize ? 180 : nil` in SelectableItem.swift) */
.filter-popover {
    background: var(--c-list);
    border-radius: 16px;
    margin-top: -4px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    overflow: hidden;
    animation: popIn 0.2s ease-out;
    align-self: stretch;        /* fills the parent row width */
}
.filter-popover.time-popover { width: 180px; align-self: flex-start; }
@keyframes popIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.selectable-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.selectable-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}
.selectable-row .row-icon-wrap {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.selectable-row .row-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.selectable-row .row-icon-wrap svg { color: var(--c-link); }
.selectable-row .row-title {
    flex: 1;
    font-size: 16px;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.selectable-row .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(30,30,30,0.30);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 24px;
    height: 20px;
    line-height: 1;
}
.selectable-row .check {
    width: 24px; height: 24px;
    color: var(--c-link);
    flex-shrink: 0;
}
.selectable-row .check.hidden { visibility: hidden; }

/* ===== Bottom sheet =====
   3 positions, identical to iOS BottomSheetView.swift:
     bottom = 230px tall, middle = 100% / 1.7, full = 100%
   Sheet is bottom-anchored; height changes drive the visible portion. */
.sheet {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    background: var(--c-list);
    border-radius: 20px 20px 0 0;
    z-index: 30;
    transition: height 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: height;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 18px rgba(0,0,0,0.06);
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
}
/* iOS minHeight = 230pt INCLUDES the tab bar safe area; visually only ~80pt
   sheet content shows above the tab bar. We anchor the sheet on top of the
   tab bar instead, so 175px gives that ~90px of visible header room. */
.sheet[data-position="bottom"] { height: 175px; }
.sheet[data-position="middle"] { height: 58.8%; }                       /* 100 / 1.7 */
.sheet[data-position="full"]   { height: calc(100% - var(--status-h)); } /* respects top safe area */

/* Big invisible drag-handle hit area so the user can grab anywhere along
   the top of the sheet without having to hit the small grabber pill */
.sheet-handle {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.sheet-handle:active { cursor: grabbing; }
.grabber {
    width: 40px;
    height: 5px;
    border-radius: 2.5px;
    background: var(--c-deselected);
}
.sheet-header {
    padding: 4px 16px 8px;
    flex-shrink: 0;
    position: relative;
}
.sheet-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sheet-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--c-text);
    margin: 0;
    letter-spacing: -0.3px;
    flex: 1;
}
.sheet-subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: var(--c-text);
}
.sheet-scroll-top-btn {
    border: none;
    background: transparent;
    color: var(--c-link);
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.18s ease;
}
.sheet-scroll-top-btn[hidden] { display: none !important; }
.sheet-scroll-top-btn svg { width: 18px; height: 18px; stroke-width: 2.5; }

.events-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px calc(var(--tabbar-h) + 32px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.18s ease;
}
.sheet[data-position="bottom"] .events-list { opacity: 0; pointer-events: none; }

/* ===== Event cell ===== */
.event-cell {
    background: var(--c-cell);
    border-radius: 16px;
    padding: 16px;
    box-sizing: border-box;
    border: 2px solid transparent;
    transition: border-color 0.15s ease;
    cursor: pointer;
}
.event-cell.selected { border-color: var(--c-link); }
.event-cell-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.event-emoji-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--c-list);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
}
.event-meta {
    flex: 1;
    min-width: 0;
}
.event-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.event-title {
    flex: 1;
    font-size: 20px;
    font-weight: 500;
    color: var(--c-link);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-menu-btn {
    border: none;
    background: transparent;
    color: var(--c-link);
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    transform: rotate(90deg);
}
.event-summary {
    margin-top: 4px;
    font-size: 16px;
    color: var(--c-text);
    line-height: 1.3;
}
.event-source {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--c-link);
}
.event-source-avatar {
    width: 16px; height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.event-source-name {
    color: var(--c-link);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-footer {
    margin-top: 12px;
    border-top: 1px solid var(--c-divider);
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--c-text);
}
.event-footer-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.event-footer-item .clock-icon,
.event-footer-item .pin-icon {
    width: 14px; height: 14px;
    color: var(--c-deselected);
    stroke-width: 2;
    flex-shrink: 0;
}

/* ===== Map pins (Leaflet markers) =====
   One continuous SVG path: circle bubble + triangular tail (comic speech bubble
   shape). White stroke wraps the entire shape; a radial gradient overlay gives
   a subtle 3-D / glossy look. The bottom tip of the tail = the geographic
   anchor point. Selected pin is ~1.85× larger; the tail tip stays put while
   the bubble grows upward. */
.map-pin {
    position: relative;
    width: 80px;
    height: 92px;
    cursor: pointer;
}

.pin-shape {
    position: absolute;
    left: 50%;
    bottom: 18px;                   /* leaves room for the time pill */
    transform: translateX(-50%);
    width: 32px;
    height: 33px;                   /* viewBox 60×62, 32 × 62/60 = 33 */
    transition: width 0.22s cubic-bezier(0.32, 0.72, 0, 1),
                height 0.22s cubic-bezier(0.32, 0.72, 0, 1);
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.30));
    color: inherit;
    overflow: visible;
}
.map-pin.selected .pin-shape {
    width: 60px;
    height: 62px;
}
.pin-shape svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.map-pin .map-pin-time {
    position: absolute;
    bottom: 2px; left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.78);
    color: #fff;
    font-size: 6.5px;
    font-weight: 500;
    padding: 0.5px 4px;
    border-radius: 3px;
    white-space: nowrap;
    letter-spacing: 0.05px;
}

.map-pin.dimmed { filter: saturate(0.3) brightness(0.85); }

/* Tab bar (iOS 18 style — pill background under active item) */
.tab-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: var(--tabbar-h);
    background: var(--c-bottom-menu);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    z-index: 60;
    padding-bottom: 22px;
    border-top: 0.5px solid rgba(0,0,0,0.10);
}
.tab-item {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--c-text);
    padding: 6px 0 0;
    transition: color 0.15s ease;
    position: relative;
}
.tab-icon-wrap {
    position: relative;
    width: 64px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    transition: background-color 0.18s ease;
}
.tab-icon { width: 26px; height: 26px; stroke-width: 1.6; }
.tab-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05px;
    color: var(--c-text);
}
.tab-item.active .tab-icon-wrap { background: rgba(118, 118, 128, 0.12); }
.tab-item.active .tab-icon       { color: var(--c-link); }
.tab-item.active .tab-label      { color: var(--c-link); }

/* Active tab uses the FILLED variant of the icon; inactive uses the
   stroked outline. We keep both layers in the SVG and toggle via CSS. */
.tab-icon .tab-icon-fill   { display: none; }
.tab-icon .tab-icon-stroke { display: inline; }
.tab-item.active .tab-icon .tab-icon-fill   { display: inline; }
.tab-item.active .tab-icon .tab-icon-stroke { display: none; }

/* ====== SOURCES SCREEN ====== */
.sources-screen {
    background: var(--c-list);
    padding-top: var(--status-h);
    overflow-y: auto;
}
.sources-header {
    margin-top: 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--c-text);
}
.channels-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.channel-item {
    background: var(--c-cell);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.25s ease;
}
.channel-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    height: 80px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
}
.channel-avatar-stack {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}
.channel-avatar-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
}
.channel-avatar-bg {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--c-cell);
}
.channel-avatar {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    object-fit: cover;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
}
.channel-title {
    flex: 1;
    font-size: 17px;
    color: var(--c-text);
    line-height: 1.2;
}
.channel-chevron {
    width: 18px; height: 18px;
    color: var(--c-deselected);
    transition: transform 0.25s ease;
    stroke-width: 2.4;
    flex-shrink: 0;
}
.channel-item.expanded .channel-chevron { transform: rotate(180deg); }

.channel-expand-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 12px;
}
.channel-item.expanded .channel-expand-content { max-height: 200px; padding: 0 12px 12px; }
.expand-label {
    font-size: 13px;
    color: var(--c-deselected);
    margin: 4px 0 8px;
}
.color-options {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex: 1;
}
.color-dot svg { width: 18px; height: 18px; display: none; }
.color-dot.selected svg { display: block; }

.edit-channels-btn {
    align-self: center;
    margin-bottom: calc(var(--tabbar-h) + 16px);
}

.link-btn {
    background: none;
    border: none;
    color: var(--c-link);
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px 16px;
}

/* ====== SETTINGS SCREEN ====== */
.settings-screen {
    background: var(--c-list);
}
.nav-bar {
    position: relative;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: var(--status-h);
    flex-shrink: 0;
}
.nav-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--c-text);
    margin: 0;
    letter-spacing: -0.3px;
}
.settings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 calc(var(--tabbar-h) + 16px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.section-header {
    font-size: 17px;
    font-weight: 600;
    color: var(--c-secondary);
    padding: 0 32px;
}

.map-settings-card,
.settings-card {
    background: var(--c-cell);
    border-radius: 16px;
    margin: 0 16px;
}
.map-settings-card { padding: 16px; }

.map-preview {
    position: relative;
    height: 195px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}
.preview-img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.preview-alert-area {
    position: absolute;
    width: 100px; height: 100px;
    background: #ff3b30;
    filter: blur(30px);
    opacity: 0;
    top: 50%; left: 50%;
    transform: translate(-50%, calc(-50% - 20px));
    border-radius: 50%;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.preview-alert-area.visible { opacity: 0.85; }

.preview-pins {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.preview-pin {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.preview-pin .balloon {
    position: relative;
    width: 73px; height: 66px;
    /* iOS uses empty_pin.png — the red balloon shape — for all 3 demo pins.
       Matches MapSettingsView.swift `Image(.emptyPin)`. */
    background-image: url('../assets/empty_pin.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: filter 0.25s ease;
}
.preview-pin .balloon-glyph {
    position: absolute;
    top: 8px; left: 0; right: 0;
    text-align: center;
    font-size: 22px;
    line-height: 32px;
}
.preview-pin .balloon-avatar {
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-52%);
    width: 30px; height: 30px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid #fff;
}
.preview-pin .balloon-avatar[data-avatar="1"] { background-image: url('../assets/avatar1.png'); }
.preview-pin .balloon-avatar[data-avatar="2"] { background-image: url('../assets/avatar2.png'); }
.preview-pin .balloon-avatar[data-avatar="3"] { background-image: url('../assets/avatar3.png'); }
.preview-pin.dim .balloon { filter: saturate(0.3) brightness(0.85) contrast(0.85); }

.preview-pin .time-pill {
    margin-top: -10px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 8px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
}
.preview-pin .time-pill.hidden { display: none; }

.preview-pin.pp1 { left: 16%;  top: 18%; }
.preview-pin.pp2 { left: 42%;  top: 32%; }
.preview-pin.pp3 { left: 70%;  top: 46%; }

.toggle-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.toggle-label {
    font-size: 17px;
    color: var(--c-text);
    flex: 1;
    line-height: 1.2;
}

/* iOS toggle switch */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 51px; height: 31px;
    flex-shrink: 0;
}
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-switch .track {
    position: absolute;
    inset: 0;
    background: #E9E9EA;
    border-radius: 16px;
    transition: background 0.2s ease;
}
.ios-switch .thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 27px; height: 27px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15),
                0 1px 1px rgba(0,0,0,0.06);
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.ios-switch input:checked + .track { background: var(--c-link); }
.ios-switch input:checked + .track .thumb { transform: translateX(20px); }

/* Settings rows */
.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
}
.settings-row .row-icon {
    width: 22px; height: 22px;
    color: var(--c-link);
    flex-shrink: 0;
    margin-right: 2px;
}
.settings-row .row-text {
    flex: 1;
    font-size: 17px;
    color: var(--c-text);
}
.settings-row .row-chevron {
    width: 12px; height: 12px;
    color: var(--c-tertiary);
    flex-shrink: 0;
}
.settings-row-tall { align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
.settings-row-tall .row-icon { margin-top: 2px; }
.row-text-stack { flex: 1; min-width: 0; }
.row-text-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.row-text-row .row-text { flex: 1; }
.row-subtitle {
    font-size: 13px;
    color: var(--c-secondary);
    margin-top: 2px;
    line-height: 1.3;
}
.settings-divider {
    height: 1px;
    background: var(--c-divider);
    margin-left: 44px;
}

/* ===== Action sheet ===== */
[hidden] { display: none !important; }
.action-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.30);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
    padding-bottom: 12px;
    animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.action-sheet {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.action-list, .action-cancel {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    border-radius: 14px;
    overflow: hidden;
}
.action-row, .action-cancel {
    width: 100%;
    border: none;
    background: transparent;
    padding: 17px 16px;
    font-size: 20px;
    color: var(--c-link);
    cursor: pointer;
    border-bottom: 0.5px solid rgba(60,60,67,0.20);
}
.action-row:last-child { border-bottom: none; }
.action-row.destructive { color: var(--pin-red); }
.action-cancel { font-weight: 600; padding: 17px 16px; }

/* Mobile (no phone frame on small screens) */
@media (max-width: 480px) {
    body { background: var(--c-list); }
    .stage { padding: 0; min-height: 100vh; }
    .phone {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
    }
    .phone::before, .phone::after { display: none; }
    .phone-screen { border-radius: 0; }
}

/* ===== Embed mode (used when ?embed=1 — landing page iframe) ===== */
html.embed, html.embed body, body.embed {
    background: transparent !important;
}
html.embed .stage, body.embed .stage {
    background: transparent !important;
    padding: 0 !important;
    min-height: auto;
}
/* Iframes can be ≤480px wide, which triggers the mobile media query above and
   strips the phone chrome. In embed mode we always want the native phone frame. */
html.embed .phone, body.embed .phone {
    width: 390px !important;
    height: 844px !important;
    border-radius: 54px !important;
    padding: 14px !important;
    box-shadow: none !important;
}
html.embed .phone::before, body.embed .phone::before,
html.embed .phone::after,  body.embed .phone::after { display: block !important; }
html.embed .phone-screen, body.embed .phone-screen {
    border-radius: 42px !important;
    /* Chrome bug: overflow:hidden + border-radius doesn't always clip a
       backdrop-filter layer (used by .tab-bar). clip-path forces it. */
    clip-path: inset(0 round 42px);
    isolation: isolate;
}
html.embed .phone, body.embed .phone {
    clip-path: inset(0 round 54px);
    isolation: isolate;
}

/* ----- Embed dark theme — mirrors the iOS app's dark colour set ----- */
html.embed, body.embed {
    --c-bottom-menu: #202342;
    --c-cell:        #2D325A;
    --c-deselected:  #7E81AD;
    --c-divider:     #34363A;
    --c-link:        #4F7FFF;
    --c-list:        #252A4A;
    --c-text:        #DAE0EE;
    --c-secondary:   #9BA0B5;
    --c-tertiary:    #5C6173;
}
/* Status bar text/icons go light on dark */
body.embed .status-bar { color: rgba(255, 255, 255, 0.92); }
body.embed .icon-signal,
body.embed .icon-wifi { fill: rgba(255, 255, 255, 0.92); }
body.embed .icon-battery .battery-body { border-color: rgba(255, 255, 255, 0.45); }
body.embed .icon-battery .battery-fill { background: rgba(255, 255, 255, 0.92); }
body.embed .icon-battery .battery-cap  { background: rgba(255, 255, 255, 0.45); }
/* Dynamic island stays dark (it's a hole-punch on iOS).
   Map tiles stay in their native light voyager palette in embed mode too. */
