@import url('gcss.css');
@import url('all.min.css');

/* ===== Design Tokens ===== */
:root {
    /* Brand */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --primary-glow: rgba(99, 102, 241, 0.15);

    /* Accent per category */
    --accent: #8b5cf6;

    /* Neutrals */
    --bg: #ffffff;
    --bg-soft: #f9fafb;
    --bg-mute: #f3f4f6;
    --bg-card: #ffffff;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Component backgrounds */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --nav-bg: #ffffff;
    --input-bg: #ffffff;
    --overlay-bg: rgba(15, 23, 42, 0.5);

    /* Shadows (layered, soft) */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    --shadow-glow: 0 0 40px var(--primary-glow);

    /* Radius */
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Motion */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --header-h: 64px;
    --nav-h: 48px;
    --max-w: 1280px;
}

/* ===== Dark Theme (user explicitly selected dark) ===== */
/* 顺序：auto @media 在前，显式 [data-theme="dark"] 在后，确保用户选择覆盖系统偏好 */
/* 同时添加 html[data-theme="dark"] 以兼容 iOS Safari / 老版移动端浏览器的属性匹配 */
html[data-theme="dark"],
:root[data-theme="dark"],
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.12);
    --primary-glow: rgba(99, 102, 241, 0.25);
    --accent: #a78bfa;

    --bg: #0f172a;
    --bg-soft: #1e293b;
    --bg-mute: #334155;
    --bg-card: #1e293b;

    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border: #334155;
    --border-light: #1e293b;

    --glass-bg: rgba(15, 23, 42, 0.72);
    --nav-bg: #1e293b;
    --input-bg: #0f172a;
    --overlay-bg: rgba(0, 0, 0, 0.6);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 40px var(--primary-glow);
}

/* ===== Light Theme (user explicitly selected light, even when system is dark) ===== */
/* iOS 关键修复：当用户显式切换到亮色（移除 data-theme 且设置 data-theme="light"）时，强制亮色变量 */
html[data-theme="light"],
:root[data-theme="light"] {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --accent: #8b5cf6;

    --bg: #ffffff;
    --bg-soft: #f9fafb;
    --bg-mute: #f3f4f6;
    --bg-card: #ffffff;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --glass-bg: rgba(255, 255, 255, 0.72);
    --nav-bg: #ffffff;
    --input-bg: #ffffff;
    --overlay-bg: rgba(15, 23, 42, 0.5);

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    --shadow-glow: 0 0 40px var(--primary-glow);
}

/* Auto dark mode (respects system preference, only when NO explicit theme set) */
/* 注意：此 @media 必须放在 [data-theme="dark"] / [data-theme="light"] 之前
   但为了兼容 iOS，在下方再次以 html[data-theme="dark"] 形式覆盖 */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]):not([data-theme-set]),
    :root:not([data-theme]):not([data-theme-set]) {
        --primary: #818cf8;
        --primary-dark: #6366f1;
        --primary-light: rgba(99, 102, 241, 0.12);
        --primary-glow: rgba(99, 102, 241, 0.25);
        --accent: #a78bfa;

        --bg: #0f172a;
        --bg-soft: #1e293b;
        --bg-mute: #334155;
        --bg-card: #1e293b;

        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;

        --border: #334155;
        --border-light: #1e293b;

        --glass-bg: rgba(15, 23, 42, 0.72);
        --nav-bg: #1e293b;
        --input-bg: #0f172a;
        --overlay-bg: rgba(0, 0, 0, 0.6);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.35);
        --shadow-glow: 0 0 40px var(--primary-glow);
    }
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}

a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
input { font-family: inherit; }

::selection { background: var(--primary-light); color: var(--primary-dark); }

/* ===== Layout ===== */
.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 0px;
}

/* 全宽容器：Header / Nav / Mega Menu / Breadcrumb / Tool Page / Footer / Related Tools */
.site-header > .container,
.main-nav > .container,
.mega-menu > .container,
.breadcrumb > .container,
.tool-page,
.site-footer > .container,
.related-tools > .container {
    max-width: 100%;
    padding-left: clamp(24px, 3vw, 64px);
    padding-right: clamp(24px, 3vw, 64px);
}

/* ===== Header (Glassmorphism) ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--glass-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-light);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 100%;
}

.logo {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo::before {
    content: '';
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: url("favicon.ico") center / contain no-repeat;
    display: inline-block;
    flex-shrink: 0;
}

.logo span {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0;
}

/* Search */
.search-box {
    flex: 1;
    min-width: 0;
    max-width: none;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    background: var(--bg-soft);
    color: var(--text);
    transition: all var(--transition);
    outline: none;
}

.search-box input::placeholder { color: var(--text-muted); }

.search-box input:focus {
    border-color: var(--primary);
    background: var(--input-bg);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.search-box .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Buttons */
.header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
    padding: 8px 18px;
    border: none;
    white-space: nowrap;
}

.btn--outline {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
}
.btn--outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ===== Main Nav with Mega Menu ===== */
.main-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: var(--header-h);
    z-index: 90;
}

.nav-list {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 0;
    -ms-overflow-style: none;
}
.nav-list::-webkit-scrollbar { display: none; }

.nav-item {
    flex-shrink: 0;
    position: static;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition);
    cursor: pointer;
}

.nav-link:hover,
.nav-item.mega-open .nav-link,
.nav-item.open .nav-link {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link i { font-size: 0.85rem; opacity: 0.8; }
.nav-item.mega-open .nav-link i,
.nav-item.open .nav-link i { opacity: 1; }

/* 桌面端：导航项均布撑满全宽 */
@media (min-width: 769px) {
    .nav-list {
        gap: 0;
        overflow-x: visible;
        justify-content: stretch;
    }
    .nav-item {
        flex: 1;
        text-align: center;
    }
    .nav-link {
        width: 100%;
        justify-content: center;
        border-radius: var(--radius);
    }
}

/* Mega Dropdown */
.mega-menu {
    position: fixed;
    top: calc(var(--header-h) + var(--nav-h));
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 89;
    max-height: calc(100vh - var(--header-h) - var(--nav-h) - 24px);
    overflow-y: auto;
}

/* 透明桥接：消除导航与弹窗之间的 hover 间隙 */
.mega-menu::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
}

/* JS 控制 .mega-open（桌面端 hover）和 .open（移动端 click） */
.nav-item.mega-open .mega-menu,
.nav-item.open .mega-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.mega-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 20px 0 12px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 12px;
}

.mega-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.mega-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.mega-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2px;
    padding-bottom: 20px;
}

.mega-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.mega-item:hover {
    background: color-mix(in srgb, var(--cat, var(--primary)) 8%, transparent);
    color: var(--cat, var(--primary));
}

.mega-item i {
    width: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--cat, var(--primary));
    opacity: 0.7;
    transition: opacity var(--transition);
}

.mega-item:hover i { opacity: 1; }

.mega-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Main ===== */
main { min-height: calc(100vh - var(--header-h)); }

/* ===== Autocomplete Dropdown ===== */
.ac-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    max-height: 420px;
    overflow-y: auto;
    padding: 6px;
    animation: acFadeIn 0.15s ease;
}

@@keyframes acFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    transition: background 0.1s ease;
    cursor: pointer;
}

.ac-item.active,
.ac-item:hover {
    background: var(--bg-soft);
}

.ac-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: var(--bg-mute);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ac-name {
    flex: 1;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ac-name mark {
    background: transparent;
    color: var(--primary);
    font-weight: 700;
}

.ac-cat {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-mute);
    flex-shrink: 0;
    white-space: nowrap;
}

.ac-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-secondary); transition: color var(--transition); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 8px; color: var(--text-muted); opacity: 0.5; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ===== Tool Page ===== */
.tool-page {
    padding-top: 32px;
    padding-bottom: 32px;
}

/* ===== Related Tools (底部同类推荐) ===== */
.related-tools {
    --cat-color: #6366f1;
    background: var(--bg-soft);
    border-top: 1px solid var(--border-light);
    padding: 40px 0 56px;
}

.related-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.related-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.related-bar {
    width: 4px;
    height: 22px;
    border-radius: 2px;
    flex-shrink: 0;
}

.related-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.related-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 3px 10px;
    background: var(--bg-mute);
    border-radius: var(--radius-full);
}

.related-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--cat-color);
    transition: gap var(--transition);
}

.related-more:hover { gap: 10px; }

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.related-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    box-shadow: var(--shadow-xs);
}

.related-item:hover {
    border-color: var(--cat-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.related-item:hover .related-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--cat-color);
}

.related-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-mute);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.related-name {
    flex: 1;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: all var(--transition);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .related-grid {
        grid-template-columns: 1fr;
    }
}

.tool-card-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 40px 32px;
    margin-bottom: 24px;
}

.tool-placeholder { text-align: center; padding: 60px 20px; }

.tool-placeholder .ph-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border-radius: var(--radius-lg);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.tool-placeholder h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.tool-placeholder p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 24px; }

.tool-placeholder .badge-dev {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.tool-placeholder .badge-dev::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 2s ease-in-out infinite;
}

@@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Footer ===== */
.site-footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--border-light);
    padding: 32px 0;
    margin-top: 64px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { transition: color var(--transition); }
.footer-links a:hover { color: var(--primary); }

/* ===== Wide Screen (≥1440px) ===== */
@media (min-width: 1440px) {
    .header-inner { gap: 40px; }
    .mega-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .mega-item { padding: 10px 16px; }
}

@media (min-width: 1920px) {
    .header-inner { gap: 56px; }
    .mega-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --header-h: 56px; }
    .container { padding: 0 16px; }
    .header-inner { gap: 12px; }
    .search-box { order: 3; max-width: 100%; flex-basis: 100%; }
    .logo { font-size: 1.1rem; }
    .logo span { display: none; }
    .main-nav { top: var(--header-h); }
    .nav-link { padding: 7px 12px; font-size: 0.8rem; }

    /* Mobile: mega menu click toggle */
    .mega-menu {
        position: fixed;
        top: calc(var(--header-h) + var(--nav-h));
        max-height: 60vh;
    }
    /* 移动端禁用 hover 打开，仅用 click (.open) */
    .nav-item.mega-open .mega-menu {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px);
    }
    .nav-item.open .mega-menu {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateY(0) !important;
    }
    .mega-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .mega-item { padding: 8px 12px; font-size: 0.82rem; }

    .tool-card-box { padding: 24px 20px; }
    .footer-inner { flex-direction: column; text-align: center; }
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    font-size: 0.95rem;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.theme-toggle {
    /* iOS 点击高亮/触摸反馈 */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }

/* 暗色图标（用户显式设置 data-theme="dark"）*/
html[data-theme="dark"] .theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }

html[data-theme="dark"] .theme-toggle .icon-moon,
:root[data-theme="dark"] .theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 亮色图标（用户显式设置 data-theme="light"）*/
html[data-theme="light"] .theme-toggle .icon-moon,
:root[data-theme="light"] .theme-toggle .icon-moon { display: inline-block; }

html[data-theme="light"] .theme-toggle .icon-sun,
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* Auto dark mode: system prefers dark AND no explicit theme set */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]):not([data-theme-set]) .theme-toggle .icon-sun,
    :root:not([data-theme]):not([data-theme-set]) .theme-toggle .icon-sun { display: inline-block; }

    html:not([data-theme]):not([data-theme-set]) .theme-toggle .icon-moon,
    :root:not([data-theme]):not([data-theme-set]) .theme-toggle .icon-moon { display: none; }
}

/* iOS/移动端：主题切换按钮激活态反馈（按下态） */
.theme-toggle:active {
    -webkit-transform: scale(0.96);
    transform: scale(0.96);
}

/* ===== Scrollbar (Light + Dark) ===== */
html[data-theme="dark"] ::-webkit-scrollbar,
:root[data-theme="dark"] ::-webkit-scrollbar,
[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track,
:root[data-theme="dark"] ::-webkit-scrollbar-track,
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-soft);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb,
:root[data-theme="dark"] ::-webkit-scrollbar-thumb,
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-soft);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* System dark auto: scrollbar dark when system prefers dark AND no explicit theme */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar,
    :root:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar {
        width: 10px;
        height: 10px;
    }
    html:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-track,
    :root:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-track {
        background: var(--bg-soft);
    }
    html:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-thumb,
    :root:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-thumb {
        background: var(--text-muted);
        border-radius: var(--radius-full);
        border: 2px solid var(--bg-soft);
    }
    html:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-thumb:hover,
    :root:not([data-theme]):not([data-theme-set]) ::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
    }
}

/* ===== Theme Transition ===== */
body, .site-header, .main-nav, .mega-menu, .ac-dropdown,
.tool-card-box, .related-item, .btn, .search-box input,
.breadcrumb, .site-footer, .tool-card, .theme-toggle {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
