:root {
    --bg: #0c141b;
    --panel: #131f29;
    --line: #283844;
    --text: #e5edf0;
    --muted: #92a6b4;
    --accent: #8de4bd;
    --green: #39bf98;
    --warn: #e8c27e;
    --red: #f29c9c
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, Segoe UI, sans-serif
}

button,
input,
select {
    font: inherit
}

button,
select,
input {
    border: 1px solid var(--line);
    border-radius: 8px
}

button {
    cursor: pointer;
    color: var(--text);
    background: #1b2a36;
    padding: 9px 13px;
    transition: background .15s
}

button:hover {
    background: #2b3d49
}

button:disabled {
    opacity: .4;
    cursor: default
}

input,
select {
    background: #0e1922;
    color: var(--text);
    padding: 8px;
    min-width: 0;
    width: 100%
}

input:focus,
select:focus,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px
}

input[type=range] {
    accent-color: var(--green);
    padding: 0
}

input[type=checkbox] {
    width: auto;
    accent-color: var(--green)
}

label {
    font-size: 13px;
    color: var(--muted);
    display: block
}

label select {
    margin-top: 5px
}

header {
    height: 78px;
    max-width: 1440px;
    margin: auto;
    padding: 0 40px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px
}

.logo {
    background: var(--accent);
    color: #143b2d;
    padding: 5px 9px;
    border-radius: 8px;
    font-size: 17px
}

.badge {
    font-size: 10px;
    letter-spacing: 1px;
    background: #20323e;
    padding: 5px 8px;
    border-radius: 5px;
    color: var(--muted)
}

main {
    max-width: 1440px;
    margin: auto;
    padding: 0 40px
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 44px 0 36px
}

.eyebrow {
    letter-spacing: 2px;
    font-size: 11px;
    color: var(--accent);
    margin: 0 0 8px;
    font-weight: 700
}

h1 {
    font-size: clamp(32px, 4vw, 46px);
    line-height: 1.15;
    letter-spacing: -1.5px;
    margin: 0 0 15px
}

h1 span {
    color: var(--accent)
}

h2 {
    font-size: 21px;
    letter-spacing: -.4px;
    margin: 0
}

h3 {
    font-size: 14px;
    margin: 20px 0 10px
}

p {
    margin: 8px 0 14px
}

.hero p:last-child {
    color: var(--muted);
    max-width: 550px
}

.hero-art {
    width: 240px;
    color: #5b7c8e;
    text-align: center
}

.hero-art span {
    font-size: 11px;
    color: var(--muted)
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px
}

.model {
    padding: 22px
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px
}

.section-heading h3 {
    margin: 0
}

.section-heading p {
    margin-bottom: 3px
}

.dot {
    height: 8px;
    width: 8px;
    background: var(--green);
    border-radius: 50%
}

.row {
    display: flex;
    gap: 12px
}

.controls {
    margin-top: 16px
}

.controls label {
    flex: 1
}

.coefficient-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px
}

.coefficient-grid label {
    text-align: center
}

.coefficient-grid input {
    margin-top: 3px;
    text-align: center
}

.constraint {
    padding: 10px 0 13px;
    border-bottom: 1px solid var(--line)
}

.constraint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px
}

.remove {
    padding: 0 7px;
    font-size: 16px;
    background: transparent;
    border: 0
}

.constraint-bottom {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 8px;
    margin-top: 8px
}

.add {
    width: 100%;
    margin-top: 12px;
    border-style: dashed;
    color: var(--accent);
    background: transparent
}

.nonnegative {
    text-align: center;
    font-size: 12px;
    color: var(--muted)
}

.preview {
    background: #0e1922;
    border-radius: 8px;
    padding: 14px;
    font-size: 13px;
    margin: 12px 0;
    line-height: 1.9;
    overflow-wrap: anywhere
}

.primary {
    background: var(--accent);
    color: #103b2c;
    width: 100%;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between
}

.primary:hover {
    background: #b3f1d4
}

.ghost {
    background: transparent;
    font-size: 12px
}

.file-actions {
    margin-top: 12px;
    justify-content: center
}

.file-actions button {
    padding: 6px 9px
}

.muted {
    color: var(--muted);
    font-size: 12px
}

.hidden {
    display: none !important
}

.empty {
    text-align: center;
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center
}

.empty p {
    max-width: 330px;
    color: var(--muted)
}

.empty-icon {
    font-size: 44px;
    color: var(--accent);
    margin-bottom: 20px
}

.status {
    padding: 15px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    background: #153e32;
    border: 1px solid #276b50;
    color: #b1edcd
}

.status.warn {
    background: #3b3020;
    border-color: #6c5530;
    color: var(--warn)
}

.status.bad {
    background: #3c252a;
    border-color: #75404a;
    color: var(--red)
}

.status strong {
    display: block;
    font-size: 16px
}

.status p {
    margin: 3px 0 0;
    font-size: 13px
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 10px;
    margin-bottom: 22px
}

.metric {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--panel)
}

.metric span {
    color: var(--muted);
    font-size: 11px;
    display: block
}

.metric strong {
    font-size: 23px;
    letter-spacing: -.5px
}

.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 14px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line)
}

.tabs button {
    border: 0;
    border-radius: 0;
    white-space: nowrap;
    background: none;
    padding: 12px 13px;
    color: var(--muted);
    font-size: 13px
}

.tabs button.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent)
}

.canvas-wrap {
    position: relative;
    height: 380px;
    background: #0e1922;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden
}

canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab
}

.graph-tooltip {
    position: absolute;
    pointer-events: none;
    background: #203642;
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 12px;
    padding: 5px 9px;
    max-width: 220px
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0
}

.legend button {
    font-size: 11px;
    padding: 3px 6px;
    border: 0;
    background: transparent
}

.legend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px
}

.slider-label {
    margin: 8px 0 18px
}

.slider-label span {
    float: right;
    color: var(--accent)
}

.slider-label input {
    display: block;
    margin-top: 10px
}

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

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
    text-align: right;
    white-space: nowrap
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line)
}

th {
    background: #1b2a36;
    color: var(--muted);
    font-weight: 500
}

td:first-child,
th:first-child {
    text-align: left
}

.binding {
    color: var(--accent)
}

.notice {
    font-size: 13px;
    padding: 13px 15px;
    border-radius: 8px;
    background: #20323e;
    color: #c1d6e0;
    border-left: 3px solid #5e8ca0;
    margin: 12px 0
}

.step-controls {
    display: flex;
    align-items: center;
    gap: 12px
}

.step-controls button {
    white-space: nowrap
}

.step-controls input {
    flex: 1
}

.entering {
    background: #193e34;
    color: var(--accent)
}

.leaving td {
    background: #3b3525
}

.leaving .entering {
    background: #65532c;
    color: #ffe5a6;
    font-weight: 700
}

.inline {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin-right: 10px
}

.error {
    color: var(--red);
    font-size: 13px
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px
}

.help-grid p {
    color: var(--muted);
    font-size: 13px
}

#help {
    margin-bottom: 24px
}

details {
    margin-top: 16px;
    color: var(--muted);
    font-size: 12px
}

summary {
    cursor: pointer
}

#history button {
    display: block;
    width: 100%;
    text-align: left;
    margin-top: 8px;
    font-size: 12px
}

footer {
    text-align: center;
    padding: 35px 0;
    font-size: 11px;
    color: var(--muted)
}

.tab-content>h3:first-child {
    margin-top: 0
}

#interpretation p {
    font-size: 14px
}

#normalization {
    margin-top: 15px;
    font-size: 13px;
    color: var(--muted)
}

@media(max-width:1050px) {

    header,
    main {
        padding-left: 20px;
        padding-right: 20px
    }

    .workspace {
        grid-template-columns: 330px minmax(0, 1fr);
        gap: 16px
    }

    .panel {
        padding: 18px
    }

    .tabs button {
        padding: 12px 8px;
        font-size: 12px
    }

    .canvas-wrap {
        height: 340px
    }
}

@media(max-width:780px) {
    .workspace {
        grid-template-columns: 1fr
    }

    .hero-art {
        display: none
    }

    .brand .badge {
        display: none
    }

    .hero {
        padding: 30px 0
    }

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

    .results {
        min-width: 0
    }

    header {
        height: 64px
    }

    .canvas-wrap {
        height: 360px
    }

    .step-controls {
        gap: 6px
    }
}

@media print {
    body {
        background: white;
        color: #111;
        font-size: 11px
    }

    header,
    .hero,
    .model,
    footer,
    .tabs,
    #print,
    .step-controls,
    button,
    .slider-label,
    #stale {
        display: none !important
    }

    main {
        padding: 0
    }

    .workspace {
        display: block
    }

    .results,
    .panel,
    .metric {
        background: white;
        border-color: #ccc;
        color: #111
    }

    .tab-content.hidden {
        display: block !important
    }

    .panel {
        break-inside: avoid;
        margin: 14px 0
    }

    .muted,
    th {
        color: #444
    }

    th {
        background: #eee
    }

    .notice,
    .status,
    .status.bad,
    .status.warn {
        background: #eee;
        color: #111;
        border-color: #ccc
    }

    .metrics {
        display: flex;
        flex-wrap: wrap
    }

    .metric {
        flex: 1
    }

    canvas {
        max-width: 100%
    }

    .table-wrap {
        overflow: visible
    }

    th,
    td {
        border-color: #ccc;
        padding: 6px
    }

    input,
    .inline {
        display: none
    }

    .eyebrow {
        color: #444
    }

    .canvas-wrap {
        background: white
    }

    #graph-unavailable.hidden {
        display: none !important
    }
}