:root {
    --background: #f4f3ef;
    --surface: #ffffff;
    --text: #1d1d1f;
    --muted: #6b6b70;
    --border: #dcdad3;
    --accent: #e0700b;
    --accent-soft: rgba(224, 112, 11, 0.16);
    --sample: rgba(224, 112, 11, 0.35);
    --point: #1d1d1f;
    --knot: #2f6fb3;
    --hp: #2f8f5b;
    --grid: #ecebe6;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #151517;
        --surface: #1e1e21;
        --text: #ececef;
        --muted: #9a9aa2;
        --border: #34343a;
        --accent: #ff9a3d;
        --accent-soft: rgba(255, 154, 61, 0.18);
        --sample: rgba(255, 154, 61, 0.4);
        --point: #ececef;
        --knot: #6aa8ea;
        --hp: #5ccf8e;
        --grid: #26262a;
    }
}

* {
    box-sizing: border-box;
}

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

header {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px 8px;
}

h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

header p {
    margin: 0;
    color: var(--muted);
    max-width: 900px;
}

main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 16px 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
}

#plot-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    min-height: 280px;
}

#plot {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

#panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    align-self: start;
}

.row {
    display: block;
    margin-bottom: 16px;
}

.row > span {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-weight: 600;
}

output {
    font-weight: 400;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

input[type="range"], select {
    width: 100%;
    accent-color: var(--accent);
}

select, button {
    font: inherit;
    color: var(--text);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
}

button {
    cursor: pointer;
}

button:hover {
    border-color: var(--accent);
}

.toggles label {
    display: block;
    accent-color: var(--accent);
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#stats {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

#stats dt {
    color: var(--muted);
}

#stats dd {
    margin: 0;
    text-align: right;
}

@media (max-width: 800px) {
    main {
        grid-template-columns: 1fr;
    }
}
