:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1b2430; --muted: #657084; --line: #e2e6ec;
  --accent: #2f6fed; --accent-ink: #ffffff; --ok: #1f9d55; --err: #d6403b; --warn: #b7791f;
  --trigger: #7c5cff; --action: #2f6fed; --logic: #d9822b; --data: #1f9d8a; --ai: #d14b8f;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161c; --panel: #1a2029; --ink: #e6eaf0; --muted: #93a0b4; --line: #2a3340; --accent: #5b92ff; --accent-ink: #0b1220; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 120px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 7px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: default; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; overflow: auto; max-height: 260px; white-space: pre-wrap; word-break: break-word; }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 750; font-size: 16px; padding: 0 8px 12px; }
.side a.nav { padding: 8px 10px; border-radius: 7px; color: var(--ink); }
.side a.nav.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.side .who { margin-top: auto; padding: 10px 8px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.quota { height: 5px; background: var(--line); border-radius: 3px; margin: 6px 0; overflow: hidden; }
.quota > div { height: 100%; background: var(--accent); }
.main { padding: 22px 26px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.muted { color: var(--muted); }
.err { color: var(--err); } .okc { color: var(--ok); }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; }
.pill.success, .pill.active { color: var(--ok); } .pill.error { color: var(--err); }
.pill.running, .pill.queued, .pill.skipped, .pill.inactive { color: var(--muted); }

.auth { max-width: 380px; margin: 9vh auto; }
.auth .card { padding: 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.editor { display: grid; grid-template-columns: 190px 1fr 330px; gap: 14px; margin-top: 14px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } .side { flex-direction: row; flex-wrap: wrap; } }
.palette button { display: block; width: 100%; text-align: left; margin-bottom: 6px; border-left: 4px solid var(--line); }
.palette h3 { margin: 12px 0 6px; }
.cat-trigger { border-left-color: var(--trigger) !important; } .cat-action { border-left-color: var(--action) !important; }
.cat-logic { border-left-color: var(--logic) !important; } .cat-data { border-left-color: var(--data) !important; } .cat-ai { border-left-color: var(--ai) !important; }
.canvas { overflow: auto; background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 18px 18px; padding: 0; min-height: 300px; }
.canvas svg { display: block; }
.gnode rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.gnode.sel rect { stroke: var(--accent); stroke-width: 2.5; }
.gnode text { fill: var(--ink); font-size: 12.5px; pointer-events: none; }
.gnode text.sub { fill: var(--muted); font-size: 11px; }
.gnode .bar.trigger { fill: var(--trigger); } .gnode .bar.action { fill: var(--action); } .gnode .bar.logic { fill: var(--logic); }
.gnode .bar.data { fill: var(--data); } .gnode .bar.ai { fill: var(--ai); }
.gnode { cursor: pointer; }
.edge { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.edgelabel { fill: var(--muted); font-size: 11px; }
.logrow { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--panel); }
.logrow > summary { cursor: pointer; padding: 8px 12px; display: flex; gap: 10px; align-items: center; }
.logrow > div { padding: 0 12px 12px; }
.small { font-size: 12px; }
.conn { display: flex; gap: 6px; align-items: center; padding: 3px 0; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; z-index: 10; max-width: 420px; }
.toast.bad { background: var(--err); color: #fff; }
