:root {
    color-scheme: light;
    --bg: #f3f4f6;
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --surface-border: rgba(15, 23, 42, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.2);
}

html {
    /* Reserve scrollbar gutter to prevent layout shift when scrollbar appears */
    scrollbar-gutter: stable;
}

* {
    box-sizing: border-box;
}

@font-face {
    font-family: 'Inter-fallback';
    src: local('Arial');
    ascent-override: 90.44%;
    descent-override: 22.52%;
    line-gap-override: 0%;
    size-adjust: 107.64%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', 'Inter-fallback', sans-serif;
    color: var(--text-main);
    background: linear-gradient(180deg, var(--bg), var(--bg-soft));
}


.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.site-nav-inner {
    width: min(1200px, 94vw);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
}

.site-brand {
    flex: 0 0 auto;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.03em;
}

.site-brand:hover {
    color: var(--accent-dark);
}

.site-nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
}

.site-nav-links a {
    display: block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.site-nav-links a:hover,
.site-nav-links a:focus-visible {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    outline: none;
}

.breadcrumbs {
    margin: -8px 4px 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.breadcrumbs ol {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.breadcrumbs li + li::before {
    content: ">";
    color: #94a3b8;
    font-size: 0.78rem;
}

.breadcrumbs a {
    color: inherit;
    text-decoration: none;
}

.breadcrumbs a:hover,
.breadcrumbs a:focus-visible {
    color: var(--accent-dark);
    text-decoration: underline;
    outline: none;
}

.breadcrumbs [aria-current="page"] {
    color: #475569;
    font-weight: 600;
}

.page-wrap {
    width: min(1200px, 94vw);
    margin: 0 auto;
    padding: 28px 0 24px;
}

.hero {
    padding: 4px 4px 18px;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--accent);
}

.hero h1 {
    margin: 8px 0 10px;
    font-size: clamp(2rem, 4vw, 3.2rem);
    letter-spacing: -0.03em;
}

.hero-subtitle {
    margin: 0;
    max-width: 780px;
    color: var(--text-muted);
    line-height: 1.55;
}

.hero-intro {
    margin: 10px 0 0;
    max-width: 860px;
    color: #475569;
    line-height: 1.6;
}

.hero-links {
    margin-top: 16px;
    font-size: 0.94rem;
}

.hero-links a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
}

.hero-links a:hover {
    text-decoration: underline;
}

.hero-links .hero-link-button {
    color: #ffffff;
}

.hero-links .hero-link-button:hover,
.hero-links .hero-link-button:focus-visible {
    color: #ffffff;
    text-decoration: none;
}

.hero-link-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 999px;
    border: 1px solid rgba(79, 70, 229, 0.35);
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    position: relative;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    transition: transform 0.2s ease;
}

/* Hover shadow via opacity transition — compositable, avoids painting */
.hero-link-button::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.hero-link-button:hover::before {
    opacity: 1;
}

.hero-link-button::after { content: ""; }

.hero-link-button:hover {
    transform: translateY(-2px);
}

.hero-link-button:active {
    transform: translateY(0);
}

.hero-link-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ring), 0 6px 16px rgba(37, 99, 235, 0.2);
}

.app-shell-link {
    margin-top: 14px;
    margin-bottom: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: 380px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

main > .app-shell {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid rgba(148, 163, 184, 0.26);
}

.card {
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--surface-border);
    background: var(--surface);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.control-panel {
    position: sticky;
    top: 18px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.15rem;
}

.panel-heading p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.form-grid {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.distribution-description {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.87rem;
    line-height: 1.4;
}

.inline-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

select,
input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid #dbe3f1;
    background: #fff;
    font-size: 0.94rem;
    color: var(--text-main);
    padding: 11px 13px;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring);
}

.calculate-btn {
    margin-top: 2px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 12px 20px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    transition: transform 0.2s ease;
}

.calculate-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.28);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.calculate-btn:hover::before {
    opacity: 1;
}

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

.wide-textarea {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    border: 1px solid #dbe3f1;
    border-radius: 12px;
    font: inherit;
    resize: vertical;
}

.wide-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    outline: none;
}

.content-table-wrap {
    margin: 18px 0;
    overflow-x: auto;
}

.content-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    background: #fff;
    border: 1px solid rgba(79, 70, 229, 0.16);
    border-radius: 12px;
    overflow: hidden;
}

.content-table th,
.content-table td {
    padding: 10px 12px;
    border: 1px solid rgba(79, 70, 229, 0.14);
    text-align: left;
    vertical-align: top;
}

.content-table th {
    color: #1e1b4b;
    background: rgba(79, 70, 229, 0.10);
    font-weight: 700;
}

.result-table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(79, 70, 229, 0.16);
    background: #ffffff;
}

.result-box table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.94rem;
    font-weight: 500;
    line-height: 1.55;
    background: #fff;
}

.result-box th,
.result-box td {
    padding: 11px 13px;
    border-bottom: 1px solid rgba(79, 70, 229, 0.14);
    text-align: left;
    white-space: nowrap;
}

.result-box th + th,
.result-box td + td {
    border-left: 1px solid rgba(79, 70, 229, 0.10);
}

.result-box tbody tr:last-child td {
    border-bottom: 0;
}

.result-box th {
    color: #1e1b4b;
    background: rgba(79, 70, 229, 0.10);
    font-weight: 700;
}

.result-box {
    margin-top: 18px;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.75 !important;
    letter-spacing: 0.005em;
    border-radius: 16px;
    padding: 16px 18px;
    color: #312e81;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.10), rgba(79, 70, 229, 0.055));
    border: 1px solid rgba(79, 70, 229, 0.18);
    box-shadow: inset 4px 0 0 rgba(79, 70, 229, 0.28), 0 12px 28px rgba(79, 70, 229, 0.06);
    min-height: 3.35rem;
    white-space: pre-line;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums lining-nums;
}

.result-box p {
    margin: 0;
}

.result-box p + p {
    margin-top: 12px;
}

.result-box strong {
    color: #1e1b4b;
    font-weight: 800;
}


.result-box br + strong,
.result-box br + span,
.result-box br + em {
    display: inline-block;
    margin-top: 4px;
}

.chart-wrap {
    margin-top: 14px;
    min-height: 440px;
    contain: layout;
}

canvas {
    width: 100% !important;
    height: 440px !important;
}

.sample-size-panel {
    margin-top: 20px;
}

.sample-grid {
    margin-top: 16px;
}

#sampleSizeResult {
    margin-top: 14px;
}

.formula-box {
    margin-top: 10px;
    border-radius: 12px;
    padding: 12px 14px;
    color: #1e293b;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.35);
    font-size: 0.93rem;
    line-height: 1.5;
    min-height: 3.5rem;
    contain: layout;
}

.formula-box code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
}

.content-card {
    margin-top: 22px;
    max-width: 100%;
}

.content-card h2 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

.content-card h3 {
    margin: 18px 0 8px;
    font-size: 1.08rem;
    color: #1e293b;
}

.content-card p,
.content-card li {
    font-size: 0.98rem;
    line-height: 1.75;
    color: #334155;
}

.content-card ul {
    margin: 0;
    padding-left: 18px;
}

.external-ref {
    margin-top: 16px;
    font-size: 0.88rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding-top: 10px;
}

.external-ref a {
    color: #4f46e5;
}

.distribution-links {
    list-style: none;
    padding-left: 0 !important;
    margin-top: 14px !important;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.distribution-links li {
    margin: 0;
}

.distribution-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.2;
    color: #312e81;
    position: relative;
    background: rgba(79, 70, 229, 0.12);
    border: 1px solid rgba(79, 70, 229, 0.26);
    transition: transform 0.2s ease, background 0.2s ease;
}

.distribution-links a::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 10px 18px rgba(79, 70, 229, 0.16);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.distribution-links a:hover::before {
    opacity: 1;
}

.distribution-links a:hover {
    background: rgba(79, 70, 229, 0.2);
    transform: translateY(-1px);
}


.tools-grid {
    list-style: none;
    padding: 0 !important;
    margin: 16px 0 0 !important;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.tools-grid li {
    margin: 0;
}

.tools-grid a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, 0.08);
    font-weight: 600;
    line-height: 1.3;
    transition: background 0.2s ease, transform 0.2s ease;
}

.tools-grid a:hover {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}


.distribution-tools-grid a {
    display: flex;
    align-items: center;
    gap: 10px;
}

.distribution-tools-grid a::before {
    content: "";
    width: 28px;
    height: 18px;
    flex: 0 0 28px;
    border-radius: 5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cpath d='M2 36 H62' stroke='%23cbd5e1' stroke-width='2'/%3E%3Cpath d='M4 35 C14 35 18 11 32 11 C46 11 50 35 60 35' fill='none' stroke='%232563eb' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.95;
}


.sample-size-tools-grid a,
.hypothesis-tools-grid a {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sample-size-tools-grid a::before,
.hypothesis-tools-grid a::before {
    content: "";
    width: 28px;
    height: 18px;
    flex: 0 0 28px;
    border-radius: 5px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.95;
}

.sample-size-tools-grid a::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Crect x='3' y='3' width='58' height='34' rx='6' fill='%23f8fafc' stroke='%23cbd5e1' stroke-width='2'/%3E%3Cline x1='16' y1='9' x2='16' y2='31' stroke='%232563eb' stroke-width='2'/%3E%3Cline x1='28' y1='9' x2='28' y2='31' stroke='%232563eb' stroke-width='2'/%3E%3Cline x1='40' y1='9' x2='40' y2='31' stroke='%232563eb' stroke-width='2'/%3E%3Cline x1='52' y1='9' x2='52' y2='31' stroke='%232563eb' stroke-width='2'/%3E%3C/svg%3E");
}

.hypothesis-tools-grid a::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cpath d='M2 36 H62' stroke='%23cbd5e1' stroke-width='2'/%3E%3Cpath d='M4 35 C14 35 18 11 32 11 C46 11 50 35 60 35' fill='none' stroke='%232563eb' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M46 35 C49 28 51 21 52 16 C54 22 56 29 60 35 Z' fill='%23ef4444' fill-opacity='0.75'/%3E%3C/svg%3E");
}

.formula-line {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.2);
    color: #312e81;
    font-weight: 600;
    overflow-wrap: anywhere;
    min-height: 2.5rem;
    contain: layout;
}

.learning-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.learning-grid .content-card {
    margin-top: 0;
}

.learning-grid .card {
    border-radius: 14px;
    box-shadow: none;
    border: 1px solid rgba(15, 23, 42, 0.06);
}

.faq-section article + article {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.26);
}

footer {
    text-align: center;
    padding: 28px 0 8px;
    color: #94a3b8;
    font-size: 0.84rem;
}

.legal-page {
    max-width: 880px;
    margin: 0 auto;
}

.legal-content {
    line-height: 1.7;
}

.legal-content h1 {
    margin-top: 0;
    margin-bottom: 18px;
}

.legal-content h2 {
    margin-top: 28px;
    margin-bottom: 10px;
}

.legal-content ul {
    padding-left: 20px;
}

.legal-footer {
    padding-top: 18px;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .control-panel {
        position: static;
    }

    .learning-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tools-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {

    .site-nav-inner {
        align-items: flex-start !important;
        flex-direction: column !important;
    }

    .site-nav-links {
        justify-content: flex-start !important;
    }

    .site-nav-links a {
        padding: 6px 10px !important;
        font-size: 0.82rem !important;
    }

    .page-wrap {
        width: min(100%, 96vw);
        padding-top: 20px;
    }

    .card {
        padding: 18px;
    }

    .inline-inputs {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .hero-links {
        line-height: 1.6;
    }

    canvas {
        height: 350px !important;
    }

    .chart-wrap {
        min-height: 350px;
    }

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

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

.pillar-guide {
    border-top: 3px solid #0ea5e9;
}

.example-card {
    border-left: 4px solid #22c55e;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08), #ffffff 38%);
}

.decision-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.decision-grid > div {
    padding: 16px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    background: #f8fafc;
}

.decision-grid h3 {
    margin-top: 0;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 8px;
}

.table-action-btn {
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 999px;
    background: #ffffff;
    color: #1e40af;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 7px 14px;
    transition: background 0.15s, color 0.15s;
}

.table-action-btn:hover,
.table-action-btn:focus-visible {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.5);
    color: #1d4ed8;
    outline: none;
}

.table-action-btn:focus-visible {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

.table-action-btn-print {
    border-color: rgba(15, 23, 42, 0.18);
    color: #334155;
}

@media print {
    .table-actions {
        display: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Global Search (search.js)
   ══════════════════════════════════════════════════════════════════════ */

/* ── Search button in nav ── */
.search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.04);
    color: #64748b;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.search-btn:hover {
    background: rgba(37, 99, 235, 0.07);
    border-color: rgba(37, 99, 235, 0.3);
    color: #2563eb;
}

.search-btn-kbd {
    padding: 1px 5px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.04);
    font-size: 0.7rem;
    font-family: inherit;
    color: #94a3b8;
}

/* ── Search modal backdrop ── */
body.search-open {
    overflow: hidden;
}

#search-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 16px 16px;
}

#search-modal.is-open {
    display: flex;
}

.search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ── Search dialog box ── */
.search-box {
    position: relative;
    width: 100%;
    max-width: 640px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.22), 0 4px 14px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    flex-shrink: 0;
    color: #94a3b8;
}

.search-icon {
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.05rem;
    font-family: inherit;
    color: #0f172a;
    background: transparent;
    min-width: 0;
}

#search-input::placeholder {
    color: #94a3b8;
}

.search-esc-hint {
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.04);
    font-size: 0.7rem;
    font-family: inherit;
    color: #94a3b8;
}

/* ── Results area ── */
.search-results {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.search-group {
    padding: 8px 0 4px;
}

.search-group + .search-group {
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.search-group-label {
    padding: 4px 18px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #94a3b8;
}

.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    text-decoration: none;
    color: #0f172a;
    transition: background 0.1s;
    cursor: pointer;
}

.search-item:hover,
.search-item.is-active {
    background: rgba(37, 99, 235, 0.06);
}

.search-item--section {
    gap: 12px;
}

.search-item-icon {
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
}

.search-item-name {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 600;
    min-width: 0;
}

.search-item-desc {
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: nowrap;
}

.search-item-cat {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.search-item mark {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
    border-radius: 2px;
    font-style: normal;
}

.search-empty {
    padding: 28px 18px;
    color: #64748b;
    text-align: center;
    font-size: 0.9rem;
}

.search-more {
    padding: 8px 18px 10px;
    font-size: 0.78rem;
    color: #94a3b8;
    font-style: italic;
}

/* ── Footer bar ── */
.search-help-bar {
    display: flex;
    gap: 16px;
    padding: 7px 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    font-size: 0.72rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.search-help-bar kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-family: inherit;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    #search-modal {
        padding: 6vh 8px 8px;
        align-items: flex-start;
    }

    .search-box {
        max-height: 80vh;
        border-radius: 14px;
    }

    .search-btn-kbd,
    .search-btn-text {
        display: none;
    }

    .search-btn {
        padding: 6px 8px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   Wizard — ¿Qué herramienta necesito? (wizard.js)
   ══════════════════════════════════════════════════════════════════════ */

.wz-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(79, 70, 229, 0.28);
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.06);
    color: #4338ca;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.wz-nav-btn:hover {
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(79, 70, 229, 0.45);
    color: #3730a3;
}

/* ── Modal ── */
#wizard-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 16px 16px;
}

#wizard-modal.is-open {
    display: flex;
}

.wz-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.wz-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 600px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.22), 0 4px 14px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

/* ── Header ── */
.wz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 13px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
    flex-shrink: 0;
}

.wz-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #4338ca;
}

.wz-close {
    border: none;
    background: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}

.wz-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
}

/* ── Breadcrumb trail ── */
.wz-trail {
    padding: 8px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    background: rgba(79, 70, 229, 0.03);
    flex-shrink: 0;
}

.wz-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #64748b;
}

.wz-breadcrumb span {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wz-bc-sep {
    color: #cbd5e1;
    max-width: none !important;
}

/* ── Body ── */
.wz-body {
    overflow-y: auto;
    flex: 1;
    padding: 18px 18px 4px;
}

.wz-question {
    margin: 0 0 14px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
    line-height: 1.35;
}

/* ── Options ── */
.wz-opts {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-bottom: 14px;
}

.wz-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 12px;
    background: #ffffff;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    font-family: inherit;
    width: 100%;
}

.wz-opt:hover {
    border-color: rgba(79, 70, 229, 0.35);
    background: rgba(79, 70, 229, 0.04);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}

.wz-opt-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(79, 70, 229, 0.08);
    color: #4338ca;
    font-size: 0.95rem;
    font-weight: 700;
}

.wz-opt-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.wz-opt-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #0f172a;
}

.wz-opt-desc {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.3;
}

.wz-opt-arrow {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 1rem;
    font-weight: 400;
}

.wz-opt-arrow--next {
    font-size: 1.2rem;
}

/* ── Footer ── */
.wz-footer {
    padding: 10px 18px 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    flex-shrink: 0;
}

.wz-back {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    font-family: inherit;
    color: #64748b;
    padding: 4px 0;
    transition: color 0.12s;
}

.wz-back:hover {
    color: #4338ca;
}

@media (max-width: 640px) {
    #wizard-modal {
        padding: 4vh 8px 8px;
        align-items: flex-start;
    }

    .wz-box {
        max-height: 88vh;
        border-radius: 14px;
    }

    .wz-nav-btn-text {
        display: none;
    }

    .wz-nav-btn {
        padding: 6px 8px;
    }
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.theme-btn:hover,
.theme-btn:focus-visible {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    outline: none;
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
html.dark-mode {
    color-scheme: dark;
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --surface: #1e293b;
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-dark: #2563eb;
    --ring: rgba(59, 130, 246, 0.3);
}

html.dark-mode body {
    background: var(--bg);
    color: var(--text-main);
}

html.dark-mode .site-header {
    background: #1e293b;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .site-nav {
    background: rgba(15, 23, 42, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .site-nav-links a {
    color: #e2e8f0;
}

html.dark-mode .site-nav-links a:hover,
html.dark-mode .site-nav-links a:focus-visible {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

html.dark-mode .theme-btn {
    color: #94a3b8;
}

html.dark-mode .theme-btn:hover,
html.dark-mode .theme-btn:focus-visible {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

html.dark-mode .search-btn,
html.dark-mode .wz-nav-btn {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.3);
}

html.dark-mode .search-btn:hover,
html.dark-mode .wz-nav-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
}

html.dark-mode .tool-card,
html.dark-mode .card {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

html.dark-mode .tool-card:hover,
html.dark-mode .card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.15), 0 4px 16px rgba(0, 0, 0, 0.4);
}

html.dark-mode .tool-card h3,
html.dark-mode .card h3,
html.dark-mode .tool-card .card-title {
    color: #e2e8f0;
}

html.dark-mode .tool-card p,
html.dark-mode .card p,
html.dark-mode .tool-card .card-desc {
    color: #94a3b8;
}

html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode h4 {
    color: #e2e8f0;
}

html.dark-mode p,
html.dark-mode li {
    color: #cbd5e1;
}

html.dark-mode .hero-intro,
html.dark-mode .section-intro,
html.dark-mode .page-intro {
    color: #94a3b8;
}

html.dark-mode .category-section,
html.dark-mode .section-block {
    background: transparent;
}

html.dark-mode .section-header h2,
html.dark-mode .cat-title {
    color: #e2e8f0;
}

html.dark-mode .breadcrumbs,
html.dark-mode .breadcrumbs a,
html.dark-mode .breadcrumbs li {
    color: #94a3b8;
}

html.dark-mode .breadcrumbs a:hover {
    color: var(--accent);
}

html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

html.dark-mode input:focus,
html.dark-mode select:focus,
html.dark-mode textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

html.dark-mode label {
    color: #cbd5e1;
}

html.dark-mode .result-box,
html.dark-mode .output-box,
html.dark-mode .result-panel {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

html.dark-mode .formula-box {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

html.dark-mode .formula-line {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
}

html.dark-mode .related-tools,
html.dark-mode .related-section {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .related-tools a,
html.dark-mode .related-link {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #93c5fd;
}

html.dark-mode .related-tools a:hover,
html.dark-mode .related-link:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
}

html.dark-mode .site-footer {
    background: #1e293b;
    border-top-color: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

html.dark-mode .site-footer a {
    color: #93c5fd;
}

/* Search modal dark */
html.dark-mode #search-modal {
    background: rgba(0, 0, 0, 0.6);
}

html.dark-mode .search-box {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

html.dark-mode #search-input {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

html.dark-mode #search-input::placeholder {
    color: #64748b;
}

html.dark-mode .search-results {
    border-top-color: rgba(255, 255, 255, 0.06);
}

html.dark-mode .search-item {
    color: #e2e8f0;
}

html.dark-mode .search-item:hover,
html.dark-mode .search-item.active {
    background: rgba(59, 130, 246, 0.12);
}

html.dark-mode .search-item-name {
    color: #e2e8f0;
}

html.dark-mode .search-item-cat,
html.dark-mode .search-item-desc {
    color: #94a3b8;
}

html.dark-mode .search-section-title {
    color: #64748b;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* Wizard modal dark */
html.dark-mode #wizard-modal {
    background: rgba(0, 0, 0, 0.6);
}

html.dark-mode .wz-box {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

html.dark-mode .wz-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

html.dark-mode .wz-title {
    color: #e2e8f0;
}

html.dark-mode .wz-close {
    color: #94a3b8;
}

html.dark-mode .wz-close:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.08);
}

html.dark-mode .wz-question {
    color: #e2e8f0;
}

html.dark-mode .wz-opt {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

html.dark-mode .wz-opt:hover,
html.dark-mode .wz-opt:focus-visible {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.08);
}

html.dark-mode .wz-opt-icon {
    color: #93c5fd;
}

html.dark-mode .wz-opt-label {
    color: #e2e8f0;
}

html.dark-mode .wz-opt-desc {
    color: #94a3b8;
}

html.dark-mode .wz-back {
    color: #94a3b8;
}

html.dark-mode .wz-back:hover {
    color: #93c5fd;
}

html.dark-mode .wz-breadcrumb {
    color: #64748b;
}

html.dark-mode .wz-result-card {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.3);
}

html.dark-mode .wz-result-name {
    color: #93c5fd;
}

html.dark-mode .wz-result-desc {
    color: #94a3b8;
}

html.dark-mode .wz-result-link {
    background: var(--accent);
    color: #fff;
}

html.dark-mode .wz-result-link:hover {
    background: var(--accent-dark);
}

/* ══════════════════════════════════════════════════════════════════════
   Dark-mode overrides — hardcoded light colours across the site
   ══════════════════════════════════════════════════════════════════════ */

/* ── Global components (style_new.css) ── */
html.dark-mode .content-table {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .content-table th {
    color: #e2e8f0;
    background: rgba(99, 102, 241, 0.15);
}

html.dark-mode .result-table-wrap {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .result-box table {
    background: transparent;
}

html.dark-mode .tools-grid a {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .tools-grid a:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
}

html.dark-mode .decision-grid > div {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .example-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), #1e293b 38%);
}

html.dark-mode .table-action-btn {
    background: #1e293b;
    border-color: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

html.dark-mode .table-action-btn:hover,
html.dark-mode .table-action-btn:focus-visible {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
    color: #bfdbfe;
}

html.dark-mode .table-action-btn-print {
    border-color: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

/* ── Index page ── */
html.dark-mode .stats-strip {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .stat-label {
    color: #94a3b8;
}

html.dark-mode .intent-card {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .intent-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.3);
}

html.dark-mode .intent-card h3 {
    color: #e2e8f0;
}

html.dark-mode .intent-card p {
    color: #94a3b8;
}

/* ── FAQ items (index, simulaciones, etc.) ── */
html.dark-mode .faq-item {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .faq-item h3,
html.dark-mode details.faq-item summary {
    color: #e2e8f0;
}

html.dark-mode .faq-item p,
html.dark-mode details.faq-item p {
    color: #94a3b8;
}

html.dark-mode .faq-list li strong {
    color: #e2e8f0;
}

/* ── Tabla pages ── */
html.dark-mode .tab-btn {
    background: #1e293b;
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.12);
}

html.dark-mode .tab-btn:hover:not(.active) {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}

html.dark-mode .dist-table tbody td {
    color: #cbd5e1;
}

html.dark-mode .dist-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
}

/* ── A/B testing and power pages ── */
html.dark-mode .mode-tab,
html.dark-mode .sim-tab {
    background: #1e293b;
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.12);
}

html.dark-mode .mode-tab:hover,
html.dark-mode .sim-tab:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}

/* ── Simulation pages ── */
html.dark-mode .chart-panel h3,
html.dark-mode .chart-outer h3,
html.dark-mode .chart-card h3,
html.dark-mode .matrix-section h3 {
    color: #e2e8f0;
}

html.dark-mode .chart-card {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .chart-wrap {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .stats-table {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .stats-table th {
    color: #e2e8f0;
    background: rgba(99, 102, 241, 0.15);
}

html.dark-mode .stats-table td:first-child {
    color: #94a3b8;
}

html.dark-mode .stat-cell .stat-val {
    color: #e2e8f0;
}

html.dark-mode .legend-row,
html.dark-mode .legend-dots,
html.dark-mode .ci-legend {
    color: #94a3b8;
}

html.dark-mode .matrix-table th {
    color: #94a3b8;
    background: rgba(99, 102, 241, 0.12);
}

html.dark-mode .matrix-table input[type="text"] {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.15);
}

html.dark-mode .preset-tab {
    background: #1e293b;
    color: #94a3b8;
    border-color: rgba(255, 255, 255, 0.12);
}

html.dark-mode .preset-tab:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
}

html.dark-mode .slider-val {
    color: #e2e8f0;
}

html.dark-mode .traj-list {
    color: #94a3b8;
}

html.dark-mode .form-group label {
    color: #94a3b8;
}

html.dark-mode .form-group select,
html.dark-mode .form-group input[type="number"] {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.15);
}
