.sidebar-header {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 4px;
}

.close-btn:hover {
    opacity: 1;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-emoji {
    font-size: 26px;
    /* Emoji 不受背景裁切影響，保持原色 */
}

.sidebar-controls {
    padding: 10px 15px;
    /* 扁平化：減小上下內距 */
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* 減小元素間距 */
}

.search-box {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.6);
}

.search-box:focus {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-box {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    background: rgba(255, 255, 255, 0.6);
    cursor: pointer;
}

.rating-buttons {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}

.rating-btn {
    flex: 1;
    padding: 8px 2px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    white-space: nowrap;
}

.rating-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.rating-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transform: scale(1.05);
}

/* 自訂 Range Slider 樣式 */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.05);
    height: 6px;
    border-radius: 3px;
    outline: none;
    margin: 10px 0;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.action-button {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-button:hover {
    background: var(--primary-hover);
}

.action-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 150px 8px;
    /* 自訂捲軸 */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* 輕量化目錄樣式 */
.batch-item {
    margin-bottom: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
    transition: all 0.2s ease;
}

.batch-item:hover {
    transform: none;
    box-shadow: none;
}

.batch-header {
    padding: 5px 6px;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    position: relative;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.batch-header:hover {
    background: rgba(255, 255, 255, 0.6);
}

.batch-actions {
    display: flex;
    gap: 8px;
    padding: 0 16px 16px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.icon-btn {
    flex: 1;
    padding: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: white;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.icon-btn.delete:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Eye icon button (visibility toggle) */
.eye-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.15s;
    flex-shrink: 0;
    color: var(--primary-color);
    font-size: 15px;
    margin-right: 3px;
    padding: 0;
}

.eye-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.eye-btn.hidden-eye {
    color: #a0aec0;
}

.eye-btn.hidden-eye:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
}

.eye-btn-sm {
    width: 20px;
    height: 20px;
    margin-right: 3px;
}

.batch-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-main);
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Batch count badge */
.batch-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* More button (hover reveal) */
.batch-more-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    opacity: 0;
    transition: all 0.15s;
    margin-left: 2px;
    padding: 0;
}

.batch-header:hover .batch-more-btn {
    opacity: 1;
}

.batch-more-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-tertiary);
}

/* Touch devices: always show more button (no hover capability) */
@media (hover: none) {
    .batch-more-btn {
        opacity: 0.4;
    }
    .batch-more-btn:active {
        opacity: 1;
        background: rgba(0, 0, 0, 0.06);
    }
}

/* Quick Explore Toolbar - 權限與顯示控制 */
.quick-explore-toolbar {
    padding: 0 10px 8px 10px;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: none;
    touch-action: pan-y;
}

/* Logged-in user: show quick explore toolbar (ID+class beats class alone) */
#sidebar.admin-mode .quick-explore-toolbar,
#sidebar.user-mode .quick-explore-toolbar {
    display: block;
}

.explore-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.explore-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
    /* Scrollbar space */
    -webkit-overflow-scrolling: touch;
}

.explore-btn {
    flex: 1;
    min-width: 32px;
    height: 32px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.explore-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.explore-btn:active {
    transform: translateY(0);
}

.explore-btn.clear {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger-color);
}

.explore-btn.clear:hover {
    background: var(--danger-light);
    border-color: var(--danger-color);
}

/* 隱藏原生 details 標記 */
summary::-webkit-details-marker {
    display: none;
}

summary {
    list-style: none;
    outline: none;
}

/* Chevron rotation - driven by native [open] state */
details[open] > summary .batch-chevron {
    transform: rotate(90deg);
}

.batch-chevron {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    color: var(--text-muted);
    transition: transform 0.25s ease;
    font-size: 10px;
    flex-shrink: 0;
}

/* Content area with indent guide */
.location-list {
    display: none;
    position: relative;
    padding-left: 8px;
    margin-left: 8px;
    background: transparent;
    transition: opacity 0.3s;
}

/* Indent guide line */
.location-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 8px;
    width: 1px;
    background: linear-gradient(to bottom, var(--border-light) 0%, var(--border-light) 50%, transparent 100%);
}

/* When batch is hidden from map, dim child items but keep them interactive
   (dragging and reordering should still work) */
.batch-item:not(.parent-visible) .location-list {
    opacity: 0.55;
}

.location-list.expanded {
    display: block;
}

/* Progressive font scaling for nested levels */
.location-list .batch-header { font-size: 13px; }
.location-list .location-item { font-size: 12.5px; }
.location-list .location-item .poly-meta,
.location-list .location-item .loc-rating { font-size: 10.5px; }

.location-list .location-list .batch-header { font-size: 12.5px; }
.location-list .location-list .location-item { font-size: 12px; }
.location-list .location-list .location-item .poly-meta,
.location-list .location-list .location-item .loc-rating { font-size: 10px; }

.location-list .location-list .location-list .batch-header { font-size: 12px; }
.location-list .location-list .location-list .location-item { font-size: 11.5px; }
.location-list .location-list .location-list .location-item .poly-meta,
.location-list .location-list .location-list .location-item .loc-rating { font-size: 9.5px; }

/* Section divider (locations / polylines) */
.section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 5px 8px 2px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.location-item {
    padding: 2px 6px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background 0.12s;
    cursor: pointer;
    margin: 0;
}

.location-item:hover {
    background: rgba(99, 102, 241, 0.06);
}

.location-item.draggable {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.location-item.draggable:active {
    cursor: grabbing;
}

/* Polyline item — color bar separator */
.poly-color-bar {
    width: 3px;
    align-self: stretch;
    border-radius: 2px;
    margin: 2px 0;
    flex-shrink: 0;
}
.location-item.polyline-item:hover {
    background: rgba(66, 133, 244, 0.06);
}

/* Hidden state for individual items */
.location-item.is-hidden .location-name {
    color: #a0aec0;
    text-decoration: line-through;
    text-decoration-color: var(--border-light);
}

.location-item.is-hidden .loc-rating,
.location-item.is-hidden .poly-meta {
    opacity: 0.3;
}

/* Hidden state for batch header */
.batch-header.batch-hidden .batch-name {
    color: var(--text-muted);
}

.batch-header.batch-hidden .batch-icon {
    opacity: 0.35;
}

.batch-header.batch-hidden .batch-count {
    opacity: 0.35;
}


/* 手機版適應 (RWD) */
@media (max-width: 768px) {

    /* 
       Refactored Mobile Sidebar: Use Height Transition instead of Transform
       This prevents issues with bottom URL bars (Chrome Android) overlaying the content.
    */
    #sidebar {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        /* Half-screen default: show map + category list together */
        border-radius: 24px 24px 0 0;
        transform: none !important;
        transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 1000;
        overflow: hidden;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    #sidebar.collapsed {
        height: calc(125px + env(safe-area-inset-bottom));
        /* 重新計算封閉高度：僅保留把手+Header+Explore */
    }

    /* [Style 01] 把手 — enlarged for easier touch dragging */
    .mobile-handle-area {
        display: flex;
        width: 100%;
        height: 36px;
        justify-content: center;
        align-items: center;
        cursor: grab;
    }

    .mobile-handle-pill {
        width: 40px;
        height: 5px;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 3px;
        transition: all 0.2s;
    }

    #sidebar:active .mobile-handle-pill {
        width: 60px;
        background: var(--primary-color);
    }

    .sidebar-header {
        padding: 0 16px 8px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: none;
        background: transparent;
        flex-shrink: 0;
    }

    .header-status-group {
        display: flex;
        align-items: center;
        margin-left: auto;
        gap: 4px;
        flex-shrink: 0;
    }

    /* Header icon buttons: touch-friendly but compact */
    .header-icon-btn {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-icon-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Ensure drag handle never gets compressed */
    .mobile-handle-area {
        flex-shrink: 0;
    }

    /* 快速探索列：手機版改為橫向捲動 (Style 01 核心) */
    .quick-explore-toolbar {
        padding: 0 16px 12px 16px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .explore-buttons {
        gap: 10px;
        padding-bottom: 8px;
    }

    .explore-btn {
        flex: 0 0 44px;
        /* 固定寬度，利於捲動 */
        height: 44px;
        border-radius: 12px;
        background: var(--bg-subtle);
        border: 1px solid var(--bg-input);
        font-size: 20px;
    }

    /* 搜尋與濾鏡列：壓縮 */
    .sidebar-controls {
        padding: 8px 16px 16px 16px;
    }

    .search-box {
        height: 42px;
        background: var(--bg-input);
        border: none;
        border-radius: 12px;
    }

    /* 底部進度條 */
    .header-progress-container {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: rgba(0, 0, 0, 0.02);
    }

    .header-progress-fill {
        height: 100%;
        background: var(--primary-color);
        width: 0%;
        /* JS 同步 */
        transition: width 0.3s;
    }

    /* Touch-friendly targets: enlarge small buttons to min 40px */
    .eye-btn {
        min-width: 40px;
        min-height: 40px;
        border-radius: 8px;
    }

    .eye-btn-sm {
        min-width: 36px;
        min-height: 36px;
    }

    .batch-more-btn {
        min-width: 40px;
        min-height: 40px;
        border-radius: 8px;
        opacity: 0.5;
    }

    /* Explore buttons: scroll fade hint for discoverability */
    .quick-explore-toolbar {
        position: relative;
    }
    .quick-explore-toolbar::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 32px;
        height: calc(100% - 12px);
        background: linear-gradient(to right, transparent, rgba(255,255,255,0.9));
        pointer-events: none;
        z-index: 1;
    }

    /* 隱藏/調整不必要元件 */
    .close-btn {
        display: none;
    }

    /* 手機版不使用電腦版按鈕 */
    #sidebar-toggle-btn {
        display: none;
    }
}

/* 電腦版樣式補償：確保電腦版不跑掉 */
@media (min-width: 769px) {
    .mobile-handle-area {
        display: none;
    }

    .header-progress-container {
        display: none;
    }

    .header-status-group {
        display: flex;
        align-items: center;
        margin-left: auto;
    }
}

/* Drag-to-Delete Trash Box */
#sidebar-trash-box {
    display: none;
    /* 預設完全不佔空間 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 10px;
    background: #fff5f5;
    border: 2px dashed #feb2b2;
    border-radius: 12px;
    color: #c53030;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px);
}

/* Logged-in user dragging: show trash box */
.admin-mode.dragging-active #sidebar-trash-box,
.user-mode.dragging-active #sidebar-trash-box {
    display: flex;
    opacity: 0.6;
    transform: translateY(0);
}

#sidebar-trash-box.drag-over {
    background: #fed7d7 !important;
    border-color: #f56565 !important;
    border-style: solid;
    color: #9b2c2c;
    opacity: 1 !important;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.2);
}

.trash-icon {
    font-size: 28px;
    margin-bottom: 4px;
    transition: transform 0.2s;
}

#sidebar-trash-box.drag-over .trash-icon {
    transform: scale(1.2) rotate(-10deg);
}

.trash-text {
    font-size: 13px;
    font-weight: 600;
}

/* --- InfoWindow 雜誌風格 (Style 16) --- */
/* Magazine card container (custom overlay, replaces Google Maps InfoWindow) */
.magazine-card-container {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: none;
    filter: drop-shadow(0 8px 30px rgba(0,0,0,0.2));
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}
.magazine-card-container.show { display: block; }

@media (max-width: 768px) {
    .magazine-card-container {
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        transform: none;
        filter: none;
        /* B234: float above the mobile bottom-sheet sidebar (z-index:1000) so a
           long card's action buttons stay tappable instead of being covered. */
        z-index: 1100;
    }
    .magazine-card-container .magazine-card {
        min-width: unset;
        /* B234: full-screen card on mobile. The base width:400px MUST be
           overridden to 100% -- max-width:100% alone only caps the width, it
           does not stretch a 400px card, so on phones wider than 400px the
           card stayed 400px and left a gap (map showing) on the right.
           box-sizing:border-box so the 12px .offline/.google accent
           border-left counts within the width instead of overflowing it. */
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
    }
    /* B234: full-screen card -> keep the close button clear of the status-bar
       notch, and let the last body row clear the iPhone home indicator. */
    .magazine-card-container .magazine-card-close {
        top: calc(8px + env(safe-area-inset-top));
    }
    .magazine-card-container .magazine-body {
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
    }
    .magazine-hero { height: 180px; }
    .magazine-hero-overlay .magazine-title { font-size: 22px; }
    .magazine-card-container {
        /* B234: full-screen card. dvh tracks the visible viewport so a long
           card never overflows behind the browser chrome; the vh line is a
           fallback. The bottom safe-area is handled by .magazine-body's
           padding-bottom instead of being subtracted here. */
        max-height: 100vh;
        max-height: 100dvh;
    }
    /* B234: enlarge place-info-card text to 17px on mobile for readability.
       Selectors are container-scoped so their specificity beats the base
       rules that appear later in this file. Decorative micro-labels
       (.magazine-hero-badge, .magazine-attach-meta) and the pure icon
       (.magazine-attach-icon) are intentionally excluded. */
    .magazine-card-container .magazine-subtitle,
    .magazine-card-container .magazine-rating-row,
    .magazine-card-container .magazine-hero-overlay .magazine-stars,
    .magazine-card-container .magazine-hero-overlay .magazine-count,
    .magazine-card-container .magazine-address,
    .magazine-card-container .magazine-batch-move,
    .magazine-card-container .magazine-note-label,
    .magazine-card-container .magazine-note-box,
    .magazine-card-container .magazine-note-input,
    .magazine-card-container .magazine-attach-row,
    .magazine-card-container .magazine-attach-add,
    .magazine-card-container .magazine-link-item,
    .magazine-card-container .magazine-link-delete,
    .magazine-card-container .magazine-link-add-btn,
    .magazine-card-container .magazine-nav-link,
    .magazine-card-container .magazine-btn,
    .magazine-card-container .magazine-hero-actions button,
    .magazine-card-container .magazine-hero-upload-btn {
        font-size: 17px;
    }
    /* B234: at 17px the three nav-link buttons (Google Maps / NAVITIME /
       copy-name) no longer fit on one row and their nowrap text overflowed
       into each other. flex-basis:100% stacks them one per full-width row. */
    .magazine-card-container .magazine-nav-link {
        flex-basis: 100%;
    }
}

.magazine-card-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 15;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: 0.15s;
    line-height: 1;
}
.magazine-card-close:hover { background: rgba(0,0,0,0.7); }

.magazine-card {
    width: 400px;
    padding: 0;
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    position: relative;
    color: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.magazine-card.offline {
    border-left: 12px solid #2563eb;
}

.magazine-card.google {
    border-left: 12px solid var(--danger-hover);
}

/* Photo hero (D1 style) */
.magazine-hero {
    position: relative;
    height: 300px;
    overflow: hidden;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.magazine-hero.no-photo { height: 100px; }
.magazine-card.google .magazine-hero { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.magazine-hero.no-photo { cursor: default; }
.magazine-hero.no-photo .magazine-hero-overlay { background: none; }
.magazine-hero.drag-over {
    outline: 3px dashed rgba(255,255,255,0.6);
    outline-offset: -6px;
}
.magazine-hero.no-photo.drag-over {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}
.magazine-hero.uploading { opacity: 0.6; pointer-events: none; }
.magazine-hero.no-photo.google-bg { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.magazine-hero img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.magazine-hero.img-error img { display: none; }
.magazine-hero-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 14px 16px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    z-index: 2;
}
.magazine-hero-overlay .magazine-subtitle { color: rgba(255,255,255,0.75); }
.magazine-hero-overlay .magazine-title { color: #fff; font-size: 20px; margin-bottom: 4px; }
.magazine-hero-overlay .magazine-rating-row { margin: 0; }
.magazine-hero-overlay .magazine-stars { font-size: 13px; }
.magazine-hero-overlay .magazine-count { color: rgba(255,255,255,0.8); font-size: 12px; }
.magazine-hero-badge {
    position: absolute; top: 8px; left: 8px;
    background: rgba(0,0,0,0.55); color: #fff;
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    backdrop-filter: blur(4px); z-index: 5;
}
.magazine-hero-actions {
    position: absolute; bottom: 6px; right: 6px; z-index: 5;
    display: flex; gap: 4px;
}
.magazine-hero-actions button {
    background: rgba(0,0,0,0.45); color: #fff; border: none; border-radius: 4px;
    padding: 3px 8px; font-size: 11px; cursor: pointer; backdrop-filter: blur(4px);
}
.magazine-hero-actions button:hover { background: rgba(0,0,0,0.7); }
.magazine-hero-upload-btn {
    margin-left: auto;
    color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 600;
    cursor: pointer; padding: 3px 10px;
    border: 1px solid rgba(255,255,255,0.3); border-radius: 12px;
    transition: 0.2s; white-space: nowrap;
}
.magazine-hero-upload-btn:hover {
    color: #fff; border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.15);
}

/* Corner badge (hidden — type shown in hero overlay subtitle) */
.magazine-corner { display: none; }

.magazine-body {
    padding: 14px 20px 15px 15px;
}

.magazine-subtitle {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 4px;
}

.magazine-title {
    font-size: 22px;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.magazine-rating-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin-bottom: 8px;
}

.magazine-stars {
    color: #fbbf24;
    letter-spacing: 1px;
}

.magazine-count {
    color: #666;
    font-weight: 500;
}

.magazine-address {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 6px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.magazine-batch-move {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.15s;
    white-space: nowrap;
}

.magazine-batch-move:hover {
    color: #2563eb;
}

/* Note section */
.magazine-note-section {
    margin-bottom: 4px;
}

.magazine-note-label {
    font-size: 11px;
    font-weight: 800;
    color: #111;
    margin-bottom: 6px;
    display: block;
}

.magazine-note-box {
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
}

.magazine-note-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
    font-family: inherit;
    margin-top: 0;
    outline: none;
    resize: none;
    background: transparent;
    overflow: hidden;
    field-sizing: content;
    min-height: 2lh;
}

.magazine-note-input:focus {
    border-color: #2563eb;
    background: #fff;
}

/* Attachments section */
.magazine-attachments {
    border-top: 1px solid #f0f0f0;
    padding-top: 8px;
    margin-top: 6px;
}
.magazine-attach-row {
    display: flex; align-items: center; gap: 6px; padding: 5px 0;
    font-size: 12px; color: #555; cursor: pointer; transition: 0.15s;
}
.magazine-attach-row:hover { color: #2563eb; }
.magazine-attach-icon { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.magazine-attach-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.magazine-attach-meta { font-size: 10px; color: #bbb; flex-shrink: 0; }
.magazine-attach-add {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; color: #bbb; cursor: pointer; padding: 4px 0; transition: 0.15s;
}
.magazine-attach-add:hover { color: #2563eb; }

/* Link items */
.magazine-link-item {
    display: flex; align-items: center; gap: 6px; padding: 5px 0;
    font-size: 12px; color: #555; text-decoration: none; transition: 0.15s;
    border-bottom: 1px solid #f5f5f5; position: relative;
}
.magazine-link-item:last-of-type { border-bottom: none; }
.magazine-link-item:hover { color: #2563eb; }
.magazine-link-delete {
    margin-left: auto; font-size: 11px; color: #ccc; cursor: pointer;
    padding: 2px 4px; border-radius: 3px; transition: 0.15s; flex-shrink: 0;
}
.magazine-link-delete:hover { color: #ef4444; background: #fef2f2; }
.magazine-link-actions {
    display: flex; gap: 12px; padding-top: 6px;
}
.magazine-link-add-btn {
    font-size: 11px; color: #bbb; cursor: pointer; transition: 0.15s;
}
.magazine-link-add-btn:hover { color: #2563eb; }
.magazine-link-add-btn.drag-over { color: #2563eb; outline: 2px dashed #2563eb; outline-offset: 2px; border-radius: 4px; }

/* Navigation links (expandable) */
.magazine-nav-links {
    display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap;
}
.magazine-nav-link {
    flex: 1; min-width: 0; text-align: center; font-size: 11px; font-weight: 600;
    color: #2563eb; text-decoration: none; padding: 7px 4px;
    border: 1px solid #e8edf5; border-radius: 6px; transition: 0.15s;
    white-space: nowrap;
}
.magazine-nav-link:hover { background: #f0f5ff; border-color: #2563eb; }
.magazine-nav-link.secondary { color: #888; border-color: #eee; }
.magazine-nav-link.secondary:hover { color: #555; background: #f9f9f9; border-color: #ccc; }

/* Action buttons */
.magazine-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.magazine-btn {
    flex: 1;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #ddd;
    background: white;
    color: #111;
    transition: 0.2s;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.magazine-btn:hover {
    background: #f5f5f5;
}

.magazine-btn.primary {
    background: #111;
    color: white;
    border-color: #111;
}

.magazine-btn.stale {
    border-color: transparent;
    background: transparent;
    color: inherit;
}

/* --- Polyline Card (lightweight info card) --- */
.polyline-card-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
}
.polyline-card-style-preview {
    margin-bottom: 8px;
}
.polyline-card-route-info {
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    font-weight: 600;
}
.polyline-card-transit-summary {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #f8f8f8;
    border-radius: 6px;
    border-left: 3px solid #ddd;
}
.polyline-card-batch {
    font-size: 11px;
    color: #aaa;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
}

/* Polyline inline link form */
.poly-link-form {
    margin-top: 8px;
    padding: 8px;
    background: #f8f8f8;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
}
.poly-link-form input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    margin-bottom: 6px;
    background: #fff;
}
.poly-link-form input:focus { border-color: #2563eb; }
.poly-link-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}
.poly-link-form-btn {
    padding: 4px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    background: #fff;
    color: #555;
}
.poly-link-form-btn.submit {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.poly-link-form-btn.submit:hover { background: #1d4ed8; }
.poly-link-form-btn.cancel:hover { background: #f0f0f0; }

/* Filter modal overlay */
.filter-overlay-panel { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; }
.filter-overlay-panel.show { display: flex; }

.filter-dialog { background: white; border-radius: 12px; padding: 20px; min-width: 280px; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.filter-dialog-title { font-size: 15px; font-weight: 600; color: #333; margin-bottom: 12px; }

/* Section headers */
.filter-section-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px; margin: 0 -4px; cursor: pointer; user-select: none; border-radius: 6px; background: #eaeaea; }
.filter-section-header:hover { background: #e0e0e0; }
.filter-section-label { font-size: 13px; font-weight: 600; color: #555; }
.filter-section-arrow { font-size: 11px; color: #999; transition: transform 0.2s; }
.filter-section-arrow.up { transform: rotate(180deg); }

.filter-divider { height: 1px; background: #f0f0f0; margin: 4px 0; }

/* Preset list */
.filter-preset-list { max-height: 300px; overflow-y: auto; transition: max-height 0.3s ease, opacity 0.2s; }
.filter-preset-list.collapsed { max-height: 0; opacity: 0; overflow: hidden; margin: 0; }

.filter-preset-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; color: #333; transition: background 0.1s; }
.filter-preset-row:hover { background: #f3f4f6; }
.filter-preset-row.on { background: #f0f7ff; }
.filter-preset-icon { font-size: 17px; flex-shrink: 0; }
.filter-preset-body { flex: 1; display: flex; align-items: baseline; gap: 6px; }
.filter-preset-name { font-size: 14px; font-weight: 500; color: #333; white-space: nowrap; }
.filter-preset-sub { font-size: 11px; color: #999; white-space: nowrap; }
.filter-preset-check { font-size: 14px; color: #2563eb; opacity: 0; transition: opacity 0.15s; }
.filter-preset-row.on .filter-preset-check { opacity: 1; }

/* Detail wrap */
.filter-detail-wrap { transition: max-height 0.3s ease, opacity 0.2s; max-height: 400px; overflow: hidden; }
.filter-detail-wrap.collapsed { max-height: 0; opacity: 0; }

.filter-detail-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: #999; font-weight: 600; margin-bottom: 4px; margin-top: 8px; }
.filter-detail-val { font-weight: 700; }
.filter-detail-val.orange { color: #e8960a; }
.filter-detail-val.blue { color: #2563eb; }

/* Big numbers */
.filter-big-nums { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.filter-big-num { font-size: 20px; font-weight: 800; line-height: 1; }
.filter-big-num.orange { color: #e8960a; }
.filter-big-num.blue { color: #2563eb; }
.filter-big-sep { color: #ddd; font-size: 14px; }

/* Dual range slider */
.filter-dual-range { position: relative; height: 32px; margin: 2px 0; }
.filter-dual-track { position: absolute; top: 13px; left: 0; right: 0; height: 4px; background: #e8e8e8; border-radius: 2px; }
.filter-dual-fill { position: absolute; top: 13px; height: 4px; border-radius: 2px; background: linear-gradient(90deg, #f0c040, #e8960a); transition: left 0.05s, right 0.05s; }
.filter-dual-range input[type="range"] { position: absolute; top: 3px; left: 0; width: 100%; height: 24px; -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none; margin: 0; }
.filter-dual-range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: white; border: 2px solid #e8960a; box-shadow: 0 1px 3px rgba(0,0,0,0.18); pointer-events: auto; cursor: grab; position: relative; z-index: 2; }
.filter-range-labels { display: flex; justify-content: space-between; font-size: 9px; color: #ccc; margin-top: 1px; }

/* Review slider */
.filter-review-slider { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.filter-review-slider input[type="range"] { flex: 1; accent-color: #2563eb; }
.filter-slider-edge { font-size: 10px; color: #bbb; min-width: 14px; }

/* Footer */
.filter-dialog-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 8px; }
.filter-footer-btn { cursor: pointer; font-size: 13px; color: #888; }
.filter-footer-btn:hover { color: #333; }
.filter-footer-btn.red { color: #ef4444; }
.filter-footer-btn.red:hover { color: #dc2626; }

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

}

/* ─── Drag & Drop Visuals: Dot-ended insertion lines ─── */

/* Source element (being dragged) */
.dragging-active .batch-header[style*="opacity: 0.4"],
.dragging-active .location-item[style*="opacity: 0.4"] {
    outline: 2px dashed #bbb;
    outline-offset: -2px;
}

/* Non-target items dim during drag */
.dragging-active .location-item:not([style*="opacity"]):not(.drag-insert-before):not(.drag-insert-after),
.dragging-active .batch-header:not([style*="opacity"]):not(.drag-over-top):not(.drag-over-bottom):not(.drag-over-center) {
    opacity: 0.55;
}

/* Batch: insert above */
.batch-header.drag-over-top {
    border-top: 2px solid var(--primary-color);
    position: relative;
    overflow: visible;
}
.batch-header.drag-over-top::before,
.batch-header.drag-over-top::after {
    content: '';
    position: absolute;
    top: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    pointer-events: none;
}
.batch-header.drag-over-top::before { left: 0; }
.batch-header.drag-over-top::after { right: 0; }

/* Batch: insert below */
.batch-header.drag-over-bottom {
    border-bottom: 2px solid var(--primary-color);
    position: relative;
    overflow: visible;
}
.batch-header.drag-over-bottom::before,
.batch-header.drag-over-bottom::after {
    content: '';
    position: absolute;
    bottom: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    pointer-events: none;
}
.batch-header.drag-over-bottom::before { left: 0; }
.batch-header.drag-over-bottom::after { right: 0; }

/* Batch: move inside */
.batch-header.drag-over-center {
    background: rgba(66, 133, 244, 0.08);
    border: 1.5px dashed var(--primary-color);
}

/* Root drop zone */
#sidebarContent.drag-over-root {
    box-shadow: inset 0 0 0 2px var(--primary-color);
    background-color: rgba(66, 133, 244, 0.04);
}

/* ─── Location Drag Reorder: Dot-ended insertion lines ─── */
.location-item.drag-insert-before {
    border-top: 2px solid var(--primary-color);
    position: relative;
    overflow: visible;
}
.location-item.drag-insert-before::before,
.location-item.drag-insert-before::after {
    content: '';
    position: absolute;
    top: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    pointer-events: none;
}
.location-item.drag-insert-before::before { left: 0; }
.location-item.drag-insert-before::after { right: 0; }

.location-item.drag-insert-after {
    border-bottom: 2px solid var(--primary-color);
    position: relative;
    overflow: visible;
}
.location-item.drag-insert-after::before,
.location-item.drag-insert-after::after {
    content: '';
    position: absolute;
    bottom: -5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    pointer-events: none;
}
.location-item.drag-insert-after::before { left: 0; }
.location-item.drag-insert-after::after { right: 0; }

/* Prevent text selection on long-press for touch devices (sidebar items) */
@media (pointer: coarse) {
    #sidebarContent,
    .batch-header,
    .location-item,
    .polyline-item {
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
        touch-action: pan-y;
    }
}

/* (Map visual modes use StyledMapType — no CSS needed) */
