:root {
    color-scheme: dark;
    --bg: #090e18;
    --rail: #0c1322;
    --panel: #11192b;
    --panel-2: #162033;
    --line: #24324a;
    --ink: #e7edf7;
    --muted: #8ea0b8;
    --faint: #6d7f98;
    --accent: #7c6bff;
    --accent-ink: #ffffff;
    --good: #3cba9f;
    --warn: #e0b15c;
    --bad: #e36d78;
    --shadow: 0 16px 40px rgba(0, 0, 0, .28);
    --sans: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
    --mono: "IBM Plex Mono", "ui-monospace", monospace;
}
html[data-theme="light"] {
    color-scheme: light;
    --bg: #eef2f7;
    --rail: #f8fafc;
    --panel: #ffffff;
    --panel-2: #f3f6fb;
    --line: #d5deea;
    --ink: #162033;
    --muted: #5d6e86;
    --faint: #7d8da3;
    --shadow: 0 10px 30px rgba(22, 32, 51, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail {
    background: var(--rail);
    border-right: 1px solid var(--line);
    padding: 18px 12px 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 16px; }
.mark {
    width: 28px; height: 28px; border-radius: 7px;
    background: #11182a; color: white; display: grid; place-items: center;
    font-weight: 700; letter-spacing: -.04em;
}
html[data-theme="light"] .mark { background: #162033; }
.brand strong { display: block; letter-spacing: .12em; font-size: 13px; }
.brand span { color: var(--faint); font-size: 12px; }
.nav-label { margin: 16px 8px 6px; color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav a, .nav button.link {
    display: block; width: 100%; text-align: left; text-decoration: none;
    padding: 7px 8px; border-radius: 8px; color: var(--muted); border: 0; background: transparent;
}
.nav a.active, .nav a:hover { background: var(--panel-2); color: var(--ink); }
.workspace { min-width: 0; }
.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 16px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.crumb { color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 64px; max-width: 1180px; }
h1 { font-size: 26px; letter-spacing: -.03em; margin: 0 0 6px; font-weight: 620; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 620; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 68ch; }
.banner {
    border: 1px solid var(--line); background: var(--panel); border-left: 3px solid var(--warn);
    padding: 10px 12px; border-radius: 10px; margin-bottom: 16px; color: var(--muted);
}
.grid-5, .grid-4, .grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.4fr .8fr; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 12px; }
.card .q { color: var(--muted); font-size: 12.5px; min-height: 34px; }
.metric { font-size: 28px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin-top: 8px; }
.metric small { display: block; margin-top: 4px; color: var(--faint); font-size: 12px; letter-spacing: 0; }
.section { margin-top: 22px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--faint); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.btn, button.btn {
    background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px;
    padding: 8px 12px; font-weight: 600;
}
.btn.secondary, button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.row-actions, .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { justify-content: space-between; margin-bottom: 12px; }
label { display: block; margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
input, select, textarea {
    width: 100%; margin-top: 4px; background: var(--bg); border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 88px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth-copy { padding: 64px 56px; border-right: 1px solid var(--line); }
.auth-copy h1 { font-size: 42px; line-height: 1.05; max-width: 12ch; }
.auth-panel { display: grid; align-items: center; padding: 40px 48px; }
.auth-card { max-width: 420px; width: 100%; }
.points { padding: 0; margin: 28px 0 0; list-style: none; }
.points li { padding: 8px 0; border-top: 1px solid var(--line); color: var(--muted); }
.state { padding: 28px 8px; color: var(--muted); }
.state strong { color: var(--ink); display: block; margin-bottom: 4px; }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 12px; color: var(--muted); }
.tag.good { color: var(--good); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--bad); }
.error { color: var(--bad); margin: 8px 0; }
.split { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.canvas { position: relative; height: 280px; background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; }
.node {
    position: absolute; width: 180px; padding: 8px; border-radius: 10px; background: var(--panel);
    border: 1px solid var(--line); cursor: grab;
}
.kbd { font-family: var(--mono); font-size: 12px; }
@media (max-width: 1100px) {
    .grid-5, .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-2, .split, .auth { grid-template-columns: 1fr; }
    .auth-copy { display: none; }
}
@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .rail { position: relative; height: auto; }
    .content, .topbar, .auth-panel { padding-left: 16px; padding-right: 16px; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}
