:root {
  color-scheme: light;
  --paper: #f7f4ea;
  --surface: #fffdf7;
  --line: #ded6c4;
  --ink: #2d3133;
  --muted: #706b61;
  --yellow: #f4c84a;
  --teal: #4d9aa8;
  --red: #b85042;
  --brown: #6d4f2e;
  --code: #202426;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; min-height: 36px; padding: 0 12px; }
button:hover { border-color: var(--ink); }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; }
.topbar { height: 68px; display: grid; grid-template-columns: 260px 1fr auto auto; gap: 16px; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(255,253,247,.92); position: sticky; top: 0; z-index: 5; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-lockup strong { display: block; font-size: 18px; }
.brand-lockup span { display: block; color: var(--muted); font-size: 12px; }
.seal { width: 38px; height: 38px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink); display: grid; place-items: center; font-weight: 900; font-size: 12px; }
.top-tabs { display: flex; gap: 4px; }
.tab { border-color: transparent; background: transparent; color: var(--muted); }
.tab.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.wallet-pill { border: 1px solid var(--line); background: #fff8dc; border-radius: 999px; padding: 8px 12px; white-space: nowrap; }
.publish-button { background: #2f7d5b; color: white; border-color: #2f7d5b; font-weight: 800; }
.workspace { display: grid; grid-template-columns: 280px minmax(480px, 1fr) 380px; min-height: calc(100vh - 68px); }
.gallery-panel, .canvas-panel, .chat-panel { min-width: 0; border-right: 1px solid var(--line); }
.gallery-panel { padding: 16px; background: #f0eadb; }
.panel-heading p, .eyebrow { margin: 0 0 4px; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0; font-weight: 800; }
.panel-heading strong { font-size: 16px; }
.template-list { margin-top: 14px; display: grid; gap: 10px; }
.template-card { text-align: left; display: grid; gap: 8px; padding: 12px; background: var(--surface); min-height: 118px; }
.template-card.active { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--yellow); }
.template-card strong { font-size: 14px; }
.template-card span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.template-card small { color: var(--brown); font-weight: 800; }
.canvas-panel { display: grid; grid-template-rows: auto minmax(300px, 1fr) auto; background: var(--surface); }
.canvas-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: 26px; }
.status-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.status-stack span, #result-status { border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; font-size: 12px; color: var(--muted); background: #fff; }
.status-stack span:last-child { color: #23614b; background: #e8f6ee; border-color: #b9dfc9; }
.canvas-stage { position: relative; overflow: hidden; min-height: 360px; background-image: linear-gradient(#ede5d4 1px, transparent 1px), linear-gradient(90deg, #ede5d4 1px, transparent 1px); background-size: 32px 32px; }
.node { position: absolute; width: 150px; min-height: 74px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px; box-shadow: 0 10px 22px rgba(45,49,51,.08); }
.node::before { content: attr(data-kind); display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 900; }
.node.Task { border-top: 5px solid var(--yellow); }
.node.Parallel { border-top: 5px solid var(--teal); }
.node.Branch { border-top: 5px solid var(--red); }
.node span { display: block; font-size: 12px; line-height: 1.3; }
.edge { position: absolute; height: 2px; background: #b9ae99; transform-origin: left center; }
.edge::after { content: ""; position: absolute; right: -2px; top: -4px; border-left: 8px solid #b9ae99; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.bottom-panel { display: grid; grid-template-columns: 1fr 220px 140px; gap: 12px; padding: 14px; border-top: 1px solid var(--line); background: #fbf8ef; }
.input-card, .meter-card { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px; display: grid; gap: 7px; }
.input-card label, .meter-card span { color: var(--muted); font-size: 12px; font-weight: 800; }
textarea, input { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 9px; background: white; color: var(--ink); }
textarea { min-height: 78px; resize: vertical; }
.compact button, .chat-input button { background: var(--yellow); border-color: #d5a820; font-weight: 900; }
.meter-card strong { font-size: 18px; }
.chat-panel { border-right: 0; display: grid; grid-template-rows: 1fr minmax(240px, 36vh) auto; background: #f7f1e2; }
.chat-scroll { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.message { padding: 10px 12px; border-radius: 8px; line-height: 1.42; font-size: 14px; border: 1px solid var(--line); }
.message.assistant { background: var(--surface); align-self: flex-start; }
.message.user { background: #e6f3f5; align-self: flex-end; max-width: 88%; }
.code-panel { border-top: 1px solid var(--line); background: var(--code); color: #f7f4ea; min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 12px; color: #d7d0be; }
.code-head button { background: transparent; color: #f7f4ea; border-color: rgba(255,255,255,.25); }
pre { margin: 0; overflow: auto; padding: 12px; font: 12px/1.45 "IBM Plex Mono", ui-monospace, Menlo, monospace; white-space: pre-wrap; }
.chat-input { display: grid; grid-template-columns: 1fr 72px; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.drawer { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 16px 18px; border-top: 1px solid var(--line); background: #eaf5f6; }
.drawer h2 { font-size: 20px; }
.drawer p:last-child { margin: 6px 0 0; color: var(--muted); max-width: 900px; }
.endpoint-actions { display: flex; gap: 8px; }
.result-tray { margin: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.result-header { display: flex; justify-content: space-between; padding: 14px; border-bottom: 1px solid var(--line); }
.result-body { padding: 14px; display: grid; gap: 14px; }
.logo-preview svg { width: 100%; max-width: 560px; height: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
.palette { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 8px; }
.swatch { min-height: 92px; border-radius: 8px; border: 1px solid var(--line); padding: 8px; display: flex; align-items: end; color: white; text-shadow: 0 1px 2px rgba(0,0,0,.35); font-size: 12px; font-weight: 800; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px 1fr; }
  .chat-panel { grid-column: 1 / -1; min-height: 520px; border-top: 1px solid var(--line); }
  .bottom-panel { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr auto; height: auto; min-height: 68px; flex-wrap: wrap; }
  .top-tabs, .wallet-pill { display: none; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .gallery-panel { border-bottom: 1px solid var(--line); }
  .canvas-toolbar, .drawer, .result-header { align-items: flex-start; flex-direction: column; display: flex; }
  .canvas-stage { min-height: 520px; }
  .node { width: 140px; }
  .palette { grid-template-columns: 1fr 1fr; }
}
