:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --line: #dfe2e8;
  --text: #1c2230;
  --muted: #5f6878;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --good: #1d7f4e;
  --warn: #9a6400;
  --bad: #c0352b;
  --changed: rgba(47, 111, 222, 0.14);
  --node: #eef3fd;
  --node-line: #9db7ea;
  --site: #f1f7ef;
  --site-line: #9bc49a;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --panel: #1a1e26;
    --panel-2: #20252f;
    --line: #2e3542;
    --text: #e3e7ee;
    --muted: #97a0b0;
    --accent: #5b8fef;
    --accent-ink: #0d1117;
    --good: #4cc38a;
    --warn: #e0a84a;
    --bad: #f07167;
    --changed: rgba(91, 143, 239, 0.18);
    --node: #1f2a3d;
    --node-line: #3f5f99;
    --site: #1e2e22;
    --site-line: #4b7d52;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #12151b;
    --panel: #1a1e26;
    --panel-2: #20252f;
    --line: #2e3542;
    --text: #e3e7ee;
    --muted: #97a0b0;
    --accent: #5b8fef;
    --accent-ink: #0d1117;
    --good: #4cc38a;
    --warn: #e0a84a;
    --bad: #f07167;
    --changed: rgba(91, 143, 239, 0.18);
    --node: #1f2a3d;
    --node-line: #3f5f99;
    --site: #1e2e22;
    --site-line: #4b7d52;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}
h2, h3 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
button, .button, select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, select:focus-visible, textarea:focus-visible, [data-ref]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
code { font-family: var(--mono); font-size: 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.brand-sub { font-weight: 400; color: var(--muted); }
.logo { color: var(--accent); font-size: 18px; }
.engine { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.engine progress { width: 140px; }
.device { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); display: inline-block; }
.dot.ready { background: var(--good); }
.dot.bad { background: var(--bad); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.6fr) minmax(260px, 1fr);
  gap: 10px;
  padding: 10px 16px 16px;
}
.workspace.settings-hidden { grid-template-columns: minmax(280px, 1fr) minmax(360px, 2fr); }
.workspace.settings-hidden .settings { display: none; }
.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.pane-head.sub { border-top: 1px solid var(--line); background: var(--panel-2); }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

/* chat */
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { border-radius: 9px; padding: 8px 11px; max-width: 100%; overflow-wrap: anywhere; }
.msg p { margin: 0; }
.msg p + p, .msg ul { margin-top: 6px; }
.msg ul { padding-left: 18px; margin-bottom: 0; font-family: var(--mono); font-size: 12px; }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); max-width: 88%; }
.msg-user { position: relative; }
.edit-last { display: block; margin: 6px 0 0 auto; font-size: 11px; padding: 1px 8px; background: transparent; color: inherit; border-color: currentColor; opacity: 0.85; }
.edit-last:hover:not(:disabled) { opacity: 1; border-color: currentColor; }
.msg-assistant { background: var(--panel-2); border: 1px solid var(--line); }
.msg-system { color: var(--muted); background: transparent; border: 1px dashed var(--line); }
.status.good { color: var(--good); font-weight: 600; }
.status.warn { color: var(--warn); font-weight: 600; }
.status.bad { color: var(--bad); font-weight: 600; }
.note { color: var(--muted); font-size: 12px; }
.raw { margin-top: 6px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.raw pre { margin: 6px 0 0; font: 12px/1.4 var(--mono); white-space: pre-wrap; max-height: 220px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggestions button { font-size: 12px; }
.suggestions button.fresh { border-style: dashed; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: vertical;
  min-height: 42px;
  max-height: 200px;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
#send { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding: 8px 16px; font-weight: 600; }
#stop { padding: 8px 16px; color: var(--bad); }

/* editors */
.editor { flex: 1; min-height: 160px; overflow: hidden; position: relative; }
.manifest .editor { flex: 1.3; }
.editor .CodeMirror {
  position: absolute;
  inset: 0;
  height: auto;
  font: 13px/1.5 var(--mono);
  background: var(--panel);
  color: var(--text);
}
.CodeMirror-gutters { background: var(--panel-2); border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: var(--muted); }
.CodeMirror-cursor { border-left-color: var(--text); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: var(--changed) !important; }
.changed-line { background: var(--changed); transition: background 0.6s; }
.cm-s-default .cm-atom { color: var(--accent); }
.cm-s-default .cm-comment { color: var(--muted); font-style: italic; }
.cm-s-default .cm-string { color: var(--good); }
.cm-s-default .cm-number { color: var(--warn); }
.cm-s-default .cm-meta, .cm-s-default .cm-def { color: var(--bad); }

.problems { margin: 0; padding: 7px 12px 7px 28px; border-top: 1px solid var(--line); font-size: 12px; color: var(--bad); max-height: 110px; overflow-y: auto; }
.problems.ok { color: var(--good); padding-left: 12px; list-style: none; }

/* diagram */
.diagram-wrap { flex: 1; min-height: 150px; overflow: auto; padding: 4px; background: var(--panel-2); }
.diagram { display: block; max-width: 100%; height: auto; }
.diagram-empty { color: var(--muted); font-size: 12px; padding: 12px; margin: 0; }
.diagram .node rect { fill: var(--node); stroke: var(--node-line); stroke-width: 1.2; }
.diagram .node[data-ref] { cursor: pointer; }
.diagram .node[data-ref]:hover rect { stroke: var(--accent); stroke-width: 2; }
.diagram .node-site rect { fill: var(--site); stroke: var(--site-line); stroke-dasharray: 4 3; }
.diagram .node-missing rect { stroke: var(--bad); stroke-width: 1.6; }
.diagram .node-kind { font-size: 10.5px; fill: var(--muted); font-family: system-ui, sans-serif; }
.diagram .node-name { font-size: 12.5px; fill: var(--text); font-family: var(--mono); }
.diagram .edge { fill: none; stroke: var(--node-line); stroke-width: 1.4; }
.diagram .edge-site { stroke: var(--site-line); stroke-dasharray: 4 3; }
.diagram .arrow-head { fill: var(--node-line); }
.diagram .edge-label { font-size: 10px; fill: var(--muted); font-family: system-ui, sans-serif; paint-order: stroke; stroke: var(--panel-2); stroke-width: 3px; }

.settings-foot { padding: 9px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* small screens: one pane at a time, picked by the tabs */
.tabs { display: none; }
@media (max-width: 1100px) {
  .tabs { display: flex; gap: 6px; padding: 8px 16px 0; }
  .tabs button { flex: 1; padding: 7px 0; }
  .tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .workspace, .workspace.settings-hidden { grid-template-columns: 1fr; padding: 8px 16px 16px; }
  .workspace > .pane { display: none; }
  .workspace[data-pane="chat"] > .chat, .workspace[data-pane="manifest"] > .manifest, .workspace[data-pane="settings"] > .settings { display: flex; }
  .engine-detail { flex-basis: 100%; }
}

/* autocomplete */
.CodeMirror-hints { font: 12.5px/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.18); z-index: 20; max-height: 16em; }
.CodeMirror-hint { color: var(--text); padding: 1px 8px; }
li.CodeMirror-hint-active { background: var(--accent); color: var(--accent-ink); }
.CodeMirror-hints { max-width: min(560px, calc(100vw - 24px)); }
.CodeMirror-hint { display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: baseline; }
.CodeMirror-hint .hint-name { white-space: nowrap; }
.CodeMirror-hint .hint-shape { color: var(--muted); font-size: 11px; justify-self: end; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18ch; }
.CodeMirror-hint .hint-desc { grid-column: 1 / -1; color: var(--muted); font: 11px/1.35 system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
li.CodeMirror-hint-active .hint-shape, li.CodeMirror-hint-active .hint-desc { color: inherit; opacity: .85; }
.CodeMirror-hint.hint-template .hint-name { font-weight: 600; }
.prompt-hints { position: absolute; left: 10px; bottom: calc(100% - 4px); margin: 0; padding: 4px 0; list-style: none; min-width: 220px; max-width: calc(100% - 20px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.18); z-index: 20; }
.prompt-hints li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 10px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; }
.prompt-hints li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-hints li small { color: var(--muted); font-family: system-ui, sans-serif; white-space: nowrap; }
.prompt-hints li[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.prompt-hints li[aria-selected="true"] small { color: inherit; }

/* loading detail, review bar, problems, retry, example groups */
.engine-detail { color: var(--muted); font-size: 12px; }
.review { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 6px 12px; background: var(--changed); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.review-actions { display: flex; gap: 6px; }
#review-keep { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.problems li.jump { cursor: pointer; }
.problems li.jump:hover { text-decoration: underline; }
.problems li.warning { color: var(--warn); }
.problems.ok li.warning { list-style: disc; margin-left: 16px; }
.problems .fix { font-size: 11px; padding: 0 7px; margin-left: 4px; }
.retry { margin-top: 8px; font-size: 12px; }
.suggestions { flex-direction: column; align-items: stretch; }
.suggestion-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.group-label { flex-basis: 100%; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.cm-comment { cursor: default; }
.prompt-hints li.phrase span { font-family: system-ui, sans-serif; }
.prompt-hints li.history small::before { content: "↺ "; }

/* help */
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#help { width: min(860px, calc(100vw - 32px)); max-height: min(86vh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#help[open] { display: flex; flex-direction: column; }
#help::backdrop { background: rgba(10, 14, 22, .45); }
.help-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.help-head h2 { font-size: 15px; }
.help-tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.help-tabs button { border-color: transparent; background: transparent; }
.help-tabs button[aria-selected="true"] { background: var(--changed); border-color: var(--accent); color: var(--text); }
.help-close { font-size: 18px; line-height: 1; padding: 2px 9px; }
.help-body { overflow-y: auto; padding: 16px 20px 22px; font-size: 14px; }
.help-body .lead { margin: 0 0 14px; color: var(--muted); }
.help-body h3 { font-size: 13.5px; margin: 0 0 4px; }
.help-body p { margin: 0 0 8px; }
.steps { padding-left: 22px; margin: 0 0 14px; display: grid; gap: 10px; }
.steps li strong { display: block; margin-bottom: 2px; }
.rule { padding: 12px 0; border-top: 1px solid var(--line); }
.rule:first-of-type { border-top: none; padding-top: 0; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.compare > div { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel-2); }
.compare .bad { border-left: 3px solid var(--bad); }
.compare .good { border-left: 3px solid var(--good); }
.compare .tag { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.compare code { white-space: normal; overflow-wrap: anywhere; }
.example-area { margin-bottom: 14px; }
.example-list { display: flex; flex-direction: column; gap: 6px; }
button.example { text-align: left; padding: 6px 10px; display: block; width: 100%; }
button.example code { white-space: normal; overflow-wrap: anywhere; font-size: 12.5px; }
button.example.fresh { border-style: dashed; }
.steps button.example { width: auto; display: inline-block; margin-top: 2px; }
.try { color: var(--muted); font-size: 12px; margin-right: 4px; }
.limits dt { font-weight: 600; margin-top: 10px; }
.limits dd { margin: 2px 0 0; color: var(--text); }
.keys { border-collapse: collapse; margin-bottom: 12px; }
.keys td { padding: 5px 14px 5px 0; vertical-align: top; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }

/* tour */
.tour { position: fixed; inset: 0; z-index: 1000; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10, 14, 22, .55); outline: 2px solid var(--accent); pointer-events: none; transition: all .2s ease; }
.tour-card { position: fixed; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: 0 12px 34px rgba(0,0,0,.35); }
.tour-card h3 { margin: 0 0 6px; font-size: 14px; }
.tour-card p { margin: 0 0 12px; font-size: 13.5px; }
.tour-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.tour-actions .note { margin-right: auto; }
.help-offer { position: fixed; right: 16px; bottom: 16px; z-index: 900; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 28px rgba(0,0,0,.25); font-size: 13px; }
.help-offer .dismiss { border: none; background: none; font-size: 16px; padding: 0 4px; }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
/* the hidden attribute must win over display rules above */
[hidden] { display: none !important; }

/* kinds reference */
#kinds { width: min(1100px, calc(100vw - 32px)); height: min(88vh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#kinds[open] { display: flex; flex-direction: column; }
#kinds::backdrop { background: rgba(10, 14, 22, .45); }
#kind-search { flex: 1; min-width: 180px; font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; }
.kinds-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px 1fr; }
.kind-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel-2); }
.kind-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 6px 4px; }
.kind-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%; text-align: left; border-color: transparent; background: transparent; font-family: var(--mono); font-size: 12.5px; padding: 3px 6px; }
.kind-item[aria-current="true"] { background: var(--changed); border-color: var(--accent); }
.kind-item.muted { color: var(--muted); }
.in-yaml { font-family: system-ui, sans-serif; font-size: 10.5px; color: var(--good); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; }
.kind-detail { overflow-y: auto; padding: 16px 22px 24px; }
.kind-detail h3 { font-size: 18px; margin: 0 0 6px; font-family: var(--mono); }
.kind-detail h4 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.badge { font-size: 11.5px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--panel-2); }
.badge.good { color: var(--good); border-color: currentColor; }
.badge.muted { color: var(--muted); }
.kind-summary { font-size: 14.5px; margin: 0 0 12px; }
.kind-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rel { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.rel-label { font-size: 12px; font-weight: 600; color: var(--muted); font-family: var(--mono); }
.rel-item { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kind-chip { display: inline-flex; gap: 6px; align-items: baseline; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--node); border: 1px solid var(--node-line); }
.kind-chip strong { font-family: var(--mono); font-weight: 600; }
.kind-chip.site { background: var(--site); border: 1px dashed var(--site-line); }
.rel-how { color: var(--muted); }
.rel-path { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.fields { list-style: none; margin: 4px 0 0; padding-left: 16px; border-left: 1px solid var(--line); }
.fields li { margin: 3px 0; }
.fields details > summary { cursor: pointer; list-style-position: outside; }
.field-head { display: inline-flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.field-name { font-weight: 600; font-size: 12.5px; }
.field-shape { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.req { font-size: 10.5px; color: var(--bad); border: 1px solid currentColor; border-radius: 999px; padding: 0 5px; }
.field-desc { display: block; font-size: 12px; color: var(--muted); margin: 1px 0 2px; }
@media (max-width: 760px) {
  .kinds-body { grid-template-columns: 1fr; grid-template-rows: 34% 1fr; }
  .kind-list { border-right: none; border-bottom: 1px solid var(--line); }
}
.fields details > summary, .kind-detail > section > details > summary { display: list-item; }
.kind-detail summary .field-name { margin-right: 8px; }
.kind-item { overflow-wrap: normal; word-break: normal; }
@media (max-width: 1100px) { .brand-sub { display: none; } }

/* kind diagrams */
.kind-diagram, .kind-map { display: block; width: 100%; height: auto; margin: 4px 0 14px; }
.kind-map-wrap { overflow-x: auto; }
.kind-map { min-width: 760px; }
.kd-node rect { fill: var(--node); stroke: var(--node-line); stroke-width: 1.2; }
.kd-node[data-kind] { cursor: pointer; }
.kd-node[data-kind]:hover rect, .kd-node[data-kind]:focus rect { stroke: var(--accent); stroke-width: 2; }
.kd-node:focus { outline: none; }
.kd-center rect { fill: var(--accent); stroke: var(--accent); }
.kd-center .kd-name { fill: var(--accent-ink); font-weight: 600; }
.kd-site rect { fill: var(--site); stroke: var(--site-line); stroke-dasharray: 4 3; }
.kd-name { font: 12px var(--mono); fill: var(--text); }
.kd-col { font: 600 11px system-ui, sans-serif; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kd-edge { fill: none; stroke: var(--node-line); stroke-width: 1.4; }
.kd-site-edge { stroke: var(--site-line); stroke-dasharray: 4 3; }
.kd-head { fill: var(--node-line); }
.kd-label { font: 10.5px system-ui, sans-serif; fill: var(--muted); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; }
.km-group { fill: var(--panel-2); stroke: var(--line); }
.km-group-name { font: 600 11px system-ui, sans-serif; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.km-name { font-size: 11.5px; }
.km-edge { fill: none; stroke: var(--node-line); stroke-width: 1; opacity: .45; transition: opacity .15s; }
.kind-map.km-focus .km-edge { opacity: .07; }
.kind-map.km-focus .km-edge.km-on { opacity: 1; stroke: var(--accent); stroke-width: 1.8; }
.kind-map.km-focus .km-node:not(.km-on) { opacity: .35; }
.kind-map.km-focus .km-node.km-on rect { stroke: var(--accent); stroke-width: 2; }
.map-item { font-family: system-ui, sans-serif; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .km-edge { transition: none; } }
.kd-how { font: 10.5px system-ui, sans-serif; fill: var(--muted); }

/* menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: " ▾"; color: var(--muted); font-size: 11px; }
details.menu[open] > summary, details.menu > summary:hover { border-color: var(--accent); }
details.menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.menu-panel { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: min(360px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.2); padding: 5px; display: flex; flex-direction: column; gap: 2px; }
.menu-right .menu-panel { left: auto; right: 0; }
.menu-panel > button, .menu-panel .menu-row, .menu-panel .file-row > button:first-child { text-align: left; border-color: transparent; background: transparent; width: 100%; padding: 6px 9px; }
.menu-panel > button:hover:not(:disabled), .menu-panel .file-row > button:hover { background: var(--changed); border-color: transparent; }
.menu-panel hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.menu-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 9px 2px; }
.menu-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text); }
.template-item { display: flex !important; flex-direction: column; align-items: flex-start; gap: 1px; }
.template-item small { color: var(--muted); font-size: 11.5px; white-space: normal; }
.file-row { display: flex; align-items: center; gap: 4px; }
.file-del { font-size: 11px; padding: 1px 7px; color: var(--bad); }
.menu-panel .note { padding: 4px 9px; margin: 0; }

/* create or change */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.mode-switch button { border: none; border-radius: 0; padding: 4px 10px; background: var(--panel-2); }
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* replies */
.report { margin: 8px 0 0 8px; font-size: 12px; color: var(--muted); }
.plain-problems ul { font-family: inherit; font-size: 13px; }
.plain-problems .tip { margin-top: 6px; font-size: 12.5px; color: var(--text); }
.restored-divider { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0; }

/* editor helpers */
.problem-gutter { width: 14px; }
.problem-dot { color: var(--bad); font-size: 11px; cursor: help; padding-left: 3px; }
.field-tip { position: fixed; z-index: 60; max-width: 380px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 12.5px; pointer-events: none; }
.field-tip strong { font-family: var(--mono); }
.field-tip .tip-shape { color: var(--muted); font-size: 11.5px; }
.field-tip p { margin: 4px 0 0; color: var(--muted); }
.settings-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* import and diff dialogs */
#import-dialog, #diff-dialog { width: min(720px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#import-dialog::backdrop, #diff-dialog::backdrop { background: rgba(10, 14, 22, .45); }
.import-form { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.import-form h2 { font-size: 15px; }
.import-form p { margin: 0; }
.cmd { margin: 0; font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; overflow-x: auto; }
#import-text { font: 12px var(--mono); color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; resize: vertical; }
.import-actions { display: flex; justify-content: flex-end; gap: 8px; }
#diff-dialog[open] { display: flex; flex-direction: column; max-height: 86vh; }
.diff { margin: 0; overflow: auto; padding: 10px 14px; font: 12.5px/1.5 var(--mono); }
.diff .add { background: rgba(29, 127, 78, .14); color: var(--good); display: block; }
.diff .del { background: rgba(192, 53, 43, .12); color: var(--bad); display: block; text-decoration: line-through; text-decoration-color: rgba(192,53,43,.4); }
.diff .same { color: var(--muted); display: block; }
.menu-panel .template-item { text-align: left; border-color: transparent; background: transparent; padding: 7px 9px; }
.menu-panel .template-item:hover { background: var(--changed); }
.menu-panel .template-item strong { font-size: 13px; }
/* keep the top bar on one row while the model downloads: the detail line shrinks and truncates */
.engine { flex-wrap: nowrap; min-width: 0; }
.topbar { flex-wrap: nowrap; }
.engine-detail { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
#engine-status { white-space: nowrap; }
@media (max-width: 1100px) { .topbar, .engine { flex-wrap: wrap; } .engine-detail { max-width: none; white-space: normal; } }

/* questions, readiness, version */
.question { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 8px; background: var(--changed); }
.question p { margin: 0 0 6px; font-weight: 600; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { font-family: var(--mono); font-size: 12px; }
#ready-dialog { width: min(720px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#ready-dialog[open] { display: flex; flex-direction: column; max-height: 86vh; }
#ready-dialog::backdrop { background: rgba(10, 14, 22, .45); }
.ready-list { list-style: none; margin: 0; padding: 12px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.ready-list > li { display: grid; grid-template-columns: 20px 1fr; gap: 2px 8px; }
.ready-list > li > details { grid-column: 2; font-size: 12.5px; color: var(--muted); }
.ready-list .mark { font-weight: 700; }
.ready-list li.good .mark { color: var(--good); }
.ready-list li.bad .mark { color: var(--bad); }
.ready-foot { padding: 10px 18px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.menu-version { padding: 4px 9px !important; font-size: 11.5px; }
.brand .logo { width: 24px; height: 24px; display: block; border-radius: 6px; }

/* phones: a compact header and menus as a bottom sheet */
@media (max-width: 760px) {
  .topbar { padding: 6px 12px; gap: 6px; }
  .engine { gap: 6px; width: 100%; flex-wrap: nowrap; }
  .engine > button { padding: 3px 9px; }
  #engine-status { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; font-size: 12.5px; }
  #engine-bar { width: 56px; flex: none; }
  .engine-detail { display: none; }
  .tabs { padding: 6px 12px 0; }
  .tabs button { padding: 5px 0; }
  .workspace, .workspace.settings-hidden { padding: 6px 12px 12px; }
  .pane-head { padding: 7px 10px; }
  .menu-panel, .menu-right .menu-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; max-width: none; max-height: 72vh; border-radius: 12px; box-shadow: 0 -8px 30px rgba(0,0,0,.3); z-index: 200; }
  details.menu[open]::before { content: ""; position: fixed; inset: 0; background: rgba(10, 14, 22, .35); z-index: 150; }
  .msg-system .hint { font-size: 12px; }
}

/* platform kinds in the kinds browser */
.kind-icon { width: 1.4em; flex: none; text-align: center; font-family: system-ui, sans-serif; font-size: 12px; opacity: .85; }
.kind-item { justify-content: flex-start; }
.kind-item .in-yaml { margin-left: auto; }
.kind-chip.platform { border-style: dashed; background: var(--panel-2); }
.kind-legend { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.badge.access-managed, .badge.access-cluster, .badge.access-created { border-style: dashed; }
.kd-platform rect { stroke-dasharray: 4 3; fill: var(--panel-2); }
.kd-creates, .km-creates { stroke-dasharray: 5 4; stroke: var(--warn); }
table.deps { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0 10px; }
table.deps th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); padding: 5px 8px 5px 0; }
table.deps td { vertical-align: top; border-bottom: 1px solid var(--line); padding: 6px 8px 6px 0; }
table.deps td code { font-size: 11.5px; overflow-wrap: anywhere; }
.creates-tree { list-style: none; margin: 4px 0 8px; padding-left: 16px; border-left: 1px dashed var(--warn); font-size: 13px; }
.creates-tree li { margin: 3px 0; }
.kind-detail pre.cmd { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 10px; }

/* resizable panes */
.workspace { column-gap: 0; }
.workspace > .pane { margin: 0 2px; }
.splitter { position: relative; z-index: 5; touch-action: none; }
.splitter-vertical { cursor: col-resize; width: 6px; align-self: stretch; }
.splitter-horizontal { cursor: row-resize; height: 7px; flex: none; background: var(--panel-2); border-top: 1px solid var(--line); }
.splitter::after { content: ""; position: absolute; border-radius: 2px; background: var(--line); transition: background .15s; }
.splitter-vertical::after { left: 2px; width: 2px; top: 30%; bottom: 30%; }
.splitter-horizontal::after { top: 2px; height: 3px; left: 42%; right: 42%; }
.splitter:hover::after, .splitter:focus-visible::after, .splitter.dragging::after { background: var(--accent); }
.splitter:focus-visible { outline: none; }
body.resizing-x, body.resizing-x * { cursor: col-resize !important; user-select: none; }
body.resizing-y, body.resizing-y * { cursor: row-resize !important; user-select: none; }
@media (max-width: 1100px) { .splitter { display: none; } }
.access-icon { width: 13px; height: 13px; vertical-align: -2px; flex: none; }
.kind-icon { display: inline-flex; align-items: center; justify-content: center; }
.badge .access-icon { margin-right: 2px; }

/* chat suggestions: a slim strip above the box, never over the conversation */
.prompt-hints { display: none !important; }
.prompt-strip { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; background: var(--panel); }
.prompt-strip[hidden] { display: none; }
.strip-label { flex: none; font-size: 11px; color: var(--muted); font-weight: 600; }
.chip-suggestion { flex: none; display: inline-flex; align-items: baseline; gap: 6px; max-width: 46ch; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); }
.chip-suggestion span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.chip-suggestion.phrase span { font-family: system-ui, sans-serif; font-size: 12.5px; }
.chip-suggestion small { color: var(--muted); font-size: 11px; }
.chip-suggestion.active { border-color: var(--accent); background: var(--changed); }
.chip-suggestion.history span::before { content: "↺ "; color: var(--muted); }

/* collapsible chat and settings panes */
.collapse { padding: 0 7px; margin-right: 4px; font-size: 14px; line-height: 1.3; }
.workspace.chat-collapsed > .chat, .workspace.settings-collapsed > .settings { cursor: pointer; min-width: 0; }
.workspace.chat-collapsed > .chat > :not(.pane-head), .workspace.settings-collapsed > .settings > :not(.pane-head) { display: none !important; }
.workspace.chat-collapsed > .chat .pane-head, .workspace.settings-collapsed > .settings .pane-head { border-bottom: none; flex-direction: column; align-items: center; padding: 8px 0; height: 100%; }
.workspace.chat-collapsed > .chat .pane-head > :not(h2), .workspace.settings-collapsed > .settings .pane-head > :not(h2) { display: none; }
.workspace.chat-collapsed > .chat h2, .workspace.settings-collapsed > .settings h2 { writing-mode: vertical-rl; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.workspace.chat-collapsed > .chat h2 .collapse, .workspace.settings-collapsed > .settings h2 .collapse { writing-mode: horizontal-tb; margin: 0 0 6px; }
.splitter.inert { pointer-events: none; visibility: hidden; }
.workspace.settings-hidden .settings { display: flex; }
@media (max-width: 1100px) { .collapse { display: none; } }

/* validations in the kinds browser */
.validations { display: block; margin-top: 3px; }
.validations ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.validations li { font-size: 11.5px; color: var(--muted); }
.validations code { font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; color: var(--text); }
.validations .v-label { font-weight: 600; }
.validations .v-title { display: block; font-size: 11.5px; color: var(--text); margin-bottom: 2px; }
.field-shape { overflow-wrap: anywhere; }

/* context size under the chat box */
.context-meter { display: flex; align-items: center; gap: 8px; padding: 0 12px 8px; font-size: 11.5px; color: var(--muted); }
.context-meter .meter { flex: none; width: 90px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.context-meter .meter-fill { display: block; height: 100%; width: 0; background: var(--good); transition: width .2s; }
.context-meter.warn .meter-fill { background: var(--warn); }
.context-meter.over .meter-fill { background: var(--bad); }
.context-meter.over { color: var(--bad); }
.workspace.chat-collapsed > .chat > .context-meter { display: none !important; }

/* form view */
.view-switch { margin-right: auto; margin-left: 10px; }
.form-view { flex: 1.3; min-height: 160px; overflow-y: auto; padding: 10px 14px 16px; background: var(--panel); }
.form-view[hidden] { display: none; }
.form-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.form-picker, .form-enum, .form-addfield { font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; max-width: 100%; }
.form-status { font-size: 12px; color: var(--muted); }
.form-status.bad { color: var(--bad); }
.form-group { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 10px; margin: 0 0 10px; }
.form-group > legend { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 4px; }
.form-field { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 2px 10px; align-items: center; padding: 4px 0; }
.form-label { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.form-key { font: 600 12.5px var(--mono); }
.form-control { display: flex; gap: 6px; align-items: center; min-width: 0; }
.form-input { flex: 1; min-width: 0; font: 12.5px var(--mono); color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; }
.form-input:invalid { border-color: var(--bad); }
.form-help { grid-column: 2; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-section { border-left: 2px solid var(--line); margin: 4px 0; padding-left: 8px; }
.form-section > summary { cursor: pointer; display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.form-meta { font-size: 11.5px; color: var(--muted); }
.form-section .form-remove { margin-left: auto; }
.form-object, .form-list, .form-map { padding: 2px 0 4px; }
.form-row { display: flex; gap: 6px; align-items: center; margin: 3px 0; }
.map-row .key { flex: 0 0 38%; }
.form-remove { padding: 0 7px; font-size: 13px; color: var(--muted); }
.form-add { font-size: 12px; margin-top: 4px; }
.form-addfield { margin-top: 6px; font-size: 12px; color: var(--muted); }
.form-yaml { width: 100%; font: 12px var(--mono); color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.form-empty { color: var(--muted); font-size: 13px; }

#about { width: min(860px, calc(100vw - 32px)); max-height: min(88vh, 900px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#about[open] { display: flex; flex-direction: column; }
#about::backdrop { background: rgba(10, 14, 22, .45); }
.about-body h3 { margin: 16px 0 6px; }
.about-table a { color: var(--accent); }

/* model off, settings enforcement, zoomable map */
.enforce { display: flex; align-items: center; gap: 6px; font-size: 12.5px; flex-basis: 100%; }
.kind-map-wrap.zoomable { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; height: min(62vh, 640px); }
.kind-map-wrap.zoomable .kind-map { min-width: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.kind-map-wrap.zoomable .kind-map.panning { cursor: grabbing; }
.zoom-bar { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 4px; }
.zoom-bar button { padding: 2px 9px; background: var(--panel); }
