:root {
  color-scheme: dark;
  --bg: #000;
  --tile: #161617;
  --field: #2c2c2e;
  --ink: #f5f5f7;
  --muted: #a1a1a6;
  --line: rgba(255,255,255,.12);
  --blue: #0071e3;
  --link: #2997ff;
  font: 16px/1.45 -apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Arial,sans-serif;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; }
header { min-height: 64px; padding: 10px clamp(12px, 3vw, 40px); border-bottom: 1px solid var(--line); }
header, .toolbar, footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { color: var(--ink); font-size: 1.2rem; font-weight: 750; text-decoration: none; letter-spacing: -.035em; }
.brand span, .kind { color: var(--link); }
main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; padding: 14px; height: calc(100dvh - 64px); min-height: 500px; }
.workspace, aside { border: 1px solid var(--line); border-radius: 22px; background: var(--tile); min-width: 0; min-height: 0; }
.workspace { display: flex; flex-direction: column; overflow: hidden; }
.toolbar, aside { padding: 18px; }
aside { overflow: auto; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 3vw, 1.85rem); letter-spacing: -.045em; }
h2 { font-size: 1.15rem; letter-spacing: -.025em; }
h3 { font-size: .95rem; }
p, label, summary { font-size: .875rem; }
p { margin: 10px 0; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--field); border-radius: 999px; padding: 8px 13px; cursor: pointer; font-size: .875rem; }
button:hover { filter: brightness(1.2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--blue); border-color: transparent; color: white; }
button.remove { color: #ff8080; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.tools { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
input, select, textarea { background: var(--field); border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0; }
#name { background: transparent; padding: 4px 0; color: var(--muted); max-width: 260px; font-size: .875rem; }
textarea { resize: vertical; min-height: 76px; }
label { display: grid; gap: 4px; margin: 10px 0; color: var(--muted); }
#viewport { flex: 1; overflow: auto; background: #08080a radial-gradient(#303034 1px, transparent 1px) 0 0 / 24px 24px; }
#surface, #world { position: relative; }
#world { position: absolute; transform-origin: top left; }
#edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.node { width: 228px; position: absolute; padding: 0; border-radius: 16px; background: #1d1d1f; border: 1px solid #3a3a3c; text-align: left; touch-action: none; cursor: grab; overflow: hidden; }
.node:hover { filter: none; border-color: var(--link); }
.node[aria-pressed=true] { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.node span, .node strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .kind { font-size: .82rem; }
.node .description { color: var(--muted); }
.node .content { padding: 10px 13px; }
.node .port { height: 29px; padding: 4px 13px; border-top: 1px solid var(--line); color: #b7d9ff; }
footer { padding: 8px 18px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }
fieldset { min-width: 0; margin: 12px 0; border: 1px solid var(--line); border-radius: 14px; padding: 4px 10px 10px; }
legend { font-size: .875rem; color: var(--link); }
details { margin: 16px 0; }
summary { cursor: pointer; }
dialog { width: min(440px, 90vw); background: var(--tile); color: var(--ink); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
dialog::backdrop { background: #000a; }
@media (max-width: 780px) {
  main { grid-template-columns: 1fr; height: auto; padding: 8px; gap: 8px; }
  .workspace { height: max(390px, 58dvh); }
  aside { overflow: visible; }
}
.node .content { height: 84px; }
.node .kind { line-height: 18px; }
.node strong, .node .description { line-height: 22px; }
#surface { overflow: hidden; }

#formats { width: min(900px, 92vw); max-height: calc(100dvh - 32px); }
.export-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px; }
.export-layout h2 label { margin-top: 0; color: inherit; font: inherit; }
@media (max-width: 600px) {
  .export-layout { grid-template-columns: 1fr; gap: 18px; }
}
#prompt { display: block; max-height: 42dvh; }
.prompt-tools { margin-top: 8px; }
#prompt-status { color: var(--muted); font-size: .875rem; }
