:root {
    color-scheme: dark;
    --bg: #090c0b;
    --panel: #121715;
    --panel-raised: #181e1b;
    --line: #2b3530;
    --line-bright: #3c4a43;
    --muted: #91a198;
    --text: #edf5f0;
    --green: #76e6a5;
    --green-dark: #153e29;
    --amber: #e8bd74;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 82% 8%, rgba(35, 105, 66, 0.17), transparent 32rem),
        linear-gradient(180deg, #0d110f 0%, var(--bg) 70%);
    color: var(--text);
}

main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 68px 0 38px; }
.hero { max-width: 780px; margin-bottom: 38px; }
.eyebrow, .step {
    margin: 0 0 11px;
    color: var(--green);
    font: 700 0.7rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.14em;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.035em; }
h1 { font-size: clamp(2.8rem, 7vw, 5.5rem); line-height: 0.98; }
h2 { font-size: 1.45rem; }
h3 { font-size: 0.92rem; color: #cbd8d0; margin-bottom: 12px; }
var { font-family: Georgia, serif; }
.lede { color: var(--muted); font-size: 1.12rem; line-height: 1.65; max-width: 690px; }

.local-note { display: inline-flex; align-items: center; gap: 9px; color: #b8c7bf; font-size: 0.86rem; }
.local-note span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(18, 23, 21, 0.95);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.explorer-card { padding: 29px; }
.section-heading, .results-heading, .detail-heading, .action-row {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
}
.heading-note { margin: 0; color: var(--muted); font-size: 0.8rem; }

.expression-grid {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 0.7fr) 110px minmax(150px, 1fr);
    gap: 13px;
    margin-top: 28px;
}
.target-field { margin-top: 14px; }

label { display: grid; gap: 8px; color: #cad6cf; font-size: 0.84rem; }
label small { color: var(--muted); font-weight: 400; }
label em { font-style: normal; }
textarea, input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    background: #0d120f;
    color: var(--text);
    font: 0.84rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    transition: border-color 120ms, box-shadow 120ms;
}
textarea { resize: vertical; padding: 11px 12px; }
input, select { min-height: 43px; padding: 0 11px; }
textarea:focus, input:focus, select:focus { border-color: #4da974; box-shadow: 0 0 0 3px rgba(118, 230, 165, 0.1); }

fieldset { padding: 0; margin: 24px 0 0; border: 0; }
legend { margin-bottom: 9px; color: #cad6cf; font-size: 0.84rem; }
.degree-options { display: flex; gap: 7px; }
.degree-options label { position: relative; display: block; }
.degree-options input { position: absolute; opacity: 0; pointer-events: none; }
.degree-options span {
    display: grid;
    place-items: center;
    width: 44px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d120f;
    color: var(--muted);
    cursor: pointer;
    font: 700 0.82rem ui-monospace, SFMono-Regular, Menlo, monospace;
}
.degree-options input:checked + span { border-color: #479969; background: var(--green-dark); color: var(--green); }
.degree-options input:focus-visible + span { box-shadow: 0 0 0 3px rgba(118, 230, 165, 0.15); }

.action-row { margin-top: 24px; }
button {
    min-width: 160px;
    height: 46px;
    border: 0;
    border-radius: 9px;
    background: var(--green);
    color: #092014;
    font-weight: 800;
    cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { cursor: wait; opacity: 0.55; }
.status { min-height: 20px; margin: 0; color: var(--muted); font-size: 0.85rem; }
.status[data-kind="error"] { color: #ff9b98; }
.status[data-kind="success"] { color: var(--green); }
.status[data-kind="working"] { color: var(--amber); }
.status[data-kind="warning"] { color: var(--amber); }

.results-card { margin-top: 20px; overflow: hidden; }
.results-heading { padding: 25px 28px 22px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 17px; border-bottom: 1px solid rgba(43, 53, 48, 0.75); text-align: left; }
th { color: var(--muted); font-size: 0.7rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
td { color: #c8d4cd; font: 0.79rem ui-monospace, SFMono-Regular, Menlo, monospace; }
tbody tr { transition: background 100ms; }
tbody tr:hover, tbody tr[data-selected="true"] { background: rgba(118, 230, 165, 0.045); }
tbody tr:last-child td { border-bottom: 0; }
th button {
    min-width: 0;
    height: auto;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}
th button[data-active="true"] { color: var(--green); }
td code { color: var(--text); font: inherit; }
.rank { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 5px; border-radius: 5px; background: #202824; color: var(--muted); font-size: 0.68rem; }
.murphy-value { color: var(--green); font-weight: 700; }
.inspect-button { min-width: 0; height: 31px; padding: 0 11px; border: 1px solid var(--line-bright); background: transparent; color: #c7d4cc; font-size: 0.72rem; }

.detail-card { margin-top: 20px; padding: 27px 28px; }
.secondary-button { min-width: 155px; height: 39px; border: 1px solid #3d7253; background: var(--green-dark); color: var(--green); }
.detail-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 28px; margin-top: 25px; }
pre {
    min-height: 170px;
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #0b100d;
    color: #cfe0d6;
    font: 0.77rem/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.detail-grid ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.82rem; line-height: 1.65; }
.detail-grid li + li { margin-top: 7px; }

.manual-shell { margin-top: 22px; }
.manual-shell > summary { width: fit-content; padding: 10px 2px; color: var(--muted); cursor: pointer; font-size: 0.82rem; }
.manual-shell[open] > summary { margin-bottom: 10px; color: #bdcbc3; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.8fr); gap: 20px; align-items: start; }
.input-card, .result-card { padding: 28px; }
.result-card { position: sticky; top: 20px; }
.degree-field { grid-template-columns: auto 76px; align-items: center; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0 14px; }
.skew-field { width: min(240px, 45%); }
#score-form .status { margin-top: 20px; }
dl { margin: 28px 0 0; }
dl > div { display: flex; justify-content: space-between; gap: 18px; padding: 14px 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); font-size: 0.85rem; }
dd { margin: 0; font: 0.9rem ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.primary-result { display: block; padding: 20px 0 24px; }
.primary-result dd { margin-top: 8px; color: var(--green); font-size: 1.42rem; text-align: left; }

footer { display: flex; justify-content: space-between; gap: 24px; margin-top: 27px; color: #68766f; font-size: 0.75rem; }
.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; }

@media (max-width: 820px) {
    main { padding-top: 44px; }
    .expression-grid { grid-template-columns: 1fr 1fr; }
    .workspace, .detail-grid { grid-template-columns: 1fr; }
    .result-card { position: static; }
}

@media (max-width: 580px) {
    .explorer-card, .input-card, .result-card, .detail-card { padding: 22px; }
    .expression-grid, .field-grid { grid-template-columns: 1fr; }
    .section-heading, .results-heading, .detail-heading, .action-row, footer { align-items: stretch; flex-direction: column; }
    .degree-field { grid-template-columns: 1fr; }
    .skew-field { width: 100%; }
    .action-row > button { width: 100%; }
    .results-heading .heading-note { word-break: break-word; }
}
