/* WhatIsMyError — single stylesheet, light + dark via prefers-color-scheme. */
:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #e11d48;
    --accent-2: #be123c;
    --accent-soft: #ffe4e6;
    --ok: #059669;
    --warn: #d97706;
    --info-bg: #eff6ff;
    --info: #1d4ed8;
    --code-bg: #0d1117;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --surface: #111827;
        --surface-2: #1e293b;
        --text: #e5e7eb;
        --muted: #94a3b8;
        --border: #263247;
        --accent: #fb7185;
        --accent-2: #f43f5e;
        --accent-soft: #3b1420;
        --info-bg: #102040;
        --info: #93c5fd;
        --shadow: none;
    }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .4em 0 .3em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .4em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
pre code { background: none; padding: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.section { padding: 28px 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 760px; }
.center.lead, .center .lead { margin-left: auto; margin-right: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 99; }
.hp { position: absolute !important; left: -9999px !important; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 62px; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-mark { background: var(--accent); color: #fff; border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; font-family: var(--mono); font-size: .9rem; }
.logo-text b { color: var(--accent); }
.header-search { flex: 1; max-width: 420px; position: relative; }
.header-search input { width: 100%; }
.main-nav { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.main-nav a { color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.main-nav a:hover, .main-nav a.active { background: var(--surface-2); text-decoration: none; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 1.2rem; }

/* Forms */
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
textarea { font-family: var(--mono); font-size: .9rem; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: .92rem; }
.stack { display: grid; gap: 12px; }
.inline-form { display: inline-block; margin: 0 6px 0 0; }
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-sm { padding: 5px 11px; font-size: .88rem; }
.main-nav .btn { color: var(--text); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius); margin: 14px 0; border: 1px solid var(--border); background: var(--surface); }
.alert-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.alert-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.alert-info { border-color: #bfdbfe; background: var(--info-bg); color: var(--info); }
@media (prefers-color-scheme: dark) {
    .alert-success { background: #052e22; color: #6ee7b7; border-color: #065f46; }
    .alert-error { background: #3a0d0d; color: #fca5a5; border-color: #7f1d1d; }
}

/* Hero */
.hero { background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%); padding: 56px 0 36px; text-align: center; border-bottom: 1px solid var(--border); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin-bottom: .1em; }
.hero .lead { margin: 0 auto 24px; }
.hero-search { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; position: relative; }
.hero-search input { font-size: 1.08rem; padding: 14px 16px; }
.hero-search.slim { margin: 12px 0 20px; max-width: 640px; }
.hero-search.slim input { font-size: 1rem; padding: 10px 12px; }
.hero-sub { margin-top: 14px; color: var(--muted); }
.flow { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 22px; color: var(--muted); font-size: .85rem; }
.flow span { background: var(--surface); border: 1px solid var(--border); padding: 2px 10px; border-radius: 99px; }

/* Autocomplete */
.suggest-box { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; text-align: left; overflow: hidden; }
.suggest-box a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.suggest-box a:last-child { border-bottom: 0; }
.suggest-box a:hover, .suggest-box a.active { background: var(--surface-2); text-decoration: none; }
.suggest-box small { color: var(--muted); margin-left: auto; }

/* Cards & grids */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.section-head h2, .section-head h1 { margin-bottom: .4em; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card-grid.three { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card, .panel, .result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card { color: var(--text); display: block; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card h3 { margin: .5em 0 .3em; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }
.card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel h2:first-child { margin-top: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.code-pill { font-family: var(--mono); font-weight: 700; background: var(--accent-soft); color: var(--accent-2); padding: 2px 9px; border-radius: 6px; font-size: .88rem; display: inline-block; }
.code-pill.big { font-size: 1.25rem; padding: 4px 14px; }
.code-pill.soft { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) { .code-pill { color: var(--accent); } }
.badge { font-size: .8rem; background: var(--surface-2); color: var(--muted); padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
a.badge:hover { text-decoration: none; color: var(--text); }
.badge-soft { background: transparent; }
.badge-pro { background: #7c3aed; color: #fff; border-color: #7c3aed; font-weight: 700; font-size: .7rem; letter-spacing: .03em; }
.chips, .signals, .samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.chip { font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 3px 10px; border-radius: 99px; cursor: default; font-family: inherit; }
a.chip, button.chip { cursor: pointer; }
a.chip:hover, button.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-platform { background: var(--info-bg); color: var(--info); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.cat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--text); display: grid; gap: 2px; }
.cat-card:hover { border-color: var(--accent); text-decoration: none; }
.cat-icon { font-size: 1.5rem; }
.cat-name { font-weight: 600; }
.cat-count { font-size: .82rem; color: var(--muted); }
.cat-list { display: grid; gap: 8px; }
.cat-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; color: var(--text); }
.cat-row small { display: block; }
.cat-row:hover { border-color: var(--accent); text-decoration: none; }
.cat-row.empty { opacity: .65; }

/* Tables */
.error-table, .compare-table, .admin-table, .kv { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.error-table th, .error-table td, .compare-table th, .compare-table td, .admin-table th, .admin-table td, .kv th, .kv td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.error-table thead th, .compare-table thead th, .admin-table thead th { background: var(--surface-2); font-size: .85rem; color: var(--muted); }
.error-table tr:last-child td { border-bottom: 0; }
.status-table { margin-bottom: 10px; }
.status-table td:first-child { width: 80px; }
.status-table td:nth-child(2) { width: 300px; }
.table-wrap { overflow-x: auto; margin: 20px 0; }
.compare-table tbody th { width: 22%; background: var(--surface-2); }
.kv th { width: 55%; font-weight: 500; color: var(--muted); }
.filter-bar { margin: 14px 0; max-width: 420px; }

/* Error page */
.error-head { padding: 10px 0 6px; }
.error-head-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.error-layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.toc { position: sticky; top: 80px; font-size: .92rem; }
.toc nav { display: grid; gap: 2px; border-left: 2px solid var(--border); padding-left: 12px; }
.toc nav b { margin-bottom: 6px; }
.toc a { color: var(--muted); padding: 2px 0; }
.toc a:hover, .toc a.active { color: var(--accent); text-decoration: none; }
.error-body { min-width: 0; }
.error-body section { scroll-margin-top: 80px; }
.error-body > section:first-child h2 { margin-top: .4em; }
.check-list { list-style: none; padding: 0; }
.check-list li { padding: 6px 0 6px 28px; position: relative; border-bottom: 1px dashed var(--border); }
.check-list li:last-child { border-bottom: 0; }
.check-list li::before { content: "•"; position: absolute; left: 8px; color: var(--accent); font-weight: 700; }
.callout { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 4px 20px 10px; margin: 20px 0; }
@media (prefers-color-scheme: dark) { .callout { border-color: #7f1d3a; } }
.callout h2 { margin-top: .8em; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel h3 { display: none; }
.tab-panel li { margin: 6px 0; }
.code { border-radius: var(--radius); overflow: hidden; margin: 10px 0; border: 1px solid #1f2937; background: var(--code-bg); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: #161b22; color: #8b949e; font-size: .8rem; font-family: var(--mono); }
.copy-btn { background: #21262d; color: #c9d1d9; border: 1px solid #30363d; border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: .78rem; }
.copy-btn:hover { background: #30363d; }
.code pre { margin: 0; padding: 14px; overflow-x: auto; color: #e6edf3; font-family: var(--mono); font-size: .88rem; line-height: 1.5; }
.code pre code.hljs { padding: 0; background: transparent; }
.example { margin-bottom: 18px; }
.note { color: var(--muted); font-size: .93rem; margin-top: 4px; }
.diag-flow { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin: 12px 0; }
.diag-node { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: .93rem; }
.arrow { color: var(--muted); padding-left: 18px; line-height: 1; }
.diag-steps li { margin: 6px 0; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.related { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; color: var(--text); font-size: .93rem; }
.related:hover { border-color: var(--accent); text-decoration: none; }
.compare-links a { margin-right: 12px; }
.analyze-cta { margin-top: 28px; }
.analyze-cta form { display: grid; gap: 10px; justify-items: start; }
.feedback { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.helpful { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.correction { margin-top: 12px; }
.correction summary { cursor: pointer; color: var(--muted); }
.correction form { display: grid; gap: 8px; margin-top: 10px; max-width: 560px; justify-items: start; }
.ad { margin: 20px 0; min-height: 90px; }
.crumbs { font-size: .85rem; color: var(--muted); padding-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 20px 0; }

/* Analyze */
.analyze-form { display: grid; gap: 10px; }
.analyze-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.analyze-row label { flex: 1; min-width: 220px; }
.toggle { display: inline-flex !important; align-items: center; gap: 6px; flex: 0 0 auto !important; min-width: 0 !important; }
.result-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 22px 0; box-shadow: var(--shadow); }
.result-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.result-head h2 { margin: 0; }
.confidence { margin-left: auto; font-size: .85rem; font-weight: 700; padding: 4px 12px; border-radius: 99px; }
.c-high { background: #d1fae5; color: #065f46; }
.c-medium { background: #fef3c7; color: #92400e; }
.c-low { background: var(--surface-2); color: var(--muted); }
.ai-panel { border-color: #7c3aed; }
.causes-ranked li { margin: 6px 0; }
.likelihood { font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; margin-right: 6px; }
.l-high { background: #fee2e2; color: #991b1b; }
.l-medium { background: #fef3c7; color: #92400e; }
.l-low { background: var(--surface-2); color: var(--muted); }
.mini-code { background: var(--code-bg); color: #e6edf3; padding: 12px; border-radius: 8px; font-family: var(--mono); font-size: .85rem; }
.link-list { padding-left: 18px; }
.link-list li { margin: 4px 0; }
.result-list { display: grid; gap: 10px; }
.result { color: var(--text); display: block; }
.result:hover { border-color: var(--accent); text-decoration: none; }
.result h3 { margin: .4em 0 .2em; }
.result p { margin: 0; color: var(--muted); }
.empty-state { text-align: center; padding: 40px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* Compare */
.vs-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.vs-cards h2 { margin-top: .6em; }

/* Tools */
.tool textarea { min-height: 160px; }
.tool-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.tool-row label { flex: 1; min-width: 240px; }
.trace-output { background: var(--code-bg); color: #e6edf3; padding: 14px; border-radius: var(--radius); font-family: var(--mono); font-size: .86rem; overflow-x: auto; white-space: pre; min-height: 20px; }
.trace-output:empty { display: none; }
.trace-output .own { color: #ffa657; font-weight: 700; }
.trace-output .lib { color: #6e7681; }
.trace-output .head { color: #ff7b72; font-weight: 700; }
.trace-output .err-line { background: #5a1e1e; display: inline-block; width: 100%; }

/* Pricing / auth / prose */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 24px 0; }
.price-card { display: flex; flex-direction: column; gap: 6px; }
.price-card .btn { margin-top: auto; justify-content: center; }
.price-card.featured { border: 2px solid var(--accent); }
.price { font-size: 2rem; font-weight: 800; }
.price small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.auth-box { max-width: 440px; }
.prose { max-width: 760px; }
.docs h2 { border-top: 1px solid var(--border); padding-top: 1em; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; padding: 32px 0 18px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; }
.footer-grid h4 { margin: 0 0 8px; font-size: .9rem; }
.footer-grid a:not(.logo) { display: block; color: var(--muted); font-size: .9rem; padding: 2px 0; }
.footer-bottom { font-size: .8rem; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 200px 1fr; gap: 24px; }
.admin-nav { display: grid; gap: 2px; align-content: start; }
.admin-nav a { color: var(--text); padding: 7px 10px; border-radius: 8px; }
.admin-nav a.active, .admin-nav a:hover { background: var(--surface-2); text-decoration: none; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.6rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { color: var(--muted); font-size: .8rem; }
.admin-table td form { display: inline; }

/* Responsive */
@media (max-width: 900px) {
    .error-layout { grid-template-columns: 1fr; }
    .toc { display: none; }
    .split, .vs-cards, .form-grid, .admin-layout { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .header-inner { flex-wrap: wrap; padding: 8px 16px; }
    .nav-toggle { display: block; }
    .header-search { order: 3; flex-basis: 100%; max-width: none; }
    .main-nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; order: 4; padding-bottom: 8px; }
    .main-nav.open { display: flex; }
    .hide-sm { display: none; }
    .hero { padding: 36px 0 24px; }
    .hero-search { flex-direction: column; }
    .confidence { margin-left: 0; }
    .status-table td:nth-child(2) { width: auto; }
}
