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

:root {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.18);
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #999;
    --accent: #7F77DD;
    --accent-bg: #EEEDFE;
    --accent-text: #3C3489;
    --accent-border: #AFA9EC;
    --nav-h: 54px;
    --radius: 12px;

    --font-base: 16px;
    --font-small: 13px;
    --font-mini: 12px;
    --font-title: 15px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111110;
        --surface: #1c1c1a;
        --border: rgba(255,255,255,0.08);
        --border-hover: rgba(255,255,255,0.2);
        --text-primary: #f0efe8;
        --text-secondary: #999;
        --text-muted: #666;
        --accent-bg: #26215C;
        --accent-text: #CECBF6;
        --accent-border: #534AB7;
    }
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 16px; /* ← 从 15 → 16 */
    line-height: 1.6; /* ← 稍微增加可读性 */
    min-height: 100vh;
}

/* ── Top bar ── */
#topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 28px;
}

#logo {
    font-size: 17px; /* ↑ */
    font-weight: 600;
    letter-spacing: -0.3px;
    flex-shrink: 0;
    user-select: none;

}

#logo span { color: var(--accent); }

#cats {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
}

#cats::-webkit-scrollbar { display: none; }

.cat-btn {
    padding: 6px 18px;
    border-radius: 20px;
    border: 0.5px solid transparent;
    background: transparent;
    font-size: 14px; /* ↑ 原 13 */
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
}

.cat-btn:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.cat-btn.active {
    background: var(--accent-bg);
    color: var(--accent-text);
    border-color: var(--accent-border);
}

/* ── Search ── */
#search-wrap {
    position: relative;
    flex-shrink: 0;
}

#search {
    background: var(--bg);
    border: 0.5px solid var(--border);
    border-radius: 20px;
    padding: 5px 14px 5px 34px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    width: 160px;
    font-family: inherit;
    transition: border-color .15s, width .2s;
}

#search::placeholder { color: var(--text-muted); }
#search:focus { border-color: var(--accent-border); width: 220px; }

#search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

/* ── Main ── */
#main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 28px 100px;
}

/* ── Section ── */
.section { margin-bottom: 52px; }

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.section-line {
    flex: 1;
    height: 0.5px;
    background: var(--border);
}

/* ── Grid ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: border-color .15s, transform .12s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.favicon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    font-style: normal;
}

.card-name {
    font-size: 15px; /* ↑ 原 14 */
    font-weight: 600;
    line-height: 1.3;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}

.card-tag {
    display: inline-block;
    font-size: 12px; /* ↑ 原 11 */
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-muted);
    align-self: flex-start;
}

/* favicon color fills */
.f-purple { background: #EEEDFE; }
.f-teal   { background: #E1F5EE; }
.f-amber  { background: #FAEEDA; }
.f-blue   { background: #E6F1FB; }
.f-coral  { background: #FAECE7; }
.f-pink   { background: #FBEAF0; }
.f-green  { background: #EAF3DE; }
.f-gray   { background: #F1EFE8; }

/* ── Empty state ── */
#empty {
    display: none;
    text-align: center;
    padding: 80px 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    #topbar { padding: 0 16px; gap: 12px; }
    #main { padding: 24px 16px 80px; }
    #search { display: none; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}