:root {
    --page-bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #fff1ee;
    --border: #e3e6ef;
    --text: #202330;
    --muted: #697082;
    --brand: #d14d3f;
    --brand-dark: #9f2f27;
    --blue: #4f46e5;
    --amber: #b7791f;
    --rose: #be123c;
    --shadow: 0 12px 30px rgba(32, 35, 48, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background: var(--page-bg);
    font-family: 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    line-height: 1.6;
    letter-spacing: 0;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(246, 247, 251, 0.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.header-inner,
.page-shell,
.site-footer {
    width: min(1120px, calc(100vw - 32px));
    margin: 0 auto;
}

.header-inner {
    display: grid;
    grid-template-columns: auto minmax(240px, 420px) auto;
    gap: 18px;
    align-items: center;
    min-height: 72px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--brand-dark);
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark {
    position: relative;
    width: 28px;
    height: 22px;
    border-radius: 6px;
    background: var(--brand);
    box-shadow: inset 0 -7px 0 rgba(255, 255, 255, 0.24);
}

.brand-mark::before {
    content: '';
    position: absolute;
    left: 7px;
    top: -6px;
    width: 14px;
    height: 8px;
    border: 3px solid #f0b26f;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-form::before {
    content: '⌕';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-52%);
    color: var(--muted);
    font-size: 1.05rem;
    pointer-events: none;
}

.search-form input {
    width: 100%;
    height: 40px;
    padding: 0 44px 0 38px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: 0;
}

.search-form input:focus {
    border-color: rgba(209, 77, 63, 0.68);
    box-shadow: 0 0 0 3px rgba(209, 77, 63, 0.13);
}

.search-form input::-webkit-search-cancel-button,
.search-form input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.search-form input::-ms-clear {
    display: none;
}

.icon-button {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.icon-button:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.top-nav {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.top-nav a {
    padding: 8px 12px;
    color: var(--muted);
    border-radius: 8px;
    font-size: 0.95rem;
    text-decoration: none;
}

.top-nav a:hover,
.top-nav a.active {
    color: var(--brand-dark);
    background: var(--surface-soft);
}

.page-shell {
    flex: 1 0 auto;
    padding: 28px 0 42px;
}

.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 0 18px;
}

.page-intro h1 {
    margin: 0;
    font-size: 2.15rem;
    line-height: 1.22;
}

.intro-text {
    max-width: 560px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.category-strip {
    margin: 10px 0 22px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tab {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.category-tab b {
    min-width: 20px;
    padding: 1px 6px;
    color: var(--brand-dark);
    background: var(--surface-soft);
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.5;
}

.category-tab:hover,
.category-tab.active {
    color: var(--brand-dark);
    background: var(--surface-soft);
    border-color: rgba(209, 77, 63, 0.24);
}

.tools-section {
    padding: 20px 0 0;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-head h2 {
    margin: 0;
    font-size: 1.45rem;
}

.result-count {
    margin: 0;
    color: var(--muted);
    white-space: nowrap;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.tool-card {
    min-height: 204px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(32, 35, 48, 0.06);
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.tool-card[data-tool-url] {
    cursor: pointer;
}

.tool-card:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: 0 14px 28px rgba(32, 35, 48, 0.1);
    transform: translateY(-2px);
}

.tool-card-head,
.tool-title-line,
.tool-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tool-icon {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: #ffffff;
    background: var(--accent);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 900;
    overflow: hidden;
    white-space: nowrap;
}

.favorite-button {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--amber);
    background: #fffaf0;
    border: 1px solid #f6d69b;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
}

.favorite-button:hover,
.favorite-button[aria-pressed='true'] {
    color: #ffffff;
    background: var(--amber);
    border-color: var(--amber);
}

.tool-card-body {
    padding: 13px 0 12px;
}

.tool-title-line {
    align-items: flex-start;
    margin-bottom: 7px;
}

.tool-title-line h3 {
    min-width: 0;
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.tool-title-line span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.82rem;
}

.tool-card-body p {
    display: -webkit-box;
    min-height: 44px;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.92rem;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tool-tags {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-tags span {
    max-width: 90px;
    padding: 2px 7px;
    overflow: hidden;
    color: color-mix(in srgb, var(--accent) 68%, #26352f);
    background: color-mix(in srgb, var(--accent) 10%, #ffffff);
    border-radius: 999px;
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    height: 32px;
    flex: 0 0 auto;
    color: var(--brand-dark);
    background: var(--surface-soft);
    border: 1px solid rgba(209, 77, 63, 0.18);
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
}

.tool-link:hover {
    color: #ffffff;
    background: var(--brand);
    border-color: var(--brand);
}

.tool-link[aria-disabled='true'] {
    color: #8a8f9d;
    background: #f5f6fa;
    border-color: #e3e6ef;
    cursor: default;
    pointer-events: none;
}

.empty-state {
    padding: 36px 16px;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    text-align: center;
}

.empty-state strong,
.empty-state span {
    display: block;
}

.empty-state strong {
    color: var(--text);
    margin-bottom: 4px;
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 22px 0 30px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    text-align: center;
}

.footer-records {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin: 0;
    line-height: 1.8;
}

.footer-records a {
    color: var(--muted);
    text-decoration: none;
}

.footer-records a:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}

.footer-separator {
    margin: 0 0.5rem;
    color: rgba(105, 112, 130, 0.45);
}

@media (max-width: 920px) {
    .header-inner {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px 0;
    }

    .top-nav {
        justify-content: flex-start;
    }

    .page-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .header-inner,
    .page-shell,
    .site-footer {
        width: min(100% - 24px, 1120px);
    }

    .page-shell {
        padding-top: 18px;
    }

    .page-intro h1 {
        font-size: 1.7rem;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .tool-card {
        min-height: 188px;
    }
}
