/* ForgeWeaver — a Forgeverse Studio app.
   Design language: forgeverse.css v2 (--bg/--card/--surface*/--line*/--text*/--accent) + kit.css components.
   Dark theme only. Rendered inside the Forgeverse workspace iframe; the shell owns branding/account chrome,
   so this app is a slim tool row + IDE panes and nothing else. No external requests: fonts vendored below. */

@font-face { font-family: "Plex"; src: url("vendor/fonts/IBMPlexSans-Variable.woff2") format("woff2"); font-weight: 100 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("vendor/fonts/IBMPlexMono-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --bg: #09090b;
  --bg-raised: #0e0e11;
  --card: #121215;
  --surface: #121215;
  --surface-2: #18181c;
  --surface-3: #202025;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --line-3: rgba(255, 255, 255, .2);
  --text: #f4f4f5;
  --text-2: #b4b4bd;
  --text-3: #94949e;
  --accent: #ff7a45;
  --accent-2: #ff5a2a;
  --accent-soft: rgba(255, 122, 69, .12);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --r-lg: 16px;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 20px 50px rgba(0, 0, 0, .5);
  --font: "Plex", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
kbd { font: 11px var(--mono); background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: var(--text-2); }

/* ---- Forgeverse design-system components (btn / seg / chip / tag / field / empty / card) ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px;
  font: 500 14.5px var(--font); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.btn:hover { background: var(--surface-3); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1a0904; }
.btn.accent:hover { background: #ff8a5a; }
.btn.primary { background: var(--text); color: #0a0a0b; border-color: var(--text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 32px; }
.btn.danger { color: #fca5a5; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.active { background: var(--accent-soft); border-color: rgba(255,122,69,.4); color: var(--accent); }

.seg { display: flex; flex-wrap: wrap; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.seg button { flex: 1 1 auto; min-width: max-content; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2);
  font: 500 13px var(--font); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(255,122,69,.35); }

.chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 12px; font: 500 13px var(--font); border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--line-3); }
.chip.on { background: var(--accent-soft); border-color: rgba(255,122,69,.45); color: var(--accent); }

.tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.field { display: grid; gap: 7px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.small { font-size: 13px; }
.muted { color: var(--text-3); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.card .card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.card .card-h strong { font-weight: 600; font-size: 13.5px; }
.card .card-b { padding: 14px; }
.empty { margin: auto; text-align: center; max-width: 420px; display: grid; justify-items: center; gap: 12px; padding: 40px 20px; }
.empty .art { width: 110px; height: 110px; border-radius: 28px; display: grid; place-items: center; background: var(--surface);
  border: 1px solid var(--line-2); box-shadow: 0 30px 60px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.05) inset; color: var(--text-2); }
.empty .art svg { width: 48px; height: 48px; stroke-width: 1.2; }
.empty h2 { font-size: 19px; margin: 8px 0 0; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--text-3); font-size: 13.5px; line-height: 1.55; }
.empty-mini { color: var(--text-3); font-size: 12.5px; line-height: 1.55; }
.empty-mini.pad { padding: 14px; }

/* inputs styled as the design system's controls */
.tb-input, .tb-select, textarea.tb-input {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text); border-radius: var(--r-sm);
  font: 400 13px var(--font); padding: 7px 10px; outline: none; min-width: 0;
}
.tb-input:focus, .tb-select:focus, textarea.tb-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tb-select { appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a1a1aa' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.tb-select option { background: var(--surface-2); color: var(--text); }
.tb-select-sm { height: 30px; font-size: 12.5px; padding: 3px 24px 3px 8px; }
.tb-input-xs { width: 62px; padding: 4px 7px; font-size: 12px; }
textarea.tb-input { resize: vertical; font-size: 13px; }
input[type=number].tb-input::-webkit-inner-spin-button { opacity: .4; }

/* ================= APP SHELL ================= */
#app { display: grid; grid-template-rows: auto minmax(0,1fr) auto; height: 100vh; }

/* slim in-app tool row — true 3-zone grid so the mode switcher stays centered
   regardless of left/right group widths (flex margin-auto pushed it off-center) */
#toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 14px; padding: 8px 12px;
  background: var(--bg-raised); border-bottom: 1px solid var(--line); min-height: 48px;
}
.tb-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-center { justify-content: center; }
.tb-right { justify-content: flex-end; }
/* unify control heights in the tool row (36px buttons vs 30px pills vs 20px icons) */
#toolbar .btn, #toolbar .fw-pill { height: 32px; }
#toolbar .btn.icon-only { width: 32px; }
#toolbar .tb-select { height: 32px; }
#project-select { max-width: 240px; }
.fw-pill { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font: 500 12.5px var(--font); cursor: pointer; }
.fw-pill:hover { color: var(--text); border-color: var(--line-3); }
#git-pill-dot.ok { background: var(--ok); } #git-pill-dot.warn { background: var(--warn); } #git-pill-dot.bad { background: var(--bad); }

/* main row: left sidebar | splitter | center | splitter | right sidebar */
#main-row { display: flex; min-height: 0; min-width: 0; }
#left-sidebar, #right-sidebar { background: var(--bg); display: flex; flex-direction: column; min-height: 0; overflow: hidden; flex: none; }
#left-sidebar { width: 260px; border-right: 1px solid var(--line); }
#right-sidebar { width: 300px; border-left: 1px solid var(--line); }
#center-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--bg-raised); }

.splitter { flex: none; position: relative; z-index: 20; background: transparent; }
.splitter-v { width: 6px; cursor: col-resize; margin: 0 -3px; }
.splitter-h { height: 6px; cursor: row-resize; margin: -3px 0; }
/* hairline always visible so every pane boundary reads as a divider */
.splitter::before { content: ""; position: absolute; background: var(--line-2); transition: background .15s, opacity .15s; pointer-events: none; }
.splitter-v::before { top: 0; bottom: 0; left: 50%; width: 1px; }
.splitter-h::before { left: 0; right: 0; top: 50%; height: 1px; }
.splitter:hover::before, .splitter.dragging::before { background: var(--accent); opacity: .7; }
/* code|preview divider: wide, with a real grip handle (VS Code-style affordance) */
#split-mid { width: 11px; margin: 0; background: var(--bg-raised); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
#split-mid::before { left: 50%; width: 1px; background: transparent; }
#split-mid::after { content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 7px; height: 30px; border-radius: 4px; pointer-events: none;
  background-image: radial-gradient(circle, var(--text-3) 1.1px, transparent 1.4px);
  background-size: 7px 10px; background-repeat: repeat-y; background-position: center top;
  opacity: .85; transition: opacity .15s; }
#split-mid:hover, #split-mid.dragging { background: var(--surface-2); border-color: rgba(255,122,69,.45); }
#split-mid:hover::after, #split-mid.dragging::after {
  background-image: radial-gradient(circle, var(--accent) 1.2px, transparent 1.5px); opacity: 1; }

/* side tabs (left: Files/Git/Blocks, right: Properties/AI) */
.side-tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.side-tabs button { flex: 1; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3);
  font: 500 12.5px var(--font); cursor: pointer; }
.side-tabs button:hover { color: var(--text-2); }
.side-tabs button.active { background: var(--accent-soft); color: var(--accent); }
.lpane, .rpane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---- file explorer ---- */
.tree-tools { padding: 8px; display: grid; gap: 6px; flex: none; }
.tree-tool-btns { display: flex; gap: 4px; }
.tree-tool-btns .btn { flex: 1; height: 26px; padding: 0 6px; font-size: 11.5px; border-radius: 6px; }
.file-tree { flex: 1; overflow: auto; padding: 2px 6px 14px; font-size: 13px; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--text-2); white-space: nowrap; user-select: none; }
.tree-row:hover { background: var(--surface); color: var(--text); }
.tree-row.selected { background: var(--accent-soft); color: var(--accent); }
.tree-row .tw { width: 12px; flex: none; text-align: center; color: var(--text-3); font-size: 10px; }
.tree-row .nm { overflow: hidden; text-overflow: ellipsis; }
.tree-row .sz { margin-left: auto; font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tree-row .acts { display: none; gap: 2px; margin-left: auto; }
.tree-row:hover .acts { display: inline-flex; }
.tree-row:hover .sz { display: none; }
.tree-row .acts button { width: 20px; height: 20px; border: 0; border-radius: 4px; background: transparent; color: var(--text-3); cursor: pointer; font-size: 11px; line-height: 1; }
.tree-row .acts button:hover { background: var(--surface-3); color: var(--text); }
.tree-row.dir > .nm { color: var(--text); font-weight: 500; }
.tree-children { margin-left: 14px; border-left: 1px solid var(--line); padding-left: 2px; }

/* ---- git panel ---- */
.git-panel { flex: 1; overflow: auto; padding: 10px; display: grid; gap: 12px; align-content: start; }
.git-panel h4 { margin: 0; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.git-file { display: flex; gap: 8px; align-items: center; padding: 4px 8px; border-radius: 6px; font: 12.5px var(--mono); cursor: pointer; color: var(--text-2); }
.git-file:hover { background: var(--surface); }
.git-file .st-badge { width: 16px; text-align: center; font-weight: 600; }
.git-file .st-badge.M { color: var(--warn); } .git-file .st-badge.A, .git-file .st-badge.\?\? { color: var(--ok); } .git-file .st-badge.D { color: var(--bad); }
.git-commit-row { display: grid; gap: 6px; }
.git-log-entry { padding: 6px 8px; border-radius: 6px; font-size: 12px; color: var(--text-2); border-left: 2px solid var(--line-2); }
.git-log-entry .h { color: var(--accent); font-family: var(--mono); font-size: 11px; }
.git-log-entry:hover { background: var(--surface); }
.git-branch { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 6px; font-size: 12.5px; color: var(--text-2); }
.git-branch:hover { background: var(--surface); }
.git-branch .cur { color: var(--ok); }
pre.git-diff { margin: 0; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  font: 11.5px/1.5 var(--mono); overflow: auto; max-height: 260px; white-space: pre; color: var(--text-2); }
pre.git-diff .add { color: var(--ok); } pre.git-diff .del { color: var(--bad); } pre.git-diff .hd { color: #7aa2f7; }

/* ---- workspace & modes ---- */
#workspace { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }
.ws { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* code mode */
.tabbar { display: flex; align-items: stretch; gap: 2px; background: var(--bg); border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; flex: none; min-height: 36px; scrollbar-width: thin; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; height: 35px; font-size: 12.5px; color: var(--text-3);
  background: transparent; border: 0; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; max-width: 220px; }
.tab:hover { color: var(--text-2); background: var(--surface); }
.tab.active { color: var(--text); background: var(--bg-raised); box-shadow: inset 0 2px 0 var(--accent); }
.tab .nm { overflow: hidden; text-overflow: ellipsis; }
.tab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tab .x { width: 16px; height: 16px; border-radius: 4px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; font-size: 11px; line-height: 1; flex: none; }
.tab .x:hover { background: var(--surface-3); color: var(--text); }
.monaco-slot { flex: 1; min-height: 0; position: relative; }
.monaco-host { position: absolute; inset: 0; }
.monaco-host .spin-wrap { position: absolute; inset: 0; display: grid; place-items: center; }

/* design mode */
.design-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 12px;
  background: var(--accent-soft); border-bottom: 1px solid rgba(255,122,69,.25); color: var(--text-2); flex: none; }
.design-banner b { color: var(--accent); font-family: var(--mono); font-size: 12px; }
.design-banner-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
#design-stage { flex: 1; min-height: 0; position: relative; display: flex; }
#gjs { flex: 1; min-width: 0; }
#btn-ask-element.floating { position: absolute; right: 16px; bottom: 16px; z-index: 60; box-shadow: var(--shadow); }
#design-empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg-raised); z-index: 5; }

/* split mode */
#ws-split { flex-direction: column; }
.split-body { flex: 1 1 0; height: 0; min-height: 0; min-width: 0; display: flex; flex-direction: row; }
.split-editor { flex: 1 1 50%; min-width: 0; min-height: 0; height: 100%; position: relative; overflow: hidden; }
.split-preview { flex: 1 1 50%; min-width: 0; min-height: 0; height: 100%; background: #fff; display: flex; overflow: hidden; }
.split-preview iframe { flex: 1 1 auto; width: 100%; height: 100%; min-height: 0; border: 0; display: block; }
/* In Split mode the right panel is hidden by default (code+preview get the room);
   the ✦ AI button re-reveals it (body.show-right). */
body.mode-split #right-sidebar, body.mode-split #split-right { display: none; }
body.mode-split.show-right #right-sidebar { display: flex; }
body.mode-split.show-right #split-right { display: block; }
.split-toolbar { gap: 10px; }
.split-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); }
.live-dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.split-hint { margin-left: auto; }
.code-editor-tools { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--bg); border-bottom: 1px solid var(--line); flex: none; }
#btn-split-wrap.active { background: var(--accent-soft); border-color: rgba(255,122,69,.4); color: var(--accent); }

/* preview mode */
.device-toolbar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; flex-wrap: wrap; }
.dev-btn.active { background: var(--accent-soft); border-color: rgba(255,122,69,.4); color: var(--accent); }
.dev-sep { width: 1px; height: 20px; background: var(--line-2); }
.dev-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); }
.preview-stage { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  background: var(--bg-raised); background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); background-size: 22px 22px; padding: 14px; }
.preview-box { background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: var(--shadow);
  width: 100%; height: 100%; overflow: hidden; transform-origin: top center; flex: none; }
.preview-box iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

/* bottom panel */
#bottom-panel { flex: none; height: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg);
  border-top: 1px solid var(--line); overflow: hidden; transition: none; }
#bottom-panel.open { height: 180px; }
.bottom-tabs { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--line); flex: none; }
.btab { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font: 500 12.5px var(--font); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btab:hover { color: var(--text-2); }
.btab.active { background: var(--accent-soft); color: var(--accent); }
.bottom-spacer { flex: 1; }
.bpane { flex: 1; overflow: auto; min-height: 0; }
.sse-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.sse-detail { font-family: var(--mono); font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-list { padding: 6px 12px 12px; display: grid; gap: 4px; font: 12px/1.5 var(--mono); }
.err-item { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 3px 6px; border-radius: 5px; }
.err-item:hover { background: var(--surface); }
.err-item .t { color: var(--text-3); }
.err-item.bad .m { color: #fca5a5; } .err-item.warn .m { color: var(--warn); } .err-item.info .m { color: var(--text-2); }
.err-item .m { overflow-wrap: anywhere; }

/* status bar */
#statusbar { display: flex; align-items: center; gap: 0; height: 24px; padding: 0 10px; background: var(--bg-raised);
  border-top: 1px solid var(--line); font: 11.5px var(--font); color: var(--text-3); flex: none; user-select: none; }
.st { padding: 0 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-file { color: var(--text-2); max-width: 30vw; font-family: var(--mono); font-size: 11px; }
.st-element { color: var(--accent); font-family: var(--mono); font-size: 11px; max-width: 34vw; }
.st-spacer { flex: 1; }
#st-sse.ok { color: var(--ok); } #st-sse.bad { color: var(--bad); } #st-sse.warn { color: var(--warn); }

/* ---- right sidebar: properties (GrapesJS) + AI ---- */
.gjs-side { overflow: visible; }
#rpane-props { overflow-y: auto; }
.gjs-side-head { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.gjs-layers-box { max-height: 240px; overflow: auto; }

#rpane-ai { overflow: hidden; }
.ai-head { padding: 10px; display: grid; gap: 9px; border-bottom: 1px solid var(--line); flex: none; }
.ai-include-list { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-include-list .inc { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: 6px;
  background: var(--accent-soft); border: 1px solid rgba(255,122,69,.35); color: var(--accent); font: 11px var(--mono); max-width: 100%; }
.ai-include-list .inc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-include-list .inc button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 12px; padding: 0; line-height: 1; }
.ai-transcript { flex: 1; overflow-y: auto; padding: 10px; display: grid; gap: 10px; align-content: start; }
.ai-msg { border-radius: 10px; padding: 9px 11px; font-size: 13px; line-height: 1.55; max-width: 100%; overflow-wrap: anywhere; }
.ai-msg.user { background: var(--surface-2); border: 1px solid var(--line); margin-left: 24px; }
.ai-msg.assistant { background: var(--card); border: 1px solid var(--line); margin-right: 8px; }
.ai-msg .who { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 5px; }
.ai-msg pre { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; overflow-x: auto;
  font: 12px/1.5 var(--mono); margin: 7px 0; position: relative; }
.ai-msg code { font-family: var(--mono); font-size: 12px; }
.ai-msg p { margin: 5px 0; }
.ai-msg ul, .ai-msg ol { margin: 5px 0; padding-left: 20px; }
.copy-code { position: absolute; top: 5px; right: 5px; height: 22px; padding: 0 8px; border-radius: 5px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text-3); font: 11px var(--font); cursor: pointer; }
.copy-code:hover { color: var(--text); }
.ai-msg-tools { display: flex; gap: 6px; margin-top: 7px; }
.ai-compose { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); flex: none; align-items: flex-end; }
.ai-compose textarea { flex: 1; max-height: 140px; }

/* ---- GrapesJS blocks pane (left sidebar Blocks tab) ---- */
#lpane-blocks { overflow-y: auto; }
#gjs-blocks { padding: 8px; }

/* GrapesJS skin overrides — blend into Forgeverse surfaces */
.gjs-one-bg { background-color: var(--bg); }
.gjs-two-color { color: var(--text-2); }
.gjs-three-bg { background-color: var(--accent); }
.gjs-four-color, .gjs-four-color-h:hover { color: var(--accent); }
.gjs-editor { font-family: var(--font); }
.gjs-cv-canvas { background-color: var(--bg-raised); top: 0; width: 100%; height: 100%; }
.gjs-cv-canvas__frames { padding: 10px; }
.gjs-block { width: auto; min-height: auto; padding: 10px 8px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-2); font-size: 11.5px; transition: border-color .15s, color .15s; }
.gjs-block:hover { border-color: var(--accent); color: var(--text); }
.gjs-block svg { fill: currentColor; }
.gjs-block-label { color: inherit; }
.gjs-category-title, .gjs-block-category .gjs-title { background: var(--surface); color: var(--text-2); border-bottom: 1px solid var(--line); font-size: 12px; }
.gjs-title-inner, .gjs-category-title .gjs-title-inner { color: var(--text); }
.gjs-blocks-c { gap: 6px; }
.gjs-clm-tags, .gjs-sm-sector { border-color: var(--line); }
.gjs-sm-header, .gjs-clm-header-label, .gjs-sm-sector-title { color: var(--text-2); font-size: 12px; font-weight: 600; }
.gjs-field { background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; color: var(--text); }
.gjs-field:focus-within { border-color: var(--accent); }
.gjs-input, .gjs-field input, .gjs-field select, .gjs-field textarea { color: var(--text); font-size: 12px; }
.gjs-label { color: var(--text-3); font-size: 11.5px; }
.gjs-sm-btn, .gjs-clm-tag-btn, .gjs-sm-composite .gjs-sm-btn { background: var(--surface-2); color: var(--text-2); border-radius: 5px; }
.gjs-sm-btn:hover { background: var(--surface-3); color: var(--text); }
.gjs-clm-tags-c { background: transparent; }
.gjs-sel-cmp, .gjs-comp-selected { color: var(--text-3); font-size: 12px; }
.gjs-toolbar { background: var(--accent); border-radius: 6px; }
.gjs-toolbar-item { color: #1a0904; }
.gjs-resizer-h { border-color: var(--accent); background: var(--accent); }
.gjs-badge { background: var(--accent); color: #1a0904; }
.gjs-frame-wrapper__titler, .gjs-com-badge { color: var(--text-2); }
.gjs-pn-panel { border-color: var(--line); background: var(--bg); }
.gjs-pn-btn { color: var(--text-3); }
.gjs-pn-btn.gjs-pn-active, .gjs-pn-btn:hover { color: var(--text); }
.gjs-layer { background: var(--surface); color: var(--text-2); border-bottom: 1px solid var(--line); }
.gjs-layer:hover { background: var(--surface-2); }
.gjs-layer-title-inn, .gjs-layer-name { color: inherit; }
.gjs-layer.gjs-selected { background: var(--accent-soft); color: var(--accent); }
.gjs-layer-caret { color: var(--text-3); }
.gjs-sm-colorp-c, .gjs-checker-bg { background-color: var(--surface-2); }
.gjs-sp-fp .sp-replacer, .sp-replacer { border-color: var(--line-2); background: var(--surface-2); color: var(--text-2); }
.sp-container { background: var(--surface-2); border-color: var(--line-2); }
.sp-cancel, .sp-choose, .sp-initial, .sp-button-container { color: var(--text); }
.gjs-sm-btn-prim { background: var(--accent); color: #1a0904; }
.gjs-sm-icon { color: var(--text-3); }
.gjs-sm-composite { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
.gjs-sm-stack #gjs-sm-add { background: var(--surface-2); color: var(--text-2); }
.gjs-clm-tag { background: var(--accent-soft); color: var(--accent); }
.gjs-trt-trait .gjs-field, .gjs-trt-header { color: var(--text-2); }
.gjs-mdl-dialog { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); color: var(--text); box-shadow: var(--shadow); }
.gjs-mdl-header { border-bottom: 1px solid var(--line); color: var(--text); }
.gjs-mdl-title { color: var(--text); font-size: 14px; }
.gjs-mdl-btn-close { color: var(--text-3); }
.gjs-import-label, .gjs-export-title { color: var(--text-2); }
.gjs-am-assets-cont, .gjs-am-file-uploader { background: var(--surface-2); border-color: var(--line); }
.gjs-input-holder input { color: var(--text); }

/* ---- toasts ---- */
#toast-host { position: fixed; right: 16px; bottom: 40px; z-index: 3000; display: grid; gap: 8px; justify-items: end; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; font-size: 13.5px;
  box-shadow: var(--shadow); max-width: min(420px, 90vw); animation: toastin .18s var(--ease); }
.toast.bad { border-color: rgba(248,113,113,.4); }
.toast.ok { border-color: rgba(52,211,153,.35); }
.toast .ic { flex: none; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- modals ---- */
#modal-host { position: fixed; inset: 0; z-index: 2500; background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 24px; }
#modal-host.hidden { display: none; }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow);
  width: min(560px, 94vw); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1200px, 96vw); }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal-h .btn { height: 26px; width: 26px; padding: 0; font-size: 12px; }
.modal-b { padding: 16px 18px; overflow: auto; display: grid; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal label.field { font-size: 12.5px; }
.radio-row { display: grid; gap: 7px; }
.radio-row label { display: flex; gap: 9px; align-items: center; font-size: 13.5px; color: var(--text-2); cursor: pointer;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.radio-row label:hover { border-color: var(--line-3); }
.radio-row label.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.radio-row input { accent-color: var(--accent); }

/* command palette / quick open */
.palette-input { width: 100%; background: var(--bg); border: 0; border-bottom: 1px solid var(--line); color: var(--text);
  font: 15px var(--font); padding: 14px 18px; outline: none; }
.palette-list { overflow-y: auto; max-height: 56vh; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); font-size: 13.5px; }
.palette-item .kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; flex: none; }
.palette-item .path { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.palette-item.hl { background: var(--surface-2); color: var(--text); }
.palette-item.hl .path { color: var(--text-2); }

/* diff modal */
.diff-modal-body { padding: 0; display: grid; gap: 8px; }
.diff-file { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font: 12px var(--mono); color: var(--text-2);
  border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.diff-file .tag { font-family: var(--font); }
.diff-host { height: min(60vh, 560px); }

/* screenshot modal */
.shot-wrap { text-align: center; overflow: auto; background: var(--bg); border-radius: var(--r-sm); border: 1px solid var(--line); padding: 10px; }
.shot-wrap img { max-width: 100%; border-radius: 6px; }

/* spinner */
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; padding: 10px; }

/* Monaco context-menu / suggest widgets match the surfaces */
.monaco-editor .context-view .monaco-menu { background: var(--surface-2) !important; border: 1px solid var(--line-2); border-radius: 8px; }
.monaco-editor .suggest-widget { background: var(--surface-2) !important; border: 1px solid var(--line-2) !important; border-radius: 8px; }

/* scrollbars — dark everywhere; Firefox via scrollbar-color, WebKit below.
   (A stray LIGHT native scrollbar on a pane boundary was the only light-mode
   element in the dark UI — every scrollable surface now themes consistently.) */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2c2c33; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

/* narrow layouts (1366x768 works; below that sidebars shrink) */
@media (max-width: 1200px) {
  #left-sidebar { width: 210px; }
  #right-sidebar { width: 260px; }
  #project-select { max-width: 160px; }
}
@media (max-width: 980px) {
  #toolbar { flex-wrap: wrap; gap: 8px; }
  .tb-center { margin: 0; }
}
