/* ========== AI Tool Navigator - Main Stylesheet ========== */
:root {
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --sidebar-width: 200px;
    --header-height: 60px;
}

/* 暗色AI主题（默认） */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2333;
    --bg-card-hover: #212a3b;
    --accent: #58a6ff;
    --accent-rgb: 88,166,255;
    --accent-purple: #8b5cf6;
    --accent-purple-rgb: 139,92,246;
    --accent-green: #3fb950;
    --accent-green-rgb: 63,185,80;
    --accent-orange: #d29922;
    --accent-pink: #db61a2;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #5d6a7a;
    --border: #30363d;
    --border-light: #21262d;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 30px rgba(var(--accent-rgb), 0.15);
    --bg-gradient: radial-gradient(circle at 20% 0%, rgba(var(--accent-rgb), 0.08) 0%, transparent 50%),
                  radial-gradient(circle at 80% 30%, rgba(var(--accent-purple-rgb), 0.06) 0%, transparent 50%),
                  radial-gradient(circle at 60% 80%, rgba(var(--accent-green-rgb), 0.04) 0%, transparent 40%);
    --header-bg: rgba(13,17,23,0.92);
}

/* 亮色简约主题 */
[data-theme="light"] {
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f4f8;
    --accent: #0969da;
    --accent-rgb: 9,105,218;
    --accent-purple: #8250df;
    --accent-purple-rgb: 130,80,223;
    --accent-green: #1a7f37;
    --accent-green-rgb: 26,127,55;
    --accent-orange: #bf8700;
    --accent-pink: #bf3989;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --border: #d0d7de;
    --border-light: #d8dee4;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 30px rgba(var(--accent-rgb), 0.1);
    --bg-gradient: radial-gradient(circle at 20% 0%, rgba(var(--accent-rgb), 0.04) 0%, transparent 40%),
                  radial-gradient(circle at 80% 30%, rgba(var(--accent-purple-rgb), 0.03) 0%, transparent 40%);
    --header-bg: rgba(246,248,250,0.92);
}

/* 暖色护眼主题 */
[data-theme="warm"] {
    --bg-primary: #fdf6e3;
    --bg-secondary: #fef9ef;
    --bg-card: #fffdf7;
    --bg-card-hover: #fef5e7;
    --accent: #b55903;
    --accent-rgb: 181,89,3;
    --accent-purple: #9c4dcc;
    --accent-purple-rgb: 156,77,204;
    --accent-green: #5b8c00;
    --accent-green-rgb: 91,140,0;
    --accent-orange: #e67e22;
    --accent-pink: #c0392b;
    --text-primary: #3e3a32;
    --text-secondary: #7a7465;
    --text-muted: #a39a88;
    --border: #d6cdb8;
    --border-light: #e0d9c7;
    --shadow: 0 4px 20px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 30px rgba(var(--accent-rgb), 0.08);
    --bg-gradient: radial-gradient(circle at 20% 0%, rgba(var(--accent-rgb), 0.03) 0%, transparent 40%),
                  radial-gradient(circle at 80% 60%, rgba(var(--accent-purple-rgb), 0.02) 0%, transparent 40%);
    --header-bg: rgba(253,246,227,0.92);
}

/* 极客绿主题 */
[data-theme="hacker"] {
    --bg-primary: #0a0e0a;
    --bg-secondary: #0f150f;
    --bg-card: #111811;
    --bg-card-hover: #152015;
    --accent: #00ff41;
    --accent-rgb: 0,255,65;
    --accent-purple: #00e5ff;
    --accent-purple-rgb: 0,229,255;
    --accent-green: #39ff14;
    --accent-green-rgb: 57,255,20;
    --accent-orange: #ffb300;
    --accent-pink: #ff4081;
    --text-primary: #b8ffb8;
    --text-secondary: #6a9a6a;
    --text-muted: #3d6a3d;
    --border: #1a3a1a;
    --border-light: #0f2a0f;
    --shadow: 0 4px 20px rgba(0,0,0,0.5);
    --shadow-hover: 0 8px 30px rgba(var(--accent-rgb), 0.12);
    --bg-gradient: radial-gradient(circle at 20% 0%, rgba(var(--accent-rgb), 0.04) 0%, transparent 50%),
                  radial-gradient(circle at 80% 60%, rgba(var(--accent-purple-rgb), 0.03) 0%, transparent 40%);
    --header-bg: rgba(10,14,10,0.94);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    background-image: var(--bg-gradient);
}

/* ========== HEADER ========== */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    z-index: 1000;
    display: flex;
    align-items: center;
}

.header-inner {
    width: 80%;
    margin: 0 auto;
    padding: 0 clamp(12px, 2vw, 32px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.logo {
    color: var(--text-primary);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
}

.logo-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
}

.logo-mark svg {
    width: 100%;
    height: 100%;
    display: block;
}

.logo-shell {
    fill: #0b1020;
    stroke: #72e0ff;
}

.logo-a {
    fill: none;
    stroke: #fff;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.logo-i {
    fill: none;
    stroke: #72e0ff;
    stroke-linecap: round;
}

.logo:hover .logo-mark {
    transform: translateY(-1px);
}

.logo-text {
    display: flex;
    align-items: baseline;
    min-width: 0;
}

.logo-word {
    font-family: var(--font-sans);
    font-size: 1.22rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text-primary);
}

.logo-word .logo-ai {
    color: #72e0ff;
}

.header-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 8px;
    scrollbar-width: none;
}

.header-nav::-webkit-scrollbar { display: none; }

.header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.88rem;
    transition: var(--transition);
    white-space: nowrap;
    flex: 0 0 auto;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-outline {
    padding: 7px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

/* ========== THEME SWITCHER ========== */
.theme-switcher { position: relative; }

.theme-btn {
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-btn:hover {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

.theme-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 6px;
    min-width: 160px;
    z-index: 1002;
}

.theme-dropdown.open { display: block; }

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
    white-space: nowrap;
}

.theme-option:hover {
    color: var(--text-primary);
    background: rgba(128,128,128,0.08);
}

.theme-option.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

.theme-option span { font-size: 1rem; }

/* ========== LANGUAGE SWITCHER ========== */
.language-switcher { position: relative; }

.language-btn {
    min-width: 46px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.language-btn:hover,
.language-switcher.open .language-btn {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--accent);
}

.language-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 232px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px;
    z-index: 1002;
}

.language-switcher.open .language-dropdown { display: block; }

.language-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 9px 10px;
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 700;
}

.language-dropdown-header span:last-child {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
}

.language-option {
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
    font-family: var(--font-sans);
    text-align: left;
    transition: var(--transition);
}

.language-option:hover {
    color: var(--text-primary);
    background: rgba(128,128,128,0.08);
}

.language-option.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.07);
}

.language-pill {
    min-width: 32px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(var(--accent-rgb), 0.10);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.language-check { margin-left: auto; font-weight: 800; }

[dir="rtl"] .language-dropdown,
[dir="rtl"] .language-option { text-align: right; }
[dir="rtl"] .language-check { margin-left: 0; margin-right: auto; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    width: 36px; height: 36px;
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
}

/* ========== SEARCH HERO ========== */
.search-hero {
    padding: 60px 24px 40px;
    text-align: center;
    margin-top: var(--header-height);
    position: relative;
}

.search-hero-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-purple), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-hero-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 24px;
}

.search-form {
    max-width: 640px;
    margin: 0 auto 20px;
    position: relative;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 50px;
    transition: var(--transition);
    overflow: hidden;
}

.search-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.1);
}

.search-icon {
    position: absolute;
    left: 18px;
    font-size: 1.1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 46px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    font-family: var(--font-sans);
}

.search-input::placeholder { color: var(--text-muted); }

.search-clear {
    position: absolute;
    right: 14px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-secondary);
    border-radius: 50%;
    width: 28px; height: 28px;
    cursor: pointer;
    font-size: 0.85rem;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-clear:hover { background: rgba(255,255,255,0.2); }
.search-clear.visible { display: flex; }

.hot-tags {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 640px;
    margin: 0 auto;
}

.hot-tags-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.hot-tag {
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    background: transparent;
    font-family: var(--font-sans);
}

.hot-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

/* ========== MAIN LAYOUT ========== */
.main-container {
    width: 80%;
    margin: 0 auto;
    padding: 0 clamp(12px, 2vw, 32px) 40px;
    display: flex;
    gap: 30px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-height) + 24px);
    align-self: flex-start;
    max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    padding: 12px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    padding: 6px 10px 10px;
    font-weight: 600;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
}

.sidebar-nav a .nav-emoji { font-size: 1rem; width: 22px; text-align: center; }

.sidebar-nav a .nav-count {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 10px;
}

/* ========== CONTENT AREA ========== */
.content { flex: 1; min-width: 0; }

.category-section {
    margin-bottom: 40px;
    scroll-margin-top: calc(var(--header-height) + 16px);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.category-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-title .cat-emoji { font-size: 1.4rem; }

.category-more {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-more:hover { color: var(--accent); }

.category-footer {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.category-toggle {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 7px 18px;
    cursor: pointer;
    font-size: 0.84rem;
    transition: var(--transition);
    font-family: var(--font-sans);
}

.category-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
}

/* ========== TOOL CARD GRID ========== */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

/* Collapse/expand animation */
.category-extra {
    display: none;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.35s ease, max-height 0.4s ease;
}
.category-section.expanded .category-extra,
.category-section.searching .category-extra {
    display: block;
    opacity: 1;
    max-height: 2000px;
}

/* Card stagger animation */
.tool-card-wrapper {
    animation: cardFadeIn 0.35s ease both;
}
.tool-card-wrapper:nth-child(1) { animation-delay: 0.01s; }
.tool-card-wrapper:nth-child(2) { animation-delay: 0.03s; }
.tool-card-wrapper:nth-child(3) { animation-delay: 0.05s; }
.tool-card-wrapper:nth-child(4) { animation-delay: 0.07s; }
.tool-card-wrapper:nth-child(5) { animation-delay: 0.09s; }
.tool-card-wrapper:nth-child(6) { animation-delay: 0.11s; }
.tool-card-wrapper:nth-child(7) { animation-delay: 0.13s; }
.tool-card-wrapper:nth-child(8) { animation-delay: 0.15s; }
.tool-card-wrapper:nth-child(9) { animation-delay: 0.17s; }
.tool-card-wrapper:nth-child(10) { animation-delay: 0.19s; }
.tool-card-wrapper:nth-child(11) { animation-delay: 0.21s; }
.tool-card-wrapper:nth-child(12) { animation-delay: 0.23s; }

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.tool-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    position: relative;
}

.tool-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.tool-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.tool-card:hover .tool-icon { border-color: var(--accent); }

.tool-icon-img,
.trending-icon-img,
.sug-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
}

.tool-icon-fallback { display: inline-flex; }

.tool-icon.has-image .tool-icon-fallback,
.trending-icon.has-image .tool-icon-fallback,
.sug-icon.has-image .tool-icon-fallback { display: none; }

.tool-icon.image-failed .tool-icon-img,
.trending-icon.image-failed .trending-icon-img,
.sug-icon.image-failed .sug-icon-img { display: none; }

.tool-icon.image-failed .tool-icon-fallback,
.trending-icon.image-failed .tool-icon-fallback,
.sug-icon.image-failed .tool-icon-fallback { display: inline-flex; }

.tool-info { flex: 1; min-width: 0; }

.tool-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    padding-right: 20px;
}

.tool-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-card .external-icon {
    position: absolute;
    right: 14px;
    top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0;
    transition: var(--transition);
}

.tool-card:hover .external-icon { opacity: 1; }

/* ========== NO RESULTS ========== */
.no-results {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-results.visible { display: block; }

.no-results-icon { font-size: 3rem; margin-bottom: 12px; }

/* ========== FOOTER ========== */
.footer {
    border-top: 1px solid var(--border-light);
    padding: 30px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.8;
}

.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ========== BACK TO TOP ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition);
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* ========== MOBILE CATEGORY TABS ========== */
.mobile-cat-nav {
    display: none;
    position: sticky;
    top: var(--header-height);
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-light);
    padding: 10px 16px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.mobile-cat-nav::-webkit-scrollbar { display: none; }

.mobile-cat-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-right: 6px;
    transition: var(--transition);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.mobile-cat-nav a.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1023px) {
    .header-nav { display: none; }
    .mobile-menu-btn { display: flex; }
    .sidebar { display: none; }
    .mobile-cat-nav { display: block; }
    .header-inner,
    .main-container,
    .footer-ad,
    .trending-section { width: 100% !important; }
    .main-container { padding: 0 16px 30px; }
    .tool-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .search-hero { padding: 40px 16px 30px; }
    .search-hero-title { font-size: 1.6rem; }
}

@media (max-width: 640px) {
    .tool-grid { grid-template-columns: 1fr; }
    .search-hero-title { font-size: 1.3rem; }
    .search-input { padding: 12px 44px 12px 40px; font-size: 0.9rem; }
    .header-inner { padding: 0 12px; }
    .btn-outline { font-size: 0.78rem; padding: 5px 12px; }
}

/* ========== MOBILE MENU OVERLAY ========== */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mobile-menu-overlay.open { display: block; opacity: 1; }

.mobile-menu-panel {
    position: fixed;
    top: 0; right: 0;
    bottom: 0;
    width: 280px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 1001;
    padding: 20px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-panel.open { transform: translateX(0); }

.mobile-menu-panel .sidebar-nav { margin-top: 20px; }

.mobile-menu-close {
    position: absolute;
    top: 12px; right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.mobile-menu-close:hover { background: rgba(255,255,255,0.05); }

@media (min-width: 1024px) {
    .mobile-menu-overlay, .mobile-menu-panel { display: none !important; }
}

/* ========== FAVORITE BUTTON ========== */
.fav-btn {
    position: absolute;
    right: 14px;
    bottom: 14px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 3px 8px;
    transition: var(--transition);
    opacity: 0;
}

.tool-card-wrapper:hover .fav-btn { opacity: 1; }
/* Mobile: always show fav button */
@media (hover: none) {
    .fav-btn { opacity: 0.6; }
    .fav-btn.favorited { opacity: 1; }
}

.fav-btn:hover { border-color: var(--accent-orange); color: var(--accent-orange); }
.fav-btn.favorited { color: var(--accent-orange); border-color: var(--accent-orange); opacity: 1; }

/* ========== SUBMIT TOOL MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 1.2rem; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center; border-radius: 6px;
}

.modal-close:hover { background: rgba(128,128,128,0.1); color: var(--text-primary); }

.form-group { margin-bottom: 16px; }

.form-label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-size: 0.9rem;
    font-family: var(--font-sans); transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent); outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.08);
}

.form-textarea { min-height: 80px; resize: vertical; }

.btn-submit {
    width: 100%; padding: 12px; border: none; border-radius: 8px;
    background: var(--accent); color: var(--bg-primary);
    font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: var(--font-sans);
    transition: var(--transition);
}

.btn-submit:hover { opacity: 0.85; }

.form-error { color: var(--accent-pink); font-size: 0.8rem; margin-top: 4px; display: none; }
.form-error.show { display: block; }

/* ========== FLOATING SUBMIT BUTTON ========== */
.float-submit-btn {
    position: fixed;
    bottom: 80px;
    right: 30px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 890;
    transition: var(--transition);
}

.float-submit-btn:hover { transform: scale(1.1); }

/* ========== AD PLACEMENTS ========== */
.ad-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    margin-bottom: 4px;
}

/* Sidebar ad */
.sidebar-ad {
    margin-top: 12px;
    padding: 10px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.sidebar-ad-inner {
    background: var(--bg-primary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    flex-direction: column;
    gap: 6px;
}

.sidebar-ad-inner:hover {
    border-color: var(--accent);
    border-style: solid;
    background: rgba(var(--accent-rgb), 0.03);
}

.sidebar-ad-inner .ad-emoji { font-size: 1.5rem; opacity: 0.6; }

/* In-feed ad card */
.ad-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.04), rgba(var(--accent-purple-rgb), 0.04));
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    color: var(--text-primary);
}

.ad-card:hover {
    border-style: solid;
    border-color: var(--accent-purple);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(var(--accent-purple-rgb), 0.1);
}

.ad-card .ad-badge {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 0.65rem;
    background: rgba(var(--accent-purple-rgb), 0.12);
    color: var(--accent-purple);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Footer banner ad */
.footer-ad {
    width: 80%;
    margin: 0 auto 30px;
    padding: 0 clamp(12px, 2vw, 32px);
    text-align: center;
}

.footer-ad-inner {
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    min-height: 90px;
}

.footer-ad-inner:hover {
    border-color: var(--accent);
    border-style: solid;
    background: rgba(var(--accent-rgb), 0.02);
}

.footer-ad-inner .ad-emoji { font-size: 1.8rem; opacity: 0.5; }

@media (max-width: 768px) {
    .footer-ad { max-width: 100%; padding: 0 16px; }
    .footer-ad-inner { min-height: 60px; font-size: 0.78rem; padding: 14px; }
}

/* ========== TAG BADGES ========== */
.tool-tags {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.tag-hot { background: rgba(210,153,34,0.15); color: var(--accent-orange); }
.tag-rec { background: rgba(219,97,162,0.12); color: var(--accent-pink); }
.tag-new { background: rgba(63,185,80,0.15); color: var(--accent-green); }
.tag-cn { background: rgba(var(--accent-rgb), 0.12); color: var(--accent); }
.tag-en { background: rgba(var(--accent-purple-rgb), 0.12); color: var(--accent-purple); }
.tag-default { background: rgba(128,128,128,0.1); color: var(--text-muted); }

.tag-filter { cursor: pointer; transition: var(--transition); }
.tag-filter:hover { filter: brightness(1.2); }

/* ========== REGION BADGE ========== */
.region-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    margin-left: 6px;
    vertical-align: middle;
}

/* ========== CLICK COUNT ========== */
.click-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ========== TRENDING SECTION ========== */
.trending-section { margin-bottom: 20px; }
.trending-section.hidden { display: none; }

.trending-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.trending-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.trending-scroll::-webkit-scrollbar { height: 4px; }
.trending-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.trending-card {
    flex: 0 0 240px;
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.trending-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.trending-card .trending-rank {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--border);
    line-height: 1;
}

.trending-card:nth-child(1) .trending-rank { color: var(--accent-orange); }
.trending-card:nth-child(2) .trending-rank { color: var(--text-muted); }
.trending-card:nth-child(3) .trending-rank { color: #cd7f32; }

.trending-card .trending-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    margin: 10px 0 12px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-primary), rgba(var(--accent-rgb), 0.08));
    border: 1px solid var(--border);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.trending-card .trending-icon.has-image {
    background: var(--bg-primary);
}

.trending-card:hover .trending-icon {
    border-color: var(--accent);
    box-shadow: 0 10px 22px rgba(var(--accent-rgb), 0.14);
}

.trending-card .trending-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.trending-card .trending-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.trending-card .trending-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ========== SORT DROPDOWN ========== */
.sort-select {
    padding: 3px 8px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.sort-select:hover { border-color: var(--accent); }

/* ========== SEARCH SUGGESTIONS ========== */
.search-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 100;
    max-height: 260px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-suggestions.open { display: block; }

.search-suggestion-item {
    padding: 10px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.search-suggestion-item:hover,
.search-suggestion-item.active {
    background: rgba(var(--accent-rgb), 0.06);
    color: var(--text-primary);
}

.search-suggestion-item .sug-emoji { font-size: 1rem; }

@media (max-width: 1023px) {
    .trending-card { flex: 0 0 200px; }
}

/* ========== SEARCH HIGHLIGHT ========== */
.search-highlight {
    background: rgba(var(--accent-rgb), 0.25);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}
[data-theme="dark"] .search-highlight {
    background: rgba(var(--accent-rgb), 0.2);
}
[data-theme="warm"] .search-highlight {
    background: rgba(var(--accent-rgb), 0.18);
}
[data-theme="hacker"] .search-highlight {
    background: rgba(0,255,65,0.2);
    color: #39ff14;
}

/* ========== TOAST NOTIFICATION ========== */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 0.88rem;
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn 0.35s ease both;
    backdrop-filter: blur(10px);
}

.toast.removing {
    animation: toastSlideOut 0.3s ease both;
}

.toast-success { border-left: 3px solid var(--accent-green); }
.toast-error { border-left: 3px solid var(--accent-pink); }
.toast-warning { border-left: 3px solid var(--accent-orange); }
.toast-info { border-left: 3px solid var(--accent); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 0.9rem; padding: 2px 4px; border-radius: 4px;
    flex-shrink: 0;
}
.toast-close:hover { background: rgba(128,128,128,0.1); color: var(--text-primary); }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* ========== SKELETON LOADING ========== */
.skeleton-container {
    width: 80%;
    margin: 0 auto;
    padding: 0 clamp(12px, 2vw, 32px) 40px;
}

.skeleton-header {
    height: 24px;
    width: 200px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 16px;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.skeleton-card {
    height: 82px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-card:nth-child(2) { animation-delay: 0.1s; }
.skeleton-card:nth-child(3) { animation-delay: 0.2s; }
.skeleton-card:nth-child(4) { animation-delay: 0.3s; }
.skeleton-card:nth-child(5) { animation-delay: 0.4s; }
.skeleton-card:nth-child(6) { animation-delay: 0.5s; }

.skeleton-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

.skeleton-sidebar-item {
    height: 38px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 4px;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}
.skeleton-sidebar-item:nth-child(2) { animation-delay: 0.1s; }
.skeleton-sidebar-item:nth-child(3) { animation-delay: 0.2s; }
.skeleton-sidebar-item:nth-child(4) { animation-delay: 0.3s; }
.skeleton-sidebar-item:nth-child(5) { animation-delay: 0.4s; }

@keyframes skeletonPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* ========== WAVE RIPPLE ========== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.15);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    top: 50%;
    left: 50%;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.ripple:active::after {
    animation: rippleAnim 0.5s ease-out;
}

@keyframes rippleAnim {
    from { transform: scale(0); opacity: 0.4; }
    to { transform: scale(4); opacity: 0; }
}

/* ========== PROGRESS BAR ========== */
.top-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-purple), var(--accent-green));
    z-index: 10001;
    transition: width 0.3s ease;
    width: 0;
}

/* ========== RESPONSIVE FOR SKELETON ========== */
@media (max-width: 1023px) {
    .skeleton-sidebar { display: none; }
}