/* ═══════════════════════════════════════════════════
   Route Planner — Apple HIG Design System
   Glassmorphic Minimalism
   ═══════════════════════════════════════════════════ */

/* ─── Variables ──────────────────────────────── */
:root {
    /* Apple HIG Color Palette */
    --blue: #007AFF;
    --blue-light: #0A84FF;
    --blue-dark: #0056B3;
    --blue-bg: rgba(0, 122, 255, 0.12);

    --gray1: #1D1D1F;
    --gray2: #636366;
    --gray3: #8E8E93;
    --gray4: #AEAEB2;
    --gray5: #C7C7CC;
    --gray6: #D1D1D6;
    --gray-bg: #F2F2F7;

    --green: #34C759;
    --orange: #FF9500;
    --red: #FF3B30;

    /* Glass Material */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-light: rgba(255, 255, 255, 0.52);
    --glass-bg-heavy: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-blur: blur(40px) saturate(180%);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --glass-shadow-lift: 0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);

    /* Layout */
    --sidebar-w: 380px;
    --card-radius: 16px;
    --input-radius: 12px;
    --btn-radius: 12px;
    --drawer-radius: 20px;
    --transition: cubic-bezier(0.25, 0.1, 0.25, 1.0);

    /* ═══════════════════════════════════════════════════
       Map Marker & Polyline UI 参数（手机端优化）
       直接修改这些变量即可调整地图上图标和连线的大小
       ═══════════════════════════════════════════════════ */

    /* 起点图标 */
    --marker-home-size: 24px;          /* 起点圆形图标直径（原 34px） */
    --marker-home-border: 2.5px;       /* 白色边框粗细（原 3px） */
    --marker-home-icon: 12px;          /* 内部 SVG 图标大小（原 16px） */

    /* 序号图标 */
    --marker-num-size: 22px;           /* 序号圆形图标直径（原 30px） */
    --marker-num-font: 11px;           /* 序号数字字号（原 13px） */
    --marker-num-border: 2px;         /* 白色边框粗细（原 2.5px） */

    /* 地图标签文字 */
    --label-home-padding-v: 2px;      /* 起点标签上下内边距（原 4px） */
    --label-home-padding-h: 6px;      /* 起点标签左右内边距（原 10px） */
    --label-home-font: 11px;          /* 起点标签字号（原 12px） */
    --label-num-padding-v: 2px;       /* 序号标签上下内边距（原 4px） */
    --label-num-padding-h: 6px;       /* 序号标签左右内边距（原 10px） */
    --label-num-font: 11px;           /* 序号标签字号（原 12px） */

    /* 路线连线粗细 */
    --polyline-main-outer: 5;         /* 主地图连线外层（白色描边，原 8） */
    --polyline-main-inner: 3;         /* 主地图连线内层（蓝色，原 5） */
    --polyline-share-outer: 4;        /* 分享弹窗连线外层（原 7） */
    --polyline-share-inner: 2;        /* 分享弹窗连线内层（原 3） */

    /* 分享弹窗地图图标尺寸 */
    --share-marker-home-size: 22px;    /* 分享弹窗起点图标（原 34px） */
    --share-marker-num-size: 20px;     /* 分享弹窗序号图标（原 30px） */
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont,
                 'SF Pro Text', 'SF Pro Display',
                 'PingFang SC', 'Microsoft YaHei',
                 sans-serif;
    color: var(--gray1);
    background: transparent;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

::selection {
    background: rgba(0, 122, 255, 0.2);
    color: var(--gray1);
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 4px;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}

input, select {
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

/* ─── Map Layer ──────────────────────────────── */
.amap-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
}

.amap-maps {
    width: 100% !important;
    height: 100% !important;
}

/* ─── Sidebar ──────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 0.5px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 20px 12px;
    flex-shrink: 0;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 22px;
    height: 22px;
    color: var(--blue);
    flex-shrink: 0;
}

.logo-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray1);
    letter-spacing: -0.3px;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 2px;
}
.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ─── Cards ─────────────────────────────────── */
.card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--card-radius);
    border: 0.5px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: card-in 0.3s var(--transition) both;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray2);
    letter-spacing: 0.02em;
}

/* ─── City Selector ─────────────────────────── */
.city-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.apple-select {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: var(--input-radius);
    background: rgba(0, 0, 0, 0.04);
    color: var(--gray1);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    border: 1px solid transparent;
}

.apple-select:focus {
    background: rgba(0, 0, 0, 0.06);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
    outline: none;
}

.apple-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.apple-select option {
    background: var(--gray-bg);
}

/* ─── Search Box ────────────────────────────── */
.search-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--input-radius);
    border: 1px solid transparent;
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
}

.search-wrap:focus-within {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
    border-color: var(--blue);
}

.input-icon {
    width: 16px;
    height: 16px;
    color: var(--gray3);
    margin-left: 12px;
    flex-shrink: 0;
}

.apple-input {
    flex: 1;
    padding: 10px 10px;
    border: none;
    background: transparent;
    color: var(--gray1);
    font-size: 15px;
    outline: none;
}

.apple-input::placeholder {
    color: var(--gray4);
}

/* ─── Start Confirmed Indicator ─────────────── */
.start-confirmed {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(52, 199, 89, 0.1);
    border: 0.5px solid rgba(52, 199, 89, 0.25);
    border-radius: 10px;
    animation: card-in 0.25s var(--transition);
}

.start-confirmed.visible {
    display: flex;
}

.start-confirmed-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(52, 199, 89, 0.4);
}

.start-confirmed-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #1a7a30;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.start-confirmed-clear {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray3);
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.start-confirmed-clear svg {
    width: 14px;
    height: 14px;
}

.start-confirmed-clear:hover {
    color: var(--red);
    background: rgba(255, 59, 48, 0.08);
}

/* ─── Suggestions ────────────────────────────── */
.suggestions {
    display: none;
    border-radius: var(--input-radius);
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 0.5px solid var(--glass-border);
    box-shadow: var(--glass-shadow-lift);
    overflow: hidden;
    z-index: 20;
}

.suggestions.show {
    display: block;
}

.suggestion-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
    transition: background 0.15s;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--blue-bg);
}

.suggestion-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.suggestion-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray1);
}

.suggestion-addr {
    font-size: 12px;
    color: var(--gray3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-dist {
    font-size: 12px;
    color: var(--gray3);
    font-weight: 400;
    margin-left: auto;
    flex-shrink: 0;
    padding-left: 8px;
    padding-top: 2px;
}

/* ─── Location List ─────────────────────────── */
.location-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 44px;
}

.location-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    font-size: 13px;
    color: var(--gray4);
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--input-radius);
    border: 1px dashed rgba(0, 0, 0, 0.08);
}

.location-list-empty svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.location-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    border: 0.5px solid transparent;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    cursor: grab;
    animation: card-in 0.25s var(--transition) both;
}

.location-item:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 122, 255, 0.2);
}

.location-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: var(--glass-shadow-lift);
    cursor: grabbing;
    z-index: 100;
}

.location-item.drag-over {
    border-top: 2px solid var(--blue);
    margin-top: -2px;
}

.location-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
}

.location-item > div {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.location-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-addr {
    font-size: 11px;
    color: var(--gray3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-remove {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray4);
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.location-remove svg {
    width: 14px;
    height: 14px;
}

.location-remove:hover {
    color: var(--red);
    background: rgba(255, 59, 48, 0.08);
}

.location-count {
    font-size: 12px;
    color: var(--gray3);
    text-align: right;
}

/* ─── Segmented Control ─────────────────────── */
.segmented-control {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    padding: 3px;
}

.seg-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray2);
    transition: background 0.25s var(--transition), color 0.25s, box-shadow 0.25s;
}

.seg-item svg {
    width: 18px;
    height: 18px;
}

.seg-item span {
    line-height: 1;
}

.seg-item.active {
    background: #fff;
    color: var(--blue);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.seg-item:not(.active):hover {
    color: var(--gray1);
    background: rgba(255, 255, 255, 0.5);
}

/* ─── Buttons ────────────────────────────────── */
.apple-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: var(--blue);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--btn-radius);
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s var(--transition), box-shadow 0.2s, background 0.2s;
    letter-spacing: -0.2px;
}

.apple-btn-primary svg {
    width: 18px;
    height: 18px;
}

.apple-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.45), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.apple-btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.apple-btn-primary:disabled {
    background: var(--gray5);
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.apple-btn-primary-sm {
    padding: 6px 14px;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.apple-btn-primary-sm:hover {
    background: var(--blue-light);
}

.apple-btn-primary-sm:active {
    transform: scale(0.96);
}

.apple-btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--blue);
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--btn-radius);
    border: 0.5px solid rgba(0, 122, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: -0.2px;
}

.apple-btn-secondary svg {
    width: 16px;
    height: 16px;
}

.apple-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.apple-btn-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.apple-btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.apple-btn-navigate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    padding: 10px 12px;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--btn-radius);
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.35), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s var(--transition), box-shadow 0.2s, background 0.2s;
    letter-spacing: -0.1px;
}

.apple-btn-navigate svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.apple-btn-navigate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(52, 199, 89, 0.45), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.apple-btn-navigate:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.apple-btn-navigate:disabled {
    background: var(--gray5);
    box-shadow: none;
    opacity: 0.6;
    cursor: not-allowed;
}

.hint-text {
    text-align: center;
    font-size: 12px;
    color: var(--gray3);
    letter-spacing: 0.01em;
}

/* ─── Bottom Drawer ──────────────────────────── */
.bottom-drawer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w);
    right: 0;
    z-index: 20;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 0.5px solid var(--glass-border);
    border-radius: var(--drawer-radius) var(--drawer-radius) 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: none;
    display: flex;
    flex-direction: column;
    touch-action: none;
    /* Ensure the grabber is always reachable regardless of content height */
    min-height: 150px;
}

/* 展开时：完全可见 */
.bottom-drawer[data-sheet="expanded"] {
    transform: translateY(0);
    z-index: 60;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 折叠时：grabber 底部距视口底部固定距离（由 JS 动态计算，CSS 不设置固定值） */
.bottom-drawer[data-sheet="collapsed"] {
    z-index: 60;
}

/* 隐藏时：完全滑出 */
.bottom-drawer[data-sheet="hidden"] {
    transform: translateY(100%);
    z-index: 20;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 兼容旧逻辑：.expanded 类仅用于快速切换 */
.bottom-drawer.expanded {
    transform: translateY(0);
    z-index: 60;
}

.drawer-grabber {
    position: relative;
    width: 36px;
    height: 24px;
    margin: 10px auto 0;
    flex-shrink: 0;
    cursor: grab;
}

.drawer-grabber::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 5px;
    border-radius: 2.5px;
    background: var(--gray4);
    transition: background 0.2s;
}

.drawer-grabber:active::before {
    background: var(--gray3);
    cursor: grabbing;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 20px 12px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.drawer-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--gray1);
    letter-spacing: -0.2px;
    flex-shrink: 0;
}

.drawer-title svg {
    width: 17px;
    height: 17px;
    color: var(--blue);
}

.drawer-summary {
    font-size: 13px;
    color: var(--gray2);
    font-weight: 500;
    margin-left: auto;
    white-space: nowrap;
}

.drawer-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    padding: 10px 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--btn-radius);
    border: 0.5px solid rgba(0, 122, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: -0.1px;
    cursor: pointer;
}

.drawer-edit-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.drawer-edit-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.drawer-edit-btn:active {
    transform: scale(0.98);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-track { background: transparent; }
.drawer-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* ─── Route Segments ─────────────────────────── */
.segments-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.segment-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    position: relative;
    animation: card-in 0.3s var(--transition) both;
}

.segment-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 36px;
    bottom: 0;
    width: 1.5px;
    background: linear-gradient(to bottom, var(--blue), rgba(0, 122, 255, 0.15));
    border-radius: 1px;
}

.segment-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    margin-top: 2px;
}

.segment-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.segment-from-to {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray1);
    line-height: 1.4;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.segment-from-to .arrow {
    color: var(--gray3);
    font-size: 12px;
    flex-shrink: 0;
}

.segment-meta {
    font-size: 12px;
    color: var(--gray3);
}

.segment-duration {
    font-size: 15px;
    font-weight: 600;
    color: var(--blue);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 4px;
}

.segment-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--blue-bg);
    border-radius: var(--input-radius);
    border: 0.5px solid rgba(0, 122, 255, 0.15);
    font-size: 14px;
    font-weight: 600;
    color: var(--blue);
}

.segment-total-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.segment-total-info svg {
    width: 14px;
    height: 14px;
}

.drawer-actions {
    display: flex;
    gap: 8px;
    padding-top: 4px;
    align-items: stretch;
}

/* ─── Loading Overlay ────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--transition);
}

.loading-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.loading-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(0, 122, 255, 0.12);
    border-top-color: var(--blue);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray1);
    letter-spacing: -0.3px;
}

.loading-sub {
    font-size: 13px;
    color: var(--gray2);
}

/* ─── Toast ─────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s var(--transition), opacity 0.3s;
    z-index: 200;
    max-width: 90%;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: rgba(255, 59, 48, 0.92);
}

.toast.success {
    background: rgba(52, 199, 89, 0.92);
}

/* ─── Map Markers ────────────────────────────── */
.custom-home-marker {
    width: var(--marker-home-size);
    height: var(--marker-home-size);
    background: var(--blue);
    border: var(--marker-home-border) solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.4);
    cursor: pointer;
}

.custom-home-marker svg {
    width: var(--marker-home-icon);
    height: var(--marker-home-icon);
}

.amap-label-home {
    background: var(--blue);
    color: #fff;
    padding: var(--label-home-padding-v) var(--label-home-padding-h);
    border-radius: 14px;
    font-size: var(--label-home-font);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.custom-num-marker {
    width: var(--marker-num-size);
    height: var(--marker-num-size);
    background: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--marker-num-font);
    font-weight: 700;
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    border: var(--marker-num-border) solid rgba(255, 255, 255, 0.9);
}

.amap-label-num-box {
    background: rgba(29, 29, 31, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: var(--label-num-padding-v) var(--label-num-padding-h);
    border-radius: 12px;
    font-size: var(--label-num-font);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── AMap Marker Label Override ──────────── */
/* Remove AMap's default label decorations (border, shadow, arrow) */
.amap-marker-label {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Remove AMap's label arrow/pointer pseudo-elements */
.amap-marker-label::before,
.amap-marker-label::after {
    display: none !important;
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 320px;
    }
}

/* Desktop: hide mobile-only controls */
@media (min-width: 769px) {
    .mobile-overlay {
        display: none !important;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
    }

    body {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: auto;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        border-right: none;
        border-top: 0.5px solid var(--glass-border);
        transform: translateY(100%);
        transition: transform 0.4s var(--transition);
        flex-direction: column;
        z-index: 40;
        display: none;
    }

    .sidebar.open {
        transform: translateY(0);
        display: flex;
    }

    .sidebar-header {
        padding: 16px 20px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar-scroll {
        padding: 12px 14px calc(32px + env(safe-area-inset-bottom, 0px)) 14px;
        gap: 10px;
    }

    .card {
        padding: 12px 14px;
        gap: 8px;
    }

    .city-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .apple-btn-primary-sm {
        padding: 6px 12px;
        font-size: 13px;
    }

    .bottom-drawer {
        left: 0;
        right: 0;
        display: none;
        z-index: 25;
        transition: none;
        min-height: 150px;
    }

    .bottom-drawer[data-sheet="expanded"] {
        display: flex;
        transform: translateY(0);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* 折叠时：grabber 底部距视口底部固定距离（由 JS 动态计算） */
    .bottom-drawer[data-sheet="collapsed"] {
        display: flex;
    }

    .bottom-drawer[data-sheet="hidden"] {
        display: none;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .drawer-body {
        padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 0px)) 16px;
        -webkit-overflow-scrolling: touch;
    }

    .drawer-actions {
        gap: 6px;
    }

    .toast {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 400px) {
    .city-row {
        grid-template-columns: 1fr;
    }
}

/* ─── Mobile Overlay ───────────────────────────── */
/* Bottom-sheet: map always visible, panel draggable from bottom */
.mobile-overlay {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    z-index: 50;
    pointer-events: none;
}

.mobile-overlay.open {
    display: block;
}

.mobile-overlay-bg {
    display: none;
}

.mobile-overlay-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 20px 20px 0 0;
    border: 0.5px solid var(--glass-border);
    border-bottom: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
    max-height: 100dvh;
    height: auto;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    /* Default: panel at bottom (expanded) */
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    overflow: hidden;
    pointer-events: auto;
    touch-action: none;
}

/* Collapsed: panel at 65% from bottom, only grabber tip visible */
.mobile-overlay[data-sheet="collapsed"] > .mobile-overlay-panel {
    transform: translateY(calc(65dvh));
}

/* Expanded: fully visible */
.mobile-overlay[data-sheet="expanded"] > .mobile-overlay-panel {
    transform: translateY(0);
}

.mobile-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    flex-shrink: 0;
    min-height: 80px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-overlay-grabber {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 24px;
    border-radius: 2.5px;
    background: transparent;
    cursor: grab;
    z-index: 10;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.mobile-overlay-grabber::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 5px;
    border-radius: 2.5px;
    background: var(--gray4);
    transition: background 0.2s;
}

.mobile-overlay-grabber:active::before {
    background: var(--gray3);
    cursor: grabbing;
}

.mobile-overlay-grabber:active {
    cursor: grabbing;
}

.mobile-overlay-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--gray1);
    letter-spacing: -0.3px;
}

.mobile-overlay-title .logo-icon {
    width: 22px;
    height: 22px;
    color: var(--blue);
}

.mobile-overlay-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: var(--gray2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.mobile-overlay-close svg {
    width: 16px;
    height: 16px;
}

.mobile-overlay-close:active {
    background: rgba(0, 0, 0, 0.12);
    color: var(--gray1);
}

.mobile-overlay-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 16px calc(32px + env(safe-area-inset-bottom, 0px)) 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mobile-overlay-scroll::-webkit-scrollbar {
    display: none;
}

.mobile-overlay-city-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mobile-overlay-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--card-radius);
    border: 0.5px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ─── AMap Control Override ─────────────────── */
.amap-scale {
    bottom: 24px !important;
    left: 16px !important;
}

/* ─── Mobile Overlay Responsive ─────────────── */
@media (min-width: 769px) {
    .mobile-overlay {
        display: none !important;
    }
}

/* ─── Geolocation Button ─────────────────────────── */
.geo-locate-btn {
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px 9px 12px;
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 0.5px solid var(--glass-border);
    border-radius: 999px;
    box-shadow: var(--glass-shadow-lift);
    color: var(--blue);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.2s var(--transition), box-shadow 0.2s;
    white-space: nowrap;
    animation: card-in 0.4s 1s var(--transition) both;
}

.geo-locate-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.geo-locate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(0, 0, 0, 0.08);
}

.geo-locate-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: var(--glass-shadow);
}

.geo-locate-btn.hidden {
    display: none;
}

/* On mobile, push above the bottom drawer when it's visible */
@media (max-width: 768px) {
    .geo-locate-btn {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .bottom-drawer.expanded ~ .geo-locate-btn {
        bottom: calc(60dvh + 20px + env(safe-area-inset-bottom, 0px));
    }
}

/* ─── Share Modal ────────────────────────────────── */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.share-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.share-modal {
    position: relative;
    width: min(400px, calc(100vw - 24px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 0.5px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 16px 12px 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    animation: modal-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(16px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ─── Simple Map Picker (bottom sheet) ───────────────── */
.simple-picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.simple-picker-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.simple-picker {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 420px;
    padding: 0 0 env(safe-area-inset-bottom, 12px);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

.simple-picker-overlay.visible .simple-picker {
    transform: translateY(0);
}

.simple-picker-list {
    padding: 8px 0;
}

.simple-picker-row {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    font-size: 16px;
    font-weight: 500;
    color: var(--gray1);
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
}

.simple-picker-row:last-child {
    border-bottom: none;
}

.simple-picker-row:hover {
    background: rgba(0, 0, 0, 0.04);
}

.simple-picker-row:active {
    background: rgba(0, 0, 0, 0.08);
}

/* ─── Map Picker (legacy — remove after unify) ─────── */
/* .map-picker-item { */
/*     display: flex; */
/*     align-items: center; */
/*     gap: 12px; */
/*     padding: 12px 14px; */
/*     background: rgba(248, 248, 250, 0.8); */
/*     border-radius: 14px; */
/*     cursor: pointer; */
/*     transition: background 0.15s, transform 0.12s, box-shadow 0.15s; */
/*     border: 0.5px solid rgba(0, 0, 0, 0.06); */
/* } */

.share-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray2);
    transition: background 0.2s;
    padding: 0;
}

.share-modal-close:hover {
    background: rgba(0, 0, 0, 0.12);
}

.share-modal-close svg {
    width: 14px;
    height: 14px;
}

.share-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-right: 24px;
}

.share-modal-header svg {
    width: 20px;
    height: 20px;
    color: var(--blue);
    flex-shrink: 0;
}

.share-modal-header span {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray1);
    letter-spacing: -0.3px;
}

.share-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-modal-poster {
    background: #fff;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

/* Poster card: top header strip with city + route stats */
.share-poster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(0, 122, 255, 0.10);
    gap: 8px;
}

.share-poster-city {
    font-size: 15px;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.share-poster-stats {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.share-poster-stat {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(0, 122, 255, 0.12);
    border-radius: 20px;
    padding: 2px 8px;
}

.share-poster-stat-icon {
    width: 12px;
    height: 12px;
    color: var(--blue);
    opacity: 0.85;
}

.share-poster-stat-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    white-space: nowrap;
}

.share-poster-map-wrap {
    position: relative;
    overflow: hidden;
    height: 220px;
    flex-shrink: 0;
    width: 100%;
}

/* Override global amap-container (position:fixed) for share modal map */
.share-poster-map-wrap .amap-container {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    inset: auto !important;
}

.share-poster-map-wrap .amap-maps {
    width: 100% !important;
    height: 100% !important;
}

.share-poster-map-wrap .amap-sdit {
    display: block !important;
}

.share-poster-map-wrap .amap-layers {
    display: block !important;
}

.share-poster-map-wrap .amap-container {
    border-radius: 0;
}

.share-poster-map-wrap .amap-maps {
    border-radius: 0;
}

.share-poster-map-wrap canvas {
    border-radius: 0;
}

/* Footer: QR + text */
.share-poster-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 12px;
}

.share-poster-qr {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    overflow: hidden;
    background: #fff;
    border: 0.5px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-poster-qr canvas,
.share-poster-qr img {
    display: block;
    width: 100%;
    height: 100%;
}

.share-poster-footer-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding-right: 4px;
}

.share-poster-footer-scan {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-poster-footer-credit {
    font-size: 11px;
    color: var(--gray3);
}

.share-link-row {
    width: 100%;
}

.share-link-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray2);
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}

.share-link-input-row {
    display: flex;
    gap: 8px;
}

.share-link-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    color: var(--gray1);
    font-family: inherit;
    outline: none;
    min-width: 0;
    cursor: text;
}

.share-link-input:focus {
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

.share-copy-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.2s, transform 0.15s;
}

.share-copy-btn:hover {
    background: var(--blue-light);
}

.share-copy-btn:active {
    transform: scale(0.96);
}

.share-copy-btn.copied {
    background: var(--green);
}

.share-divider {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray4);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.share-divider::before,
.share-divider::after {
    content: '';
    flex: 1;
    height: 0.5px;
    background: var(--gray6);
}

/* Drawer share button */
.drawer-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    background: rgba(0, 122, 255, 0.12);
    border: none;
    border-radius: 12px;
    padding: 10px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    letter-spacing: -0.1px;
}

.drawer-share-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.drawer-share-btn:hover {
    background: rgba(0, 122, 255, 0.2);
}

.drawer-share-btn:active {
    transform: scale(0.98);
}

/* ── History Sidebar ─────────────────────────────────────────────────────── */

/* ─── History Sidebar ──────────────────────────────────── */

.history-hamburger-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    color: var(--gray1);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

.history-hamburger-btn svg {
    width: 20px;
    height: 20px;
    color: var(--gray1);
}

.history-hamburger-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
}

.history-hamburger-btn:active {
    transform: scale(0.95);
}

.history-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.history-sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.history-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 400;
    width: 320px;
    max-width: 85vw;
    background: rgba(248, 248, 250, 0.96);
    backdrop-filter: blur(60px) saturate(180%);
    -webkit-backdrop-filter: blur(60px) saturate(180%);
    border-right: 0.5px solid rgba(0, 0, 0, 0.08);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.1), 2px 0 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.history-sidebar.open {
    transform: translateX(0);
}

.history-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.07);
    flex-shrink: 0;
}

.history-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--gray1);
    letter-spacing: -0.3px;
}

.history-sidebar-title svg {
    width: 18px;
    height: 18px;
    color: var(--blue);
}

.history-sidebar-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray2);
    transition: background 0.2s, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.history-sidebar-close-btn svg {
    width: 16px;
    height: 16px;
}

.history-sidebar-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.history-sidebar-close-btn:active {
    transform: scale(0.92);
}

.history-sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px 24px;
    -webkit-overflow-scrolling: touch;
}

.history-sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.history-sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 2px;
}

/* ─── Empty State ──────────────────────────────────────── */
.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 56px 20px;
    text-align: center;
}

.history-empty-icon-wrap {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 122, 255, 0.07);
    border-radius: 20px;
}

.history-empty-icon-wrap svg {
    width: 30px;
    height: 30px;
    color: var(--blue);
    opacity: 0.5;
}

.history-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray2);
    line-height: 1.4;
}

.history-empty-sub {
    font-size: 13px;
    color: var(--gray4);
    line-height: 1.5;
    max-width: 200px;
}

/* ─── History List Items ───────────────────────────────── */
.history-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 14px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.85);
    border: 0.5px solid rgba(0, 0, 0, 0.07);
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    animation: card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.18s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.history-item:active,
.history-item-pressing {
    transform: scale(0.985);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
    background: rgba(246, 250, 255, 0.98);
    border-color: rgba(0, 122, 255, 0.18);
}

.history-item-pinned {
    border-color: rgba(0, 122, 255, 0.25);
    background: rgba(255, 255, 255, 0.95);
}

.history-item-pinned:hover {
    background: rgba(255, 255, 255, 1);
}

/* Header row: title + actions */
.history-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray1);
    line-height: 1.3;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.history-item-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(0, 122, 255, 0.1);
    color: var(--blue);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.01em;
}

.history-item-meta-dot {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--gray5);
    flex-shrink: 0;
}

.history-item-meta span {
    font-size: 12px;
    color: var(--gray4);
    white-space: nowrap;
}

.history-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}

.history-item-time {
    font-size: 11px;
    color: var(--gray5);
    letter-spacing: 0.01em;
}

/* Action buttons — tap target meets 36x36 Apple HIG minimum */
.history-item-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin: -4px -4px -4px 0;
}

.history-action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    color: var(--gray4);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 0;
}

.history-action-btn svg {
    width: 15px;
    height: 15px;
}

.history-action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--gray2);
}

.history-action-btn:active {
    transform: scale(0.88);
}

.history-action-pin.active {
    color: var(--blue);
}

.history-action-pin.active:hover {
    background: rgba(0, 122, 255, 0.1);
}

.history-action-delete:hover {
    color: #FF3B30;
    background: rgba(255, 59, 48, 0.1);
}
