:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;

    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .06);

    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--background);
    overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--space-4);
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 60px;
}
.brand {
    font-weight: 700;
    color: var(--text);
    font-size: 1.125rem;
}
.site-nav a {
    color: var(--text-muted);
    font-weight: 500;
}
.site-nav a:hover { color: var(--primary); text-decoration: none; }

.hero {
    padding: var(--space-12) 0;
    background: linear-gradient(180deg, var(--primary-light), var(--background));
}
.hero__title {
    font-size: clamp(1.75rem, 4vw + .5rem, 2.75rem);
    line-height: 1.15;
    margin: 0 0 var(--space-3);
    letter-spacing: -.02em;
}
.hero__lead {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 60ch;
    margin: 0;
}

.section { padding: var(--space-8) 0; }
.section__title {
    font-size: 1.35rem;
    margin: 0 0 var(--space-6);
    letter-spacing: -.01em;
}

.tool-grid,
.category-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

@media (min-width: 480px)  { .tool-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px)  { .tool-grid { grid-template-columns: repeat(3, 1fr); }
                             .category-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .tool-grid { grid-template-columns: repeat(4, 1fr); }
                             .category-grid { grid-template-columns: repeat(3, 1fr); } }

.tool-card,
.category-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tool-card:hover,
.category-card:hover,
.tool-card:focus-visible,
.category-card:focus-visible {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.tool-card__title {
    margin: 0 0 var(--space-2);
    font-size: 1.05rem;
    letter-spacing: -.01em;
}
.tool-card__desc {
    margin: 0;
    color: var(--text-muted);
    font-size: .9rem;
}

.breadcrumbs {
    font-size: .875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}
.breadcrumbs ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.breadcrumbs li + li::before {
    content: "/";
    margin-right: var(--space-2);
    color: var(--border);
}

.muted { color: var(--text-muted); }
.error-page { padding: var(--space-12) var(--space-4); text-align: center; }

.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-6) 0;
    margin-top: var(--space-12);
    color: var(--text-muted);
    font-size: .875rem;
}
.site-footer__inner p { margin: 0; }
/* ============================================================
   Stage 5 — Navbar search form
   ============================================================
   Appended block. All selectors are new or extend an existing
   rule with a non-conflicting property. Nothing above this line
   is affected.
   ============================================================ */

/* Allow the header inner flex container to wrap on small screens
   so the search form can drop to a second row. */
.site-header__inner {
    flex-wrap: wrap;
}

/* --- Search form (navbar) ---------------------------------- */
.navbar-search {
    flex: 1 1 220px;
    max-width: 420px;
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
}

.navbar-search input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.3;
}
.navbar-search input[type="search"]::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.navbar-search__submit {
    flex: 0 0 auto;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s ease, border-color .12s ease;
}
.navbar-search__submit:hover,
.navbar-search__submit:focus-visible {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    outline: none;
}

/* --- Screen-reader utility (site-wide) --------------------- */
.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;
}

/* --- Small screens: brand + nav on row 1, search on row 2 -- */
@media (max-width: 640px) {
    .navbar-search {
        flex-basis: 100%;
        max-width: none;
    }
    .brand              { order: 1; }
    .site-nav           { order: 2; }
    .navbar-search      { order: 3; }
}
/* ============================================================
   Stage 8, Phase F — Tool page on-page SEO layout
   ============================================================
   Appended block. All selectors are namespaced under .tool-page
   or use classes that do not previously exist. No rule above
   this line is affected.
   ============================================================ */

.tool-page {
    margin: 0;
}

.tool-page__header {
    margin-bottom: var(--space-6);
}

.tool-page__title {
    font-size: clamp(1.5rem, 4vw + .5rem, 2.15rem);
    line-height: 1.2;
    letter-spacing: -.015em;
    margin: 0 0 var(--space-3);
    color: var(--text);
    word-break: break-word;
}

.tool-lead {
    margin: 0;
    font-size: 1.02rem;
    color: var(--text-muted);
    max-width: 70ch;
    line-height: 1.55;
}

.tool-page__body {
    margin-bottom: var(--space-8);
}

.tool-page-section {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}

.tool-page-section__title {
    font-size: 1.3rem;
    margin: 0 0 var(--space-4);
    letter-spacing: -.01em;
    color: var(--text);
    line-height: 1.25;
}

.tool-instructions {
    color: var(--text);
    line-height: 1.7;
    max-width: 70ch;
}

.tool-instructions p {
    margin: 0 0 var(--space-2);
}

.tool-description {
    color: var(--text);
    line-height: 1.7;
    max-width: 70ch;
}

.tool-description p {
    margin: 0 0 var(--space-3);
}

.tool-faq {
    margin: 0;
    max-width: 70ch;
}

.tool-faq dt {
    font-weight: 600;
    color: var(--text);
    margin: var(--space-4) 0 var(--space-2);
    line-height: 1.4;
}

.tool-faq dt:first-child {
    margin-top: 0;
}

.tool-faq dd {
    margin: 0 0 var(--space-3);
    color: var(--text-muted);
    line-height: 1.7;
}

.tool-faq dd p {
    margin: 0 0 var(--space-2);
}

.tool-related {
    /* reserved for future modification — currently styled by .tool-page-section */
}

@media (max-width: 480px) {
    .tool-page-section {
        margin-top: var(--space-6);
        padding-top: var(--space-4);
    }
    .tool-page-section__title {
        font-size: 1.15rem;
    }
}
/* ============================================================
   Stage 8, Phase G — Homepage and category page additions
   ============================================================
   Appended block. All selectors are new or extend existing
   classes with non-conflicting properties. Nothing above this
   line is affected.
   ============================================================ */

/* --- Homepage hero stats and CTA --- */
.hero__stats {
    margin: var(--space-3) 0 0;
    color: var(--text-muted);
    font-size: .92rem;
}
.hero__stats strong {
    color: var(--primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.hero__actions {
    margin-top: var(--space-6);
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: .7rem 1.3rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: background-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.hero-cta:hover,
.hero-cta:focus-visible {
    background: var(--primary-dark);
    text-decoration: none;
    outline: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* --- Section header with inline "View all" link --- */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}
.section-header .section__title {
    margin: 0;
}
.section-link {
    color: var(--primary);
    font-weight: 500;
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
}
.section-link:hover,
.section-link:focus-visible {
    text-decoration: underline;
}

/* --- Category card internal structure (homepage + category sibling nav) --- */
.category-card {
    display: flex;
    flex-direction: column;
}

.category-card__title {
    margin: 0 0 var(--space-2);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text);
    line-height: 1.3;
}
.category-card__desc {
    margin: 0 0 var(--space-3);
    color: var(--text-muted);
    font-size: .85rem;
    line-height: 1.5;
}
.category-card__count {
    display: inline-block;
    margin-top: auto;
    padding-top: var(--space-2);
    font-size: .72rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
}

/* --- Category page header --- */
.category-header {
    margin-bottom: var(--space-6);
}
.category-header__title {
    margin: 0 0 var(--space-3);
    font-size: clamp(1.5rem, 4vw + .5rem, 2.15rem);
    line-height: 1.2;
    letter-spacing: -.015em;
    color: var(--text);
    word-break: break-word;
}
.category-header__desc {
    margin: 0 0 var(--space-3);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 70ch;
}
.category-header__meta {
    margin: 0;
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

/* --- Category tool list heading --- */
.category-tools-title {
    margin: var(--space-6) 0 var(--space-4);
    font-size: 1.15rem;
    color: var(--text);
    letter-spacing: -.01em;
    line-height: 1.3;
}

/* --- Sibling categories block --- */
.category-siblings {
    margin-top: var(--space-8);
    padding-top: var(--space-8);
    border-top: 1px solid var(--border);
}

/* --- Back link --- */
.category-back {
    margin: var(--space-8) 0 0;
    font-size: .9rem;
}
.category-back a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}
.category-back a:hover,
.category-back a:focus-visible {
    text-decoration: underline;
}

/* --- Mobile adjustments --- */
@media (max-width: 480px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    .section-link {
        white-space: normal;
    }
    .hero-cta {
        display: flex;
        width: 100%;
        justify-content: center;
    }
}