/* OneNav Lite · 前台样式（无外部依赖） */
:root {
    --bg: #f5f6fb;
    --bg-deco: #eceef8;
    --panel: #ffffff;
    --panel-soft: #fbfbfe;
    --text: #1a1e28;
    --muted: #6a7183;
    --line: #e5e8f1;
    --line-strong: #d8dce9;
    --accent: #5b63f5;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(91, 99, 245, .1);
    --ok: #16a34a;
    --bad: #ef4444;
    --shadow: 0 14px 34px -22px rgba(23, 28, 60, .35);
    --shadow-lg: 0 30px 70px -30px rgba(23, 28, 60, .45);
    --radius: 16px;
    --radius-sm: 12px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0c0e14;
    --bg-deco: #11141d;
    --panel: #151923;
    --panel-soft: #12161f;
    --text: #e7e9f1;
    --muted: #98a0b3;
    --line: #232936;
    --line-strong: #2c3342;
    --accent: #7c86ff;
    --accent-2: #a78bfa;
    --accent-soft: rgba(124, 134, 255, .14);
    --ok: #4ade80;
    --bad: #f87171;
    --shadow: 0 18px 40px -26px rgba(0, 0, 0, .8);
    --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .85);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --bg: #0c0e14;
        --bg-deco: #11141d;
        --panel: #151923;
        --panel-soft: #12161f;
        --text: #e7e9f1;
        --muted: #98a0b3;
        --line: #232936;
        --line-strong: #2c3342;
        --accent: #7c86ff;
        --accent-2: #a78bfa;
        --accent-soft: rgba(124, 134, 255, .14);
        --ok: #4ade80;
        --bad: #f87171;
        --shadow: 0 18px 40px -26px rgba(0, 0, 0, .8);
        --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .85);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 12% -8%, var(--accent-soft), transparent 65%),
        radial-gradient(700px 380px at 92% 0%, rgba(139, 92, 246, .08), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
img { max-width: 100%; }

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px clamp(16px, 3vw, 34px);
    background: color-mix(in srgb, var(--panel) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
    width: 38px; height: 38px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-weight: 700; font-size: 18px;
    box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.brand-logo { width: 38px; height: 38px; border-radius: 12px; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 16.5px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search {
    position: relative;
    flex: 1 1 320px;
    max-width: 520px;
    margin-left: auto;
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px;
    height: 42px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: border-color .18s, box-shadow .18s;
}
.search:focus-within {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--panel);
}
.search svg { width: 18px !important; height: 18px !important; color: var(--muted); flex: none; }
.search input {
    flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
    height: 100%;
}
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
    font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--muted); border: 1px solid var(--line-strong); border-bottom-width: 2px;
    border-radius: 5px; padding: 4px 6px; background: var(--panel);
}
.search-clear {
    display: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
    width: 24px; height: 24px; border-radius: 50%;
}
.search-clear:hover { background: var(--line); color: var(--text); }
.search.has-value .search-clear { display: grid; place-items: center; }
.search.has-value kbd { display: none; }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: 11px; border: 1px solid var(--line); background: var(--panel);
    color: var(--muted); cursor: pointer;
    transition: color .18s, border-color .18s, transform .18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }
#themeToggle .i-moon { display: none; }
html[data-theme="dark"] #themeToggle .i-sun { display: none; }
html[data-theme="dark"] #themeToggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] #themeToggle .i-sun { display: none; }
    html[data-theme="auto"] #themeToggle .i-moon { display: block; }
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0 16px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
    background: var(--panel); color: var(--text); font-weight: 600; font-size: 14px;
    cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; border-color: transparent;
    box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn-primary:hover { box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--accent) 75%, transparent); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

/* ---------- 布局 ---------- */
.shell {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    gap: clamp(18px, 2.6vw, 36px);
    max-width: 1360px;
    margin: 0 auto;
    padding: 26px clamp(16px, 3vw, 34px) 40px;
}

.sidebar {
    position: sticky;
    top: 82px;
    align-self: start;
    max-height: calc(100vh - 110px);
    display: flex; flex-direction: column;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.sidebar-scroll { overflow-y: auto; padding: 14px 10px 8px; }
.sidebar-label {
    margin: 4px 10px 10px; font-size: 11.5px; letter-spacing: .12em;
    text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.cat-link {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px; margin: 2px 0;
    border-radius: 10px; color: var(--muted); font-size: 14px;
    transition: background .15s, color .15s;
}
.cat-link:hover { background: var(--panel-soft); color: var(--text); }
.cat-link.active {
    background: var(--accent-soft);
    color: color-mix(in srgb, var(--accent) 72%, var(--text));
    font-weight: 600;
}
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-link.active .cat-count { color: inherit; opacity: .8; }
.sidebar-foot { padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }

.main { min-width: 0; }

/* ---------- 分类区域 ---------- */
.notice {
    margin: 0 0 22px; padding: 14px 18px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-soft), rgba(139, 92, 246, .06));
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
    color: var(--text); font-size: 14px;
}
.back-home { margin: 0 0 18px; }
.back-home a { color: var(--muted); font-size: 13.5px; }
.back-home a:hover { color: var(--accent); }

.cat-section { margin: 0 0 34px; }
.cat-section.sub {
    margin: 22px 0 0; padding-left: 14px;
    border-left: 3px solid var(--line);
}
.cat-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-title { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.cat-section.sub .cat-title { font-size: 16.5px; }
.cat-num {
    font-size: 11.5px; color: var(--muted); background: var(--panel);
    border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px;
    font-variant-numeric: tabular-nums;
}
.cat-desc { color: var(--muted); font-size: 13px; flex: 1; min-width: 120px; }
.cat-open {
    color: var(--muted); font-size: 13px; border: 1px solid var(--line);
    width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
}
.cat-open:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.empty-cat { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }

/* ---------- 站点卡片 ---------- */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
    gap: 12px;
}
.site-card {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 13px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
    min-height: 76px;
}
.site-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
    box-shadow: 0 20px 40px -26px rgba(30, 36, 80, .45);
}
.site-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.site-card.dragging { opacity: .45; }
.site-card.drop-target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.site-icon {
    position: relative;
    width: 44px; height: 44px; flex: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-soft), rgba(139, 92, 246, .12));
    display: grid; place-items: center;
    overflow: hidden;
    color: color-mix(in srgb, var(--accent) 60%, var(--text));
}
.site-icon .letter { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.site-icon .emoji { font-size: 22px; line-height: 1; }
.site-icon img {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; padding: 6px; background: var(--panel);
}
.site-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.site-name {
    font-size: 14.5px; font-weight: 650; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center; gap: 5px;
}
.site-name .pin { color: #f59e0b; font-size: 11px; }
.site-meta {
    color: var(--muted); font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-side { display: flex; align-items: center; gap: 6px; flex: none; }
.tag-lock { color: var(--muted); display: grid; place-items: center; }
.tag-lock svg { width: 14px; height: 14px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.clicks { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 搜索无结果 ---------- */
.search-hint {
    margin: -6px 0 20px; padding: 12px 16px; border-radius: 12px;
    background: var(--panel); border: 1px dashed var(--line-strong);
    color: var(--muted); font-size: 13px;
}
.search-hint kbd {
    font: 11px/1 ui-monospace, monospace; border: 1px solid var(--line-strong);
    border-radius: 5px; padding: 2px 5px; color: var(--text);
}
.no-results {
    padding: 70px 20px; text-align: center; color: var(--muted);
    background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.no-results p { margin: 0 0 6px; font-size: 17px; color: var(--text); font-weight: 600; }
.no-results span { font-size: 13.5px; }

/* ---------- 页脚 ---------- */
.site-footer {
    padding: 22px 20px 34px; text-align: center;
    color: var(--muted); font-size: 12.5px;
}
.site-footer .sep { margin: 0 8px; opacity: .6; }
.site-footer a:hover { color: var(--accent); }

/* ---------- 后台浮动按钮 ---------- */
.admin-fab { position: fixed; right: 24px; bottom: 26px; z-index: 30; }
.fab-btn {
    width: 50px; height: 50px; border-radius: 50%; border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
    box-shadow: 0 16px 34px -14px color-mix(in srgb, var(--accent) 75%, transparent);
    transition: transform .16s;
}
.fab-btn:hover { transform: translateY(-2px) scale(1.03); }

/* ---------- 右键菜单 ---------- */
.ctx-menu {
    position: fixed; z-index: 80; min-width: 178px; padding: 6px;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow-lg);
    font-size: 13.5px;
}
.ctx-menu button {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.ctx-menu button:hover { background: var(--panel-soft); }
.ctx-menu button.danger { color: var(--bad); }
.ctx-menu .ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.ctx-menu .ctx-key { margin-left: auto; color: var(--muted); font-size: 11px; }

/* ---------- 登录 / 分享锁定 ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-wrap { width: 100%; max-width: 392px; }
.auth-card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 22px; padding: 32px 30px;
    box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; }
.auth-brand .brand-mark { width: 42px; height: 42px; font-size: 19px; }
.auth-brand strong { display: block; font-size: 17px; line-height: 1.3; }
.auth-brand small { color: var(--muted); font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label span { font-size: 12.5px; color: var(--muted); }
.auth-form input {
    height: 42px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--panel-soft); color: var(--text);
    outline: 0; transition: border-color .16s, box-shadow .16s;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }
.auth-form .btn { margin-top: 6px; height: 44px; }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.auth-foot a:hover { color: var(--accent); }
.auth-copy { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }
.lock-note { margin: 0 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--panel-soft); color: var(--muted); font-size: 13px; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.error { background: color-mix(in srgb, var(--bad) 10%, var(--panel)); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 28%, var(--line)); }
.alert.ok { background: color-mix(in srgb, var(--ok) 10%, var(--panel)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, var(--line)); }

/* ---------- 安装向导 ---------- */
.install-page { display: block; min-height: 100vh; padding: 40px 24px; }
.install-wrap { max-width: 720px; margin: 0 auto; }
.install-card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 24px; padding: 34px; box-shadow: var(--shadow-lg);
}
.install-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.install-head .brand-mark { width: 48px; height: 48px; font-size: 22px; }
.install-head h1 { font-size: 22px; margin: 0 0 2px; }
.install-head p { margin: 0; color: var(--muted); font-size: 13px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 26px; }
.check-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 11px;
    border: 1px solid var(--line); border-radius: 9px; font-size: 12.5px;
    background: var(--panel-soft);
}
.check-icon { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; flex: none; color: #fff; }
.check-item.ok .check-icon { background: var(--ok); }
.check-item.warn .check-icon { background: #f59e0b; }
.check-item.bad .check-icon { background: var(--bad); }
.check-name { flex: 1; }
.check-value { color: var(--muted); font-size: 11.5px; }

.install-form h2 { font-size: 15px; margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.install-form label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.install-form label span { font-size: 12.5px; color: var(--muted); }
.install-form input[type="text"], .install-form input[type="password"], .install-form input[type="number"] {
    height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--panel-soft); color: var(--text); outline: 0;
}
.install-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.db-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.db-option {
    position: relative; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel-soft); cursor: pointer; display: flex; flex-direction: column; gap: 3px;
    transition: border-color .16s, box-shadow .16s;
}
.db-option input { position: absolute; opacity: 0; pointer-events: none; }
.db-option strong { font-size: 14.5px; }
.db-option small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.db-option.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }
.db-fields { padding: 16px; border: 1px dashed var(--line-strong); border-radius: 12px; margin-bottom: 8px; }
.inline-check { flex-direction: row !important; align-items: center; gap: 8px !important; }
.inline-check input { width: 16px; height: 16px; }
.install-tip { margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.install-actions { display: flex; gap: 12px; margin-top: 18px; }
code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-soft); padding: 2px 5px; border-radius: 5px; }

/* ---------- 分享页 ---------- */
.share-page { display: block; min-height: 100vh; }
.share-wrap { max-width: 1040px; margin: 0 auto; padding: 34px 24px 50px; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 36px; }
.share-badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 12px; }
.share-title h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
.share-title p { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.share-note { margin-top: 10px !important; padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.share-title { margin-bottom: 26px; }
.share-foot { margin-top: 46px; text-align: center; color: var(--muted); font-size: 12.5px; }
.share-foot span { margin: 0 6px; }

/* ---------- 通用 ---------- */
[hidden] { display: none !important; }

.toast {
    position: fixed; left: 50%; bottom: 28px; z-index: 90;
    transform: translate(-50%, 12px); opacity: 0;
    padding: 10px 18px; border-radius: 10px;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line); box-shadow: var(--shadow-lg);
    font-size: 13px; transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; gap: 18px; padding-top: 18px; }
    .sidebar {
        position: static; max-height: none;
        flex-direction: row; align-items: center;
        overflow-x: auto; padding: 6px;
    }
    .sidebar-scroll { display: flex; align-items: center; gap: 4px; padding: 2px; overflow: visible; }
    .sidebar-label { display: none; }
    .cat-link { white-space: nowrap; padding: 6px 11px; font-size: 13px; }
    .cat-link .cat-count { display: none; }
    .cat-link[style] { padding-left: 11px !important; }
    .sidebar-foot { display: none; }
    .topbar { gap: 10px; padding: 10px 14px; }
    .brand-text small { display: none; }
    .search { flex-basis: auto; }
    .search kbd { display: none; }
    .site-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 640px) {
    .brand { display: none; }
    .search { margin-left: 0; }
    .site-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .site-card { min-height: 68px; padding: 11px; gap: 9px; }
    .site-icon { width: 38px; height: 38px; border-radius: 10px; }
    .site-meta { display: none; }
    .site-name { font-size: 13.5px; }
    .cat-title { font-size: 18px; }
    .grid-2, .db-switch { grid-template-columns: 1fr; }
    .install-card { padding: 22px 18px; }
    .top-actions .btn { display: none; }
}
@media (max-width: 380px) {
    .site-grid { grid-template-columns: 1fr; }
}
