/* ========================
   CSS Variables
   ======================== */
:root {
    --bg: #f5f6fa;
    --bg-secondary: #ffffff;
    --bg-hover: #eef0f7;
    --border: #e2e5ef;
    --text: #1a1d23;
    --text-secondary: #5a6175;
    --text-muted: #9ca3af;
    --accent: #5b6af0;
    --accent-hover: #4757e8;
    --accent-light: #eef0fe;
    --sponsor: #f59e0b;
    --sponsor-light: #fffbeb;
    --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 220px;
    --navbar-height: 62px;
    /* 整体字号基准放大20% → 原来14px基准 × 1.2 = 16.8px */
    font-size: 16px;
}

[data-theme="dark"] {
    --bg: #0f1117;
    --bg-secondary: #16192a;
    --bg-hover: #1e2235;
    --border: #252840;
    --text: #e4e6f0;
    --text-secondary: #8b91a8;
    --text-muted: #505878;
    --accent: #6c7ff5;
    --accent-hover: #5b6af0;
    --accent-light: #1a1f45;
    --sponsor-light: #2d2200;
    --shadow-sm: 0 1px 4px rgba(0,0,0,.28);
    --shadow-md: 0 4px 16px rgba(0,0,0,.38);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.50);
}

/* ========================
   Reset & Base
   ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    font-size: var(--font-base, 1rem);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ========================
   Navbar
   ======================== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    transition: background .25s, border-color .25s, box-shadow .25s;
}
.navbar.scrolled { box-shadow: var(--shadow-md); }

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

/* LOGO */
.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    flex-shrink: 0;
}
.logo svg { flex-shrink: 0; }
.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    letter-spacing: -.01em;
}
.logo-text em {
    font-style: normal;
    color: var(--accent);
}

/* 搜索框 */
.nav-search {
    flex: 1;
    max-width: 440px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 0 14px;
    height: 40px;
    transition: border-color .2s, box-shadow .2s;
}
.nav-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.nav-search i { color: var(--text-muted); font-size: .9rem; }
.nav-search input {
    flex: 1; border: none; background: transparent;
    color: var(--text); font-size: .95rem; outline: none;
}
.nav-search input::placeholder { color: var(--text-muted); }
.search-shortcut {
    font-size: .75rem; color: var(--text-muted);
    background: var(--bg-hover); border: 1px solid var(--border);
    border-radius: 5px; padding: 1px 6px; flex-shrink: 0;
}

/* 右侧操作区 */
.nav-actions {
    display: flex; align-items: center; gap: 6px;
    margin-left: auto; flex-shrink: 0;
}
.nav-divider {
    width: 1px; height: 20px;
    background: var(--border); margin: 0 4px;
}

/* 天气组件 */
.weather-widget {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 11px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--border);
    cursor: pointer; transition: border-color .15s, background .15s;
    font-size: .85rem; color: var(--text-secondary);
    white-space: nowrap;
}
.weather-widget:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.weather-widget i { font-size: .95rem; color: #f59e0b; }
#weatherInfo { font-weight: 600; color: var(--text); font-size: .9rem; }
.weather-city { font-size: .78rem; color: var(--text-muted); }

/* 主题切换 */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 8px;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s; font-size: .95rem;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }

/* 导航链接 */
.nav-link {
    display: flex; align-items: center; gap: 5px;
    color: var(--text-secondary); font-size: .9rem;
    padding: 6px 11px; border-radius: 8px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }

/* 赞助按钮 */
.btn-sponsor {
    display: flex; align-items: center; gap: 5px;
    background: linear-gradient(135deg, #ff6b6b, #f59e0b);
    color: #fff; font-size: .88rem; font-weight: 600;
    padding: 6px 14px; border-radius: 8px;
    transition: opacity .15s, transform .15s;
}
.btn-sponsor:hover { opacity: .88; transform: translateY(-1px); }
.btn-sponsor i { font-size: .85rem; }

/* 登录 */
.btn-login {
    background: var(--accent); color: #fff;
    font-size: .9rem; font-weight: 600;
    padding: 6px 16px; border-radius: 8px;
    transition: background .15s, transform .15s;
}
.btn-login:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* ========================
   Modal 通用
   ======================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.48);
    z-index: 500;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-lg);
    transform: translateY(16px);
    transition: transform .25s;
    max-width: 90vw;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-close {
    position: absolute; top: 14px; right: 14px;
    width: 30px; height: 30px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: .9rem;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* ========================
   赞助弹窗
   ======================== */
.sponsor-box { width: 480px; text-align: center; }
.sponsor-header { margin-bottom: 24px; }
.sponsor-heart {
    font-size: 2.4rem; color: #ef4444;
    display: block; margin-bottom: 10px;
    animation: heartbeat 1.4s ease infinite;
}
@keyframes heartbeat {
    0%,100% { transform: scale(1); }
    14% { transform: scale(1.25); }
    28% { transform: scale(1); }
    42% { transform: scale(1.15); }
    56% { transform: scale(1); }
}
.sponsor-header h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 6px; }
.sponsor-header p { font-size: .9rem; color: var(--text-secondary); }

.sponsor-methods {
    display: flex; gap: 20px; justify-content: center; margin: 20px 0;
}
.sponsor-method { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-placeholder {
    width: 140px; height: 140px; border-radius: 12px;
    background: linear-gradient(135deg, #07c160, #00a854);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; color: #fff;
}
.qr-placeholder i { font-size: 2.4rem; }
.qr-placeholder span { font-size: .78rem; font-weight: 600; }
.qr-placeholder.alipay { background: linear-gradient(135deg, #1677ff, #0958d9); }
.sponsor-method p { font-size: .82rem; color: var(--text-secondary); }

.sponsor-note { font-size: .85rem; color: var(--text-muted); margin-bottom: 14px; }
.sponsor-tiers { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tier {
    padding: 5px 13px; border-radius: 20px;
    background: var(--sponsor-light); border: 1px solid #fde68a;
    font-size: .8rem; color: #92400e; font-weight: 600;
}
[data-theme="dark"] .tier { color: #fbbf24; border-color: #78350f; }

/* ========================
   城市弹窗
   ======================== */
.city-box { width: 380px; }
.city-box h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 18px; }
.city-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.city-btn {
    padding: 8px 6px; border-radius: 7px;
    background: var(--bg); border: 1px solid var(--border);
    font-size: .88rem; color: var(--text-secondary);
    transition: all .15s;
}
.city-btn:hover, .city-btn.active {
    background: var(--accent-light); border-color: var(--accent);
    color: var(--accent); font-weight: 600;
}

/* ========================
   Layout
   ======================== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--navbar-height) + 24px) 24px 48px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ========================
   Sidebar
   ======================== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--navbar-height) + 14px);
    display: flex;
    flex-direction: column;
    gap: 0;
    /* 撑满以便底部榜单入口沉底 */
    max-height: calc(100vh - var(--navbar-height) - 40px);
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-section h3 {
    font-size: .72rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .07em;
    padding: 0 9px; margin-bottom: 5px;
}

.category-list li {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 9px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: .9rem; cursor: pointer;
    transition: background .15s, color .15s;
}
.category-list li i { width: 16px; font-size: .82rem; color: var(--text-muted); flex-shrink: 0; }
.category-list li span:nth-child(2) { flex: 1; }
.category-list li .count {
    font-size: .73rem; color: var(--text-muted);
    background: var(--bg-hover); padding: 1px 7px; border-radius: 10px;
}
.category-list li:hover { background: var(--bg-hover); color: var(--text); }
.category-list li.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.category-list li.active i { color: var(--accent); }
.category-list li.active .count { background: var(--accent); color: #fff; }

/* 榜单区 */
.sidebar-rank { margin-top: auto; padding-top: 4px; border-top: 1px solid var(--border); }
.rank-list { display: flex; flex-direction: column; gap: 5px; }
.rank-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 9px; border-radius: var(--radius-sm);
    font-size: .9rem; color: var(--text-secondary);
    transition: background .15s, color .15s;
}
.rank-link:hover { background: var(--bg-hover); color: var(--text); }
.rank-link i { width: 16px; font-size: .82rem; }
.rank-link span:nth-child(2) { flex: 1; }
.rank-badge {
    font-size: .68rem; padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}
.rank-hot { color: #dc2626; }
.rank-hot:hover { background: #fef2f2; color: #dc2626; }
.rank-hot i { color: #ef4444; }
.rank-hot .rank-badge { background: #fef2f2; color: #ef4444; }
[data-theme="dark"] .rank-hot:hover { background: #450a0a; }
[data-theme="dark"] .rank-hot .rank-badge { background: #450a0a; }

.rank-discuss { color: #7c3aed; }
.rank-discuss:hover { background: #f5f3ff; color: #7c3aed; }
.rank-discuss i { color: #8b5cf6; }
.rank-discuss .rank-badge { background: #f5f3ff; color: #7c3aed; }
[data-theme="dark"] .rank-discuss:hover { background: #2e1065; }
[data-theme="dark"] .rank-discuss .rank-badge { background: #2e1065; color: #a78bfa; }

/* ========================
   Content Area
   ======================== */
.content-area { flex: 1; min-width: 0; }

/* ========================
   Hero
   ======================== */
.hero-simple {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; padding: 4px 0 18px; flex-wrap: wrap;
}
.hero-text h1 {
    font-size: 1.85rem; font-weight: 800;
    letter-spacing: -.025em; line-height: 1.25; margin-bottom: 4px;
}
.gradient-text {
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-text p { color: var(--text-secondary); font-size: .95rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.hero-tags .tag {
    padding: 4px 13px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 18px;
    font-size: .82rem; color: var(--text-secondary);
    cursor: pointer; transition: all .15s; white-space: nowrap;
}
.hero-tags .tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ========================
   Info Bar
   ======================== */
.info-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.news-ticker {
    display: flex; align-items: center;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); height: 40px; overflow: hidden;
}
.ticker-label {
    display: flex; align-items: center; gap: 5px;
    padding: 0 13px; font-size: .78rem; font-weight: 700;
    color: var(--accent); background: var(--accent-light);
    height: 100%; white-space: nowrap; flex-shrink: 0;
    border-right: 1px solid var(--border);
}
.ticker-wrap { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; padding: 0 14px; }
.ticker-track {
    display: flex; gap: 56px; white-space: nowrap;
    animation: tickerScroll 32s linear infinite;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-item { font-size: .84rem; color: var(--text-secondary); cursor: pointer; transition: color .15s; }
.ticker-item:hover { color: var(--accent); }
@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ad-banner {
    display: flex; align-items: center; gap: 9px;
    background: linear-gradient(135deg, var(--accent-light), #f5f0ff);
    border: 1px solid rgba(91,106,240,.3); border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: .86rem; color: var(--text-secondary);
}
[data-theme="dark"] .ad-banner { background: linear-gradient(135deg,#1a1f45,#1a1430); }
.ad-banner i { color: var(--accent); }
.ad-banner span { flex: 1; }

/* ========================
   Section Header
   ======================== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-header h2 { font-size: 1.05rem; font-weight: 700; }
.filter-tabs { display: flex; gap: 4px; background: var(--bg-hover); padding: 3px; border-radius: var(--radius-sm); }
.filter-tabs button {
    padding: 4px 13px; border-radius: 6px; font-size: .82rem;
    color: var(--text-secondary); transition: all .15s;
    display: flex; align-items: center; gap: 4px;
}
.filter-tabs button.active {
    background: var(--bg-secondary); color: var(--text);
    font-weight: 600; box-shadow: var(--shadow-sm);
}
.filter-tabs button:hover:not(.active) { color: var(--text); }

/* ========================
   Tools Grid
   ======================== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

/* ========================
   Tool Card — 紧凑横向，修复文字遮盖
   ======================== */
.tool-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 14px 14px 14px;
    display: grid;
    /* 图标 | 内容区 */
    grid-template-columns: 50px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 0;
    cursor: pointer;
    position: relative;
    transition: border-color .18s, box-shadow .18s, transform .18s;
    /* 收藏按钮右上角不被内容遮盖，右侧留出空间 */
    padding-right: 38px;
}
.tool-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* 赞助商卡片特殊样式 */
.tool-card.sponsored {
    border-color: var(--sponsor);
    background: linear-gradient(to bottom right, var(--bg-secondary), var(--sponsor-light));
}
.tool-card.sponsored::before {
    content: '赞助';
    position: absolute;
    top: 8px; left: 12px;
    font-size: .62rem; font-weight: 700;
    color: #92400e; background: #fde68a;
    padding: 1px 5px; border-radius: 4px;
    line-height: 1.6;
}
[data-theme="dark"] .tool-card.sponsored::before { color: #fbbf24; background: #78350f; }

/* 图标 — 占据两行 */
.card-icon {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 50px; height: 50px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700; color: #fff;
    flex-shrink: 0; overflow: hidden;
    align-self: center;
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }

/* 顶部行：名称 + 标签 */
.card-top {
    grid-column: 2; grid-row: 1;
    display: flex; flex-direction: column; gap: 3px;
    min-width: 0;
}
.card-name {
    font-size: .96rem; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3;
}
.card-badges { display: flex; gap: 3px; flex-wrap: nowrap; overflow: hidden; }
.badge {
    font-size: .66rem; font-weight: 600; padding: 1px 6px;
    border-radius: 4px; line-height: 1.65; white-space: nowrap;
}
.badge-free { background: #ecfdf5; color: #059669; }
.badge-hot  { background: #fef2f2; color: #ef4444; }
.badge-new  { background: #eff6ff; color: #3b82f6; }
.badge-sponsored { background: #fffbeb; color: #d97706; }
[data-theme="dark"] .badge-free { background: #064e3b; color: #34d399; }
[data-theme="dark"] .badge-hot  { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge-new  { background: #1e3a5f; color: #60a5fa; }
[data-theme="dark"] .badge-sponsored { background: #2d2200; color: #fbbf24; }

/* 底部行：描述文字 */
.card-desc {
    grid-column: 2; grid-row: 2;
    font-size: .8rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.45;
    margin-top: 4px;
}

/* 收藏按钮 —— 右上角绝对定位，不遮盖正文 */
.btn-favorite {
    position: absolute; top: 10px; right: 10px;
    width: 26px; height: 26px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: .8rem;
    transition: all .18s; background: transparent; z-index: 2;
    flex-shrink: 0;
}
.btn-favorite:hover { background: #fef2f2; color: #ef4444; transform: scale(1.18); }
.btn-favorite.active { color: #ef4444; }
[data-theme="dark"] .btn-favorite:hover { background: #450a0a; }

/* 点击量标记 */
.card-clicks {
    position: absolute; bottom: 8px; right: 10px;
    font-size: .68rem; color: var(--text-muted);
    display: flex; align-items: center; gap: 3px;
}
.card-clicks i { font-size: .65rem; }

/* ========================
   Empty State
   ======================== */
.empty-state { grid-column: 1 / -1; text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; margin-bottom: 10px; display: block; }

/* ========================
   Footer
   ======================== */
.footer-simple { border-top: 1px solid var(--border); padding: 20px; text-align: center; margin-top: 40px; }
.footer-simple p { color: var(--text-muted); font-size: .85rem; }

/* ========================
   Back to Top
   ======================== */
.back-to-top {
    position: fixed; bottom: 28px; right: 28px;
    width: 40px; height: 40px; background: var(--accent);
    color: #fff; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: .88rem;
    opacity: 0; pointer-events: none; transform: translateY(10px);
    transition: opacity .22s, transform .22s;
    box-shadow: var(--shadow-md); z-index: 50;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-hover); }

/* ========================
   Fade-in
   ======================== */
.fade-in { opacity: 0; transform: translateY(10px); transition: opacity .38s ease, transform .38s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ========================
   Responsive
   ======================== */
@media (max-width: 960px) {
    .sidebar { display: none; }
    .hero-simple { flex-direction: column; align-items: flex-start; gap: 10px; }
    .weather-city { display: none; }
}
@media (max-width: 640px) {
    :root { font-size: 15px; }
    .search-shortcut { display: none; }
    .nav-link span { display: none; }
    .tools-grid { grid-template-columns: 1fr 1fr; }
    .main-container { padding: calc(var(--navbar-height) + 14px) 14px 32px; }
    .btn-sponsor span { display: none; }
    .weather-widget span { display: none; }
}
@media (max-width: 440px) {
    .tools-grid { grid-template-columns: 1fr; }
}
