@font-face {
    font-family: Orbitron;
    src: url("../fonts/orbitron-500.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: Orbitron;
    src: url("../fonts/orbitron-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #020805;
    --bg-raise: #07140e;
    --line: rgba(57, 255, 106, 0.24);
    --text: #d7ffe6;
    --muted: #8fbfa4;
    --accent: #39ff6a;
    --accent-ink: #03150a;
    --warn: #d6ff4a;
    --bad: #ff5c7a;
    --good: #7dffb2;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    --header: rgba(2, 8, 5, 0.92);
    --field: #04110b;
    --meter: rgba(57, 255, 106, 0.14);
    --grid: rgba(57, 255, 106, 0.08);
    --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --display: Orbitron, "Segoe UI", sans-serif;
    --mono: Orbitron, ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f6f1;
    --bg-raise: #ffffff;
    --line: rgba(10, 90, 42, 0.2);
    --text: #102117;
    --muted: #3d5c49;
    --accent: #0b7a3a;
    --accent-ink: #f4fff8;
    --warn: #8a6400;
    --bad: #a32038;
    --good: #0c7a3e;
    --shadow: 0 12px 28px rgba(16, 33, 23, 0.08);
    --header: rgba(243, 246, 241, 0.94);
    --field: #ffffff;
    --meter: rgba(11, 122, 58, 0.14);
    --grid: rgba(11, 122, 58, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 42px 42px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
img { max-width: 100%; }
h1, h2, h3, .brand, .site-nav a, .button, button, .eyebrow, .code, .status, .score-number, .steps, legend, .idea-label {
    font-family: var(--display);
    letter-spacing: 0.04em;
}
h1, h2, h3 { line-height: 1.15; font-weight: 700; }
.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--accent);
    color: var(--accent-ink);
    padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.5rem; }
.wrap { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding-bottom: 4rem; }
.mono, code, pre { font-family: var(--mono); }
.muted { color: var(--muted); }
.lede { font-size: 1.15rem; max-width: 42rem; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--header);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.header-bar {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: center;
    padding: 0.8rem 0;
}
.brand { display: flex; gap: 0.65rem; align-items: center; color: var(--text); text-decoration: none; }
.brand-mark {
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: 4px;
    padding: 0.2rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}
.brand-name { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; max-width: 14rem; line-height: 1.25; }
.theme-toggle { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; }
[data-theme="dark"] .when-light,
[data-theme="light"] .when-dark { display: none; }
.site-nav, .header-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.theme-toggle { margin-left: auto; }
.header-actions { margin-left: 0; }
.site-nav a, .header-actions a { color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"], .admin-nav a[aria-current="page"] { color: var(--accent); }
.nav-toggle {
    margin-left: auto;
    display: none;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
}

.button, button, input, select, textarea {
    font: inherit;
    color: inherit;
}
.button, button {
    border: 1px solid var(--line);
    background: transparent;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
}
.button-primary, button.button-primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: transparent;
    font-weight: 650;
}
.button-quiet { color: var(--muted); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.hero { padding: 3.2rem 0 1rem; max-width: 48rem; position: relative; }
[data-theme="dark"] .hero h1 { text-shadow: 0 0 22px rgba(57, 255, 106, 0.28); }
.hero h1 { font-size: clamp(1.8rem, 4.6vw, 3.1rem); margin-bottom: 0.4rem; }
.eyebrow {
    font-family: var(--mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warn);
    font-size: 0.78rem;
}
.hero-actions, .inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.disclaimer, .site-footer {
    color: var(--muted);
    max-width: 46rem;
}
.site-footer {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto 2rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
}
.footer-links { display: flex; gap: 1rem; }

.section { margin-top: 2.2rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow);
}
.card-link { color: inherit; text-decoration: none; display: block; }
.card-preview { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; margin-bottom: 0.6rem; }
.code { letter-spacing: 0.04em; color: var(--accent); margin: 0; }
.meta, .tags { display: flex; flex-wrap: wrap; gap: 0.45rem 0.8rem; padding: 0; list-style: none; color: var(--muted); font-size: 0.92rem; }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.8rem 0; }
.scores dt { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.scores dd { margin: 0.2rem 0 0; display: flex; align-items: center; gap: 0.4rem; }
.meter, .bar {
    position: relative;
    flex: 1;
    height: 0.45rem;
    background: var(--meter);
    border-radius: 999px;
    overflow: hidden;
}
.meter > span, .bar > span {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: var(--warn);
}
.meter-evidence > span, .bar > span { background: var(--accent); }
.score-value {
    flex: none;
    min-width: 1.7rem;
    color: var(--text);
    font-family: var(--display);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    text-align: right;
}
.card-foot { display: flex; justify-content: space-between; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.status {
    display: inline-block;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.75rem;
}
.status-good { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }
.status-neutral { color: var(--text); }
.status-muted { color: var(--muted); }

.flash { border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; }
.flash-error { border-color: var(--bad); }
.flash-success { border-color: var(--accent); }
.flash-info { border-color: var(--warn); }
.field-error { color: var(--bad); margin-top: 0; }

.stack { display: grid; gap: 1rem; }
.stack-form, .filters { display: grid; gap: 0.8rem; margin: 1rem 0 1.5rem; }
.filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
label { display: grid; gap: 0.3rem; }
input, select, textarea {
    width: 100%;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}
.check { grid-template-columns: auto 1fr; align-items: center; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.places-suggest {
    position: fixed;
    z-index: 30;
    margin: 0;
    padding: 0.25rem;
    max-height: 240px;
    overflow: auto;
    background: var(--bg-raise);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.places-suggest button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--text);
    border: 0;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-family: var(--sans);
    letter-spacing: 0;
    text-transform: none;
}
.places-suggest button:hover,
.places-suggest button.is-active { background: var(--meter); }

.facts, .layers, .stat-grid { display: grid; gap: 0.8rem; }
.facts div, .layers div, .stat-grid div {
    border-top: 1px solid var(--line);
    padding-top: 0.45rem;
}
.facts dt, .layers dt, .stat-grid dt { color: var(--muted); font-size: 0.85rem; }
.facts dd, .layers dd, .stat-grid dd { margin: 0.15rem 0 0; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-grid dd { font-size: 1.6rem; }

.score-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.score-number { font-family: var(--mono); font-size: 2.4rem; margin: 0; }
.score-anomaly { color: var(--warn); }
.score-number small { font-size: 1rem; color: var(--muted); }
.factors { list-style: none; padding: 0; }
.factors li, .bars li { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; padding: 0.25rem 0; }
.bars { list-style: none; padding: 0; }
.bars .bar { max-width: 46%; }

.report section { margin-top: 2rem; }
.prose, .prose-block { max-width: 46rem; }
.activity { padding-left: 1.1rem; }
.comment { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.support { border-left: 3px solid var(--accent); padding-left: 0.6rem; }
.counter { border-left: 3px solid var(--warn); padding-left: 0.6rem; }
.questions { display: grid; gap: 0.5rem; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1rem 0; }
#map { height: 70vh; min-height: 420px; border-radius: 16px; border: 1px solid var(--line); }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 1rem; }
.steps { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; padding: 0; list-style: none; color: var(--muted); font-size: 0.85rem; }
.steps .is-current { color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 16px; margin: 0; }
legend { padding: 0 0.4rem; }

.idea { margin-top: 2.4rem; }
.idea-intro { max-width: 42rem; }
.idea-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}
.idea-card {
    margin: 0;
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: var(--shadow);
}
.idea-card h3 { margin: 0.2rem 0 0.6rem; font-size: 1rem; }
.idea-label {
    margin: 0;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}
.idea-label.warn { color: var(--warn); }
.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}
.split p { margin: 0.35rem 0 0; font-size: 0.92rem; }
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 0.35rem; align-items: center; margin: 0.4rem 0 0.8rem; }
.flow-node {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.45rem 0.3rem;
    text-align: center;
    font-family: var(--display);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.flow-node.is-done { border-color: var(--accent); color: var(--accent); }
.flow-arrow { color: var(--muted); }

@media (max-width: 800px) {
    .header-bar { flex-wrap: nowrap; }
    .header-bar.is-open { flex-wrap: wrap; }
    .brand { flex: 1; min-width: 0; }
    .brand-name { max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nav-toggle { display: inline-flex; margin-left: 0; flex: none; }
    .theme-toggle { margin-left: auto; flex: none; }
    .site-nav, .header-actions { display: none; width: 100%; }
    .header-bar.is-open .site-nav, .header-bar.is-open .header-actions { display: flex; flex-basis: 100%; }
    .idea-grid, .split { grid-template-columns: 1fr; }
    .flow { grid-template-columns: 1fr; }
    .flow-arrow { transform: rotate(90deg); justify-self: center; }
    #map { height: 60vh; }
}

.admin-search { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin: 0.6rem 0 1rem; }
.admin-search label { display: grid; gap: 0.25rem; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-raise); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { text-align: left; vertical-align: top; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); }
.admin-table th { font-size: 0.75rem; }
.admin-table th a { color: var(--muted); text-decoration: none; }
.admin-table th[aria-sort] a { color: var(--accent); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table select { min-width: 8rem; }
.admin-table .tight { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; animation: none !important; }
}
