/* ===========================================
   AB导航 - 前台样式
   =========================================== */
/* hidden 属性优先于任何 display 声明 */
[hidden] { display: none !important; }


:root {
    --bg: #f4f7fb;
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafd;
    --text: #0f172a;
    --text-dim: #475569;
    --muted: #8a97ab;
    --card: #ffffff;
    --card-hover: #f7faff;
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.16);
    --accent: #2563eb;
    --accent-2: #0ea5e9;
    --accent-rgb: 37, 99, 235;
    --radius: 16px;
    --shadow: 0 16px 40px -24px rgba(15, 23, 42, 0.35);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -18px rgba(15, 23, 42, 0.25);
}

body.theme-aurora { --accent: #2563eb; --accent-2: #0ea5e9; --accent-rgb: 37, 99, 235; }
body.theme-nebula { --accent: #7c3aed; --accent-2: #db2777; --accent-rgb: 124, 58, 237; }
body.theme-matrix { --accent: #059669; --accent-2: #0d9488; --accent-rgb: 5, 150, 105; }
body.theme-sunset { --accent: #ea580c; --accent-2: #e11d48; --accent-rgb: 234, 88, 12; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
svg { width: 100%; height: 100%; }

/* ---------- 背景层 ---------- */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    opacity: 0.16;
    filter: blur(20px);
}

.orb-1 {
    width: 620px; height: 620px;
    top: -240px; left: -140px;
    background: radial-gradient(circle, var(--accent), transparent 68%);
}

.orb-2 {
    width: 520px; height: 520px;
    top: -160px; right: -120px;
    background: radial-gradient(circle, var(--accent-2), transparent 68%);
    opacity: 0.14;
}

.orb-3 {
    width: 700px; height: 700px;
    bottom: -420px; left: 42%;
    background: radial-gradient(circle, #7c3aed, transparent 70%);
    opacity: 0.09;
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 20%, transparent 76%);
    mask-image: radial-gradient(circle at 50% 30%, #000 20%, transparent 76%);
}


/* ---------- 顶部栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 28px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }

.brand-mark {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 24px -8px rgba(var(--accent-rgb), 0.85);
    padding: 8px;
    color: #fff;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.06); }

.brand-text { font-size: 17px; font-weight: 700; letter-spacing: 0.4px; }

.user-area { display: flex; align-items: center; gap: 10px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; flex-wrap: nowrap; }

.theme-switch {
    display: flex;
    gap: 7px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.025);
}

.theme-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: 0.25s;
    position: relative;
}

.theme-dot[data-theme="aurora"] { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.theme-dot[data-theme="nebula"] { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.theme-dot[data-theme="matrix"] { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.theme-dot[data-theme="sunset"] { background: linear-gradient(135deg, #f59e0b, #f43f5e); }

.theme-dot:hover { transform: scale(1.22); }
.theme-dot.active { border-color: rgba(15, 23, 42, 0.3); transform: scale(1.15); }

.btn-login {
    height: 38px;
    padding: 0 18px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    font-size: 13.5px;
    font-weight: 500;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 10px 26px -12px rgba(var(--accent-rgb), 0.95);
    transition: 0.25s;
}

.btn-login:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -12px rgba(var(--accent-rgb), 1); }

.btn-edit {
    height: 38px;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0 15px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    border: 1px solid var(--border-strong);
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-dim);
    transition: 0.25s;
}

.btn-edit svg { width: 15px; height: 15px; }
.btn-edit:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.7); }
.btn-edit.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 10px 26px -12px rgba(var(--accent-rgb), 0.95);
}

/* 用户菜单 */
.user-box { position: relative; }

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px 0 5px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.04);
    transition: 0.25s;
}

.user-trigger:hover { border-color: var(--border-strong); background: rgba(15, 23, 42, 0.055); }

.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.user-name { font-size: 13px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-trigger > svg { width: 13px; height: 13px; color: var(--muted); }

.user-menu {
    position: absolute;
    right: 0;
    top: 48px;
    min-width: 152px;
    padding: 7px;
    border-radius: 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: 0.22s;
}

.user-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

.user-menu a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dim);
    transition: 0.18s;
}

.user-menu a:hover { background: rgba(var(--accent-rgb), 0.09); color: var(--accent); }

/* ---------- 页面容器 ---------- */
.page {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 28px 60px;
}

/* ---------- Hero ---------- */
.hero { padding: 60px 0 44px; text-align: center; }

.hero-date {
    display: inline-block;
    font-size: 12.5px;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.04);
    margin-bottom: 20px;
}

.hero-title {
    font-size: 46px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(120deg, var(--text) 8%, var(--accent) 55%, var(--accent-2) 92%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 6px 26px rgba(var(--accent-rgb), 0.35));
}

.hero-sub {
    margin-top: 12px;
    font-size: 14.5px;
    color: var(--text-dim);
    letter-spacing: 0.4px;
}

.search-box {
    position: relative;
    max-width: 660px;
    margin: 30px auto 0;
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 6px 0 6px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    transition: 0.3s;
    box-shadow: 0 18px 44px -26px rgba(15, 23, 42, 0.22);
}

.search-box:focus-within {
    border-color: rgba(var(--accent-rgb), 0.75);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14), 0 24px 60px -30px rgba(var(--accent-rgb), 0.6);
}

.engine-select { position: relative; height: 100%; display: flex; align-items: center; }

.engine-current {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 42px;
    padding: 0 12px;
    border-radius: 11px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
    white-space: nowrap;
}

.engine-current:hover { background: rgba(15, 23, 42, 0.055); color: var(--text); }
.engine-current > svg:first-child { width: 15px; height: 15px; color: var(--accent); }
.engine-current em { font-style: normal; }
.engine-current .caret { width: 12px; height: 12px; opacity: 0.6; }

.engine-list {
    position: absolute;
    top: 54px;
    left: 0;
    min-width: 132px;
    padding: 7px;
    border-radius: 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: 0.22s;
    z-index: 20;
}

.engine-list.show { opacity: 1; visibility: visible; transform: translateY(0); }

.engine-list a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dim);
    transition: 0.16s;
}

.engine-list a:hover { background: rgba(var(--accent-rgb), 0.09); color: var(--accent); }

#searchInput {
    flex: 1;
    height: 100%;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14.5px;
    padding: 0 8px;
}

#searchInput::placeholder { color: var(--muted); }

.search-btn {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    padding: 12px;
    transition: 0.25s;
    box-shadow: 0 10px 26px -12px rgba(var(--accent-rgb), 0.9);
}

.search-btn:hover { transform: scale(1.05); }

.quick-tags {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.quick-tags a {
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.025);
    color: var(--text-dim);
    transition: 0.2s;
}

.quick-tags a:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.07);
    transform: translateY(-1px);
}

/* ---------- 布局 ---------- */
.layout {
    display: grid;
    grid-template-columns: 208px 1fr;
    gap: 34px;
    align-items: start;
}

/* ---------- 侧边栏 ---------- */
.sidebar { position: sticky; top: 92px; min-width: 0; }

.sidebar-title {
    font-size: 11.5px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
    padding-left: 12px;
}

.cat-nav { display: flex; flex-direction: column; gap: 3px; }

.cat-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 11px;
    font-size: 13.5px;
    color: var(--text-dim);
    transition: 0.2s;
    position: relative;
    border: 1px solid transparent;
}

.cat-nav-item:hover { background: rgba(15, 23, 42, 0.04); color: var(--text); }

.cat-nav-item.active {
    background: rgba(var(--accent-rgb), 0.08);
    border-color: rgba(var(--accent-rgb), 0.24);
    color: var(--accent);
}

.cat-nav-item.active::before {
    content: "";
    position: absolute;
    left: -1px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 16px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.cat-nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.cat-nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-nav-count { font-size: 11px; color: var(--muted); }

.cat-nav-add {
    margin-top: 8px;
    padding: 9px 12px;
    border-radius: 11px;
    border: 1px dashed var(--border-strong);
    color: var(--muted);
    font-size: 13px;
    text-align: left;
    transition: 0.2s;
    display: none;
}

body.editing .cat-nav-add { display: block; }
.cat-nav-add:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }

.sidebar-foot { margin-top: 26px; padding: 14px 12px; border-top: 1px solid var(--border); }

.mini-stat { display: flex; gap: 22px; }
.mini-stat div { display: flex; flex-direction: column; }
.mini-stat b { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.3; }
.mini-stat span { font-size: 11.5px; color: var(--muted); }

.sidebar-tip { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 分类区块 ---------- */
.content { min-width: 0; }

.cat-section { margin-bottom: 38px; scroll-margin-top: 96px; }

.cat-head { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }

.cat-head-icon {
    width: 30px; height: 30px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 6px;
    flex-shrink: 0;
}

.cat-head h2 { font-size: 16.5px; font-weight: 650; letter-spacing: 0.3px; }

.cat-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-strong), transparent);
    margin-left: 4px;
}

.cat-count {
    font-size: 11.5px;
    color: var(--muted);
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border);
}

.cat-actions { display: none; gap: 5px; }
body.editing .cat-actions { display: flex; }

/* ---------- 链接卡片 ---------- */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 13px;
}

.link-card {
    position: relative;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), border-color 0.3s, background 0.3s, box-shadow 0.3s;
    overflow: hidden;
}

.link-card:hover {
    transform: translateY(-5px);
    background: var(--card-hover);
    border-color: rgba(var(--accent-rgb), 0.45);
    box-shadow: 0 22px 44px -22px rgba(var(--accent-rgb), 0.65), 0 0 0 1px rgba(var(--accent-rgb), 0.12) inset;
}

.link-glow {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.35s;
    background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--accent-rgb), 0.22), transparent 62%);
    pointer-events: none;
}

.link-card:hover .link-glow { opacity: 1; }

.link-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 16px;
    position: relative;
    z-index: 1;
}

.link-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    flex-shrink: 0;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--g1), var(--g2));
    box-shadow: 0 10px 22px -12px rgba(15, 23, 42, 0.2);
    overflow: hidden;
}

.link-initial {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    text-shadow: none;
    line-height: 1;
}

.link-icon img {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 24px; height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

.link-info { min-width: 0; flex: 1; }

.link-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s;
}

.link-card:hover .link-title { color: var(--accent); }

.link-desc {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* 卡片操作按钮 */
.link-actions {
    position: absolute;
    top: 7px; right: 7px;
    display: none;
    gap: 4px;
    z-index: 3;
}

body.editing .link-actions { display: flex; }

.mini-btn {
    width: 24px; height: 24px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    padding: 5px;
    transition: 0.18s;
}

.mini-btn:hover { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.55); background: rgba(var(--accent-rgb), 0.1); }
.mini-btn.danger:hover { border-color: rgba(248, 113, 113, 0.8); background: rgba(248, 113, 113, 0.25); color: #fecaca; }

/* 添加卡片 */
.link-add-card {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 73px;
    border-radius: var(--radius);
    border: 1px dashed var(--border-strong);
    color: var(--muted);
    font-size: 13px;
    transition: 0.25s;
    background: rgba(15, 23, 42, 0.02);
}

body.editing .link-add-card { display: flex; }
.link-add-card:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.link-add-card .plus { font-size: 17px; line-height: 1; }

/* 拖拽 */
.link-card.dragging { opacity: 0.35; transform: scale(0.97); }
.link-card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.4); }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 70px 20px;
    border-radius: 22px;
    border: 1px dashed var(--border-strong);
    background: rgba(15, 23, 42, 0.02);
}

.empty-icon {
    width: 66px; height: 66px;
    margin: 0 auto 18px;
    padding: 16px;
    border-radius: 20px;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.12);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
}

.empty-state h3 { font-size: 17px; margin-bottom: 7px; }
.empty-state p { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn-primary {
    height: 42px;
    padding: 0 20px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    font-weight: 500;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    transition: 0.25s;
    box-shadow: 0 12px 28px -14px rgba(var(--accent-rgb), 0.95);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -14px rgba(var(--accent-rgb), 1); }

.btn-ghost {
    height: 42px;
    padding: 0 20px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    border: 1px solid var(--border-strong);
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-dim);
    transition: 0.25s;
}

.btn-ghost:hover { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.5); }

/* ---------- 页脚 ---------- */
.footer { margin-top: 40px; padding: 26px 0 6px; border-top: 1px solid var(--border); }

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.footer-inner a { color: var(--text-dim); transition: 0.2s; }
.footer-inner a:hover { color: var(--accent); }
.footer-inner .dot { opacity: 0.4; }

/* ---------- 弹窗 ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    animation: fadeIn 0.22s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    position: relative;
    width: 100%;
    max-width: 440px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(17, 24, 42, 0.98), rgba(10, 15, 28, 0.99));
    border: 1px solid var(--border-strong);
    box-shadow: 0 32px 70px -30px rgba(15, 23, 42, 0.28);
    padding: 22px;
    animation: modalIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-size: 16px; font-weight: 600; }

.modal-close {
    width: 28px; height: 28px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}

.modal-close:hover { background: rgba(15, 23, 42, 0.06); color: var(--text); }

.form-row { margin-bottom: 14px; }

.form-row label {
    display: block;
    font-size: 12.5px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-row label i { color: #f87171; font-style: normal; }

.form-row input[type="text"],
.form-row select {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text);
    font-size: 13.5px;
    outline: none;
    transition: 0.22s;
}

.form-row input[type="text"]:focus,
.form-row select:focus {
    border-color: rgba(var(--accent-rgb), 0.8);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.form-row select option { background: #ffffff; color: var(--text); }

.icon-picker {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 6px;
}

.icon-option {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.025);
    color: var(--text-dim);
    padding: 7px;
    transition: 0.18s;
    display: flex; align-items: center; justify-content: center;
}

.icon-option:hover { color: var(--text); border-color: var(--border-strong); background: rgba(15, 23, 42, 0.04); }
.icon-option.selected { color: var(--accent); border-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.color-picker { display: flex; gap: 9px; flex-wrap: wrap; }

.color-option {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: 0.2s;
    position: relative;
}

.color-option:hover { transform: scale(1.12); }
.color-option.selected { border-color: var(--accent); transform: scale(1.12); }

.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translate(-50%, 20px);
    padding: 11px 20px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 13.5px;
    box-shadow: 0 22px 46px -22px rgba(15, 23, 42, 0.24);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    z-index: 500;
    max-width: 90vw;
}

.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.err { border-color: rgba(248, 113, 113, 0.55); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
    .layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }
    .layout > *, .sidebar, .cat-nav, .cat-section, .content { min-width: 0; max-width: 100%; }
    .sidebar {
        position: sticky;
        top: 68px;
        z-index: 40;
        padding: 10px 0;
        margin: 0 -28px;
        padding-left: 28px;
        padding-right: 28px;
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid var(--border);
    }
    .sidebar-title, .sidebar-foot { display: none; }
    .cat-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .cat-nav::-webkit-scrollbar { display: none; }
    .cat-nav-item {
        flex-shrink: 0;
        padding: 7px 14px;
        border: 1px solid var(--border);
        border-radius: 999px;
        font-size: 13px;
    }
    .cat-nav-item.active::before { display: none; }
    .cat-nav-count { display: none; }
    .cat-nav-add { display: none !important; }
}

@media (max-width: 760px) {
    .topbar-inner { padding: 0 16px; height: 62px; }
    .page { padding: 0 16px 50px; }
    .brand-text { font-size: 15px; }
    .theme-switch { display: none; }
    .user-name { display: none; }
    .btn-edit span { display: none; }
    .btn-edit { padding: 0 12px; }
    .hero { padding: 38px 0 30px; }
    .hero-title { font-size: 30px; }
    .hero-sub { font-size: 13px; }
    .search-box { height: 50px; margin-top: 22px; }
    .engine-current em { display: none; }
    .engine-current { padding: 0 9px; }
    .search-btn { width: 40px; height: 40px; padding: 11px; }
    .quick-tags { font-size: 12px; gap: 6px; }
    .sidebar { margin: 0 -16px; padding-left: 16px; padding-right: 16px; top: 62px; }
    .link-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .link-main { padding: 12px; gap: 10px; }
    .link-icon { width: 38px; height: 38px; border-radius: 10px; }
    .link-initial { font-size: 15px; }
    .link-title { font-size: 13.5px; }
    .link-desc { font-size: 11px; }
    .cat-head h2 { font-size: 15px; }
    .icon-picker { grid-template-columns: repeat(8, 1fr); }
    .footer-inner { font-size: 11.5px; }
}

@media (max-width: 400px) {
    .link-grid { grid-template-columns: 1fr; }
    .hero-title { font-size: 26px; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.24); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.42); }

::selection { background: rgba(var(--accent-rgb), 0.35); color: #fff; }

/* 管理员导航作用域提示 */
.scope-tip{display:inline-flex;align-items:center;gap:7px;margin-bottom:16px;padding:5px 13px;border-radius:999px;font-size:12.5px;color:var(--muted);background:rgba(15, 23, 42, 0.04);border:1px solid var(--border)}
.scope-tip .scope-dot{width:6px;height:6px;border-radius:50%;background:var(--accent);box-shadow:0 0 8px var(--accent)}
.scope-tip a{color:var(--accent);text-decoration:none;border-bottom:1px dashed rgba(59,130,246,.5)}
.scope-tip a:hover{color:var(--accent-2)}

/* ---------- 站内搜索 ---------- */
.search-box.is-site {
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.08), 0 18px 44px -26px rgba(15, 23, 42, 0.22);
}

.engine-divider {
    height: 1px;
    margin: 6px 8px;
    background: rgba(148, 163, 184, 0.18);
}

.engine-list a.active {
    background: rgba(var(--accent-rgb), 0.09);
    color: var(--accent);
}

.search-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--text-dim);
}

.search-tip[hidden] { display: none; }
.search-tip b { color: var(--accent); font-weight: 700; padding: 0 2px; }

.search-tip button {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.search-tip button:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.07);
}

.search-empty {
    text-align: center;
    padding: 64px 24px;
    margin-bottom: 24px;
    border: 1px dashed var(--border);
    border-radius: 22px;
    background: rgba(15, 23, 42, 0.4);
}

.search-empty[hidden] { display: none; }
.search-empty .empty-icon { margin-bottom: 16px; }
.search-empty .empty-icon svg { width: 100%; height: 100%; }
.search-empty h3 { font-size: 17px; margin-bottom: 8px; }
.search-empty p { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }

.link-card.search-hidden,
.cat-section.search-hidden,
.cat-nav-item.search-hidden { display: none !important; }

.link-card.search-hit .link-glow { opacity: 1; }
.link-card.search-hit { border-color: rgba(var(--accent-rgb), 0.42); }

@media (max-width: 640px) {
    .search-box.is-site .engine-current em { display: inline; font-size: 12px; }
    .search-box.is-site .engine-current .caret { display: none; }
    .search-box.is-site .engine-current { padding: 0 10px; }
}


/* ============================================================
   前后端分离 & 性能优化新增样式
   ============================================================ */

/* 站点图标：有本地上传图片时显示图片，加载失败自动回退到首字块 */
.link-icon .link-icon-img {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.055);
    z-index: 2;
}

/* ---------- 站点图标上传 ---------- */
.icon-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.02);
}

.icon-upload-preview {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    box-shadow: 0 8px 18px -12px rgba(15, 23, 42, 0.2);
}

.icon-upload-preview img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
}

.icon-upload-initial {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    text-shadow: none;
}

.icon-upload-main { flex: 1; min-width: 0; }

.icon-upload-ops {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12.5px;
    border-radius: 8px;
    line-height: 1.4;
}

.icon-upload-tip {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
}

/* ---------- 骨架屏 ---------- */
.sk {
    display: block;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.07), rgba(15, 23, 42, 0.04));
    background-size: 200% 100%;
    animation: skShine 1.4s linear infinite;
    border-radius: 8px;
}
@keyframes skShine {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}
.sk-card {
    height: 76px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.025);
    border: 1px solid var(--border);
}
.cat-nav-skeleton {
    height: 38px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.04);
    animation: skShine 1.4s linear infinite;
    background-image: linear-gradient(90deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.07), rgba(15, 23, 42, 0.04));
    background-size: 200% 100%;
}
.skeleton-section .sk-title {
    width: 90px;
    height: 18px;
    display: inline-block;
}
.skeleton-section .cat-head-icon.sk {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 72px 20px 80px;
    color: var(--muted);
}
.empty-state .empty-icon {
    width: 64px; height: 64px;
    margin: 0 auto 18px;
    padding: 16px;
    border-radius: 20px;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}
.empty-state h3 {
    font-size: 17px;
    color: var(--text);
    margin-bottom: 8px;
}
.empty-state p { font-size: 13.5px; margin-bottom: 20px; }
.empty-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.empty-state .btn-primary,
.empty-state .btn-ghost {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 18px;
    border-radius: 10px;
    font-size: 13.5px;
}

/* ---------- 拖拽反馈 ---------- */
.link-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.link-card.drag-over {
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.55);
}
.cat-section.dragging { opacity: 0.5; }
.cat-section[draggable="true"] .cat-head { cursor: grab; }

/* ---------- 编辑模式细节 ---------- */
body.editing .link-card { cursor: grab; }
body.editing .cat-actions,
body.editing .link-actions { opacity: 1; }

/* ---------- 站内搜索命中态 ---------- */
.link-card.search-hit { border-color: rgba(var(--accent-rgb), 0.45); }

/* ---------- Toast 类型 ---------- */
.toast.ok { border-color: rgba(34, 197, 94, 0.5); }
.toast.err { border-color: rgba(239, 68, 68, 0.55); }

/* ---------- 移动端：关闭顶栏毛玻璃，减少合成开销 ---------- */
@media (max-width: 768px) {
    .topbar {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255, 255, 255, 0.97);
    }
    .orb-1, .orb-2, .orb-3 { display: none; }
}

/* 尊重系统「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ---------- 拖动排序提示条（编辑模式） ---------- */
.drag-tip {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1320px;
    margin: 18px auto 0;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-rgb), 0.05));
    box-shadow: 0 16px 36px -26px rgba(15, 23, 42, 0.22);
    position: relative;
    z-index: 2;
}

.drag-tip-icon {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 6px;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 18px -10px rgba(var(--accent-rgb), 0.9);
}

.drag-tip-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.55;
}

.drag-tip-text b { color: var(--text); font-weight: 600; margin-right: 6px; }
.drag-tip-mb { display: none; }

.drag-tip-close {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 12.5px;
    color: #fff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.055);
    transition: background 0.18s, border-color 0.18s;
}

.drag-tip-close:hover { background: rgba(15, 23, 42, 0.09); border-color: rgba(15, 23, 42, 0.2); }

/* 编辑模式下：分类标题左侧出现拖动把手，卡片显示可抓取光标 */
body.editing .cat-head { position: relative; cursor: grab; }
body.editing .cat-head:active { cursor: grabbing; }
body.editing .cat-head::before {
    content: "⠿";
    position: absolute;
    left: -18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    line-height: 1;
    color: var(--muted);
    letter-spacing: -1px;
    opacity: 0.75;
}
body.editing .cat-head:hover::before { color: var(--accent); opacity: 1; }
body.editing .link-card { cursor: grab; }
body.editing .link-card:active { cursor: grabbing; }
body.editing .link-card .link-main { cursor: inherit; }

@media (max-width: 768px) {
    .drag-tip { margin: 12px 12px 0; padding: 11px 13px; gap: 10px; flex-wrap: wrap; }
    .drag-tip-pc { display: none; }
    .drag-tip-mb { display: inline; }
    .drag-tip-text { font-size: 12.5px; }
    .drag-tip-close { width: 100%; text-align: center; }
    body.editing .cat-head::before { left: -2px; }
}


/* ---------- 顶部导航切换（导航 / 新闻） ---------- */
.top-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
}

.top-nav a {
    padding: 7px 14px;
    border-radius: 9px;
    font-size: 13.5px;
    color: var(--text-dim);
    transition: color 0.18s, background 0.18s;
}

.top-nav a:hover { color: var(--text); background: rgba(15, 23, 42, 0.04); }

.top-nav a.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.09);
    box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.22);
}

@media (max-width: 768px) {
    .top-nav { margin-right: 0; gap: 2px; display: none;}
    .top-nav a { padding: 6px 10px; font-size: 13px; }
}

/* ---------- 首页新闻卡片 ---------- */
.news-section {
    margin-top: 44px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.news-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}

.news-head-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-width: 0;
}

.news-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: var(--text);
    white-space: nowrap;
}

.news-title-dot {
    width: 4px;
    height: 17px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.news-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 3px;
    border-radius: 11px;
    background: rgba(15, 23, 42, 0.035);
}

.news-tab {
    padding: 6px 13px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-dim);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: 0.18s;
    white-space: nowrap;
}

.news-tab:hover { color: var(--accent); }

.news-tab.active {
    color: var(--accent);
    background: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.news-head-side {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.news-updated { font-size: 12.5px; color: var(--muted); }

.news-shuffle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 15px;
    border-radius: 10px;
    border: 1px solid rgba(var(--accent-rgb), 0.32);
    background: rgba(var(--accent-rgb), 0.05);
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.news-shuffle svg { width: 15px; height: 15px; transition: transform 0.42s ease; }
.news-shuffle:hover { background: rgba(var(--accent-rgb), 0.1); border-color: rgba(var(--accent-rgb), 0.5); }
.news-shuffle.spin svg { transform: rotate(180deg); }
.news-shuffle:active { transform: scale(0.97); }

.news-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    transition: opacity 0.16s ease;
}

.news-grid.switching { opacity: 0.25; }

.news-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 16px 17px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-width: 0;
    height: 100%;
}

.news-card:hover {
    transform: translateY(-3px);
    border-color: rgba(var(--accent-rgb), 0.28);
    box-shadow: 0 14px 34px -20px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(var(--accent-rgb), 0.06);
}

.news-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 20px;
}

.news-card-cat {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.news-card-hot {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11.5px;
    color: #ea580c;
    white-space: nowrap;
}

.news-card-hot svg { width: 12px; height: 12px; }

.news-card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.18s;
}

.news-card:hover .news-card-title { color: var(--accent); }

.news-card-desc {
    font-size: 13px;
    line-height: 1.62;
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.news-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 9px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--muted);
}

.news-card-src {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 62%;
}

.news-card-time { flex-shrink: 0; }

.news-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 46px 20px;
    border-radius: 14px;
    border: 1px dashed var(--border-strong);
    background: rgba(15, 23, 42, 0.015);
    text-align: center;
}

.news-empty b { font-size: 14.5px; color: var(--text); font-weight: 600; }
.news-empty span { font-size: 12.5px; color: var(--muted); }

@media (max-width: 1180px) {
    .news-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .news-section { margin-top: 32px; padding-top: 24px; }
    .news-head { gap: 12px; }
    .news-head-main { width: 100%; gap: 10px; }
    .news-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .news-tabs::-webkit-scrollbar { display: none; }
    .news-head-side { width: 100%; justify-content: space-between; }
    .news-grid { grid-template-columns: 1fr; gap: 12px; }
    .news-card { padding: 14px 15px 12px; }
    .news-card-title { font-size: 14.5px; }
}

/* 顶部导航跳转到新闻区时避开吸顶栏 */
.news-section { scroll-margin-top: 90px; }
html { scroll-behavior: smooth; }
