/* ===== Flash · 设计系统 ===== */

* { box-sizing: border-box; }

:root,
:root[data-theme="dark"] {
    --bg-1:        #07090f;
    --bg-2:        #0d1320;
    --bg-3:        #131a2a;

    --surface-1:   rgba(255, 255, 255, 0.03);
    --surface-2:   rgba(255, 255, 255, 0.05);
    --surface-3:   rgba(255, 255, 255, 0.08);
    --surface-hi:  rgba(255, 255, 255, 0.12);

    --border-1:    rgba(255, 255, 255, 0.06);
    --border-2:    rgba(255, 255, 255, 0.1);
    --border-hi:   rgba(255, 255, 255, 0.2);

    --text-1:      #f1f4fa;
    --text-2:      #b6c0d2;
    --text-3:      #7c8699;
    --text-4:      #4d5567;

    --brand:       #7c9eff;
    --brand-2:     #5a7eff;
    --brand-3:     #9a7cff;
    --brand-glow:  rgba(124, 158, 255, 0.35);

    --success:     #10d094;
    --danger:      #ff5d6c;
    --warning:     #ffb547;

    --glow-1:      rgba(124, 158, 255, 0.15);
    --glow-2:      rgba(154, 124, 255, 0.12);
    --glow-3:      rgba(16, 208, 148, 0.04);

    --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-2: 0 4px 16px rgba(0,0,0,0.25);
    --shadow-3: 0 12px 40px rgba(0,0,0,0.4);
    --shadow-brand: 0 6px 24px rgba(124, 158, 255, 0.3);
}

:root[data-theme="light"] {
    --bg-1:        #f4f6fb;
    --bg-2:        #ffffff;
    --bg-3:        #eef2f8;

    --surface-1:   rgba(255, 255, 255, 0.7);
    --surface-2:   rgba(255, 255, 255, 0.85);
    --surface-3:   rgba(247, 249, 252, 0.92);
    --surface-hi:  rgba(238, 242, 248, 0.95);

    --border-1:    rgba(20, 30, 50, 0.06);
    --border-2:    rgba(20, 30, 50, 0.1);
    --border-hi:   rgba(20, 30, 50, 0.18);

    --text-1:      #1a2030;
    --text-2:      #4a5568;
    --text-3:      #7a8699;
    --text-4:      #aab3c2;

    --brand:       #5a7eff;
    --brand-2:     #4a6edb;
    --brand-3:     #7c5eff;
    --brand-glow:  rgba(90, 126, 255, 0.22);

    --success:     #08a878;
    --danger:      #dc3545;
    --warning:     #d68a0a;

    --glow-1:      rgba(124, 158, 255, 0.22);
    --glow-2:      rgba(124, 94, 255, 0.16);
    --glow-3:      rgba(16, 208, 148, 0.06);

    --shadow-1: 0 1px 2px rgba(20, 30, 50, 0.04);
    --shadow-2: 0 4px 16px rgba(20, 30, 50, 0.06);
    --shadow-3: 0 12px 40px rgba(20, 30, 50, 0.08);
    --shadow-brand: 0 6px 24px rgba(90, 126, 255, 0.25);
}

:root {
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-full: 9999px;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 0.15s;
    --t-base: 0.25s;
    --t-slow: 0.4s;

    /* 卡片色条 */
    --card-blue:   #5a7eff;
    --card-green:  #10d094;
    --card-yellow: #ffb547;
    --card-orange: #ff8a5b;
    --card-pink:   #f06b9f;
    --card-purple: #9a7cff;
}

html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--text-1);
    line-height: 1.55;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(ellipse 1000px 700px at 15% -10%,  var(--glow-1), transparent 50%),
        radial-gradient(ellipse 800px 1000px at 85% 110%, var(--glow-2), transparent 50%),
        radial-gradient(ellipse 600px 600px at 50% 50%,  var(--glow-3), transparent 60%),
        var(--bg-1);
    background-attachment: fixed;
    transition: background-color var(--t-slow) var(--ease);
}

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; color: inherit; }

/* ===== 顶部 header ===== */
.app-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--surface-1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-1);
    padding: 14px 20px;
    display: flex; gap: 12px; align-items: center;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; }
.app-header .brand-icon {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(124,158,255,0.3);
}
.app-header h1 {
    margin: 0;
    font-size: 17px; font-weight: 700;
    background: linear-gradient(135deg, var(--text-1) 0%, var(--brand) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.app-header .spacer { flex: 1; }
.app-header .nav { display: flex; gap: 6px; align-items: center; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    background: var(--surface-2);
    color: var(--text-1);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    font-size: 13.5px; font-weight: 500;
    transition: all var(--t-base) var(--ease);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}
.btn:hover {
    background: var(--surface-3);
    border-color: var(--border-2);
    transform: translateY(-1px);
    color: var(--text-1);
    text-decoration: none;
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-brand);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(124,158,255,0.45); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { background: #ff6e7a; }
.btn.ghost { background: transparent; border-color: transparent; padding: 8px; }
.btn.ghost:hover { background: var(--surface-2); }

.lang-toggle, .theme-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    color: var(--text-1);
    border-radius: var(--r-full);
    cursor: pointer;
    font-size: 12px; font-weight: 600;
    letter-spacing: 1px;
    min-width: 32px; height: 32px;
    padding: 0;
    transition: all var(--t-base) var(--ease);
}
.lang-toggle:hover, .theme-toggle:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
}

/* ===== 容器 ===== */
.layout {
    display: flex;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    position: relative;
}
.sidebar {
    width: 240px;
    flex-shrink: 0;
    padding: 18px 12px 12px;
    border-right: 1px solid var(--border-1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100vh - 70px);
    overflow-y: auto;
    transition: width var(--t-base) var(--ease), padding var(--t-base) var(--ease);
    position: sticky;
    top: 70px;
    align-self: flex-start;
}
.sb-foot {
    position: sticky;
    bottom: -12px;
    background: var(--bg-1);
    margin: 0 -12px -12px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border-1);
    z-index: 2;
}
.sidebar.collapsed {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border-right: none;
}
.sidebar.collapsed > * { display: none; }
.wrap {
    flex: 1;
    min-width: 0;
    padding: 28px 24px 120px;
}
.sb-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 6px 4px;
}
.sb-title {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-3);
}
.sb-toggle {
    position: fixed;
    top: 50%;
    left: 225px;
    transform: translateY(-50%);
    width: 30px; height: 30px;
    background: var(--surface-hi);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-2);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--t-fast) var(--ease);
    z-index: 5;
    box-shadow: var(--shadow-2);
}
.sb-toggle:hover { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.sb-toggle:active { transform: translateY(-50%) scale(0.92); }
.sb-toggle svg { width: 14px; height: 14px; fill: currentColor; }

.sb-search { padding: 0 4px; }
.sb-search input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    color: var(--text-1);
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color var(--t-fast) var(--ease);
}
.sb-search input:focus { border-color: var(--border-hi); }

.sb-decks {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    margin: 0 -4px;
}
.deck-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--text-2);
    font-size: 13px;
    user-select: none;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
    position: relative;
}
.deck-item:hover { background: var(--surface-2); color: var(--text-1); }
.deck-item.active {
    background: var(--surface-3);
    color: var(--text-1);
    font-weight: 500;
}
.deck-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.deck-item .deck-name {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.deck-item .deck-count {
    font-size: 11px;
    color: var(--text-3);
    background: var(--surface-2);
    padding: 1px 7px;
    border-radius: var(--r-full);
    min-width: 18px; text-align: center;
}
.deck-item.active .deck-count { background: var(--surface-hi); color: var(--text-2); }
.deck-item .deck-actions {
    display: none;
    gap: 2px;
}
.deck-item:hover .deck-actions { display: flex; }
.deck-item .deck-actions button {
    width: 22px; height: 22px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-3);
    cursor: pointer;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.deck-item .deck-actions button:hover { background: var(--surface-hi); color: var(--text-1); }
.deck-item .deck-actions button.danger:hover { color: var(--danger); }
.deck-item .deck-actions svg { width: 11px; height: 11px; fill: currentColor; }

.sb-divider {
    height: 1px;
    background: var(--border-1);
    margin: 6px 8px;
}

.sb-section-divider { margin: 8px 8px 4px; }
.sb-section-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 6px 4px;
}
.sb-section-count {
    font-size: 10px;
    color: var(--text-3);
    background: var(--surface-2);
    padding: 1px 7px;
    border-radius: var(--r-full);
}
.sb-tags {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 0 -4px;
    padding: 4px 0;
}
.sb-tags:empty::before {
    content: attr(data-empty);
    color: var(--text-4);
    font-size: 11px;
    padding: 4px 10px;
    text-align: center;
}
.tag-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--text-2);
    font-size: 12.5px;
    user-select: none;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tag-item:hover { background: var(--surface-2); color: var(--text-1); }
.tag-item.active {
    background: var(--brand-glow);
    color: var(--text-1);
    font-weight: 500;
}
.tag-item .tag-prefix {
    color: var(--brand);
    font-weight: 600;
    font-size: 11px;
}
.tag-item .tag-name {
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-item .tag-count {
    font-size: 10.5px;
    color: var(--text-3);
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: var(--r-full);
    min-width: 16px; text-align: center;
}
.tag-item.active .tag-count { background: var(--surface-hi); color: var(--text-2); }

.sb-new {
    width: 100%;
    background: var(--surface-2);
    border: 1px dashed var(--border-2);
    border-radius: var(--r-sm);
    color: var(--text-2);
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all var(--t-fast) var(--ease);
}
.sb-new:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
    color: var(--text-1);
}
.sb-new svg { width: 12px; height: 12px; fill: currentColor; }

.sb-expand {
    position: fixed;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    background: var(--surface-hi);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-2);
    cursor: pointer;
    display: none;
    align-items: center; justify-content: center;
    z-index: 20;
    box-shadow: var(--shadow-2);
}
.sb-expand:hover { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-brand); }
.sb-expand:active { transform: translateY(-50%) scale(0.92); }
.sb-expand svg { width: 16px; height: 16px; fill: currentColor; }
.sidebar.collapsed ~ .sb-expand,
.layout.sidebar-collapsed .sb-expand { display: flex; }

.deck-select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    color: var(--text-1);
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.deck-select:focus { border-color: var(--border-hi); }

.deck-modal { max-width: 420px; }

/* ===== 卡片瀑布流（CSS columns，最简单可靠） ===== */
.grid {
    column-width: 280px;
    column-gap: 14px;
}
.card-item {
    background: rgba(20, 26, 36, 0.92);
    border: 1px solid var(--border-1);
    border-radius: var(--r-md);
    padding: 16px 18px 14px 22px;
    position: relative;
    cursor: default;
    overflow: hidden;
    width: 100%;
    display: inline-block;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 14px;
    transition: border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}
.card-item:hover {
    border-color: var(--border-hi);
    box-shadow: var(--shadow-2);
}
:root[data-theme="light"] .card-item {
    background: rgba(255, 255, 255, 0.95);
}
.card-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--card-color, var(--card-blue));
    transition: width var(--t-base) var(--ease);
}
.card-item:hover::before { width: 6px; }

/* Background mode: auto */
.card-item[data-bg-mode="auto"] {
    background: color-mix(in srgb, var(--card-color, var(--card-blue)) 10%, rgba(20, 26, 36, 0.92));
}
:root[data-theme="light"] .card-item[data-bg-mode="auto"] {
    background: color-mix(in srgb, var(--card-color, var(--card-blue)) 8%, rgba(255, 255, 255, 0.95));
}
/* Background mode: custom */
.card-item[data-bg-mode="custom"] {
    background: color-mix(in srgb, var(--card-bg-color, var(--card-color)) 10%, rgba(20, 26, 36, 0.92));
}
:root[data-theme="light"] .card-item[data-bg-mode="custom"] {
    background: color-mix(in srgb, var(--card-bg-color, var(--card-color)) 8%, rgba(255, 255, 255, 0.95));
}

.card-item .front {
    font-size: 14px; line-height: 1.5;
    color: var(--text-1);
    word-break: break-word;
    white-space: pre-wrap;
}
.card-item .image-thumb {
    display: block;
    margin-top: 10px;
    width: 100%;
    max-height: 400px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--surface-2);
}
.card-item .meta {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-3);
    display: flex; align-items: center; gap: 6px;
    border-top: 1px solid var(--border-1);
    padding-top: 8px;
}
.card-item .tags {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-top: 8px;
}
.card-item .tags .tag {
    font-size: 10.5px;
    padding: 2px 8px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.card-item .tags .tag:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
    color: var(--text-1);
}
.card-item .tags .tag.active {
    background: var(--brand-glow);
    border-color: var(--brand);
    color: var(--text-1);
}

/* ===== Tag 过滤条 ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 14px;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    background: var(--brand-glow);
    border: 1px solid var(--brand);
    border-radius: var(--r-full);
    color: var(--text-1);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast) var(--ease);
}
.filter-chip:hover { background: rgba(124, 158, 255, 0.45); }
.filter-chip .filter-prefix { color: var(--brand); font-weight: 600; }
.filter-chip .filter-clear {
    width: 18px; height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: var(--text-1);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.filter-chip .filter-clear:hover { background: rgba(255,255,255,0.2); }

.card-item .actions {
    position: absolute;
    top: 8px; right: 8px;
    display: flex; gap: 4px;
    opacity: 0;
    transition: opacity var(--t-base) var(--ease);
}
.card-item:hover .actions { opacity: 1; }
.card-item .actions button {
    width: 28px; height: 28px;
    background: var(--surface-3);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--t-fast) var(--ease);
    color: var(--text-2);
    padding: 0;
}
.card-item .actions button:hover { background: var(--surface-hi); color: var(--text-1); }
.card-item .actions button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.card-item .actions button svg { width: 14px; height: 14px; fill: currentColor; }

/* ===== FAB 新建按钮 ===== */
.fab {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 40;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-3) 100%);
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(124,158,255,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
    transition: all var(--t-base) var(--ease);
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 32px rgba(124,158,255,0.5); }
.fab:active { transform: translateY(0) scale(0.95); }

/* ===== 空状态 ===== */
.empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-2);
}
.empty .icon {
    font-size: 56px;
    margin-bottom: 20px;
    display: inline-block;
    filter: drop-shadow(0 8px 24px rgba(124, 158, 255, 0.4));
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.empty h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--text-1);
    font-weight: 600;
}
.empty p { margin: 0; font-size: 14px; color: var(--text-3); }

/* ===== 模态弹窗 ===== */
.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn var(--t-base) var(--ease);
}
.modal-bg.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 24px 26px;
    max-width: 540px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-3);
    animation: slideUp var(--t-base) var(--ease-out);
}
@keyframes slideUp {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal h2 {
    margin: 0 0 20px;
    font-size: 18px; font-weight: 600;
    color: var(--text-1);
}
.modal .field { margin-bottom: 16px; }

/* ===== 查看弹窗 ===== */
.view-modal {
    max-width: 580px;
}
.view-modal .vm-body {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 4px;
}
.view-modal .vm-front {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-1);
    white-space: pre-wrap;
    word-break: break-word;
}
.view-modal .vm-label {
    font-size: 11px;
    color: var(--text-3);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 600;
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--border-1);
}
.view-modal .vm-image {
    width: 100%;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease);
}
.view-modal .vm-image:hover {
    transform: scale(1.01);
}
.view-modal .vm-back {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-1);
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 4px;
}
.view-modal .vm-tags {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-1);
}
.view-modal .vm-tags .tag {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.view-modal .vm-tags .tag:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
    color: var(--text-1);
}
.view-modal .vm-tags .tag.active {
    background: var(--brand-glow);
    border-color: var(--brand);
    color: var(--text-1);
}

/* ===== 图片灯箱 ===== */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 20px;
}
.lightbox.show { display: flex; }
.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: var(--r-sm);
    cursor: default;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    animation: lightboxIn 0.25s var(--ease-out);
}
@keyframes lightboxIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
.lightbox-close {
    position: fixed; top: 16px; right: 16px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast) var(--ease);
    z-index: 301;
    line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ===== Tag 输入 ===== */
.tag-input {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    cursor: text;
    transition: border-color var(--t-base) var(--ease);
    position: relative;
}
.tag-input:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}
.tag-input .chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px;
    padding: 3px 8px 3px 10px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    border: 1px solid var(--border-1);
    color: var(--text-1);
}
.tag-input .chip .rm {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
    padding: 0;
    line-height: 1;
    transition: color var(--t-fast) var(--ease);
}
.tag-input .chip .rm:hover { color: var(--danger); }
.tag-input input {
    flex: 1;
    min-width: 100px;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-1);
    outline: none;
    padding: 2px 0;
}
.tag-suggest {
    position: fixed;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    max-height: 180px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: var(--shadow-2);
    display: none;
}
.tag-suggest-item {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-1);
    transition: background var(--t-fast) var(--ease);
}
.tag-suggest-item:hover,
.tag-suggest-item.active {
    background: var(--surface-3);
    color: var(--brand);
}
.modal label {
    display: block;
    font-size: 12px; font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.modal textarea, .modal input[type="text"] {
    width: 100%;
    background: var(--surface-2);
    color: var(--text-1);
    border: 1px solid var(--border-1);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
    transition: all var(--t-base) var(--ease);
}
.modal textarea { min-height: 80px; }
.modal textarea:focus, .modal input[type="text"]:focus {
    border-color: var(--brand);
    background: var(--surface-3);
    box-shadow: 0 0 0 3px var(--brand-glow);
}
.modal textarea::placeholder, .modal input::placeholder { color: var(--text-4); }
.modal .row { display: flex; gap: 8px; align-items: center; }

/* ===== 颜色选择器 ===== */
.color-picker {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.color-picker label {
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 50%;
    position: relative;
    margin: 0;
    transition: transform var(--t-fast) var(--ease);
}
.color-picker label:hover { transform: scale(1.15); }
.color-picker input[type="radio"] {
    position: absolute; opacity: 0; pointer-events: none;
}
.color-picker span {
    display: block;
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all var(--t-fast) var(--ease);
}
.color-picker input[type="radio"]:checked + span {
    border-color: var(--text-1);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--bg-2);
}

/* ===== 背景模式选择器 ===== */
.bg-picker {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.bg-picker label {
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 50%;
    position: relative;
    margin: 0;
    transition: transform var(--t-fast) var(--ease);
}
.bg-picker label:hover { transform: scale(1.15); }
.bg-picker input[type="radio"] {
    position: absolute; opacity: 0; pointer-events: none;
}
.bg-picker span {
    display: block;
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all var(--t-fast) var(--ease);
}
.bg-picker input[type="radio"]:checked + span {
    border-color: var(--text-1);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--bg-2);
}
.bg-picker .bg-icon {
    display: flex;
    align-items: center; justify-content: center;
    font-size: 15px;
    background: var(--surface-2);
    border-color: var(--border-1);
    color: var(--text-3);
}
.bg-picker label:hover .bg-icon {
    background: var(--surface-3);
    color: var(--text-1);
}

/* ===== 图片上传区 ===== */
.image-drop {
    position: relative;
    border: 2px dashed var(--border-2);
    border-radius: var(--r-md);
    background: var(--surface-2);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--t-base) var(--ease);
    color: var(--text-3);
    font-size: 13px;
}
.image-drop:hover, .image-drop.dragover {
    border-color: var(--brand);
    background: var(--surface-3);
    color: var(--text-1);
}
.image-drop input[type="file"] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer;
}
.image-drop .icon { font-size: 32px; margin-bottom: 6px; }
.image-drop .remove {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    line-height: 1;
    z-index: 2;
}
.image-drop .remove:hover { background: var(--danger); }
.image-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--r-sm);
    object-fit: contain;
}

/* ===== 模态底部操作 ===== */
.modal-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-1);
}
.modal-actions .left { margin-right: auto; }

/* ===== Toast ===== */
.toast {
    position: fixed; bottom: 30px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-2);
    color: var(--text-1);
    padding: 12px 22px;
    border-radius: var(--r-full);
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-3);
    font-size: 13.5px; font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease-out);
    pointer-events: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .app-header { padding: 12px 14px; }
    .app-header h1 { font-size: 15px; }
    .sidebar { width: 200px; }
    .wrap { padding: 20px 14px 100px; }
    .grid { column-gap: 10px; }
    .card-item { padding: 14px 14px 12px 18px; }
    .fab { width: 50px; height: 50px; bottom: 18px; right: 18px; font-size: 24px; }
    .modal { padding: 20px 18px; }
    .modal h2 { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
