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

:root {
    --bg-start: #dfeeff;
    --bg-mid: #eef5ff;
    --bg-end: #f7faff;
    --text-primary: #243357;
    --text-secondary: #5f6e88;
    --text-muted: #7c8aa6;
    --card-bg: #ffffff;
    --card-border: #e3ecfa;
    --pill-bg: #f2f6ff;
    --pill-border: #dde7fb;
    --primary: #3a7bff;
    --primary-strong: #2564ff;
    --shadow-soft: 0 12px 26px rgba(44, 78, 132, 0.12);
    --shadow-hover: 0 18px 36px rgba(41, 78, 138, 0.2);
    --radius-lg: 18px;
    --modal-bg: #f2f4f8;
    --modal-card: #ffffff;
    --modal-alert-bg: #fff4d9;
    --modal-alert-border: #f6db9d;
    --modal-alert-text: #9a5a20;
    --modal-border: #e3eaf7;
    --modal-backdrop: rgba(20, 35, 60, 0.55);
    --glow-1: rgba(58, 123, 255, 0.18);
    --glow-2: rgba(111, 193, 255, 0.18);
    --glow-3: rgba(93, 160, 255, 0.14);
}

[data-theme="dark"] {
    --bg-start: #0f172a;
    --bg-mid: #111c34;
    --bg-end: #0b1326;
    --text-primary: #e2e8f0;
    --text-secondary: #a1acc3;
    --text-muted: #7b86a0;
    --card-bg: #141f35;
    --card-border: #223254;
    --pill-bg: #1c2a45;
    --pill-border: #26395e;
    --primary: #4f83ff;
    --primary-strong: #3d6dff;
    --shadow-soft: 0 12px 26px rgba(5, 12, 24, 0.35);
    --shadow-hover: 0 18px 36px rgba(8, 18, 38, 0.45);
    --modal-bg: #101a2c;
    --modal-card: #16223a;
    --modal-alert-bg: #2a1f12;
    --modal-alert-border: #5b3b1c;
    --modal-alert-text: #f2c28b;
    --modal-border: #223254;
    --modal-backdrop: rgba(5, 10, 20, 0.7);
    --glow-1: rgba(79, 131, 255, 0.22);
    --glow-2: rgba(75, 126, 255, 0.14);
    --glow-3: rgba(64, 103, 255, 0.1);
}

body {
    font-family: "Manrope", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-mid) 45%, var(--bg-end) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

body.modal-open {
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 15%, var(--glow-1), transparent 45%),
        radial-gradient(circle at 85% 10%, var(--glow-2), transparent 45%),
        radial-gradient(circle at 60% 85%, var(--glow-3), transparent 50%);
    pointer-events: none;
    z-index: -1;
}

body.modal-open .container {
    filter: blur(6px);
    transform: scale(0.995);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--pill-border);
    background: var(--card-bg);
    box-shadow: 0 10px 20px rgba(48, 82, 142, 0.16);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 1000;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 22px rgba(48, 82, 142, 0.2);
}

.theme-icon {
    font-size: 1.2rem;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.theme-icon.sun {
    display: none;
}

.theme-icon.moon {
    display: block;
}

[data-theme="dark"] .theme-icon.sun {
    display: block;
}

[data-theme="dark"] .theme-icon.moon {
    display: none;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 52px 24px 64px;
}

.header {
    text-align: center;
    margin-bottom: 24px;
}

.main-title {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    margin-top: 12px;
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

.category-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 26px auto 38px;
}

.category-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--pill-bg);
    border: 1px solid var(--pill-border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(49, 83, 143, 0.12);
    transition: all 0.2s ease;
}

.category-btn:hover {
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.category-btn.active {
    background: linear-gradient(135deg, var(--primary), #5aa3ff);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 12px 22px rgba(52, 109, 216, 0.35);
}

.category-btn .count {
    font-weight: 500;
    opacity: 0.8;
}

.tool-grid {
    --card-min: 240px;
    --grid-gap: 18px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--card-min), 1fr));
    gap: var(--grid-gap);
}

.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-height: 285px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--card-border));
    box-shadow: var(--shadow-hover);
}

.card-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    margin-bottom: 12px;
}

.tool-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: var(--modal-card);
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 16px rgba(46, 78, 136, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-icon span {
    display: none;
}

.tool-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    border-radius: 12px;
    background: #ffffff;
    padding: 6px;
}

.tool-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.tool-type {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tool-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 8px 0 12px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.tag {
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
    color: color-mix(in srgb, var(--primary) 88%, #3a68d9);
    font-size: 0.72rem;
    font-weight: 600;
}

.tag.hot {
    background: #ffecec;
    border-color: #ffd2d2;
    color: #e45454;
}

.tag.new {
    background: #fff4dd;
    border-color: #ffe3b1;
    color: #d5811f;
}

.tag.china {
    background: #ffecec;
    border-color: #ffd2d2;
    color: #e45454;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    margin-top: auto;
    border-top: 1px dashed var(--card-border);
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
}

.visit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #5aa3ff);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 10px 18px rgba(55, 112, 228, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.visit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(55, 112, 228, 0.36);
}

.footer {
    text-align: center;
    margin-top: 48px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.jump-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 2000;
}

.jump-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.jump-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(10px);
}

.jump-dialog {
    position: relative;
    width: min(420px, 92vw);
    background: var(--modal-bg);
    border-radius: 22px;
    padding: 26px 26px 22px;
    box-shadow: 0 30px 60px rgba(15, 30, 60, 0.35);
    text-align: center;
    z-index: 1;
}

.jump-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--modal-card);
    border: 1px solid var(--modal-border);
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    box-shadow: 0 10px 18px rgba(40, 64, 110, 0.2);
}

.jump-icon-img {
    width: 70%;
    height: 70%;
    object-fit: contain;
    border-radius: 12px;
    background: #ffffff;
    padding: 6px;
}

.jump-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.jump-card {
    background: var(--modal-card);
    border-radius: 16px;
    padding: 14px 16px;
    border: 1px solid var(--modal-border);
    margin-bottom: 16px;
}

.jump-name {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.jump-url {
    font-size: 0.85rem;
    color: var(--text-muted);
    word-break: break-all;
}

.jump-alert {
    background: var(--modal-alert-bg);
    border: 1px solid var(--modal-alert-border);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    margin-bottom: 18px;
    color: var(--modal-alert-text);
}

.jump-alert-title {
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.jump-alert-title::before {
    content: "⚠️";
}

.jump-alert-list {
    list-style: disc;
    padding-left: 18px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.jump-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.jump-btn {
    border: 1px solid var(--modal-border);
    background: var(--modal-card);
    color: var(--text-secondary);
    padding: 8px 20px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jump-btn:hover {
    transform: translateY(-1px);
}

.jump-btn.confirm {
    border: none;
    background: linear-gradient(135deg, var(--primary), #5aa3ff);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(55, 112, 228, 0.35);
}

.loading,
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    .container {
        padding: 44px 18px 56px;
    }

    .main-title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .category-btn {
        padding: 9px 16px;
    }
}

@media (max-width: 600px) {
    .theme-toggle {
        top: 12px;
        right: 12px;
    }

    .main-title {
        font-size: 1.7rem;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .category-btn .count {
        display: none;
    }
}
