:root {
  --bg: #14161a;
  --pane: #1b1e24;
  --pane-hd: #22262e;
  --line: #2e333d;
  --fg: #e6e8ec;
  --muted: #8b93a1;
  --accent: #4a9eff;
}

* { box-sizing: border-box; }

/* The UA default #005fcc was only ~2.5:1 on the #22262e pane header. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

#app {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  height: 100vh;
  gap: 1px;
  background: var(--line);
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--pane);
}

.pane-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--pane-hd);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  flex: 0 0 auto;
}

.pane-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---- center canvas: 3D + 2D ---- */
#canvas-body {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

#canvas-3d, #canvas-2d {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #0f1114;
}

.sub-hd {
  flex: 0 0 auto;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  background: #191c21;
  border-bottom: 1px solid var(--line);
}

.sub-hd-row { display: flex; align-items: center; gap: 6px; }
.sub-hd-row > span:first-child { margin-right: auto; }
/* At 1024 the 2D tools used to wrap every label onto two lines. Keep each
 * control on one line and let the strip scroll horizontally instead. */
#canvas-2d .sub-hd-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #46505e transparent;
}
#canvas-2d .sub-hd-row > span:first-child,
#canvas-2d .sub-hd-row > * { flex: 0 0 auto; white-space: nowrap; }
#canvas-2d .sub-hd-row .hd-btn,
#canvas-2d .sub-hd-row .export-note { white-space: nowrap; }
#canvas-2d .sub-hd-row::-webkit-scrollbar { height: 6px; }
#canvas-2d .sub-hd-row::-webkit-scrollbar-thumb {
  background: #3c4552; border-radius: 3px;
}
#btn-pdf { text-decoration: none; }
.export-note { font-size: 11px; color: var(--muted); }
.export-note.is-bad { color: #ff7b72; }

.viewport {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gl { display: block; width: 100%; height: 100%; }

/* ---- chat ---- */
.pane-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

#chat-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  background: #0f1114;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 4px;
}

#chat-send {
  padding: 6px 12px;
  background: var(--accent);
  color: #06101c;
  border: 0;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- layout modes (T014 will drive these) ---- */
body[data-layout="3d"] #canvas-body { grid-template-rows: 1fr; }
body[data-layout="3d"] #canvas-2d { display: none; }
body[data-layout="2d"] #canvas-body { grid-template-rows: 1fr; }
body[data-layout="2d"] #canvas-3d { display: none; }

/* ---- structure tree (T004) ---- */
#tree-body { padding: 4px 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.node {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: default;
  white-space: nowrap;
}

.node:hover { background: #22262e; }
.node.is-branch { cursor: pointer; }

.node-key { color: #9fc6ff; }
.node-key::after { content: ':'; color: var(--muted); margin-left: 1px; }

.node-val { color: var(--fg); overflow: hidden; text-overflow: ellipsis; }
.node-val.editable { cursor: text; }
.node-val.editable:hover { color: var(--accent); text-decoration: underline dotted; }

.node-kids {
  margin-left: 10px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.node.collapsed + .node-kids { display: none; }

/* ---- 2D drawing canvas (T013) ---- */
#drawing { background: #ffffff; padding: 4px; cursor: grab; touch-action: none; }
#drawing.panning { cursor: grabbing; }
#drawing.panning g.part { cursor: grabbing; }
.zoom-tools { display: inline-flex; gap: 2px; margin-right: 8px; }
#canvas-2d:fullscreen { background: var(--bg, #0f1115); display: flex; flex-direction: column; }
#canvas-2d:fullscreen .viewport { flex: 1 1 auto; }
#drawing svg { display: block; width: 100%; height: 100%; }

/* ---- selection highlight (T010) ---- */
.node.selected { background: #2f6fff33; outline: 1px solid #2f6fff; }

/* build status (T101) */
.hd-right { display: inline-flex; align-items: center; gap: 10px; }
.build-status { font-size: 11px; font-weight: 400; padding: 1px 8px; border-radius: 9px; border: 1px solid var(--line); }
.build-status.is-idle { color: #6fcf97; border-color: #2f5a41; }
.build-status.is-running { color: var(--accent); border-color: #2c4a70; }
.build-status.is-failed { color: #ff7b72; border-color: #6e2c2c; cursor: help; }

/* undo / redo (T114) */
.hd-btn { font: inherit; font-size: 11px; font-weight: 400; color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; cursor: pointer; }
.hd-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.hd-btn:disabled { opacity: 0.35; cursor: default; }

/* ======================================================================
   agent chat (T122)
   ====================================================================== */
#app { grid-template-columns: 260px minmax(0, 1fr) 400px; }
#chat { position: relative; }
[hidden] { display: none !important; }

.chat-hd { gap: 6px; }
.chat-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-model-bar {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-bottom: 1px solid var(--line); background: #1e2128; flex: 0 0 auto;
}
.chat-model-bar select, .model-btn {
  font: inherit; font-size: 12px; color: var(--fg); background: #0f1114;
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px;
}
.chat-model-bar select { flex: 0 1 auto; max-width: 120px; }
.model-btn { flex: 1 1 auto; min-width: 0; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn:hover:not(:disabled) { border-color: var(--accent); }
#chat-usage { margin-left: auto; white-space: nowrap; font-size: 11px; }

/* popovers: model menu, settings, session drawer */
.chat-pop {
  position: absolute; z-index: 5; left: 8px; right: 8px; top: 76px; max-height: 60%;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: #20242c; border: 1px solid #3a404c; border-radius: 6px; box-shadow: 0 8px 24px #0008;
}
.chat-pop input[type="search"] {
  font: inherit; font-size: 12px; color: var(--fg); background: #0f1114;
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px;
}
.chat-pop-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-pop-error { color: #ff7b72; font-size: 12px; padding: 4px; }
.model-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  font: inherit; color: var(--fg); background: transparent; border: 1px solid transparent;
  border-radius: 4px; padding: 4px 8px; cursor: pointer;
}
.model-item:hover { background: #2a2f39; }
.model-item.selected { border-color: var(--accent); }
.model-name { font-size: 12px; }
.model-meta { font-size: 11px; color: var(--muted); }

.chat-settings { gap: 8px; overflow: auto; }
.set-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 4px 8px; font-size: 12px; }
.set-label { color: var(--muted); }
.set-input {
  font: inherit; font-size: 12px; color: var(--fg); background: #0f1114;
  border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; min-width: 0;
}
.set-input:disabled { opacity: 0.4; }
.set-note { grid-column: 2; font-size: 11px; color: #d6a85c; }

.chat-drawer { top: 38px; bottom: 60px; max-height: none; }
.session-item { display: flex; align-items: center; gap: 4px; border-radius: 4px; }
.session-item:hover { background: #2a2f39; }
.session-item.selected { outline: 1px solid var(--accent); }
.session-main {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  font: inherit; color: var(--fg); background: transparent; border: 0; padding: 4px 6px;
  text-align: left; cursor: pointer;
}
.session-title { font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { font-size: 11px; color: var(--muted); }
.session-rename-input {
  flex: 1; font: inherit; font-size: 12px; color: var(--fg); background: #0f1114;
  border: 1px solid var(--accent); border-radius: 4px; padding: 3px 6px;
}
.session-empty { padding: 8px; }
.icon-btn {
  font: inherit; font-size: 11px; color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 4px; padding: 1px 5px; cursor: pointer; white-space: nowrap;
}
.icon-btn:hover { color: var(--fg); border-color: var(--line); }
.icon-btn.confirm { color: #ff7b72; border-color: #6e2c2c; }

/* conversation */
#chat-body { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.chat-empty { margin: auto 0; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; padding: 16px; }
.chat-empty-title { font-size: 14px; font-weight: 600; }
.chat-suggestions { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 6px; }
.chat-suggestion {
  font: inherit; font-size: 12px; color: var(--fg); background: #20242c; text-align: left;
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; cursor: pointer;
}
.chat-suggestion:hover { border-color: var(--accent); }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg-user { align-self: flex-end; max-width: 88%; }
.msg-user .msg-text {
  white-space: pre-wrap; word-break: break-word; background: #24476e;
  border-radius: 10px 10px 2px 10px; padding: 7px 10px;
}
.msg-assistant { align-self: stretch; }
.msg-blocks { display: flex; flex-direction: column; gap: 6px; }
.msg-meta { font-size: 11px; color: var(--muted); }
.msg-meta:empty { display: none; }
.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.msg-user .msg-actions { justify-content: flex-end; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-action {
  font: inherit; font-size: 11px; color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; cursor: pointer;
}
.msg-action:hover { color: var(--accent); border-color: var(--accent); }
.msg-editor {
  font: inherit; color: var(--fg); background: #0f1114; border: 1px solid var(--accent);
  border-radius: 6px; padding: 6px 8px; min-height: 60px; resize: vertical;
}

.md { line-height: 1.6; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.4em 0; }
.md ul, .md ol { margin: 0.4em 0; padding-left: 1.4em; }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: #0f1114; border-radius: 3px; padding: 0 3px;
}
.md pre { background: #0d1117; border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow: auto; }
.md pre code { background: transparent; padding: 0; }
.md table { border-collapse: collapse; font-size: 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 2px 6px; }
.md a { color: var(--accent); }

.think { border-left: 2px solid #3a404c; padding-left: 8px; color: var(--muted); font-size: 12px; }
.think summary { cursor: pointer; user-select: none; }
.think-text { white-space: pre-wrap; margin-top: 4px; }

.waiting { font-size: 12px; color: var(--muted); }
.waiting::before { content: '● '; color: var(--accent); animation: chat-pulse 1s infinite alternate; }
@keyframes chat-pulse { from { opacity: 0.3; } to { opacity: 1; } }

.tool-card {
  border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 6px;
  background: #171a1f; padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 4px;
}
.tool-card.is-ok { border-left-color: #3fb27f; }
.tool-card.is-error { border-left-color: #ff7b72; }
.tool-card.is-running { border-left-color: var(--accent); }
.tool-hd { display: flex; align-items: center; gap: 6px; }
.tool-name { font-weight: 600; }
.tool-id { color: var(--muted); font-size: 11px; }
.tool-status { margin-left: auto; color: var(--muted); font-size: 11px; }
.tool-args summary, .tool-result summary, .tool-changes summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.tool-args pre, .tool-result pre {
  margin: 4px 0 0; font-size: 11px; max-height: 200px; overflow: auto;
  background: #0f1114; padding: 6px; border-radius: 4px;
}
.tool-changes ul { margin: 4px 0 0; padding-left: 1.2em; font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.tool-summary { font-family: ui-monospace, Menlo, monospace; }
.tool-error { color: #ff7b72; }
.tool-path { margin-left: 6px; color: var(--muted); font-size: 11px; }
.tool-hint { color: #d6a85c; }
.tool-build.is-ok { color: #6fcf97; }
.tool-build.is-failed { color: #ff7b72; }
.tool-undo {
  align-self: flex-start; font: inherit; font-size: 11px; color: var(--fg); background: transparent;
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 8px; cursor: pointer;
}
.tool-undo:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tool-undo:disabled { opacity: 0.45; cursor: default; }

.msg-notice { font-size: 12px; padding: 6px 8px; border-radius: 6px; }
.msg-notice.is-warn { color: #d6a85c; background: #2b2416; }
.msg-notice.is-error { color: #ff7b72; background: #2d1717; }

/* composer */
.chat-foot { align-items: flex-end; }
#chat-text { resize: none; font: inherit; line-height: 1.4; max-height: 160px; }
#chat-stop {
  padding: 6px 12px; background: #3a2020; color: #ffb3ad; border: 1px solid #6e2c2c;
  border-radius: 4px; font-weight: 600; cursor: pointer;
}
#chat-send:disabled, #chat-stop:disabled { opacity: 0.5; cursor: default; }

/* image attachments (T413) */
.chat-attach {
  font: inherit; padding: 6px 8px; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
}
.chat-attach:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.chat-attach:disabled { opacity: 0.35; cursor: default; }
.chat-attachments { padding: 6px 8px 0; border-top: 1px solid var(--line); }
.chat-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-thumb { position: relative; width: 56px; height: 56px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.chat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-thumb.is-uploading { opacity: 0.5; }
.chat-thumb-remove {
  position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; line-height: 14px; padding: 0;
  font-size: 12px; color: #fff; background: rgba(0, 0, 0, 0.6); border: 0; border-radius: 8px; cursor: pointer;
}
.chat-attach-error { font-size: 11px; color: #ff7b72; padding: 4px 0 0; }
#chat.is-dropping { outline: 2px dashed var(--accent); outline-offset: -4px; }
.msg-images { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.msg-image { display: block; max-width: 160px; max-height: 120px; border-radius: 6px; border: 1px solid var(--line); }
.msg-image-missing { font-size: 11px; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; padding: 6px 8px; }
.msg-edit-images { font-size: 11px; color: var(--muted); }

/* ======================================================================
   left pane tabs, structure / checks / library (T105),
   layout switch (T014), drawing highlight (T015)
   ====================================================================== */
#app { grid-template-columns: 300px minmax(0, 1fr) 400px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 12px; font-weight: 500; color: var(--muted); background: transparent;
  border: 0; border-right: 1px solid var(--line); padding: 2px 9px; cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--fg); }
.seg button.active { color: var(--fg); background: #2c4a70; }
.tab-count { font-size: 10px; margin-left: 2px; }
.tab-count.ok { color: #6fcf97; }
.tab-count.warn { color: #e3b341; }
.tab-count.bad { color: #ff7b72; }

.tree-sub-bar { padding: 3px 12px; border-bottom: 1px solid var(--line); background: #1e2128; flex: 0 0 auto; }

#tree-body[data-tab] { font-family: -apple-system, "PingFang SC", system-ui, sans-serif; font-size: 12px; }
#tree-body .node-key::after { content: ''; }
#tree-body .node { flex-wrap: wrap; white-space: normal; row-gap: 0; }

.tree-section { font-weight: 600; color: var(--fg); margin-top: 4px; }
.tree-section.tree-group { font-weight: 500; color: #9fc6ff; }
.tree-title { margin-right: 4px; }
.caret { display: inline-block; width: 10px; color: var(--muted); cursor: pointer; }
.caret::before { content: '▾'; }
.node.collapsed > .caret::before { content: '▸'; }

.item-row { cursor: pointer; }
.item-label { color: var(--fg); }
.value-row .node-key { color: #9fc6ff; }
.tree-val { color: var(--fg); font-variant-numeric: tabular-nums; }
.tree-val.editable { cursor: text; }
.tree-val.editable:hover { color: var(--accent); text-decoration: underline dotted; }
.tree-raw { color: #c3a6ff; font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.tree-input {
  font: inherit; font-size: 12px; width: 150px; padding: 0 4px; color: var(--fg);
  background: #0f1114; border: 1px solid var(--accent); border-radius: 3px;
}
.tree-error { color: #ff7b72; font-size: 11px; padding: 2px 4px 4px 18px; }

.badge { font-size: 10px; line-height: 14px; padding: 0 5px; border-radius: 7px; border: 1px solid var(--line); color: var(--muted); }
.badge.src-agreement { color: #6fcf97; border-color: #2f5a41; }
.badge.src-lineart { color: #e3b341; border-color: #5c4a1c; }
.badge.src-placeholder { color: #ff9e64; border-color: #6b3a1c; }
.badge.src-vendor, .badge.src-factory { color: #79c0ff; border-color: #24476b; }
.badge.kind-expr { color: #c3a6ff; border-color: #463a66; }
.badge.kind-default { color: var(--muted); }
.badge.stale { color: #e3b341; border-color: #5c4a1c; }

.node.related { background: #b0780022; outline: 1px solid #b07800; }

.checks-summary { display: flex; gap: 10px; align-items: center; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.checks-summary .ok { color: #6fcf97; }
.checks-summary .bad { color: #ff7b72; }
.checks-summary .warn { color: #e3b341; }
.checks-summary.is-stale ~ .check-row { opacity: 0.6; }
.release-banner { margin: 4px 0 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; }
.release-banner.is-blocked { border-color: #6e2c2c; }
.release-banner.is-ok { border-color: #2f5a41; }
.release-verdict { font-weight: 600; margin-right: 10px; }
.release-banner.is-blocked .release-verdict { color: #ff7b72; }
.release-banner.is-ok .release-verdict { color: #6fcf97; }
.release-link { color: var(--accent); }
.release-blockers { margin: 4px 0 0 16px; padding: 0; color: var(--muted); }
.check-row { display: flex; gap: 8px; padding: 5px 4px; border-bottom: 1px solid #23272f; }
.check-row.clickable { cursor: pointer; }
.check-row.clickable:hover { background: #22262e; }
.check-mark { width: 14px; flex: 0 0 auto; }
.check-row.pass .check-mark { color: #6fcf97; }
.check-row.fail.sev-error .check-mark { color: #ff7b72; }
.check-row.fail.sev-warning .check-mark { color: #e3b341; }
.check-title { color: var(--fg); font-weight: 500; }
.check-msg { color: #c9ced6; }

.lib-type { border: 1px solid var(--line); border-radius: 4px; margin: 4px 0; padding: 4px 6px; background: #1e2128; }
.lib-type summary { cursor: pointer; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.lib-doc { color: #c9ced6; margin: 4px 0; }
.lib-params { width: 100%; border-collapse: collapse; font-size: 11px; margin: 4px 0; }
.lib-params th, .lib-params td { border-bottom: 1px solid var(--line); padding: 2px 4px; text-align: left; vertical-align: top; }
.lib-params th { color: var(--muted); font-weight: 500; }
.lib-surface { color: var(--muted); font-size: 11px; }

/* drawing: every part's lines are one group; selection shows in the sheet too */
#drawing g.part { cursor: pointer; }
#drawing g.part:hover path.visible { stroke: #4a9eff; }
#drawing g.part.hl path { stroke: #2f6fff; stroke-width: 0.7; }
#drawing g.part.hl path.hidden { stroke-width: 0.35; }
#drawing g.part.hl2 path { stroke: #b07800; stroke-width: 0.5; }

/* DXF download (T203) */
.dxf-link { margin-left: 6px; font-size: 10px; color: var(--accent); border: 1px solid #2c4a70;
  border-radius: 3px; padding: 0 4px; text-decoration: none; }
.dxf-link:hover { background: #2c4a7044; }

/* BOM tab (T205) */
.bom-summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bom-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px; }
.bom-table th { text-align: left; color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--line); padding: 3px 4px; }
.bom-table td { padding: 4px; border-bottom: 1px solid #2e333d66; vertical-align: top; }
.bom-row { cursor: pointer; }
.bom-row:hover { background: #2f6fff1a; }
.bom-note { font-size: 10px; margin-top: 6px; }

/* part library (T410) */
.lib-error { color: #ff7b72; font-size: 12px; padding: 4px; }
.lib-empty { padding: 4px 8px; font-size: 12px; }
.lib-vendor { display: flex; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0; }
.lib-vendor a { color: var(--accent); }
.lib-images { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.lib-images img { height: 72px; max-width: 140px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 3px; }
.lib-mount { font-size: 12px; margin: 4px 0; }
.badge.lib-used { color: #6fcf97; border-color: #2f5a41; }

/* M5: project chip and the closed-elsewhere notice */
#project-chip a { color: var(--accent); text-decoration: none; }
.project-closed { position: fixed; inset: 0 0 auto 0; z-index: 1000; padding: 10px 16px; background: #5a1d1d;
  color: #ffd7d5; font-size: 13px; text-align: center; }
.project-closed a { color: #fff; margin: 0 4px; }

/* ======================================================================
   3D viewer tools (T107)
   ====================================================================== */
.tools-3d { flex-wrap: wrap; row-gap: 3px; }
.tools-3d .view-seg button { font-size: 11px; padding: 1px 6px; }
.hd-btn.active { color: var(--fg); background: #2c4a70; border-color: #2c4a70; }
.hd-btn.attention { border-color: #e3b341; color: #e3b341; }
#gl.measuring { cursor: crosshair; }
#canvas-3d { background: #15181d; }

.viewer-panel {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; font-size: 12px;
  background: rgba(25, 28, 33, 0.92); border: 1px solid var(--line); border-radius: 5px;
}
.viewer-panel.explode { top: auto; bottom: 8px; }
.viewer-panel input[type="range"] { width: 180px; accent-color: var(--accent); }
.viewer-panel .seg button { font-size: 11px; padding: 1px 7px; }

.viewer-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.measure-dot {
  position: absolute; width: 7px; height: 7px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: #ffc94d; box-shadow: 0 0 0 1.5px #15181d;
}
.measure-label {
  position: absolute; transform: translate(-50%, -130%);
  display: flex; flex-direction: column; align-items: center;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  background: rgba(21, 24, 29, 0.9); border: 1px solid #ffc94d; color: #ffe2a0; font-size: 11px;
}
.measure-label b { font-size: 12px; color: #ffc94d; }
.measure-label span { color: var(--muted); font-size: 10px; }

.viewer-menu {
  position: absolute; z-index: 4; min-width: 140px;
  display: flex; flex-direction: column; padding: 4px 0;
  background: #1e2128; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.viewer-menu[hidden] { display: none; }
.viewer-menu-title { padding: 3px 12px 5px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 3px; }
.viewer-menu button {
  font: inherit; font-size: 12px; text-align: left; color: var(--fg); background: transparent;
  border: 0; padding: 4px 12px; cursor: pointer;
}
.viewer-menu button:hover { background: #2c4a70; }

/* tree: eye / isolate on part rows */
.part-vis { margin-left: auto; display: inline-flex; gap: 2px; }
.part-vis button {
  font: inherit; font-size: 11px; line-height: 14px; padding: 0 4px; border: 1px solid transparent; border-radius: 3px;
  color: var(--muted); background: transparent; cursor: pointer;
}
.part-vis button:hover { color: var(--fg); border-color: var(--line); }
.item-row.is-hidden .item-label { color: var(--muted); text-decoration: line-through; }
.item-row.is-hidden .part-vis .eye { color: #e3b341; }

/* T506: a STEP model waiting to be sent */
.chat-thumb.is-file { width: auto; padding: 0 22px 0 8px; display: flex; align-items: center; }
.chat-file-chip { font-size: 12px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* a paused turn: continue from here */
.msg-notice .notice-action { font: inherit; font-size: 12px; margin-left: 8px; padding: 1px 10px; color: var(--fg);
  background: #2c4a70; border: 1px solid #2c6ab8; border-radius: 4px; cursor: pointer; }
