/* ===== 前台样式（一为紧凑型） ===== */

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

:root {
    --primary: #3b82f6;
    --accent:  #1e40af;
    --bg:      #f8fafc;
    --card:    #ffffff;
    --text:    #1e293b;
    --muted:   #64748b;
    --border:  #e2e8f0;
    --radius:  10px;
    --shadow:  0 1px 3px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.1);
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 60px;
}

a { color: inherit; text-decoration: none; }

/* ===== Header ===== */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    padding: 60px 20px 80px;
    text-align: center;
    position: relative;
}

.site-header-inner {
    max-width: 800px;
    margin: 0 auto;
}

.site-title {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.site-subtitle {
    font-size: 15px;
    opacity: 0.9;
    margin-bottom: 28px;
}

/* ===== Search ===== */
.site-search { margin: 0 auto; }

.search-box {
    display: flex;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    max-width: 700px;
    margin: 0 auto;
}

.search-engine {
    border: none;
    background: #f1f5f9;
    color: var(--text);
    padding: 0 16px;
    font-size: 14px;
    cursor: pointer;
    border-right: 1px solid var(--border);
    outline: none;
    font-family: inherit;
}

.search-box input[type="text"] {
    flex: 1;
    border: none;
    padding: 14px 20px;
    font-size: 16px;
    background: transparent;
    color: var(--text);
    outline: none;
    font-family: inherit;
}

.search-btn {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 0 28px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
    font-family: inherit;
}
.search-btn:hover { background: var(--accent); }

.search-tip {
    margin-top: 14px;
    color: rgba(255,255,255,0.85);
    font-size: 13px;
}
.search-tip a { color: #fff; text-decoration: underline; }
.search-tip kbd {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: inherit;
}
.search-tip strong { color: #fff; }

/* ===== Main ===== */
.site-main {
    max-width: 1280px;
    margin: -50px auto 30px;
    padding: 0 20px;
    position: relative;
}

/* ===== Section ===== */
.cat-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 24px;
    scroll-margin-top: 20px;
}

.search-results { /* 复用 cat-section 样式 */ }

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title small {
    font-size: 12px;
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
    margin-left: auto;
}
.cat-icon { font-size: 22px; }

/* ===== 二级分类 ===== */
.sub-section {
    margin-top: 20px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    position: relative;
}

.sub-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sub-section-title small {
    font-size: 11px;
    background: var(--primary);
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 500;
    margin-left: auto;
    opacity: 0.85;
}
.sub-icon { font-size: 16px; }

/* ===== Link Grid ===== */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--text);
    overflow: hidden;
}

.link-card:hover {
    background: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.link-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}

/* title 首字占位（favicon 抓不到时启用） */
.link-icon-fallback {
    display: none;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
}

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

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

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

.link-cat {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

/* ===== 侧边浮动分类导航 ===== */
.cat-nav {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--card);
    border-radius: 10px;
    padding: 8px 4px;
    box-shadow: var(--shadow);
    z-index: 50;
    max-height: 80vh;
    overflow-y: auto;
}
.cat-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--muted);
    transition: all 0.15s;
    min-width: 48px;
}
.cat-nav a:hover,
.cat-nav a.active {
    background: var(--primary);
    color: #fff;
}
.cat-nav a span {
    font-size: 18px;
    margin-bottom: 2px;
}
.cat-nav .back-top {
    margin-top: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

/* ===== Empty ===== */
.empty-hint {
    background: var(--card);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
    box-shadow: var(--shadow);
}
.empty-hint h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}
.empty-hint p { margin-top: 6px; }
.empty-hint a { color: var(--primary); text-decoration: underline; }

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--muted);
    font-size: 13px;
}
.site-footer p { margin-top: 4px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }

/* ===== Responsive ===== */
/* 手机端：二级分类缩进少一点 */
@media (max-width: 768px) {
    .sub-section {
        margin-top: 14px;
        padding: 12px 14px;
    }
    .sub-section-title { font-size: 14px; }

    .site-header { padding: 40px 16px 60px; }
    .site-title { font-size: 26px; }
    .site-subtitle { font-size: 13px; margin-bottom: 20px; }

    .search-box { flex-wrap: wrap; border-radius: 12px; }
    .search-engine { padding: 10px 12px; font-size: 13px; }
    .search-box input[type="text"] { padding: 12px 14px; font-size: 14px; }
    .search-btn { padding: 12px 18px; }

    .site-main { padding: 0 12px; margin-top: -40px; }

    .cat-section { padding: 16px; }
    .section-title { font-size: 16px; margin-bottom: 12px; padding-bottom: 10px; }

    .link-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
    }
    .link-card { padding: 10px; gap: 8px; }
    .link-icon { width: 28px; height: 28px; }
    .link-icon-fallback { width: 28px; height: 28px; font-size: 14px; }
    .link-title { font-size: 13px; }
    .link-desc { display: none; } /* 手机隐藏描述节省空间 */

    .cat-nav { display: none; } /* 手机隐藏侧边导航 */
}

@media (max-width: 480px) {
    .link-grid { grid-template-columns: repeat(2, 1fr); }
}