* { margin: 0; padding: 0; box-sizing: border-box; }
*, *::before, *::after { -webkit-tap-highlight-color: rgba(99, 102, 241, 0.18); }

/* ===== 移动端 safe-area / 100dvh 变量 (PC 无视觉副作用) ===== */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* PC-safe 全局: text-size-adjust / overscroll-behavior 在桌面无副作用 */
html, body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior: none;
}

/* === 移动端专属: ≤768px ===
   收窄在此处,确保 PC 完全不受影响 */
@media (max-width: 768px) {
    html, body { height: 100%; }            /* iOS Safari 地址栏动态收起时高度跟手 */
    /* 防 iOS Safari 自动放大: 输入框 ≥16px (PC 输入框类规则自身定义, 此处仅 mobile) */
    input, select, textarea { font-size: 16px; }
    /* 触摸目标 ≥ 44px */
    button, [role="button"], .btn, .engine-btn, .cal-nav, .cal-picker-nav,
    .cal-picker-month, .cal-today-btn, .cal-close-btn {
        min-height: 44px;
    }
    button.btn-icon, .icon-btn, .logout-btn, .weather-change,
    .batch-mode-btn, .admin-nav-link { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4ff;
    color: #1e293b;
    /* 100dvh 优先 (iOS Safari 16+ 支持, 动态视口), 否则回落 100vh */
    min-height: 100vh;
    min-height: 100dvh;
    background-image:
        radial-gradient(ellipse 90% 60% at 15% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 85% 5%, rgba(245, 158, 11, 0.07) 0%, transparent 50%);
    /* 异形屏留 safe-area (刘海/灵动岛/底部小白条) */
    padding-left: max(0px, var(--safe-left));
    padding-right: max(0px, var(--safe-right));
}

/* ── Header ── */
.header {
    max-width: 1280px; margin: 0 auto; padding: 20px 24px 0;
}
.header-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
    position: relative; z-index: 100; /* 确保天气选择器下拉在搜索框之上 */
}
.datetime {
    font-size: 13px; color: #64748b; font-weight: 500;
    background: rgba(255,255,255,0.8); padding: 6px 14px; border-radius: 20px;
    border: 1px solid #e2e8f0;
    backdrop-filter: blur(8px);
    cursor: pointer; transition: all 0.15s;
}
.datetime:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }

/* ── 日历弹窗 ── */
.calendar-popup {
    position: absolute; top: calc(100% + 8px); left: 0;
    width: 320px; padding: 16px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15,23,42,0.15);
    z-index: 1000; font-size: 13px;
}
.calendar-popup[hidden] { display: none; }
.calendar-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.cal-title { font-weight: 600; color: #1e293b; font-size: 15px; }
.cal-title-btn {
    flex: 1; border: none; background: transparent;
    font-weight: 600; color: #1e293b; font-size: 15px;
    font-family: inherit;
    cursor: pointer; padding: 4px 8px; border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.cal-title-btn:hover { background: #f1f5f9; color: #4f46e5; }
.cal-title-btn::after { content: ' ▾'; font-size: 10px; color: #94a3b8; margin-left: 2px; }
.cal-title-btn.active { background: #e0e7ff; color: #4f46e5; }
.cal-picker {
    margin-bottom: 10px; padding: 12px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
}
.cal-picker[hidden] { display: none; }
.cal-picker-year {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.cal-picker-nav {
    width: 30px; height: 30px; border: none; border-radius: 8px;
    background: #fff; color: #475569; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.cal-picker-nav:hover { background: #e0e7ff; color: #4f46e5; }
.cal-picker-year-input {
    flex: 1; text-align: center;
    border: none; background: transparent;
    font-size: 18px; font-weight: 600; color: #1e293b;
    font-family: inherit;
    width: 90px; padding: 4px 0;
    -moz-appearance: textfield;
}
.cal-picker-year-input::-webkit-outer-spin-button,
.cal-picker-year-input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.cal-picker-year-input:focus { outline: 2px solid #c7d2fe; border-radius: 6px; background: #fff; }
.cal-picker-months {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.cal-picker-month {
    padding: 8px 0; border: 1px solid #e2e8f0; border-radius: 8px;
    background: #fff; color: #475569; font-size: 13px; font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}
.cal-picker-month:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }
.cal-picker-month.current { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.cal-picker-month.current:hover { background: #4338ca; border-color: #4338ca; color: #fff; }
.calendar-popup.picking .calendar-grid,
.calendar-popup.picking .calendar-days { display: none; }
.calendar-popup.picking .calendar-footer { display: none; }
.calendar-popup .kbd-hint {
    font-size: 10px; color: #94a3b8; text-align: center;
    margin-top: 8px; line-height: 1.5;
}
.cal-nav {
    width: 32px; height: 32px; border: none; border-radius: 8px;
    background: #f1f5f9; color: #475569; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.cal-nav:hover { background: #e0e7ff; color: #4f46e5; }
.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
    margin-bottom: 4px;
}
.cal-weekday {
    text-align: center; font-size: 11px; color: #94a3b8; font-weight: 600;
    padding: 4px 0;
}
.calendar-days {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-day {
    text-align: center; padding: 4px 0; border-radius: 8px;
    cursor: default; position: relative; line-height: 1.3;
    transition: background 0.1s;
}
.cal-day:hover { background: #f1f5f9; }
.cal-day.other-month { color: #cbd5e1; }
.cal-day.today { background: #4f46e5; color: #fff; font-weight: 600; border-radius: 8px; }
.cal-day.today:hover { background: #4338ca; }
.cal-day.weekend { color: #ef4444; }
.cal-day.today.weekend { color: #fff; }
.cal-day-num { font-size: 14px; display: block; }
.cal-day-info { font-size: 10px; color: #94a3b8; display: block; margin-top: 1px; }
.cal-day.today .cal-day-info { color: rgba(255,255,255,0.7); }
.cal-day-info.festival { color: #e11d48; font-weight: 500; }
.cal-day.today .cal-day-info.festival { color: #fde68a; }
.calendar-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid #f1f5f9;
}
.cal-today-btn, .cal-close-btn {
    padding: 6px 16px; border-radius: 16px; font-size: 12px; cursor: pointer;
    border: 1px solid #e2e8f0; background: #fff; color: #475569;
    transition: all 0.15s;
}
.cal-today-btn:hover, .cal-close-btn:hover { background: #f1f5f9; color: #4f46e5; }
.header-tool-link {
    color: #64748b; font-size: 14px; font-weight: 500;
    text-decoration: none; padding: 6px 14px; border-radius: 20px;
    border: 1px solid #e2e8f0; background: rgba(255,255,255,0.8);
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    display: inline-block;
}
.header-tool-link:hover {
    background: #4f46e5; color: #fff; border-color: #4f46e5;
    text-decoration: none; transform: translateY(-1px);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { font-size: 22px; }
.user-name {
    font-size: 14px; color: #64748b; cursor: pointer; padding: 4px 10px;
    border-radius: 20px; transition: all 0.15s;
}
.user-name:hover { background: #e0e7ff; color: #4f46e5; }
.logout-btn {
    background: none; border: 1px solid #e2e8f0; color: #64748b;
    padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.logout-btn:hover { border-color: #c7d2fe; color: #4f46e5; background: #e0e7ff; }

.admin-nav-link {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff !important;
    padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
    transition: all 0.15s; text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
    box-shadow: 0 2px 6px rgba(79,70,229,0.25);
}
.admin-nav-link:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(79,70,229,0.35); }

/* header-right 内元素排序: datetime(0) | 天气(1) | 备忘录(2) | 工具(3) | user-info(4) | 批量(5) */
.header-right .datetime       { order: 0; }
.header-weather               { order: 1; }
#memoNavLink                  { order: 2; }
#toolsNavLink                 { order: 3; }
.header-right .user-info      { order: 4; }
.header-right .batch-mode-btn { order: 5; }

.weather {
    font-size: 13px; color: #64748b; margin: 0;
    display: flex; align-items: center; gap: 6px;
}
.weather::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    border-radius: 50%; background: #22c55e; box-shadow: 0 0 6px #22c55e;
}

/* ── Search Bar ── */
.search-wrap {
    background: rgba(255,255,255,0.9);
    border: 1.5px solid #e0e7ff;
    border-radius: 16px; padding: 6px 6px 6px 16px;
    display: flex; align-items: center; gap: 8px;
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 12px rgba(99,102,241,0.08);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap:focus-within {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12), 0 4px 20px rgba(99,102,241,0.15);
}
.search-engine-selector { display: flex; gap: 3px; flex-shrink: 0; }
.engine-btn {
    padding: 6px 12px; border: 1px solid transparent; background: transparent;
    color: #64748b; border-radius: 10px; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.engine-btn:hover { color: #4f46e5; background: #e0e7ff; }
.engine-btn.active {
    background: #6366f1; color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}
.search-box { flex: 1; display: flex; align-items: center; }
.search-box input {
    width: 100%; padding: 8px 0; border: none; background: transparent;
    color: #1e293b; font-size: 15px; outline: none;
}
.search-box input::placeholder { color: #94a3b8; }
/* 隐藏浏览器自带清除按钮(type=search 默认生成),只显示自定义 X */
.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-box input::-ms-clear, .search-box input::-ms-reveal { display: none; width: 0; height: 0; }
.search-clear {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border: none; background: #e2e8f0; color: #64748b;
    border-radius: 50%;
    font-size: 16px; line-height: 18px;
    cursor: pointer; padding: 0;
    display: none;          /* 默认隐藏,有内容时才显示 */
    align-items: center; justify-content: center;
    margin: 0 10px 0 2px;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.search-clear:hover  { background: #cbd5e1; color: #1e293b; }
.search-clear:active { transform: scale(0.9); }
.search-clear.show   { display: flex; }
#searchBtn {
    padding: 9px 20px; border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(135deg, #6366f1, #818cf8); color: #fff;
    font-size: 13px; font-weight: 600; white-space: nowrap;
    transition: all 0.2s; flex-shrink: 0;
}
#searchBtn:hover { opacity: 0.88; box-shadow: 0 4px 16px rgba(99,102,241,0.4); }
#searchBtn:active { transform: scale(0.97); }

/* ── Main ── */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 24px 32px;
    display: grid;
    /* 第 1 列 auto 跟随 .cat-tabs 实际宽度(展开 200px,收起 ~40px),主内容自动向左填充 */
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
    transition: grid-template-columns 0.25s ease;
}

/* ── Category Sections ── */
.category { margin-bottom: 22px; }
.category-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.category-icon {
    width: 32px; height: 32px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.category-title-text {
    font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
}

/* Category color themes - bright */
.cat-orange .category-icon { background: #fff7ed; }
.cat-orange .category-title-text { color: #ea580c; }
.cat-orange .card:hover { border-color: rgba(249,115,22,0.25); box-shadow: 0 6px 24px rgba(249,115,22,0.12); }

.cat-green .category-icon { background: #f0fdf4; }
.cat-green .category-title-text { color: #16a34a; }
.cat-green .card:hover { border-color: rgba(34,197,94,0.25); box-shadow: 0 6px 24px rgba(34,197,94,0.12); }

.cat-blue .category-icon { background: #eff6ff; }
.cat-blue .category-title-text { color: #2563eb; }
.cat-blue .card:hover { border-color: rgba(59,130,246,0.25); box-shadow: 0 6px 24px rgba(59,130,246,0.12); }

.cat-purple .category-icon { background: #f5f3ff; }
.cat-purple .category-title-text { color: #7c3aed; }
.cat-purple .card:hover { border-color: rgba(168,85,247,0.25); box-shadow: 0 6px 24px rgba(168,85,247,0.12); }

/* ── Card Grid ── */
.card-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
.card {
    width: 120px;
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center;
    padding: 18px 12px 14px;
    border-radius: 16px; text-decoration: none; transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
    background: #fff;
    border: 1.5px solid #f1f5f9;
    cursor: pointer;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(99,102,241,0.1);
    border-color: #e0e7ff;
}
.card:active { transform: translateY(-1px) scale(0.98); }
.card img {
    width: 44px; height: 44px; border-radius: 12px; object-fit: cover;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.card:hover img { transform: scale(1.08); }
.card span {
    font-size: 11.5px; color: #475569; text-align: center;
    line-height: 1.35; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Add card button */
.add-card { border-style: dashed; opacity: 0.7; background: #fafafa; }
.add-card:hover { opacity: 1; background: #f0f4ff; border-color: #c7d2fe; transform: translateY(-4px); box-shadow: 0 8px 28px rgba(99,102,241,0.1); }
.add-card .add-icon { font-size: 28px; color: #94a3b8; margin-bottom: 4px; font-weight: 300; }
.add-card span { font-size: 11px; color: #94a3b8; }

/* ── Card Grid 折叠(超过 3 行显示"更多"按钮) ── */
.card-grid.collapsed {
    overflow: hidden;
    position: relative;
    /* max-height 由 JS 注入 = 3 行卡片高度 */
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-grid-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    color: #4f46e5;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.card-grid-more:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.5);
    color: #4338ca;
    transform: translateY(-1px);
}
.card-grid-more:active { transform: scale(0.98); }
.card-grid-more .more-icon {
    display: inline-block;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.25s ease;
}
.card-grid-more.expanded .more-icon { transform: rotate(180deg); }

/* ── Modal ── */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15,23,42,0.45); z-index: 200;
    justify-content: center; align-items: center; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: 20px; padding: 28px;
    width: 420px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(15,23,42,0.2), 0 0 0 1px rgba(0,0,0,0.04);
}
.modal h3 { font-size: 17px; margin-bottom: 22px; color: #1e293b; font-weight: 700; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: #64748b; margin-bottom: 7px; font-weight: 500; }
.form-group input {
    width: 100%; padding: 11px 14px; border: 1.5px solid #e2e8f0;
    border-radius: 10px; background: #fff; color: #1e293b; font-size: 14px; outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: #6366f1; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn-cancel, .btn-save {
    flex: 1; padding: 11px; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-cancel { background: #f1f5f9; color: #64748b; }
.btn-cancel:hover { background: #e2e8f0; }
.btn-save { background: linear-gradient(135deg, #6366f1, #818cf8); color: #fff; }
.btn-save:hover { opacity: 0.88; box-shadow: 0 6px 20px rgba(99,102,241,0.35); }

/* ── User Center ── */
.user-center-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15,23,42,0.45); z-index: 300; backdrop-filter: blur(4px);
    justify-content: center; align-items: center;
}
.user-center-overlay.active { display: flex; }
.user-center-box {
    background: #fff; border-radius: 20px; width: 420px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(15,23,42,0.2), 0 0 0 1px rgba(0,0,0,0.04);
    overflow: hidden;
}
.user-center-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #6366f1, #818cf8); color: #fff;
}
.user-center-header h2 { font-size: 17px; font-weight: 600; }
.uc-close-btn {
    background: none; border: none; color: rgba(255,255,255,0.75); font-size: 26px;
    cursor: pointer; line-height: 1; transition: opacity 0.15s;
}
.uc-close-btn:hover { opacity: 1; }
.user-center-content { padding: 24px; }
.uc-avatar-section { text-align: center; margin-bottom: 24px; }
.uc-avatar-preview {
    width: 72px; height: 72px; border-radius: 50%;
    background: #f1f5f9; display: flex; align-items: center; justify-content: center;
    font-size: 36px; margin: 0 auto 10px; cursor: pointer; transition: transform 0.2s;
    border: 2px solid #e2e8f0;
}
.uc-avatar-preview:hover { transform: scale(1.06); }
.uc-avatar-hint { font-size: 12px; color: #64748b; margin-bottom: 10px; }
.uc-avatar-picker { display: none; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 260px; margin: 0 auto; }
.uc-avatar-picker.show { display: flex; }
.uc-avatar-picker span {
    width: 40px; height: 40px; border-radius: 50%; background: #f1f5f9;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
}
.uc-avatar-picker span:hover { background: #e0e7ff; transform: scale(1.1); }
.uc-avatar-picker span.selected {
    border-color: #6366f1; background: #e0e7ff;
    box-shadow: 0 0 12px rgba(99,102,241,0.3);
}
.uc-form-group { margin-bottom: 18px; }
.uc-form-group label { display: block; font-size: 12px; color: #64748b; margin-bottom: 7px; font-weight: 500; }
.uc-form-group input[type="text"] {
    width: 100%; padding: 10px 14px; border: 1.5px solid #e2e8f0;
    border-radius: 10px; background: #fff; color: #1e293b; font-size: 14px; outline: none;
    transition: border-color 0.15s;
}
.uc-form-group input[type="text"]:focus { border-color: #6366f1; }
.uc-token-display {
    padding: 10px 14px; background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 10px; font-size: 11px; color: #64748b; word-break: break-all;
    font-family: 'SF Mono', 'Fira Code', monospace; line-height: 1.6;
}
.uc-password-hint { font-size: 12px; color: #64748b; padding: 4px 0; }
.uc-actions { display: flex; gap: 10px; margin-top: 22px; }
.uc-actions .btn-cancel, .uc-actions .btn-save { flex: 1; padding: 12px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .header { padding: 16px 16px 0; }
    .main { padding: 24px 16px 48px; }
    .card { width: 100px; }
    .card-grid { gap: 8px; }
    .card { padding: 14px 10px 12px; }
    .card img { width: 38px; height: 38px; border-radius: 10px; }
    .search-wrap { border-radius: 12px; padding: 5px 5px 5px 12px; }
    .engine-btn { padding: 5px 8px; font-size: 11px; }
    #searchBtn { padding: 8px 14px; font-size: 12px; }
    .category { margin-bottom: 28px; }
}
@media (max-width: 480px) {
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
    .card { width: 88px; }
    .header-top { flex-direction: column; align-items: flex-start; gap: 8px; }
    .datetime { order: 1; }
    .user-info { order: 0; }
}

/* ── Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Drag & Drop ── */
.card[draggable="true"] { cursor: grab; }
.card[draggable="true"]:active { cursor: grabbing; }
.card.dragging {
    opacity: 0.3;
    transform: scale(0.9) rotate(2deg);
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
}
.card-grid.drag-over {
    background: rgba(99,102,241,0.06);
    border-radius: 12px;
    outline: 2px dashed rgba(99,102,241,0.35);
    outline-offset: 4px;
    transition: outline 0.2s, background 0.2s;
}
.card-grid.drag-over .card { pointer-events: none; }
.category-header { user-select: none; }

/* 批量模式下分类可拖动 */
body.batch-mode-active .category { position: relative; cursor: grab; transition: box-shadow 0.15s; }
body.batch-mode-active .category:hover { box-shadow: 0 2px 12px rgba(99,102,241,0.10); }
body.batch-mode-active .category .category-header {
    position: relative;
    padding-left: 22px;
}
body.batch-mode-active .category .category-header::before {
    content: '\22EE\22EE';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    opacity: 0.5;
    pointer-events: none;
    font-size: 14px;
    line-height: 1;
    letter-spacing: -3px;
    user-select: none;
}
body.batch-mode-active .category.dragging {
    opacity: 0.4;
    cursor: grabbing;
    transform: scale(0.99);
    transition: opacity 0.15s, transform 0.15s;
    pointer-events: none;
}
body.batch-mode-active .category.cat-drop-target {
    box-shadow: 0 -3px 0 #6366f1, 0 4px 18px rgba(99,102,241,0.12);
    transition: box-shadow 0.15s;
}

/* ── 右键菜单 ── */
.context-menu {
    display: none;
    position: fixed;
    z-index: 500;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    min-width: 120px;
    padding: 6px 0;
    animation: contextMenuIn 0.15s ease;
}
@keyframes contextMenuIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu-item {
    padding: 10px 18px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s;
}
.context-menu-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.context-menu-item[data-action="delete"]:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* ── Modal 分类选择器 ── */
.form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.form-group select:focus {
    border-color: #6366f1;
}

/* ── Missing category color themes ── */
.cat-red .category-icon { background: #fef2f2; }
.cat-red .category-title-text { color: #dc2626; }
.cat-red .card:hover { border-color: rgba(239,68,68,0.25); box-shadow: 0 6px 24px rgba(239,68,68,0.12); }

.cat-cyan .category-icon { background: #ecfeff; }
.cat-cyan .category-title-text { color: #0891b2; }
.cat-cyan .card:hover { border-color: rgba(6,182,212,0.25); box-shadow: 0 6px 24px rgba(6,182,212,0.12); }

.cat-yellow .category-icon { background: #fefce8; }
.cat-yellow .category-title-text { color: #a16207; }
.cat-yellow .card:hover { border-color: rgba(202,138,4,0.25); box-shadow: 0 6px 24px rgba(202,138,4,0.12); }

.cat-pink .category-icon { background: #fdf2f8; }
.cat-pink .category-title-text { color: #db2777; }
.cat-pink .card:hover { border-color: rgba(236,72,153,0.25); box-shadow: 0 6px 24px rgba(236,72,153,0.12); }

.cat-teal .category-icon { background: #f0fdfa; }
.cat-teal .category-title-text { color: #0d9488; }
.cat-teal .card:hover { border-color: rgba(20,184,166,0.25); box-shadow: 0 6px 24px rgba(20,184,166,0.12); }

.cat-indigo .category-icon { background: #eef2ff; }
.cat-indigo .category-title-text { color: #4f46e5; }
.cat-indigo .card:hover { border-color: rgba(99,102,241,0.25); box-shadow: 0 6px 24px rgba(99,102,241,0.12); }

.cat-lime .category-icon { background: #f7fee7; }
.cat-lime .category-title-text { color: #65a30d; }
.cat-lime .card:hover { border-color: rgba(132,204,22,0.25); box-shadow: 0 6px 24px rgba(132,204,22,0.12); }

/* ── 分类右键菜单危险项 ── */
.context-menu-item-danger:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}

/* ── 颜色选择器 ── */
.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 0;
}
.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    border: 3px solid transparent;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.color-dot:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.color-dot.active {
    border-color: #1e293b;
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.3);
}

/* ── 图标输入行 ── */
.icon-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.icon-input-row input {
    flex: 1;
}
.icon-upload-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.icon-upload-btn:hover {
    background: #e0e7ff;
    color: #6366f1;
    border-color: #c7d2fe;
}
.icon-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.icon-preview img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #e2e8f0;
}
.icon-clear-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #fee2e2;
    color: #ef4444;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.icon-clear-btn:hover {
    background: #ef4444;
    color: #fff;
}

/* ── 新增分类按钮栏 ── */
.add-category-bar {
    text-align: center;
    padding: 10px 0 4px;
}
.add-category-btn {
    background: none;
    border: 2px dashed #c7d2fe;
    color: #6366f1;
    padding: 12px 32px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.add-category-btn:hover {
    background: #eff6ff;
    border-color: #6366f1;
    box-shadow: 0 4px 16px rgba(99,102,241,0.15);
}
.add-category-btn:active {
    transform: scale(0.97);
}

/* ── 返回顶部/底部按钮 ── */
.scroll-btns {
    position: fixed;
    right: 24px;
    bottom: 32px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 400;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}
.scroll-btns.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.scroll-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(99,102,241,0.85);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
    transition: all 0.2s;
    backdrop-filter: blur(8px);
}
.scroll-btn:hover {
    background: rgba(99,102,241,1);
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(99,102,241,0.5);
}
.scroll-btn:active {
    transform: scale(0.95);
}
.scroll-btns.at-bottom .scroll-btn-top {
    background: rgba(99,102,241,1);
}
.scroll-btns:not(.at-bottom) .scroll-btn-bottom {
    background: rgba(99,102,241,1);
}

@media (max-width: 768px) {
    .scroll-btns {
        right: 16px;
        bottom: 20px;
    }
    .scroll-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}


/* ── 分类标签条(主体左列,竖向,一体) ── */
/* .cat-tabs 高度 = 0,只做 sticky 包装,row track 高度由主内容决定,不受侧边栏影响 */
.cat-tabs {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 0;
    overflow: visible;
    min-width: 0;
    position: sticky;
    top: 16px;
    z-index: 10;
}
/* 实际显示的分类标签条(嵌入 .cat-tabs 内,负责滚动 + 视觉) */
.cat-tabs-inner {
    width: 130px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
    transition: width 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,0.25) transparent;
}
.cat-tabs-inner::-webkit-scrollbar { width: 4px; }
.cat-tabs-inner::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 2px; }
.cat-tabs-inner::-webkit-scrollbar-track { background: transparent; }

/* ── 收起/展开按钮(toggle,默认状态更明显) ── */
.cat-tabs-toggle {
    color: #475569;            /* slate-600 */
    background: #f8fafc;       /* slate-50,浅底色,提升存在感 */
    border: 1px solid #e2e8f0; /* slate-200,常态就有边框 */
    cursor: pointer;
    margin-bottom: 2px;
    font-weight: 600;          /* 加粗,文字更清晰 */
    /* 禁止拖动 */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    /* 触屏禁止长按弹菜单/手势,允许 tap */
    touch-action: manipulation;
    transition: all 0.15s;
}
.cat-tabs-toggle:hover {
    color: #4338ca;            /* indigo-700 */
    background: #e0e7ff;       /* indigo-100 */
    border-color: #c7d2fe;     /* indigo-200 */
}
.cat-tabs-toggle:active {
    transform: scale(0.97);    /* 点击时轻微缩放反馈 */
    background: #c7d2fe;       /* indigo-200 */
}
.cat-tabs-arrow {
    display: inline-block;
    width: 14px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: inherit;
}
.icon-collapse { display: inline-block; }
.icon-expand { display: none; }
/* 默认(展开态):显示"收起",隐藏"展开" */
.cat-tabs-toggle-label-show-expanded { display: inline; }
.cat-tabs-toggle-label-show-collapsed { display: none; }

/* 收起态:整列变窄,只显示 toggle 按钮 */
.cat-tabs-inner.collapsed {
    width: 80px;            /* 容纳"展开"两字(72 不够,加到 80 留 4px 缓冲) */
    min-width: 80px;
}
.cat-tabs-inner.collapsed .cat-tab:not(.cat-tabs-toggle) {
    display: none;
}
.cat-tabs-inner.collapsed .icon-collapse { display: none; }
.cat-tabs-inner.collapsed .icon-expand { display: inline-block; }
/* 收起态:显示"展开",隐藏"收起" */
.cat-tabs-inner.collapsed .cat-tabs-toggle-label-show-expanded { display: none; }
.cat-tabs-inner.collapsed .cat-tabs-toggle-label-show-collapsed { display: inline; }
.cat-tabs-inner.collapsed .cat-tabs-toggle {
    margin-bottom: 0;
    /* 收起态:按钮是唯一可见元素,用强对比突出"展开"含义 */
    color: #4f46e5;            /* indigo-600 */
    background: #e0e7ff;       /* indigo-100,蓝底 */
    border-color: #c7d2fe;     /* indigo-200 */
}
.cat-tabs-inner.collapsed .cat-tabs-toggle:hover {
    color: #4338ca;
    background: #c7d2fe;
    border-color: #a5b4fc;
}

.main > *:not(.cat-tabs) {
    grid-column: 2;
}

.cat-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    user-select: none;
}
.cat-tab:hover {
    background: #f0f4ff;
}
.cat-tab:hover .cat-tab-label { color: #1e293b; }
.cat-tab.active {
    background: #e0e7ff;
    border-color: #c7d2fe;
    box-shadow: inset 3px 0 0 #6366f1;
}
.cat-tab.active .cat-tab-label { color: #4f46e5; font-weight: 600; }
.cat-tab.active .cat-tab-dot { transform: scale(1.4); box-shadow: 0 0 6px currentColor; }
.cat-tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.15s;
}
.cat-tab-label {
    font-size: 13px;
    color: #475569;
    transition: color 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    word-break: keep-all;   /* 中文不按字符断行 */
    white-space: nowrap;    /* 强制不换行 */
}
@media (max-width: 768px) {
    .main { grid-template-columns: 1fr; gap: 16px; }
    .main > *:not(.cat-tabs) { grid-column: 1; }
    .cat-tabs { grid-column: 1; grid-row: auto; height: auto; position: static; overflow: visible; }
    .cat-tabs-inner {
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none;
        padding: 0 0 4px;
        gap: 8px;
        width: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    /* 移动端不收起(横向滚动更顺手) */
    .cat-tabs-inner.collapsed { width: auto; }
    .cat-tabs-inner.collapsed .cat-tab:not(.cat-tabs-toggle) { display: flex; }
    .cat-tabs-inner.collapsed .icon-collapse { display: inline-block; }
    .cat-tabs-inner.collapsed .icon-expand { display: none; }
    .cat-tabs-inner::-webkit-scrollbar { display: none; }
    .cat-tab {
        flex-shrink: 0;
        padding: 5px 10px;
        border-radius: 999px;
        background: rgba(241,245,249,0.7);
        border: 1px solid #e2e8f0;
    }
    .cat-tab.active {
        background: #6366f1;
        border-color: #6366f1;
        box-shadow: 0 2px 8px rgba(99,102,241,0.25);
    }
    .cat-tab.active .cat-tab-label { color: #fff; }
    .cat-tab-label { font-size: 12px; }
}
/* ── 批量调整分类 ── */
.batch-mode-btn {
    background: rgba(255,255,255,0.8);
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}
.batch-mode-btn:hover {
    background: #e0e7ff;
    color: #4f46e5;
    border-color: #c7d2fe;
}
.batch-mode-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

/* 批量模式下的卡片样式 */
.batch-mode-active a.card:not(.add-card) {
    cursor: pointer;
    position: relative;
}
.batch-mode-active a.card:not(.add-card)::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid #c7d2fe;
    background: rgba(255,255,255,0.9);
    z-index: 2;
    transition: all 0.15s;
}
.batch-mode-active a.card.batch-selected::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.batch-mode-active a.card.batch-selected {
    border-color: #6366f1;
    background: #f0f0ff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.batch-mode-active a.card:not(.add-card):hover {
    transform: translateY(-2px);
    border-color: #a5b4fc;
}
/* 批量模式禁用拖拽 */
.batch-mode-active a.card[draggable="true"] {
    cursor: pointer !important;
    draggable: false;
}
.batch-mode-active .add-card {
    opacity: 0.4;
    pointer-events: none;
}

/* 批量操作工具栏 */
.batch-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid #e2e8f0;
    padding: 12px 24px;
    z-index: 450;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    animation: batchToolbarIn 0.25s ease;
}
.batch-toolbar.active {
    display: flex;
}
@keyframes batchToolbarIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.batch-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.batch-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.batch-count {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    padding: 4px 12px;
    background: #f0f4ff;
    border-radius: 8px;
}
.batch-btn {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.batch-btn:hover {
    background: #f1f5f9;
    border-color: #c7d2fe;
    color: #4f46e5;
}
.batch-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.batch-move-btn {
    background: linear-gradient(135deg, #6366f1, #818cf8) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.batch-move-btn:hover:not(:disabled) {
    opacity: 0.88;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}
.batch-cancel-btn {
    color: #dc2626 !important;
    border-color: #fecaca !important;
}
.batch-cancel-btn:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}
.batch-delete-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}
.batch-delete-btn:hover:not(:disabled) {
    opacity: 0.88;
    box-shadow: 0 4px 16px rgba(220,38,38,0.45);
}
.batch-category-select {
    padding: 8px 32px 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 120px;
}
.batch-category-select:focus {
    border-color: #6366f1;
}

/* 按分类筛选下拉框 (与 batch-category-select 同款, 区别是仅供 “全选该分类” 使用) */
.batch-category-filter {
    padding: 8px 32px 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 130px;
}
.batch-category-filter:focus {
    border-color: #6366f1;
}

/* “全选该分类” 按钮: 静默强调 (中性填充, 比 .batch-btn 略重) */
.batch-select-by-category-btn {
    background: linear-gradient(135deg, #0ea5e9, #38bdf8) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(14,165,233,0.3);
}
.batch-select-by-category-btn:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 16px rgba(14,165,233,0.45);
}

/* “删除该分类” 按钮: 红色危险操作 (但比 .batch-delete-btn 更重) */
.batch-delete-category-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}
.batch-delete-category-btn:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 16px rgba(220,38,38,0.45);
}

/* ============== 批量删除分类: 多选下拉 + 全部分类 + 取消 + 删除选中 ============== */

/* 分隔符 */
.batch-toolbar-sep {
    color: #cbd5e1;
    margin: 0 4px;
    user-select: none;
}

/* 多选 select (展示所有分类, 默认折叠为单行) */
.batch-category-multi-select {
    padding: 6px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font-size: 13px;
    outline: none;
    min-width: 160px;
    max-width: 240px;
    cursor: pointer;
}
.batch-category-multi-select:focus {
    border-color: #6366f1;
}
.batch-category-multi-select option {
    padding: 4px 8px;
}
.batch-category-multi-select option:checked {
    background: linear-gradient(0deg, #fecaca 0%, #fecaca 40%);
    color: #7f1d1d;
    font-weight: 600;
}

/* 按钮组容器 (纵向堆叠, 节省横向空间) */
.batch-delete-cats-actions {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

/* “全部分类” 按钮: 橙色预警 (警告而非危险, 提示将批量操作) */
.batch-select-all-cats-btn {
    background: linear-gradient(135deg, #f59e0b, #fbbf24) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.batch-select-all-cats-btn:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 16px rgba(245,158,11,0.45);
}

/* “取消” 按钮: 灰色中性 */
.batch-deselect-all-cats-btn {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
}
.batch-deselect-all-cats-btn:hover:not(:disabled) {
    background: #e2e8f0 !important;
}

/* “删除选中分类” 按钮: 红色危险操作 (主操作, 比 全部分类 更醒目) */
.batch-delete-selected-cats-btn {
    background: linear-gradient(135deg, #dc2626, #ef4444) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(220,38,38,0.3);
}
.batch-delete-selected-cats-btn:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 16px rgba(220,38,38,0.45);
}

/* 批量模式时，滚动按钮上移 */
.batch-mode-active .scroll-btns {
    bottom: 70px;
}

@media (max-width: 768px) {
    .batch-toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 10px 16px;
    }
    .batch-toolbar-left, .batch-toolbar-right {
        width: 100%;
        justify-content: center;
    }
    .batch-category-select {
        flex: 1;
        min-width: 0;
    }
}

/* ==================== 空状态(无任何分类和链接时) ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
    min-height: 400px;
    color: #64748b;
}

.empty-state-icon {
    font-size: 96px;
    margin-bottom: 24px;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-state-title {
    font-size: 24px;
    font-weight: 600;
    color: #334155;
    margin: 0 0 8px;
}

.empty-state-desc {
    font-size: 15px;
    color: #94a3b8;
    margin: 0 0 32px;
}

.empty-state-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.empty-state-btn {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.empty-state-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    transform: translateY(-1px);
}

.empty-state-btn.primary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.empty-state-btn.primary:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

.empty-state-hint {
    margin-top: 32px;
    padding: 20px 24px;
    background: #f1f5f9;
    border-radius: 12px;
    text-align: left;
    max-width: 480px;
    font-size: 14px;
    line-height: 1.9;
    color: #475569;
}

.empty-state-hint p {
    margin: 0;
}

.empty-state-hint b {
    color: #1e293b;
    font-weight: 600;
}

/* ── 头部品牌(logo + 站名) ── */
.header-top {
    /* .header-right 已用 flex,这里只要保持原本 space-between 行为 */
    gap: 16px;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.header-brand-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 10px;
    padding: 4px 8px;
    margin: -4px -8px;
    /* 无 hover 背景变化, 鼠标反馈完全由内部 logo 自身的 transform/box-shadow 提供 */
}
.header-brand-link:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}
.header-brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    background: transparent;
    flex-shrink: 0;
    /* 透明背景, 无任何 hover/active 视觉反馈 (无背景色/缩放/阴影) */
}
.header-brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── 分类标签条顶部 logo(展开态显示) ── */
.cat-tabs-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px 10px;
    margin-bottom: 4px;
    border-bottom: 1px dashed #e2e8f0;
}
.cat-tabs-logo img {
    max-height: 36px;
    max-width: 160px;
    object-fit: contain;
    border-radius: 6px;
}
/* 收起态:隐藏侧边栏 logo(展开按钮自己会变成大色块) */
.cat-tabs-inner.collapsed .cat-tabs-logo {
    display: none;
}

/* ── 收起态的展开按钮(幽灵按钮思路) ── */
/* 收起时: 整列变窄, 按钮用极淡紫底 + 描边 + 极轻阴影, 默认不砸在大白底上 */
.cat-tabs-inner.collapsed {
    width: 60px;
    min-width: 60px;
}
.cat-tabs-inner.collapsed .cat-tabs-toggle {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 4px;
    width: 100%;
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    margin: 0;
    font-weight: 600;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, color 0.2s ease;
    position: relative;
}
.cat-tabs-inner.collapsed .cat-tabs-toggle:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.32);
    color: #4338ca;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18);
    transform: translateY(-1px);
}
.cat-tabs-inner.collapsed .cat-tabs-toggle:active {
    transform: scale(0.96) translateY(0);
    background: rgba(99, 102, 241, 0.18);
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.18);
}
.cat-tabs-inner.collapsed .icon-collapse { display: none; }
.cat-tabs-inner.collapsed .icon-expand {
    display: inline-block;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    color: #4f46e5;
}


/* 展开态:恢复箭头 + "收起" 文字(覆盖 collapsed 的 column 布局) */
.cat-tabs-inner:not(.collapsed) .cat-tabs-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 8px 12px;
}

/* ── 响应式:小屏隐藏站名文字,只显示 logo ── */
@media (max-width: 640px) {
    .header-brand-text { display: none; }
    .header-brand-logo { width: 32px; height: 32px; }
    .datetime { display: none; }
    .weather-row { justify-content: center; }
    .weather-change-text { display: none; }
    .weather-change { padding: 5px 8px; }
    #weatherBox #weatherText { max-width: 180px; }
}
@media (max-width: 380px) {
    .weather-row { margin-top: 8px; }
    .weather-change { padding: 5px 7px; }
}

/* ── 搜索引擎:本地按钮(强调) ── */
.engine-btn-local {
    background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%) !important;
    color: #fff !important;
    font-weight: 600;
}
.engine-btn-local:hover {
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4) !important;
    transform: translateY(-1px);
}

/* ── 本地搜索下拉建议 ── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 999;
    max-height: 420px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.06);
    padding: 6px 0;
}
.search-wrap { position: relative; }   /* 锚点,确保下拉相对搜索栏定位 */

.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid #f1f5f9;
}
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover,
.search-dropdown-item.active {
    background: linear-gradient(90deg, #eef2ff 0%, #fdf2f8 100%);
}
.search-dropdown-item .sd-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 5px;
    object-fit: contain;
    background: #f1f5f9;
}
.search-dropdown-item .sd-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.search-dropdown-item .sd-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.search-dropdown-item .sd-url {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.search-dropdown-item .sd-name mark,
.search-dropdown-item .sd-url mark {
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
    color: #92400e;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 700;
}
.search-dropdown-item .sd-cat {
    flex-shrink: 0;
    font-size: 11px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 3px 9px;
    border-radius: 999px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 滚动条美化(Webkit) */
.search-dropdown::-webkit-scrollbar { width: 6px; }
.search-dropdown::-webkit-scrollbar-track { background: transparent; }
.search-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.search-dropdown::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

@media (max-width: 640px) {
    .search-dropdown { max-height: 320px; }
    .search-dropdown-item { padding: 8px 10px; gap: 8px; }
    .search-dropdown-item .sd-name { font-size: 13px; }
    .search-dropdown-item .sd-url { font-size: 11px; }
    .search-dropdown-item .sd-cat { font-size: 10px; padding: 2px 7px; }
}

/* ==================== 本地搜索结果区(共用主体区) ==================== */
.search-area {
    grid-column: 2;
    width: 100%;
    padding: 4px 4px 24px;
    box-sizing: border-box;
    animation: searchAreaFadeIn .2s ease;
}
.search-area[hidden] { display: none; }
@keyframes searchAreaFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.search-area-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.search-area-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text, #1e293b);
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.search-area-title .search-area-q {
    color: #6366f1;
    font-weight: 700;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}
.search-area-count {
    color: #94a3b8;
    font-size: 13px;
}
.search-area-clear {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
    background: transparent;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all .15s ease;
}
.search-area-clear:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
}

.search-area-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.search-result-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 16px 10px 12px;
    min-height: 110px;
    border-radius: 12px;
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    overflow: hidden;
}
.search-result-card:hover,
.search-result-card.active {
    transform: translateY(-2px);
    border-color: #6366f1;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.18);
}
.search-result-card .src-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
    background: #f1f5f9;
}
.search-result-card .src-name {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
    max-width: 100%;
    word-break: break-all;
    color: var(--text, #1e293b);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.search-result-card .src-url {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-card .src-cat {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    font-weight: 500;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-card mark {
    background: #fef08a;
    color: #854d0e;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

.search-empty {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.8;
}
.search-empty .search-empty-q {
    color: #6366f1;
    font-weight: 600;
}
.search-empty-tip {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #cbd5e1;
}

/* 搜索模式: 隐藏原主体内容,只显示搜索结果区 */
.main.is-searching > .category,
.main.is-searching > .empty-state {
    display: none !important;
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
    .search-area-header { border-bottom-color: #334155; }
    .search-area-title { color: #f1f5f9; }
    .search-result-card {
        background: #1e293b;
        border-color: #334155;
    }
    .search-result-card .src-name { color: #f1f5f9; }
    .search-result-card .src-icon { background: #0f172a; }
    .search-area-clear { border-color: #334155; }
}

/* ============ 底部 footer ============ */
.site-footer {
    text-align: center;
    padding: 14px 12px 20px;
    margin-top: 12px;
    color: #64748b;
    font-size: 12px;
    user-select: none;
}
.site-footer-inner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    flex-wrap: wrap;
    justify-content: center;
}
.site-footer-copy {
    color: #475569;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.site-footer-sep {
    color: #cbd5e1;
    user-select: none;
}
.site-footer-icp {
    color: #64748b;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 10px;
    transition: color 0.15s ease, background 0.15s ease;
}
.site-footer-icp:hover {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.08);
}
.site-footer-icp:active {
    background: rgba(99, 102, 241, 0.16);
}
.site-footer-shield {
    font-size: 13px;
    line-height: 1;
}
@media (max-width: 480px) {
    .site-footer-inner {
        font-size: 11px;
        padding: 5px 12px;
        gap: 6px;
    }
}



/* 天气行(已移到 header-right, 保留类名兼容旧代码) */
.weather-row {
    display: none; /* 已移到 header-right */
}

/* 顶部天气组件 (header-right 内) */
.header-weather {
    order: 1; /* 在 datetime 之后 */
}
#weatherBox {
    color: #64748b; font-size: 13px; font-weight: 500;
    background: rgba(255,255,255,0.85); padding: 5px 5px 5px 14px; border-radius: 22px;
    border: 1px solid #e2e8f0; backdrop-filter: blur(8px);
    cursor: pointer; transition: all 0.2s ease;
    white-space: nowrap;
    position: relative; /* 用于 weather-picker 绝对定位 */
}
#weatherBox:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }
#weatherBox.loading { opacity: 0.6; }
#weatherBox .weather-icon { margin-right: 4px; }
#weatherBox .weather-temp { font-weight: 600; color: #4f46e5; margin: 0 4px; }
/* 文字部分单独控制截断,避免过长的城市名挤压切换按钮 */
#weatherBox #weatherText {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}

/* “切换城市”按钮(显式入口,解决双击/右键不直观的问题) */
.weather-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(124, 58, 237, 0.12));
    border: 1px solid #c7d2fe;
    color: #4f46e5;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.weather-change:hover {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}
.weather-change:active {
    transform: translateY(0) scale(0.97);
}
.weather-change-icon {
    flex-shrink: 0;
}

/* 天气选择面板 */
.weather-wrap { position: relative; }
.weather-picker {
    position: absolute; top: calc(100% + 6px); right: 0;
    width: 300px; max-height: 460px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 999; padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
    color: #334155; font-size: 13px;
}
.weather-picker[hidden] { display: none; }
.weather-picker-head {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; font-size: 13px; color: #475569; padding: 2px 4px;
}
.weather-picker-close {
    background: none; border: none; color: #94a3b8; font-size: 20px; line-height: 1;
    cursor: pointer; padding: 2px 6px; border-radius: 6px;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.weather-picker-close:hover { background: #f1f5f9; color: #475569; }
.weather-picker-input {
    width: 100%; box-sizing: border-box; padding: 8px 10px;
    border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; outline: none;
    background: #f8fafc; color: #1e293b;
}
.weather-picker-input:focus { border-color: #6366f1; background: #fff; }
.weather-picker-actions { display: flex; gap: 6px; }
.weather-picker-btn {
    flex: 1; padding: 6px 8px; border: 1px solid #e2e8f0; border-radius: 8px;
    background: #f8fafc; color: #475569; cursor: pointer; font-size: 12px;
    transition: all 0.15s ease;
}
.weather-picker-btn:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }
.weather-picker-list {
    overflow-y: auto; max-height: 320px;
    border: 1px solid #f1f5f9; border-radius: 8px; background: #fff;
}
.weather-picker-item {
    padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s ease;
}
.weather-picker-item:last-child { border-bottom: none; }
.weather-picker-item:hover, .weather-picker-item.active { background: #eef2ff; }
.weather-picker-item-name { font-weight: 600; color: #1e293b; }
.weather-picker-item-region { color: #94a3b8; font-size: 12px; margin-top: 2px; }
.weather-picker-tip { padding: 20px 10px; color: #94a3b8; text-align: center; font-size: 12px; }
.weather-picker-tip b { color: #6366f1; font-weight: 600; }
.weather-picker-loading { padding: 16px 10px; color: #6366f1; text-align: center; font-size: 12px; }
.weather-picker-empty { padding: 16px 10px; color: #94a3b8; text-align: center; font-size: 12px; }

/* 切换按钮在选择面板打开时的活动状态 */
.weather-change.active {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

/* 移动端选择面板:全宽自适应,避免超出屏幕 */
@media (max-width: 480px) {
    .weather-picker {
        position: fixed;
        top: auto; right: 8px; left: 8px;
        width: auto;
        max-height: 70vh;
    }
}

/* 天气提示 toast (定位中/失败反馈,避免静默 fallback) */
.weather-toast {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1001;
    min-width: 260px;
    max-width: 400px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #f59e0b;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    font-size: 12px;
    color: #475569;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.5;
    text-align: left;
    cursor: default;
    animation: weatherToastIn 0.25s ease-out;
}
.weather-toast-info  { border-left-color: #6366f1; }
.weather-toast-warn  { border-left-color: #f59e0b; }
.weather-toast-error { border-left-color: #ef4444; }
.weather-toast-icon  { font-size: 13px; line-height: 1.4; flex-shrink: 0; }
.weather-toast-text  { flex: 1; word-break: break-word; }
.weather-toast-close {
    background: none; border: none; color: #94a3b8;
    font-size: 16px; cursor: pointer; padding: 0 2px;
    line-height: 1; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.weather-toast-close:hover { color: #475569; }
@keyframes weatherToastIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* 定位中: 文字轻微脉动, 提示正在工作 */
#weatherBox.loading #weatherText { animation: weatherPulse 1.2s ease-in-out infinite; }
@keyframes weatherPulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}
@media (max-width: 480px) {
    .weather-toast {
        right: 0; left: 0;
        max-width: none;
        width: auto;
    }
}


/* ===== 用户中心 Tab + 信息面板 ===== */
.uc-tabs { display:flex; border-bottom:2px solid #e5e7eb; margin:0 24px; }
.uc-tab { flex:1; padding:10px 0; border:none; background:none; cursor:pointer; font-size:14px; font-weight:500; color:#888; position:relative; transition:color .2s; }
.uc-tab.active { color:#4f46e5; }
.uc-tab.active::after { content:''; position:absolute; bottom:-2px; left:20%; right:20%; height:2px; background:#4f46e5; border-radius:2px; }
.uc-tab:hover { color:#4f46e5; }
.uc-info-name { font-size:20px; font-weight:600; margin-top:12px; }
.uc-info-username { font-size:13px; color:#888; margin-top:4px; }
.uc-info-card { background:#f5f7ff; border-radius:12px; padding:16px; margin:16px 0; }
.uc-info-row { display:flex; justify-content:space-between; align-items:center; padding:8px 0; }
.uc-info-row + .uc-info-row { border-top:1px solid #e5e7eb; }
.uc-info-label { font-size:13px; color:#5b6271; }
.uc-info-value { font-size:14px; font-weight:600; color:#1f2330; }
.uc-orders-section { margin:16px 0; }
.uc-orders-section h3 { font-size:15px; font-weight:600; margin-bottom:12px; }
.uc-orders-list { max-height:200px; overflow-y:auto; }
.uc-orders-empty { text-align:center; color:#888; font-size:13px; padding:20px 0; }
.uc-order-item { display:grid; grid-template-columns:1fr auto auto auto auto; gap:12px; align-items:center; padding:8px 12px; font-size:13px; border-bottom:1px solid #f1f2f6; }
.uc-order-item:last-child { border-bottom:none; }

/* 订单类型标签 */
.uc-order-tag { display:inline-block; padding:2px 8px; border-radius:4px; font-size:12px; font-weight:500; }
.uc-order-tag.invite { background:#dbeafe; color:#1e40af; }
.uc-order-tag.renewal { background:#d1fae5; color:#065f46; }
.uc-order-code { grid-column:1/-1; padding:6px 0 0; font-size:13px; color:#475569; word-break:break-all; }
.uc-order-code b { color:#7c3aed; font-family:monospace; letter-spacing:0.5px; }

/* ========================================================================
 * P2: 移动端汉堡菜单 (≤768px)
 * - 桌面 (>768px): 完全隐藏汉堡按钮 + 抽屉
 * - 移动 (≤768px): 显示汉堡按钮, 原 .header-right 收纳进抽屉
 * ======================================================================== */

/* 汉堡按钮 (默认隐藏, 移动端显示) */
#headerMenuToggle {
    display: none;
    width: 44px; height: 44px;
    border: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border-radius: 12px;
    color: #1e293b;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.18s ease;
    /* 提级 z-index, 保证不被头部其他元素压住 */
    position: relative;
    z-index: 60;
}
#headerMenuToggle:hover { background: #e0e7ff; border-color: #c7d2fe; }
#headerMenuToggle:active { transform: scale(0.95); }
#headerMenuToggle svg { width: 22px; height: 22px; }
#headerMenuToggle.is-open { background: #4f46e5; border-color: #4f46e5; color: #fff; }

/* 抽屉遮罩 (默认隐藏) */
#headerDrawerOverlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.22s ease;
    -webkit-tap-highlight-color: transparent;
}
#headerDrawerOverlay.is-open {
    display: block;
    opacity: 1;
}

/* 抽屉本体 (默认隐藏) */
#headerMobileDrawer {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(86vw, 320px);
    background: #ffffff;
    z-index: 999;
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}
#headerMobileDrawer.is-open {
    display: flex;
    flex-direction: column;
    transform: translateX(0);
}
#headerMobileDrawer .dm-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
#headerMobileDrawer .dm-title { font-size: 17px; font-weight: 600; color: #0f172a; }
#headerMobileDrawer .dm-close {
    width: 36px; height: 36px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 10px;
    color: #475569;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#headerMobileDrawer .dm-close:active { background: #e0e7ff; }

#headerMobileDrawer .dm-section {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
}
#headerMobileDrawer .dm-section-title {
    font-size: 11px; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 10px;
}
#headerMobileDrawer .dm-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    font-size: 15px; color: #1e293b;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.15s;
}
#headerMobileDrawer .dm-row:active { background: #f1f5f9; }
#headerMobileDrawer .dm-row-ico {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.08);
    color: #4f46e5;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
#headerMobileDrawer .dm-row-text { flex: 1; }
#headerMobileDrawer .dm-row-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

#headerMobileDrawer .dm-actions { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
#headerMobileDrawer .dm-actions button {
    width: 100%; padding: 14px 16px;
    border-radius: 12px; font-size: 15px; font-weight: 500;
    border: 1px solid #e2e8f0; background: #fff; color: #1e293b;
    cursor: pointer; text-align: center;
    transition: all 0.15s;
}
#headerMobileDrawer .dm-actions button:active { background: #f1f5f9; }

/* 抽屉滑入时 body 不能滚 (避免背景穿透滚动) */
body.drawer-open { overflow: hidden; }

/* === 移动端 ≤768px === */
@media (max-width: 768px) {
    /* 顶部: 时间显示调小, 隐藏部分次要元素 */
    .header { padding: 12px 14px 0; }
    .header-top { margin-bottom: 10px; gap: 8px; }
    .header-right .datetime { font-size: 12px; padding: 5px 10px; }
    /* 移动端显示汉堡按钮 */
    #headerMenuToggle { display: inline-flex; }
    /* 移动端把整个 header-right 收纳进抽屉 (原区域留空) */
    .header-right {
        flex-shrink: 0;
        margin-left: auto;
        gap: 6px;
    }
    .header-right > *:not(#headerMenuToggle):not(.datetime) {
        display: none !important;          /* 天气/备忘录/工具/用户/批量 隐藏 */
    }
    .header-right > .datetime { display: none !important; }  /* 时间也进抽屉 */

    /* 搜索区紧凑化: 引擎选择器向下, 搜索框在上 */
    .search-wrap {
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        border-radius: 14px;
        align-items: stretch;
    }
    .search-engine-selector {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .search-engine-selector::-webkit-scrollbar { display: none; }
    .engine-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 36px;
        flex-shrink: 0;
    }
    .search-box { width: 100%; }
    .search-box input {
        font-size: 16px;
        padding: 8px 0;
        min-height: 28px;
    }
    #searchBtn {
        min-width: 64px;
        padding: 8px 16px;
        font-size: 13px;
    }
    /* 搜索 clear 按钮也加大 (iOS 上手指点不准) */
    #searchClear {
        width: 28px; height: 28px;
        font-size: 18px;
    }

    /* 日历弹窗: 移动端宽度跟随屏幕 */
    .calendar-popup { width: calc(100vw - 24px); max-width: 360px; }

    /* 主区域 */
    .main { padding: 16px 14px 32px; }

    /* 卡片标题更大 (手指好按) */
    .category h2 { font-size: 16px; }
}

/* === 极窄屏 ≤360px === */
@media (max-width: 360px) {
    .header { padding: 10px 10px 0; }
    #headerMenuToggle { width: 40px; height: 40px; }
    .engine-btn { padding: 7px 10px; font-size: 12px; }
}

/* === 横屏适配 (≤768px height) === */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .search-wrap { padding: 6px 8px; }
    .engine-btn { padding: 6px 10px; min-height: 32px; }
}

/* iPhone X+ 等 safe-area 兼容: header 加 padding-top */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: max(20px, env(safe-area-inset-top));
    }
}

/* ==================== v1.5.0: 顶栏「支持我们」入口 ==================== */
.header-sponsor-link {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    margin-right: 6px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s;
}
.header-sponsor-link:hover { background: rgba(99, 102, 241, 0.16); color: #4f46e5; }
@media (max-width: 768px) {
    .header-sponsor-link { font-size: 12px; padding: 0 8px; height: 28px; }
}

/* ==================== v1.5.0: 首页底部广告位 ==================== */
.home-ad-bottom-slot {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 999;
    max-width: 320px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    animation: homeAdSlideIn 0.4s ease-out;
}
@keyframes homeAdSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.home-ad-card {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px;
}
.home-ad-link {
    display: block;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.home-ad-img {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 100px;
    object-fit: cover;
    border-radius: 6px;
}
.home-ad-text {
    display: block;
    padding: 4px 6px;
    color: #1e293b;
    font-size: 13px;
    line-height: 1.4;
}
.home-ad-text strong {
    display: block;
    color: #4f46e5;
    font-size: 14px;
    margin-bottom: 2px;
}
.home-ad-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.home-ad-close:hover { background: rgba(0, 0, 0, 0.75); }
@media (max-width: 768px) {
    .home-ad-bottom-slot { right: 8px; bottom: 8px; max-width: 240px; }
    .home-ad-img { max-height: 80px; }
}
@media (max-width: 480px) {
    .home-ad-bottom-slot { left: 8px; right: 8px; max-width: none; }
}

/* ==================== v1.5.0: 赞助 modal ==================== */
.sponsor-modal-mask {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.sponsor-modal-mask.hidden { display: none; }
.sponsor-modal-card {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    text-align: center;
}
.sponsor-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.sponsor-modal-close:hover { color: #475569; }
.sponsor-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    color: #1e293b;
    font-weight: 600;
}
.sponsor-modal-sub {
    margin: 0 0 20px;
    color: #64748b;
    font-size: 13px;
}
.sponsor-modal-body { min-height: 80px; }
.sponsor-loading,
.sponsor-empty {
    padding: 20px 12px;
    color: #94a3b8;
    font-size: 13px;
}
.sponsor-qrs {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}
.sponsor-qr {
    flex: 0 1 auto;
    text-align: center;
}
.sponsor-qr-img {
    width: 180px;
    height: 180px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}
.sponsor-qr-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.sponsor-no-img {
    padding: 24px 12px;
    color: #94a3b8;
    font-size: 12px;
}
.sponsor-qr-label {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}
@media (max-width: 480px) {
    .sponsor-modal-card { padding: 24px 16px 16px; }
    .sponsor-qr-img { width: 140px; height: 140px; }
}
