:root {
    --ink: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #fff;
    --canvas: #f6f7f9;
    --primary: #1677ff;
    --primary-dark: #0f5fcc;
    --header: #111827;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { letter-spacing: 0; }
.site-header { background: var(--header); position: sticky; top: 0; z-index: 1030; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.site-header .navbar { min-height: 64px; }
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; color: #fff; background: var(--primary); }
.navbar-nav { gap: 4px; }
.navbar-dark .navbar-nav .nav-link { color: #cbd5e1; padding: 9px 12px; font-size: 14px; }
.navbar-dark .navbar-nav .nav-link:hover { color: #fff; }
.site-main { min-height: calc(100vh - 128px); }
.site-footer { padding: 22px 0; border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 14px; }

/* Homepage */
.home-hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 18% 0%, rgba(52, 211, 153, .22), transparent 34%),
        linear-gradient(135deg, #111827 0%, #163c35 55%, #116149 100%);
}
.home-hero::after {
    position: absolute;
    right: -90px;
    bottom: -170px;
    width: 420px;
    height: 420px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 50%;
    box-shadow: 0 0 0 58px rgba(255, 255, 255, .025), 0 0 0 116px rgba(255, 255, 255, .018);
    content: "";
}
.home-hero-inner {
    position: relative;
    z-index: 1;
    padding-top: 74px;
    padding-bottom: 58px;
    text-align: center;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 20px;
    padding: 7px 12px;
    color: #bbf7d0;
    background: rgba(17, 24, 39, .32);
    border: 1px solid rgba(187, 247, 208, .2);
    border-radius: 999px;
    font-size: 13px;
}
.home-hero h1 {
    margin: 0 0 12px;
    font-size: clamp(38px, 7vw, 62px);
    font-weight: 800;
    line-height: 1.12;
}
.hero-tagline {
    margin: 0 auto 30px;
    color: #d1fae5;
    font-size: 18px;
    line-height: 1.7;
}
.hero-search {
    position: relative;
    max-width: 680px;
    margin: 0 auto;
}
.hero-search-icon {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 20px;
    color: #667085;
    font-size: 20px;
    transform: translateY(-50%);
}
.hero-search .form-control {
    height: 60px;
    padding: 0 88px 0 54px;
    color: #172033;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .2);
    font-size: 16px;
}
.hero-search .form-control:focus {
    border-color: #34d399;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .2), 0 0 0 4px rgba(52, 211, 153, .2);
}
.hero-search .clear-search {
    right: 50px;
    color: #667085;
    opacity: 0;
    pointer-events: none;
}
.hero-search .clear-search.is-visible { opacity: 1; pointer-events: auto; }
.search-shortcut {
    position: absolute;
    top: 50%;
    right: 18px;
    display: grid;
    width: 25px;
    height: 25px;
    place-items: center;
    color: #667085;
    background: #f2f4f7;
    border: 1px solid #d0d5dd;
    border-radius: 5px;
    font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    transform: translateY(-50%);
}
.hero-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 26px;
    margin-top: 28px;
    color: #d1d5db;
    font-size: 14px;
}
.hero-stats span { display: inline-flex; align-items: center; gap: 6px; }
.hero-stats strong { color: #fff; font-size: 16px; }
.hero-stats i { color: #6ee7b7; }

.home-tools { padding: 46px 0 64px; }
.tools-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
.section-kicker {
    display: block;
    margin-bottom: 7px;
    color: #15835f;
    font-size: 13px;
    font-weight: 700;
}
.tools-heading h2 { margin: 0; font-size: 28px; font-weight: 750; }
.search-result { margin: 0; color: var(--muted); font-size: 14px; }
.category-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 42px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.category-nav a {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 7px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.category-nav a:hover { color: #13795b; background: #f0fdf7; border-color: #a7e8d0; }
.category-nav i { color: #16946a; font-size: 16px; }
.category-nav span {
    min-width: 21px;
    padding: 2px 5px;
    color: var(--muted);
    background: var(--canvas);
    border-radius: 4px;
    text-align: center;
    font-size: 11px;
}
.home-category { scroll-margin-top: 84px; margin-bottom: 44px; }
.home-category:last-of-type { margin-bottom: 0; }
.home-category .category-heading { position: relative; gap: 12px; margin-bottom: 18px; }
.category-icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    color: #13795b;
    background: #e7f8f1;
    border-radius: 7px;
    font-size: 19px;
}
.home-category .category-heading h2 { margin: 0 0 2px; font-size: 20px; }
.home-category .category-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.category-top-link {
    display: grid;
    width: 34px;
    height: 34px;
    margin-left: auto;
    place-items: center;
    color: var(--muted);
    border-radius: 6px;
    text-decoration: none;
}
.category-top-link:hover { color: #13795b; background: #e7f8f1; }
.home-tool-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    height: 100%;
    min-height: 132px;
    padding: 20px;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .02);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.home-tool-card:hover {
    color: inherit;
    border-color: #8fd9bf;
    box-shadow: 0 12px 28px rgba(16, 70, 53, .09);
    transform: translateY(-3px) scale(1.005);
}
.home-tool-card .tool-card-icon {
    width: 44px;
    height: 44px;
    margin-right: 14px;
    color: #13795b;
    background: #e7f8f1;
    font-size: 21px;
}
.tool-card-content { min-width: 0; padding-right: 14px; }
.tool-card-title { display: block; margin: 1px 0 7px; font-size: 16px; font-weight: 700; }
.tool-card-description { display: block; color: var(--muted); font-size: 13px; line-height: 1.6; }
.tool-card-arrow {
    position: absolute;
    right: 17px;
    bottom: 17px;
    color: #98a2b3;
    transition: color .18s ease, transform .18s ease;
}
.home-tool-card:hover .tool-card-arrow { color: #13795b; transform: translateX(3px); }
.empty-search[hidden], [data-tool-card][hidden], [data-category][hidden] { display: none !important; }
.empty-search {
    padding: 64px 20px;
    text-align: center;
    color: var(--muted);
}
.empty-search-icon {
    display: grid;
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    place-items: center;
    color: #13795b;
    background: #e7f8f1;
    border-radius: 50%;
    font-size: 25px;
}
.empty-search h2 { margin: 0 0 8px; color: var(--ink); font-size: 20px; }
.empty-search p { margin: 0 0 20px; }

.home-intro { padding: 58px 0 34px; text-align: center; background: #fff; border-bottom: 1px solid var(--line); }
.home-intro h1 { margin: 0 0 12px; font-size: clamp(30px, 5vw, 44px); font-weight: 750; }
.home-intro p { margin: 0 auto 26px; color: var(--muted); font-size: 17px; }
.tool-search { position: relative; max-width: 620px; margin: 0 auto; }
.tool-search i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #98a2b3; font-size: 19px; }
.tool-search input { height: 54px; padding: 0 48px; border: 1px solid #d0d5dd; border-radius: 8px; box-shadow: 0 4px 18px rgba(16,24,40,.06); }
.tool-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
.tool-search .clear-search { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: #98a2b3; display: none; }

.tools-content { padding: 36px 0 56px; }
.category-section { scroll-margin-top: 82px; margin-bottom: 38px; }
.category-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.category-heading i { color: var(--primary); font-size: 21px; }
.category-heading h2 { margin: 0; font-size: 21px; font-weight: 700; }
.tool-card { display: flex; height: 100%; min-height: 138px; padding: 22px; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.tool-card:hover { color: inherit; transform: translateY(-3px); border-color: #b9d6ff; box-shadow: 0 10px 26px rgba(16,24,40,.09); }
.tool-card-icon { flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px; margin-right: 16px; border-radius: 8px; color: var(--primary); background: #eaf3ff; font-size: 23px; }
.tool-card h3 { margin: 1px 0 8px; font-size: 17px; font-weight: 700; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.empty-search { display: none; padding: 50px 20px; text-align: center; color: var(--muted); }

.tool-page { padding: 34px 0 56px; }
.tool-breadcrumb { margin-bottom: 22px; color: var(--muted); font-size: 14px; }
.tool-breadcrumb a { color: var(--muted); text-decoration: none; }
.tool-breadcrumb a:hover { color: var(--primary); }
.tool-title-row { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.tool-title-icon { display: grid; place-items: center; flex: 0 0 auto; width: 52px; height: 52px; border-radius: 8px; color: var(--primary); background: #eaf3ff; font-size: 25px; }
.tool-title-row h1 { margin: 0 0 6px; font-size: 28px; font-weight: 750; }
.tool-title-row p { margin: 0; color: var(--muted); }
.tool-panel { padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 12px rgba(16,24,40,.035); }
.tool-panel + .tool-panel { margin-top: 20px; }
.tool-panel-title { margin: 0 0 16px; font-size: 17px; font-weight: 700; }
.form-label { font-weight: 600; font-size: 14px; }
.form-control, .form-select { border-color: #d0d5dd; border-radius: 6px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,119,255,.12); }
textarea.form-control { min-height: 220px; resize: vertical; line-height: 1.65; }
.output-area { background: #f9fafb; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn { border-radius: 6px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat-item { padding: 18px 12px; text-align: center; background: #f9fafb; border: 1px solid var(--line); border-radius: 7px; }
.stat-value { display: block; font-size: 25px; font-weight: 750; color: var(--primary); }
.stat-label { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.message-line { min-height: 24px; margin-top: 10px; font-size: 14px; }
.code-output { min-height: 220px; max-height: 500px; overflow: auto; margin: 0; padding: 16px; white-space: pre-wrap; word-break: break-word; background: #111827; color: #e5e7eb; border-radius: 6px; font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.json-key { color: #93c5fd; }.json-string { color: #86efac; }.json-number { color: #fcd34d; }.json-boolean { color: #c4b5fd; }.json-null { color: #fca5a5; }
.match-output { min-height: 180px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 6px; background: #f9fafb; line-height: 1.7; }
.match-output mark { padding: 1px 2px; background: #fde68a; border-radius: 2px; }
.color-preview { min-height: 150px; border: 1px solid var(--line); border-radius: 7px; background: #1677ff; }
.password-display { min-height: 62px; padding: 16px; overflow-wrap: anywhere; font: 700 21px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f9fafb; border: 1px solid var(--line); border-radius: 6px; }
.qr-result { display: grid; place-items: center; min-height: 280px; padding: 20px; border: 1px dashed #cbd5e1; border-radius: 7px; background: #f9fafb; }
.qr-result canvas, .qr-result img { max-width: 100%; height: auto; }

/* Homepage overrides placed after shared tool-list rules. */
.hero-search .clear-search {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 34px;
    height: 34px;
    padding: 0;
    color: #667085;
    background: transparent;
    border: 0;
    transform: translateY(-50%);
}
.home-category .category-heading .category-icon i { color: inherit; }
.home-tools .empty-search { display: block; }
.home-tools .empty-search[hidden] { display: none; }

@media (max-width: 767.98px) {
    .home-hero-inner { padding-top: 50px; padding-bottom: 42px; }
    .home-hero h1 { font-size: 40px; }
    .hero-tagline { max-width: 330px; font-size: 16px; }
    .hero-search .form-control { height: 56px; padding-right: 52px; font-size: 15px; }
    .search-shortcut { display: none; }
    .hero-search .clear-search { right: 10px; }
    .hero-stats { max-width: 360px; margin-right: auto; margin-left: auto; gap: 10px 18px; }
    .home-tools { padding-top: 34px; }
    .tools-heading { align-items: flex-end; }
    .tools-heading h2 { font-size: 23px; }
    .category-nav { margin-right: calc(var(--bs-gutter-x) * -.5); margin-bottom: 32px; }
    .home-category { margin-bottom: 36px; }
    .home-tool-card { min-height: 120px; }
    .home-intro { padding: 40px 0 28px; }
    .tools-content, .tool-page { padding-top: 26px; }
    .tool-panel { padding: 18px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-item:last-child { grid-column: span 2; }
    .tool-title-row h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .home-tool-card, .tool-card, .tool-card-arrow { transition: none; }
    .home-tool-card:hover, .tool-card:hover { transform: none; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #edf2f7;
        --muted: #a7b0bf;
        --line: #303949;
        --surface: #1b2330;
        --canvas: #121821;
        --header: #0b1017;
    }
    .site-footer, .home-intro { background: #151c26; }
    .category-nav a:hover { color: #6ee7b7; background: #18362e; border-color: #347663; }
    .category-nav span { background: #111720; }
    .category-icon,
    .home-tool-card .tool-card-icon,
    .empty-search-icon { color: #6ee7b7; background: #17352d; }
    .category-top-link:hover { color: #6ee7b7; background: #17352d; }
    .home-tool-card:hover { border-color: #347663; box-shadow: 0 12px 28px rgba(0, 0, 0, .22); }
    .home-tool-card:hover .tool-card-arrow { color: #6ee7b7; }
    .section-kicker { color: #6ee7b7; }
    .tool-panel { background: var(--surface); }
    .stat-item, .output-area, .match-output, .password-display, .qr-result { background: #151c26; }
    .form-control, .form-select {
        color: var(--ink);
        background-color: #151c26;
        border-color: #3a4556;
    }
    .form-control::placeholder { color: #7f8a9a; }
}
