/* ================= 网址导航 · 前台样式（左侧导航布局） ================= */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --text: #1f2937;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --border: #e5e7eb;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --shadow: 0 2px 10px rgba(31, 41, 55, .06);
    --shadow-hover: 0 10px 28px rgba(99, 102, 241, .16);
    --topbar-bg: rgba(246, 247, 251, .85);
    --sidebar-w: 248px;
}
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #273449;
    --text: #e5e7eb;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --border: #334155;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --shadow: 0 2px 10px rgba(0, 0, 0, .25);
    --shadow-hover: 0 10px 28px rgba(129, 140, 248, .2);
    --topbar-bg: rgba(15, 23, 42, .85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- 左侧边栏 ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 120;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 26px; flex-shrink: 0; filter: drop-shadow(0 2px 6px rgba(99, 102, 241, .3)); }
.brand-text { min-width: 0; }
.brand-text strong {
    display: block; font-size: 16px; font-weight: 700; letter-spacing: .3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small {
    display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.side-nav {
    flex: 1; overflow-y: auto; padding: 10px;
    display: flex; flex-direction: column; gap: 2px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }

.side-link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 11px; border-radius: 9px; font-size: 13.5px; color: var(--text-2);
    transition: background .15s, box-shadow .15s;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, .3);
}
.side-link.is-active .side-cnt { background: rgba(255, 255, 255, .22); color: #fff; }
.side-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-cnt {
    flex-shrink: 0; font-size: 11px; line-height: 1.5; color: var(--text-3);
    background: var(--surface-2); border-radius: 999px; padding: 0 7px;
    transition: background .15s;
}

.sidebar-foot {
    display: flex; gap: 8px; padding: 12px 14px;
    border-top: 1px solid var(--border);
}
.icon-btn {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); font-size: 15px; cursor: pointer; color: inherit;
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); background: var(--surface-2); }

/* ---------- 主区域 ---------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 12px;
    padding: 13px 24px;
    background: var(--topbar-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.menu-btn {
    display: none; width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 17px; cursor: pointer;
}
.search-wrap {
    flex: 1; max-width: 720px; margin: 0 auto; position: relative;
    display: flex; align-items: center;
}
.search-icon { position: absolute; left: 16px; font-size: 14px; opacity: .6; pointer-events: none; }
#search {
    width: 100%; padding: 11px 132px 11px 42px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text); font-size: 14.5px; outline: none;
    transition: border-color .2s, box-shadow .2s;
}
#search::placeholder { color: var(--text-3); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
.search-clear {
    position: absolute; right: 78px; width: 26px; height: 26px; border-radius: 50%;
    border: 0; background: var(--surface-2); color: var(--text-2); font-size: 15px; cursor: pointer; line-height: 1;
}
.search-clear:hover { background: var(--border); }
.search-count {
    position: absolute; right: 14px; font-size: 11.5px; color: var(--accent);
    background: rgba(99, 102, 241, .1); border-radius: 999px; padding: 2px 10px;
    white-space: nowrap;
}

/* ---------- 内容 ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 26px 24px 40px; flex: 1; }
.cat-section { margin-bottom: 34px; scroll-margin-top: 84px; }
.cat-title {
    font-size: 17px; font-weight: 600; margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}
.cat-ico { font-size: 18px; }
.cat-count {
    font-size: 11px; font-weight: 600; color: var(--accent);
    background: rgba(99, 102, 241, .12); border-radius: 999px; padding: 1px 8px;
}

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

/* ---------- 卡片 ---------- */
.card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px;
    transition: transform .18s, box-shadow .18s, border-color .18s;
    position: relative; overflow: hidden;
}
.card::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    opacity: 0; transition: opacity .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: transparent; }
.card:hover::after { opacity: 1; }

.fav {
    width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
    background: var(--c, var(--accent)); color: #fff;
    font-size: 18px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    text-transform: uppercase;
}
.fav img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
    padding: 6px; background: #fff; border-radius: 11px; opacity: 0; transition: opacity .2s;
}
[data-theme="dark"] .fav img { background: #e8ecf3; }

.card-main { min-width: 0; display: flex; flex-direction: column; }
.card-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc {
    font-size: 12px; color: var(--text-2); margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.card-host { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- 空状态 / 页脚 ---------- */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-2); }
.empty-icon { font-size: 46px; margin-bottom: 12px; }
.empty-hint { font-size: 13px; margin-top: 6px; }
.empty-hint a { color: var(--accent); }
.footer {
    text-align: center; padding: 26px 20px 34px; color: var(--text-3); font-size: 12.5px;
    border-top: 1px solid var(--border);
}
.footer-stat { margin-left: 10px; opacity: .75; }

/* ---------- 回到顶部 ---------- */
.to-top {
    position: fixed; right: 26px; bottom: 30px; z-index: 90;
    width: 42px; height: 42px; border-radius: 50%; border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-size: 18px; cursor: pointer;
    box-shadow: 0 6px 18px rgba(99, 102, 241, .4);
    transition: transform .15s;
}
.to-top:hover { transform: translateY(-3px); }

/* ---------- 遮罩（移动端抽屉） ---------- */
.backdrop {
    position: fixed; inset: 0; z-index: 110;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
}
.backdrop[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, .18);
        width: 264px;
    }
    .sidebar.is-open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .menu-btn { display: flex; align-items: center; justify-content: center; }
    html { scroll-padding-top: 76px; }
}

@media (max-width: 640px) {
    .container { padding: 18px 14px 32px; }
    .topbar { padding: 11px 14px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .card { padding: 11px; gap: 9px; }
    .fav { width: 36px; height: 36px; border-radius: 9px; font-size: 15px; }
    .fav img { padding: 5px; border-radius: 9px; }
    #search { padding-right: 96px; }
    .search-clear { right: 62px; }
    .to-top { right: 16px; bottom: 20px; }
}

/* 搜索隐藏态 */
.is-hidden { display: none !important; }
