:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9bb4;
  --accent: #3d8bfd;
  --accent2: #5eead4;
  --ok: #34d399;
  --fail: #f87171;
  --warn: #fbbf24;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Menlo, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #152033, var(--bg));
}
.brand { display: flex; gap: .75rem; align-items: center; }
.logo { font-size: 1.6rem; color: var(--accent2); }
.top h1 { margin: 0; font-size: 1.15rem; font-weight: 650; }
.sub { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.top-actions {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  flex: 1 1 16rem; justify-content: flex-end;
}
.tool-nav { display: contents; }
.key-box { font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
.key-box input {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .35rem .5rem; min-width: 12rem;
}
.public-bar {
  padding: .4rem 1.25rem; background: #12261f; border-bottom: 1px solid #1e3d32;
  font-size: .85rem; display: flex; gap: .6rem; align-items: center;
}
.public-bar a { color: var(--accent2); }
.tabs {
  display: flex; gap: .25rem; padding: .65rem 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: .55rem .9rem; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600;
}
.tab:hover:not(:disabled) { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-bottom-color: var(--panel); margin-bottom: -1px; }
.tab:disabled { opacity: .35; cursor: not-allowed; }
.auth-lock {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(7, 10, 16, .82);
  display: grid; place-items: center;
}
.auth-lock[hidden] { display: none !important; }
.auth-lock-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.4rem 1.6rem; max-width: 26rem; width: min(26rem, calc(100vw - 2rem));
}
.auth-lock-card h2 { margin: 0 0 .4rem; }
.auth-lock-card p { color: var(--muted); }
.auth-lock-card .key-box { margin: .85rem 0 .4rem; width: 100%; }
.auth-lock-card .key-box input { min-width: 0; width: 100%; }
.auth-lock-error { color: var(--fail); min-height: 1.15em; font-size: .85rem; margin: 0 0 .75rem; }

main { padding: 1rem 1.25rem 2.5rem; max-width: 1200px; margin: 0 auto; }
body.factory-page main { max-width: 1440px; }
.pane-h { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .75rem; }
.pane-h h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.jobs-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.jobs-pager .btn[disabled] { opacity: .45; cursor: default; }
.jobs-pager-gap { color: var(--muted); padding: 0 .15rem; }
.jobs-pager-bottom { margin-top: .75rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 0 0 1rem; }
.hint.small { font-size: .8rem; margin-bottom: .5rem; }
.hint code { color: var(--accent2); font-family: var(--mono); font-size: .8em; }
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .75rem; cursor: pointer; font-weight: 600;
  text-decoration: none; display: inline-flex; align-items: center; gap: .35rem;
}
a.btn { color: var(--text); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
a.btn.primary { color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { font-size: .8rem; padding: .3rem .55rem; }
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 999px; padding: .15rem .55rem; font-size: .75rem; color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: #14532d; }
.pill.fail { color: var(--fail); border-color: #7f1d1d; }
.pill.run { color: var(--warn); border-color: #78350f; }
.pill.review { color: #fbbf24; border-color: #a16207; background: #422006; }
.review-flag {
  display: inline-flex; align-items: center; gap: .25rem;
  margin-left: .35rem; border: 1px solid #a16207; background: #422006;
  color: #fde68a; border-radius: 999px; padding: .15rem .55rem;
  font-size: .75rem; font-weight: 700; cursor: pointer;
}
.review-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 80; display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 1rem; overflow: auto;
}
.review-overlay[hidden] { display: none; }
.review-card {
  width: min(720px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem 1.25rem;
}
.review-card h3 { margin: 0 0 .5rem; }
.review-instructions { color: var(--text); white-space: pre-wrap; }
.review-arts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.review-thumb { max-width: 240px; max-height: 160px; border-radius: 8px; background: #000; }
.review-card label { display: block; margin: .6rem 0; font-size: .85rem; color: var(--muted); }
.review-card textarea, .review-card select, .review-card input[type="file"] {
  display: block; width: 100%; margin-top: .25rem; background: var(--panel2);
  color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .45rem;
}
.review-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem;
}
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem; cursor: pointer; transition: border-color .15s, transform .1s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card.selected { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2); }
.card h3 { margin: 0 0 .35rem; font-size: 1rem; }
.card .meta { color: var(--muted); font-size: .8rem; }
.card .actions { margin-top: .65rem; display: flex; gap: .4rem; flex-wrap: wrap; }

/* Factory list: sort toolbar + drag-reorder */
.factory-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  margin: 0 0 .85rem;
}
.factory-sort-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.factory-sort {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .65rem; font-size: .88rem; min-width: 14rem;
}
.factory-sort-hint { margin: 0; flex: 1 1 12rem; }
.factory-cards.dnd-enabled .card { cursor: grab; }
.factory-cards .card.dragging { opacity: .55; border-style: dashed; }
.factory-cards .card.drag-over { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
.card-head {
  display: flex; align-items: flex-start; gap: .45rem; margin-bottom: .15rem;
}
.card-head h3 { flex: 1; margin: 0; font-size: 1rem; }
.card-drag-handle {
  flex: 0 0 auto; width: 1.35rem; height: 1.35rem; line-height: 1.2;
  text-align: center; border-radius: 6px; border: 1px solid var(--border);
  color: var(--muted); font-size: .85rem; user-select: none;
  cursor: grab; background: transparent;
}
.card-drag-handle:active { cursor: grabbing; }
.factory-cards:not(.dnd-enabled) .card-drag-handle {
  opacity: .35; cursor: default; pointer-events: none;
}
.card-last-job { font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.col h3 { margin: 0 0 .5rem; font-size: .95rem; color: var(--muted); font-weight: 650; }

/* Catalog: strategies left, context browser fills remaining width */
.catalog-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 22rem) 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .catalog-layout { grid-template-columns: 1fr; }
}
.catalog-strategies h3,
.catalog-context .ctx-h h3 {
  margin: 0 0 .5rem; font-size: .95rem; color: var(--muted); font-weight: 650;
}
.ctx-h {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem .75rem;
  margin-bottom: .55rem;
}
.ctx-h .hint { margin: 0; }

/* Layer tabs — horizontal, first thing you see */
.layer-tabs {
  display: flex; flex-wrap: wrap; gap: .4rem;
  margin-bottom: .75rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--border);
}
.layer-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: .4rem .65rem; cursor: pointer; color: inherit; font: inherit;
  max-width: 11rem;
}
.layer-tab:hover { border-color: var(--accent); }
.layer-tab.active {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px var(--accent2);
  background: var(--panel2);
}
.layer-tab-name { font-weight: 650; font-size: .82rem; line-height: 1.25; }
.layer-tab-meta { font-size: .68rem; color: var(--muted); }

.layer-browser {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.layer-toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .35rem;
  flex: 1 1 12rem; min-width: 0; font-size: .85rem;
}
.crumb {
  background: transparent; border: none; color: var(--accent2);
  cursor: pointer; font: inherit; font-weight: 600; padding: .15rem .3rem;
  border-radius: 4px;
}
.crumb:hover { background: var(--panel); }
.crumb.current { color: var(--text); cursor: default; }
.crumb-sep { color: var(--muted); user-select: none; }
.layer-search { flex: 0 1 16rem; }
.layer-search input {
  width: 100%;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .4rem .55rem; font: inherit; font-size: .85rem;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* List left + detail right — detail is NOT under the list */
.layer-split {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(16rem, 1.15fr);
  min-height: 22rem;
  max-height: min(70vh, 640px);
}
@media (max-width: 720px) {
  .layer-split {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .panel-sticky { position: static !important; max-height: none !important; }
}
.layer-nav {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden;
}
.layer-nav-h {
  padding: .45rem .7rem; font-size: .8rem; color: var(--muted);
  border-bottom: 1px solid var(--border); background: #121a28;
}
.node-list {
  overflow: auto; flex: 1; padding: .35rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.node-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr auto;
  gap: .45rem; align-items: center;
  text-align: left;
  background: var(--bg); border: 1px solid transparent; border-radius: 8px;
  padding: .45rem .55rem; cursor: pointer; color: inherit; font: inherit;
}
.node-row:hover { border-color: var(--border); background: var(--panel2); }
.node-row.active { border-color: var(--accent2); background: #152033; }
.node-row-icon { color: var(--muted); font-size: .75rem; text-align: center; }
.node-row.is-folder .node-row-icon { color: var(--warn); }
.node-row.is-leaf .node-row-icon { color: var(--accent2); }
.node-row-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.node-row-name { font-weight: 600; font-size: .88rem; }
.node-row-path {
  font-size: .72rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-row-go { font-size: .72rem; color: var(--muted); font-weight: 650; }
.node-row.has-thumb { grid-template-columns: 3.2rem 1fr auto; }

.node-detail.panel-sticky {
  overflow: auto;
  padding: .75rem .85rem 1rem;
  background: #0e1520;
  position: sticky;
  top: 0;
  max-height: min(70vh, 640px);
}
.node-detail-h h4 { margin: .35rem 0 .25rem; font-size: 1.05rem; }
.node-detail-empty { padding: 2rem 1rem; }
.node-block { margin-top: .75rem; }
.node-block h5 {
  margin: 0 0 .3rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.node-block pre {
  margin: 0; max-height: 14rem; overflow: auto;
  font-family: var(--mono); font-size: .78rem; white-space: pre-wrap;
  word-break: break-word; background: var(--bg); border-radius: 6px; padding: .55rem;
}
.node-block.muted .empty { padding: .5rem 0; text-align: left; }
.list { display: flex; flex-direction: column; gap: .4rem; }
.list-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: .55rem .7rem; cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.list-item:hover, .list-item.active { border-color: var(--accent); }
.list-item .meta { display: block; color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.detail {
  margin-top: .75rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem;
}
.detail h4 { margin: 0 0 .5rem; }
.detail pre, .mono {
  font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border-radius: 6px; padding: .55rem; max-height: 220px; overflow: auto;
}
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }
.chip {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 999px;
  padding: .25rem .65rem; font-size: .8rem; cursor: pointer; color: var(--text);
}
.chip:hover, .chip.active { border-color: var(--accent2); color: var(--accent2); }
.tree { margin-top: .5rem; }
.tree-node {
  margin: .2rem 0; padding: .35rem .5rem; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.tree-node:hover { background: var(--panel2); }
.tree-node.active { border-color: var(--accent); background: var(--panel2); }
.tree-children { margin-left: 1rem; border-left: 1px solid var(--border); padding-left: .5rem; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .5rem .65rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--panel); color: var(--muted); font-weight: 650; position: sticky; top: 0; }
tr { cursor: pointer; }
tr:hover td { background: var(--panel2); }
.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem; margin-bottom: 1rem;
}
.meta-grid .cell {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem;
}
.meta-grid .k { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.meta-grid .v { font-weight: 600; font-size: .9rem; word-break: break-all; }
.log { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.log-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: .45rem .65rem; font-size: .85rem;
}
.log-item[data-view] { cursor: pointer; }
.log-item[data-view]:hover { border-color: var(--accent2); }
.log-item .st { font-weight: 700; margin-right: .4rem; }
.log-item .st.ok { color: var(--ok); }
.log-item .st.fail { color: var(--fail); }
.log-item .st.run { color: var(--warn); }
.artifacts .card { cursor: pointer; }
.artifacts .card a { color: var(--accent2); }

/* Job list thumbnails */
.th-thumb { width: 4.5rem; }
.td-thumb { width: 4.5rem; padding: .35rem !important; vertical-align: middle; }
.job-thumb {
  width: 4.25rem; height: 3rem; border-radius: 8px; overflow: hidden;
  background: #0b1220; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.job-thumb img, .job-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.job-thumb-empty, .job-thumb-doc {
  color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em;
}
.job-thumb-video { position: relative; }
.job-thumb-video::after {
  content: "▶"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; text-shadow: 0 1px 3px #000; font-size: .85rem; pointer-events: none;
}
.job-thumb-audio {
  flex-direction: column; gap: .15rem; color: var(--accent2);
}
.job-thumb-audio-icon { font-size: 1.1rem; line-height: 1; }
.art-thumb-audio {
  min-height: 3.5rem; display: flex; align-items: center; justify-content: center;
  background: #0b1220; color: var(--accent2); font-size: 1.4rem;
}

/* Job detail header */
.job-header {
  display: grid;
  grid-template-columns: minmax(12rem, 22rem) 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: .85rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
@media (max-width: 720px) {
  .job-header { grid-template-columns: 1fr; }
}
.job-hero {
  background: #0b1220; border-radius: 10px; overflow: hidden;
  min-height: 12rem; display: flex; align-items: stretch; justify-content: center;
  border: 1px solid var(--border);
}
.job-hero-media {
  display: block; width: 100%; max-height: 16rem; object-fit: contain; background: #0b1220;
}
.job-hero-empty { color: var(--muted); font-size: .85rem; padding: 1rem; text-align: center; align-self: center; }
.job-hero-doc { display: flex; flex-direction: column; gap: .4rem; padding: 1rem; align-items: flex-start; }

/* Inline artifact previews (hero + Primary/Secondary cards) — content is the preview */
.art-inline {
  background: #0b1220;
  border-bottom: 1px solid var(--border);
  overflow: auto;
}
.art-inline-hero {
  width: 100%;
  min-height: 12rem;
  max-height: 18rem;
  border-bottom: none;
}
.art-inline-card {
  max-height: 22rem;
}
.art-inline video,
.art-inline img {
  display: block;
  width: 100%;
  max-height: inherit;
  object-fit: contain;
  background: #0b1220;
}
.art-inline-audio {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding: 1.1rem 1.25rem;
  justify-content: center;
  min-height: 6.5rem;
  width: 100%;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}
.art-inline-hero.art-inline-audio {
  min-height: 8rem;
  padding: 1.5rem 1.5rem;
}
.art-inline-audio audio,
.preview-audio {
  width: 100%;
  display: block;
  height: 3rem;
  min-height: 3rem;
}
.job-thumb-audio {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .25rem;
  min-width: 10rem;
  background: #0b1220;
}
.job-thumb-audio audio {
  width: 100%;
}
.art-audio-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text, #e2e8f0);
}
.preview-audio-wrap {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem 0;
  width: 100%;
}
.art-inline-hero video,
.art-inline-hero img {
  max-height: 18rem;
}
.art-inline-hero.art-inline-svg {
  max-height: 32rem;
  min-height: 16rem;
}
.art-inline-hero.art-inline-svg img {
  max-height: 32rem;
  object-fit: contain;
  background: #0b1220;
}
.art-inline-card video,
.art-inline-card img {
  max-height: 16rem;
}
.art-pdf-frame {
  display: block;
  width: 100%;
  height: 16rem;
  border: 0;
  background: #111;
}
.art-inline-hero .art-pdf-frame { height: 18rem; }
.art-inline-card .art-pdf-frame { height: 18rem; }
.art-play-frame {
  display: block;
  width: 100%;
  height: 22rem;
  border: 0;
  background: #0b0b12;
}
.art-inline-hero .art-play-frame { height: 28rem; }
.art-inline-text {
  min-height: 8rem;
  max-height: 22rem;
  display: flex;
  flex-direction: column;
}
.art-inline-hero.art-inline-text { max-height: 18rem; }
.art-text-label {
  flex: 0 0 auto;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: .4rem .75rem .15rem;
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
}
.art-md-preview {
  flex: 1 1 auto;
  overflow: auto;
  padding: .65rem .85rem .85rem;
  color: #e2e8f0;
  font-size: .86rem;
  line-height: 1.5;
}
.art-md-preview .md-body h1 { font-size: 1.15rem; margin: .5rem 0 .35rem; color: #f8fafc; }
.art-md-preview .md-body h2 { font-size: 1.02rem; margin: .55rem 0 .3rem; color: #f8fafc; }
.art-md-preview .md-body h3 { font-size: .95rem; margin: .45rem 0 .25rem; color: #f1f5f9; }
.art-md-preview .md-body p { margin: .35rem 0; }
.art-md-preview .md-body ul,
.art-md-preview .md-body ol { margin: .3rem 0 .3rem 1.1rem; padding: 0; }
.art-md-preview .md-body li { margin: .15rem 0; }
.art-md-preview .md-body code {
  background: #1e293b; padding: .08rem .28rem; border-radius: 4px; font-size: .85em;
}
.art-md-preview .md-body a { color: var(--accent2); }
.art-md-preview .md-code {
  background: #1e293b; border-radius: 8px; padding: .55rem .7rem;
  overflow: auto; font-size: .78rem; margin: .45rem 0;
}
.art-text-pre {
  margin: 0;
  padding: .75rem .9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e2e8f0;
  max-height: 22rem;
  overflow: auto;
  flex: 1 1 auto;
}
.art-text-loading {
  padding: 1.25rem 1rem;
  color: var(--muted);
  font-size: .85rem;
}
.art-inline-other {
  padding: 1rem;
  color: var(--muted);
  font-size: .85rem;
}
.art-card-expanded {
  padding: 0;
  overflow: hidden;
}
.art-card-expanded .art-card-meta {
  padding: .65rem .75rem .75rem;
}
.art-card-expanded h3 { margin: 0 0 .25rem; font-size: .95rem; }
.artifacts-expanded {
  display: grid;
  grid-template-columns: 1fr;
  gap: .85rem;
}
@media (min-width: 900px) {
  .artifacts-expanded {
    grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  }
}
.job-header-name { margin: .35rem 0 .5rem; font-size: 1.15rem; }
.job-header-title-row { display: flex; align-items: center; gap: .5rem; }
.job-header-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .75rem; margin-top: .35rem;
}
.job-header-grid .k { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.job-header-grid .v { font-weight: 600; font-size: .88rem; }
.job-header-brief { margin: .65rem 0 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.job-header-error { margin: .5rem 0 0; color: var(--fail); font-size: .85rem; }

/* Deliverable class sections */
.job-deliverables { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.deliv-section-h {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
}
.deliv-section-h h3 { margin: 0; font-size: 1rem; }
.deliv-collapsed { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.deliv-work-toggle.active { border-color: var(--accent2); }
.pill.subtle {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-weight: 500; font-size: .7rem;
}
.art-card { overflow: hidden; }
.art-thumb {
  margin: -.65rem -.65rem .55rem; height: 7.5rem; background: #0b1220;
  border-bottom: 1px solid var(--border); overflow: hidden;
}
.art-thumb img, .art-thumb video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.art-thumb-text {
  height: auto;
  min-height: 7.5rem;
  max-height: 12rem;
  overflow: hidden;
  background: #0f172a;
  padding: 0;
}
.art-text-snippet {
  margin: 0;
  padding: .55rem .7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.4;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow: hidden;
}
.art-text-loading {
  padding: 1rem .75rem;
  color: var(--muted);
  font-size: .8rem;
}
.art-thumb-doc-label {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 700; letter-spacing: .08em;
}
.job-thumb-text {
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  padding: .25rem .3rem; gap: .15rem; text-align: left;
}
.job-thumb-tag {
  font-size: .58rem; font-weight: 700; color: var(--accent2); letter-spacing: .06em;
}
.job-thumb-excerpt {
  font-size: .58rem; line-height: 1.25; color: #94a3b8;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.preview-md-toolbar {
  display: flex; gap: .35rem; padding: .45rem .65rem;
  border-bottom: 1px solid var(--border); background: var(--panel2);
}
.preview-md-toolbar .btn.active {
  border-color: var(--accent2); color: var(--accent2);
}
.preview-md {
  padding: 1rem 1.15rem;
  max-height: min(70vh, 720px);
  overflow: auto;
  background: #0b1220;
  color: #e2e8f0;
}
.md-body { font-size: .92rem; line-height: 1.55; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1rem 0 .45rem; line-height: 1.25; color: #f8fafc;
}
.md-body h1 { font-size: 1.35rem; }
.md-body h2 { font-size: 1.15rem; }
.md-body h3 { font-size: 1.02rem; }
.md-body p { margin: .45rem 0; }
.md-body ul, .md-body ol { margin: .4rem 0 .4rem 1.2rem; padding: 0; }
.md-body li { margin: .2rem 0; }
.md-body hr { border: 0; border-top: 1px solid #334155; margin: 1rem 0; }
.md-body code {
  background: #1e293b; padding: .1rem .3rem; border-radius: 4px;
  font-size: .85em;
}
.md-body a { color: var(--accent2); }
.md-code {
  background: #1e293b; border-radius: 8px; padding: .75rem .9rem;
  overflow: auto; font-size: .82rem; margin: .6rem 0;
}
.job-intake {
  margin: 1rem 0 1.15rem;
  background: linear-gradient(180deg, #152033, var(--panel));
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
}
.job-intake-h h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.job-intake-h p {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.job-intake-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}
.job-intake-chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
}
.job-intake-chip strong { color: var(--accent2); font-weight: 650; }
.job-intake-brief {
  white-space: pre-wrap;
  background: #0d1520;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 0.85rem;
}
.job-intake table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 0 0 0.85rem;
}
.job-intake caption {
  text-align: left;
  font-weight: 650;
  padding: 0 0 0.35rem;
}
.job-intake th, .job-intake td {
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.4rem;
  vertical-align: top;
  text-align: left;
}
.job-intake th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.job-intake code { font-family: var(--mono); font-size: 0.78rem; color: var(--accent2); }
.job-intake .meta { color: var(--muted); }
.job-section-fold {
  margin: .75rem 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .35rem .65rem .65rem;
}
.job-section-fold > summary {
  cursor: pointer; font-weight: 650; padding: .4rem 0; color: var(--text);
}
.job-section-fold[open] > summary { margin-bottom: .35rem; border-bottom: 1px solid var(--border); }
.artifact-preview {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.preview-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}
.preview-h h3 { margin: 0; font-size: .95rem; font-weight: 650; }
.preview-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.preview-body {
  min-height: 12rem;
  max-height: min(70vh, 720px);
  overflow: auto;
  background: #0b1220;
}
.preview-pre {
  margin: 0;
  padding: 1rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e2e8f0;
}
.preview-frame {
  display: block;
  width: 100%;
  height: min(70vh, 720px);
  border: 0;
  background: #111;
}
.preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  padding: .75rem;
}
.inline { display: flex; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.inline select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: .25rem .4rem;
}
.foot {
  padding: .75rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem;
}
.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem; background: #1e293b; color: #fff;
  padding: .65rem 1rem; border-radius: 8px; border: 1px solid var(--border); max-width: 22rem;
  z-index: 50;
}
.empty { color: var(--muted); padding: 1rem; text-align: center; }

/* Job rating */
.td-rate { white-space: nowrap; width: 5.5rem; }
.rate-btns { display: flex; gap: .25rem; }
.rate-btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 6px;
  cursor: pointer;
  padding: .15rem .35rem;
  font-size: .95rem;
  line-height: 1.2;
  opacity: .55;
}
.rate-btn:hover { opacity: 1; border-color: var(--accent); }
.rate-btn.on.up { opacity: 1; background: #14532d; border-color: var(--ok); }
.rate-btn.on.down { opacity: 1; background: #7f1d1d; border-color: var(--fail); }

/* Ralph */
.section-h { margin: 1rem 0 .4rem; font-size: .95rem; color: var(--muted); font-weight: 600; }
.ralph-log { max-height: 28rem; overflow: auto; font-family: var(--mono); font-size: .78rem; }
.log-line { border-bottom: 1px solid var(--border); padding: .4rem 0; }
.log-t { color: var(--muted); margin-right: .5rem; }
.log-lvl { color: var(--accent2); margin-right: .5rem; text-transform: uppercase; font-size: .7rem; }
.log-job { color: var(--warn); margin-right: .5rem; }
.log-msg { margin: .25rem 0 0; white-space: pre-wrap; word-break: break-word; color: var(--text); font-family: inherit; font-size: inherit; }
.level-error .log-lvl, .level-error .log-msg { color: var(--fail); }
.level-agent_start .log-lvl { color: var(--ok); }
.level-agent_stop .log-lvl { color: var(--muted); }
.meta-grid .k { color: var(--muted); margin-right: .35rem; }

/* ---- New Job wizard (generic) ---- */
.wiz-steps {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.wiz-step {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
  background: var(--panel);
}
.wiz-step .n {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel2);
  font-size: .75rem;
  font-weight: 700;
}
.wiz-step.active {
  border-color: var(--accent);
  color: var(--text);
  background: #1e3a5f;
}
.wiz-step.active .n { background: var(--accent); color: #fff; }
.wiz-step.done { border-color: var(--ok); color: var(--ok); }
.wiz-panel { margin-bottom: 1.5rem; }
.wiz-nav {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .9rem;
}
.field span { color: var(--muted); font-size: .85rem; }
.field input[type="text"],
.field textarea {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .55rem .7rem;
  font: inherit;
}
.field textarea { resize: vertical; min-height: 8rem; }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; }
.upload-block {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--panel);
  margin: 1rem 0;
}
.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.record-block { margin-top: .85rem; }
.ux-rec {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
}
.ux-rec-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.ux-rec-toggle.recording { background: var(--fail); color: #fff; border-color: var(--fail); }
.ux-rec-preview { width: 100%; max-width: 28rem; }
.file-list { list-style: none; padding: 0; margin: .75rem 0 0; }
.file-list li {
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.wiz-look-dock {
  position: sticky;
  top: 4.6rem;
  z-index: 6;
  margin: 0 0 .85rem;
  padding: .65rem .75rem .5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 88%, #0b1220);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.wiz-look-now {
  display: grid;
  grid-template-columns: minmax(9rem, 16rem) 1fr;
  gap: .75rem;
  align-items: center;
  margin: 0 0 .55rem;
}
.wiz-look-now img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: #0b1018;
}
.wiz-look-empty {
  display: block;
  min-height: 5rem;
  border-radius: 8px;
  background: #121826;
}
.wiz-look-now .look-now-k {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent2, #7dd3c0);
  font-weight: 700;
}
.wiz-look-now strong { display: block; margin: .15rem 0 .25rem; font-size: 1.05rem; }
.wiz-look-now p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
@media (max-width: 720px) {
  .wiz-look-dock { position: static; }
  .wiz-look-now { grid-template-columns: 1fr; }
}
.layer-tab {
  flex-direction: row;
  align-items: center;
  gap: .45rem;
  max-width: 16rem;
}
.layer-tab-thumb {
  width: 2.4rem;
  height: 1.5rem;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
  background: #0b1018;
}
.sel-tray {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  min-height: 2rem;
  margin-bottom: .75rem;
  padding: .5rem;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.sel-tag-pic {
  padding: .15rem .5rem .15rem .15rem;
}
.sel-tag-pic img {
  width: 2.2rem;
  height: 1.35rem;
  object-fit: cover;
  border-radius: 4px;
}
.sel-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: #1e3a5f;
  border: 1px solid var(--accent);
  font-size: .8rem;
}
.sel-tag em { font-style: normal; color: var(--accent2); }
.sel-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 .15rem;
}
.leaf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .6rem;
  margin-top: .75rem;
}
.leaf-chip {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  padding: .65rem .75rem;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transition: border-color .12s, background .12s;
}
.leaf-chip:hover { border-color: var(--accent); }
.leaf-chip.selected {
  border-color: var(--accent2);
  background: #134e4a;
  box-shadow: 0 0 0 1px var(--accent2);
}
.leaf-chip-name { font-weight: 600; font-size: .9rem; }
.leaf-chip-preview { font-size: .75rem; color: var(--muted); line-height: 1.3; }
.leaf-chip.has-thumb { padding: 0; overflow: hidden; }
.leaf-chip-thumb {
  display: block;
  height: 7.2rem;
  background: #0b1018 center/cover no-repeat;
  border-bottom: 1px solid var(--border);
}
.leaf-chip.has-thumb .leaf-chip-name,
.leaf-chip.has-thumb .leaf-chip-preview,
.leaf-chip.has-thumb .leaf-chip-len,
.leaf-chip.has-thumb .leaf-chip-meter { margin: 0 .75rem; }
.leaf-chip.has-thumb .leaf-chip-name { margin-top: .55rem; }
.leaf-chip.has-thumb .leaf-chip-len { margin-bottom: .55rem; }
.leaf-grid-thumbs { display: contents; }
.node-row-thumb {
  width: 3.2rem;
  height: 2.2rem;
  border-radius: 4px;
  background: #0b1018 center/cover no-repeat;
  flex: 0 0 auto;
}
.leaf-chip-meter {
  height: 4px;
  border-radius: 99px;
  background: #243044;
  overflow: hidden;
}
.leaf-chip-meter > span {
  display: block;
  height: 100%;
  background: var(--accent2);
}
.leaf-chip-meter.thin > span { background: var(--fail); }
.leaf-chip-len { font-size: .7rem; color: var(--muted); }
.wiz-leaf-tools { margin-top: .75rem; }
.wiz-leaf-search { max-width: 28rem; }
.wiz-leaf-params {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem;
}
.wiz-leaf-params h4 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: .85rem;
}
.wiz-param-slider { grid-column: span 1; }
.wiz-param-slider-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.wiz-param-slider-row input[type="range"] { flex: 1; min-width: 0; }
.wiz-param-slider-row input[type="number"] { width: 5.5rem; }
.wiz-param-radio { display: flex; flex-direction: column; gap: .25rem; }
.wiz-radio { font-weight: 400; color: var(--text); }
.wiz-leaf-params em { color: var(--muted); font-style: normal; font-size: .75rem; }
.job-story-stage {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.story-stage {
  position: relative;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0b1018;
  overflow: hidden;
}
.story-bg {
  min-height: 180px;
  background-size: cover;
  background-position: center;
  background-color: #071018;
}
.story-sprites { display: flex; gap: .75rem; padding: .75rem 1rem; min-height: 48px; align-items: flex-end; }
.story-sprite {
  padding: .35rem .6rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: .8rem;
  background: #102030;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-width: 160px;
}
.story-sprite img {
  width: 140px;
  height: 180px;
  object-fit: cover;
  border-radius: 6px;
}
.story-hud { padding: .75rem 1rem 1rem; }
.story-meters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.story-meter {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--accent2);
  border: 1px solid var(--border);
  padding: .15rem .45rem;
  border-radius: 999px;
}
.story-box {
  background: rgba(10, 16, 24, .86);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem .85rem;
  min-height: 72px;
}
.story-speaker { font-size: .75rem; letter-spacing: .06em; color: var(--accent2); text-transform: uppercase; }
.story-line { margin-top: .35rem; font-size: 1rem; }
.story-choices { display: flex; flex-wrap: wrap; gap: .5rem; margin: .65rem 0; }
.story-actions { display: flex; justify-content: flex-end; }
.job-sim-flow {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.job-sim-h { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.job-sim-h h3 { margin: 0; }
.sim-canvas {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: .75rem 0 1rem;
  align-items: center;
}
.sim-node {
  min-width: 88px;
  padding: .45rem .55rem;
  border: 2px solid var(--accent);
  text-align: center;
  font-size: .75rem;
  background: #102030;
}
.sim-node .sim-kind { font-size: .65rem; letter-spacing: .06em; color: var(--accent2); text-transform: uppercase; }
.sim-node .sim-val { font-family: var(--mono); font-size: .8rem; margin-top: .2rem; }
.sim-node.kind-source { clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 1rem; }
.sim-node.kind-pool { border-radius: 999px; }
.sim-node.kind-drain { clip-path: polygon(0 0, 100% 0, 50% 100%); padding-bottom: 1rem; }
.sim-node.kind-gate { transform: rotate(45deg); }
.sim-node.kind-gate .sim-kind, .sim-node.kind-gate .sim-val { transform: rotate(-45deg); }
.sim-node.kind-factory_port { border-color: var(--warn); }
.sim-edge { color: var(--muted); font-size: .75rem; }
.sim-chart { min-height: 220px; }
.layer-tab.missing { border-color: var(--fail); color: var(--fail); }
.review-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.review-ul { margin: .25rem 0 0 1.1rem; padding: 0; }
.review-pre {
  margin: .35rem 0 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--text);
  max-height: 12rem;
  overflow: auto;
  background: var(--bg);
  padding: .6rem;
  border-radius: 6px;
}
.fail-box { color: var(--fail); }
.card-desc { font-size: .82rem; color: var(--muted); margin: .4rem 0 0; }
.list-item.selected { outline: 1px solid var(--accent2); background: #134e4a33; }

/* Pipeline graph (React Flow island) */
.graph-layout {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1rem;
  min-height: 28rem;
}
@media (max-width: 800px) {
  .graph-layout { grid-template-columns: 1fr; }
}
.graph-plans {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: .6rem;
  max-height: 36rem;
  overflow: auto;
}
.graph-host-slot {
  min-height: 32rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f1419;
}
.graph-main .meta { margin-top: .5rem; }

/* Chat produce + memory */
.chat-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}
.chat-search-box {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
  min-width: 12rem;
}
.chat-search-box input {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: inherit;
}
.chat-search-results {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  max-height: 12rem;
  overflow: auto;
  font-size: 0.85rem;
}
.chat-search-hit {
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.chat-search-hit:hover { background: #134e4a33; }
.chat-search-hit .k { color: var(--accent2, #7aa2f7); font-size: 0.75rem; text-transform: uppercase; }

.chat-layout {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1rem;
  min-height: 28rem;
}
@media (max-width: 800px) {
  .chat-layout { grid-template-columns: 1fr; }
}
.chat-threads {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: .6rem;
  max-height: 32rem;
  overflow: auto;
}
.chat-main {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 28rem;
}
.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  max-height: 24rem;
}
.chat-bubble {
  max-width: 92%;
  padding: .65rem .85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
}
.chat-user {
  align-self: flex-end;
  background: #1e3a5f;
  border-color: var(--accent);
}
.chat-assistant {
  align-self: flex-start;
}
.chat-role {
  font-size: .7rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .25rem;
  letter-spacing: .04em;
}
.chat-content {
  white-space: pre-wrap;
  font-size: .92rem;
  line-height: 1.45;
}
.chat-jobs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .55rem;
}
.chat-job-chip {
  display: inline-block;
  padding: .25rem .55rem;
  border-radius: 999px;
  background: #134e4a;
  border: 1px solid var(--accent2);
  color: var(--accent2);
  font-size: .78rem;
  text-decoration: none;
}
.chat-job-chip:hover { filter: brightness(1.1); }
.chat-compose {
  border-top: 1px solid var(--border);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.chat-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  margin-top: .55rem;
}
.chat-opt {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .78rem;
  color: var(--muted);
}
.chat-opt select {
  min-width: 12rem;
  font-size: .9rem;
}
.chat-mcp {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  margin-top: .45rem;
}
.chat-mcp-row { font-size: .82rem; display: flex; gap: .35rem; align-items: center; }
.chat-compose-row {
  display: flex;
  align-items: flex-end;
  gap: .45rem;
}
.chat-compose-row textarea {
  flex: 1;
  min-width: 0;
}
.chat-ralph-loop {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
  font-size: .82rem;
  color: var(--muted, #94a3b8);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding-bottom: .35rem;
}
.chat-ralph-loop input {
  margin: 0;
  accent-color: var(--accent2, #7aa2f7);
}
.chat-loop-link {
  color: var(--accent2, #7aa2f7);
  word-break: break-all;
}
.chat-attach-btn {
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel, #1a1f2e);
  color: var(--accent2, #7aa2f7);
  cursor: pointer;
}
.chat-attach-btn:hover {
  border-color: var(--accent2, #7aa2f7);
  background: #134e4a33;
}
.chat-attach-icon {
  display: block;
}
.chat-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.chat-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  padding: .2rem .45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0f172a;
  font-size: .78rem;
  color: var(--text);
}
.chat-attach-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}
.chat-attach-chip button {
  border: 0;
  background: transparent;
  color: var(--muted, #94a3b8);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 .15rem;
}
.chat-attach-chip button:hover { color: #f87171; }
.chat-msg-atts {
  margin-top: .4rem;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.chat-msg-att {
  font-size: .75rem;
  padding: .15rem .4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--accent2, #7aa2f7);
  text-decoration: none;
}
.chat-compose textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .55rem .7rem;
  font: inherit;
  resize: vertical;
}
.chat-compose-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* ---- Documentation framework (AAA help) ---- */
.doc-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: .35rem;
  border-radius: 50%;
  border: 1px solid var(--accent2, #2dd4bf);
  background: linear-gradient(145deg, #0f766e 0%, #134e4a 100%);
  color: #ecfdf5;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.15);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.doc-help-btn:hover {
  transform: scale(1.08);
  filter: brightness(1.12);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.35);
}
.doc-help-btn:focus-visible {
  outline: 2px solid var(--accent2, #2dd4bf);
  outline-offset: 2px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.card-head h3 { flex: 1; margin: 0; }
.list-item-row {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
}
.list-item-row strong { flex: 1; text-align: left; }
.with-doc {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.layer-tab-wrap {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  margin: 0 .2rem .35rem 0;
}

body.docs-open { overflow: hidden; }
.docs-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}
.docs-drawer[hidden] { display: none !important; }
.docs-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
}
.docs-drawer-panel {
  position: relative;
  width: min(42rem, 100%);
  max-width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0b1220 0%, #0f172a 40%, #0b1220 100%);
  border-left: 1px solid var(--border, #1e293b);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  animation: docs-slide-in .22s ease;
}
@keyframes docs-slide-in {
  from { transform: translateX(12px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}
.docs-drawer-h {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border, #1e293b);
  background: rgba(15, 23, 42, 0.9);
}
.docs-drawer-brand {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
}
.docs-drawer-mark {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #14b8a6, #0f766e);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 0 20px rgba(20, 184, 166, 0.35);
}
.docs-drawer-h h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.docs-drawer-sum {
  margin: .25rem 0 0;
  color: var(--muted, #94a3b8);
  font-size: .85rem;
  line-height: 1.4;
  max-width: 32rem;
}
.docs-toc {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border, #1e293b);
  background: rgba(15, 23, 42, 0.55);
}
.docs-toc-item {
  border: 1px solid var(--border, #334155);
  background: var(--panel2, #1e293b);
  color: var(--text, #e2e8f0);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: .78rem;
  cursor: pointer;
}
.docs-toc-item.active {
  border-color: #2dd4bf;
  background: #134e4a;
  color: #ccfbf1;
}
.docs-article {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1.4rem 2rem;
}
.docs-page-h {
  margin-bottom: 1rem;
}
.docs-kind {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .68rem;
  color: #5eead4;
  border: 1px solid #134e4a;
  border-radius: 4px;
  padding: .12rem .4rem;
  margin-bottom: .4rem;
}
.docs-page-h h3 {
  margin: .35rem 0 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.docs-prose {
  color: #cbd5e1;
  line-height: 1.65;
  font-size: .95rem;
}
.docs-prose h2, .docs-prose h3, .docs-prose h4 {
  color: #f1f5f9;
  margin: 1.25rem 0 .5rem;
  letter-spacing: -0.02em;
}
.docs-prose p { margin: .55rem 0; }
.docs-prose ul { margin: .4rem 0 .8rem 1.2rem; }
.docs-prose li { margin: .25rem 0; }
.docs-prose code {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: .05rem .3rem;
  font-size: .85em;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: .75rem 0 1rem;
  font-size: .86rem;
}
.docs-table td {
  border: 1px solid #334155;
  padding: .4rem .55rem;
  vertical-align: top;
}
.docs-figure {
  margin: 1rem 0;
  padding: .75rem;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
}
.docs-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}
.docs-figure figcaption {
  margin-top: .45rem;
  color: var(--muted, #94a3b8);
  font-size: .8rem;
}

.docs-library-layout {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 1rem;
  min-height: 28rem;
}
.docs-library-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 70vh;
  background: var(--panel);
}
.docs-library-preview {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  background: linear-gradient(180deg, #0f172a, #0b1220);
  min-height: 20rem;
}
.docs-lib-preview-h h3 {
  margin: 0;
  display: inline;
}
.docs-lib-pages {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
}
.docs-lib-pages li { margin: .35rem 0; }

@media (max-width: 800px) {
  .docs-library-layout { grid-template-columns: 1fr; }
  .docs-drawer-panel { width: 100%; }
}


/* ---- Factory selection title section ---- */
.factory-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin: 0 0 1.15rem;
  padding: 1.05rem 1.25rem;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--factory-accent, #2dd4bf) 42%, #1e293b);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--factory-accent, #2dd4bf) 28%, #0b1220) 0%,
      #0f172a 42%,
      #0b1220 100%);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, .35),
    inset 0 1px 0 color-mix(in srgb, var(--factory-accent, #2dd4bf) 35%, transparent);
  overflow: hidden;
  isolation: isolate;
}
.factory-banner[hidden] { display: none !important; }
.factory-banner-glow {
  position: absolute;
  inset: -40% auto auto -10%;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--factory-accent, #2dd4bf) 55%, transparent) 0%, transparent 70%);
  opacity: .55;
  pointer-events: none;
  z-index: 0;
  filter: blur(2px);
}
.factory-banner > *:not(.factory-banner-glow) {
  position: relative;
  z-index: 1;
}
.factory-banner-icon-wrap {
  flex: 0 0 auto;
  width: 5rem;
  height: 5rem;
  border-radius: 16px;
  border: 2px solid color-mix(in srgb, var(--factory-accent, #2dd4bf) 75%, #fff);
  background:
    linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--factory-accent, #2dd4bf) 16%, transparent),
    0 10px 24px rgba(0, 0, 0, .35);
}
.factory-banner-icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.factory-banner-fallback {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--factory-accent, #2dd4bf);
  letter-spacing: .02em;
  text-shadow: 0 0 18px color-mix(in srgb, var(--factory-accent, #2dd4bf) 55%, transparent);
}
.factory-banner-body { flex: 1; min-width: 0; }
.factory-banner-kicker {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 600;
  color: color-mix(in srgb, var(--factory-accent, #2dd4bf) 90%, #e2e8f0);
  margin-bottom: .2rem;
}
.factory-banner-kicker-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--factory-accent, #2dd4bf);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--factory-accent, #2dd4bf) 28%, transparent);
  animation: factory-pulse 1.8s ease-in-out infinite;
}
@keyframes factory-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .65; transform: scale(.88); }
}
.factory-banner-title {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  line-height: 1.15;
  color: #f8fafc;
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.factory-banner-tagline {
  margin: .35rem 0 0;
  font-size: .92rem;
  line-height: 1.35;
  color: #cbd5e1;
  max-width: 42rem;
}
.factory-banner-tagline[hidden] { display: none !important; }
.factory-banner-meta {
  margin-top: .5rem;
  font-size: .82rem;
  color: #94a3b8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .65rem;
}
.factory-banner-meta .chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--factory-accent, #2dd4bf) 14%, #1e293b);
  border: 1px solid color-mix(in srgb, var(--factory-accent, #2dd4bf) 28%, #334155);
  color: #e2e8f0;
  font-size: .75rem;
  font-weight: 500;
}
.factory-banner-meta .chip strong {
  color: #f8fafc;
  font-weight: 700;
}
.factory-banner-meta .dot {
  opacity: .45;
}
.factory-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  flex: 1 1 18rem;
  justify-content: flex-end;
  max-width: 28rem;
  align-items: center;
}
.factory-tool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: flex-end;
}
.factory-tool-nav .btn.is-disabled,
.factory-tool-nav a[aria-disabled="true"] {
  opacity: .45;
  pointer-events: none;
}
@media (max-width: 720px) {
  .factory-banner {
    flex-wrap: wrap;
    padding: .95rem 1rem;
  }
  .factory-banner-actions {
    max-width: none;
    width: 100%;
    justify-content: flex-start;
  }
  .factory-banner-icon-wrap {
    width: 4.25rem;
    height: 4.25rem;
  }
}

/* Factory cards — stronger identity */
.card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 11px;
  object-fit: cover;
  border: 1.5px solid color-mix(in srgb, var(--card-accent, #64748b) 60%, #334155);
  background: #0f172a;
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.card-icon-fallback {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .95rem;
  color: #0b1220;
  background: linear-gradient(145deg, color-mix(in srgb, var(--card-accent, #64748b) 92%, #fff), var(--card-accent, #64748b));
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
/* display:grid above must not unhide letter badges next to graphic icons */
.card-icon-fallback[hidden] {
  display: none !important;
}
.card-head {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.card-head h3 {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.card {
  --card-accent: #64748b;
  border-top: 3px solid var(--card-accent);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.card.selected {
  border-color: color-mix(in srgb, var(--card-accent, #64748b) 70%, #fff);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--card-accent, #64748b) 45%, transparent),
    0 10px 28px rgba(0,0,0,.28);
}
.catalog-factory-hint {
  margin: -.25rem 0 .75rem;
  color: var(--muted, #94a3b8);
}

/* ---- Factory page tabs (under banner, not top nav) ---- */
.factory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin: -0.35rem 0 1.1rem;
  padding: .35rem;
  background: color-mix(in srgb, var(--factory-accent, #2dd4bf) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--factory-accent, #2dd4bf) 28%, var(--border));
  border-radius: 12px;
}
.factory-tabs[hidden] { display: none !important; }
.factory-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: .45rem .85rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
  font-size: .88rem;
}
.factory-tab:hover { color: var(--text); background: var(--panel2); }
.factory-tab.active {
  color: #0b1220;
  background: var(--factory-accent, var(--accent2));
  border-color: transparent;
}

.strategies-layout {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .strategies-layout { grid-template-columns: 1fr; }
}
.strategy-detail-wide { min-height: 12rem; }

.instance-dash { min-height: 16rem; }
.dash-kpi button,
button.dash-kpi {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .9rem;
  color: inherit;
  cursor: pointer;
}
button.dash-kpi:hover { border-color: var(--accent); }
.dash-thumb {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  background: var(--panel2) center/cover no-repeat;
  flex: 0 0 auto;
}

/* ---- Factory dashboard (GridStack + ApexCharts) ---- */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .7rem;
  margin: 0 0 1rem;
}
.dash-kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .9rem;
}
.dash-kpi .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.dash-kpi .v { font-size: 1.55rem; font-weight: 800; line-height: 1.2; margin-top: .15rem; }
.dash-kpi.ok .v { color: var(--ok); }
.dash-kpi.fail .v { color: var(--fail); }
.dash-kpi.run .v { color: var(--warn); }
.dash-kpi.red .v { color: #f87171; }
.dash-kpi.orange .v { color: #fb923c; }
.dash-kpi.yellow .v { color: #fbbf24; }
.dash-kpi.green .v { color: #34d399; }

.band-chip {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 20%, transparent);
}
.band-chip.red { background: #f87171; }
.band-chip.orange { background: #fb923c; }
.band-chip.yellow { background: #fbbf24; }
.band-chip.green { background: #34d399; }

.dash-gauges {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .4rem;
  align-items: end;
}
@media (max-width: 900px) {
  .dash-gauges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .dash-gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dash-gauge { text-align: center; }
.dash-gauge-chart { min-height: 150px; }
.dash-gauge-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  margin-top: -.2rem;
}
.grid-stack {
  min-height: 12rem;
}
.grid-stack-item-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .85rem;
  overflow: auto;
  color: var(--text);
}
.dash-card-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin: 0 0 .55rem;
}
.dash-card-h h3 { margin: 0; font-size: .92rem; }
.dash-list { display: flex; flex-direction: column; gap: .35rem; }
.dash-list button,
.dash-job {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem .7rem;
  width: 100%;
  text-align: left;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  padding: .45rem .6rem;
  cursor: pointer;
  font: inherit;
}
.dash-list button:hover,
.dash-job:hover { border-color: var(--accent); }
.dash-job .nm { font-weight: 650; }
.ui-resizable-handle { filter: invert(1); opacity: .4; }

/* ---- Factory settings ---- */
.settings-form { max-width: 52rem; }
.settings-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: .85rem 1rem 1rem;
  margin: 0 0 .85rem;
}
.settings-block legend {
  padding: 0 .4rem;
  font-weight: 700;
  font-size: .85rem;
  color: var(--accent2);
}
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .7rem;
}
.settings-block .field { display: flex; flex-direction: column; gap: .3rem; margin: .45rem 0; }
.settings-block .field span { font-size: .78rem; color: var(--muted); font-weight: 650; }
.settings-block input[type="text"],
.settings-block input[type="number"],
.settings-block input[type="url"],
.settings-block select,
.settings-block textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .6rem;
  font: inherit;
}
.settings-block textarea.mono { font-family: var(--mono); font-size: .82rem; }
.settings-block input[type="color"] {
  width: 3.2rem; height: 2.2rem; padding: 0; border: 1px solid var(--border); background: var(--bg);
}
.settings-block .check {
  display: flex; align-items: center; gap: .45rem;
  margin: .35rem 0; font-size: .9rem;
}
.settings-advanced { margin: 0 0 1rem; color: var(--muted); }
.settings-advanced summary { cursor: pointer; font-weight: 650; margin-bottom: .6rem; }
.settings-actions { display: flex; align-items: center; gap: .75rem; }

.docs-prose .callout {
  border-left: 3px solid #e8b86d;
  padding: .75rem 1rem;
  margin: 1rem 0;
  background: rgba(232,184,109,.08);
}
.docs-prose .callout.warn { border-color: #d9886a; }
.docs-prose .diagram {
  margin: 1rem 0;
  padding: .6rem;
  border: 1px solid #334155;
  background: #0c0e12;
  overflow-x: auto;
}
.docs-prose .diagram svg { width: 100%; height: auto; display: block; }
.docs-prose table { width: 100%; border-collapse: collapse; font-size: .86rem; margin: .8rem 0; }
.docs-prose th, .docs-prose td { border-bottom: 1px solid #334155; padding: .4rem .35rem; text-align: left; }

/* Package selector — header trigger + modal */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.proj-cluster {
  display: flex;
  align-items: center;
  gap: .35rem;
  position: relative;
  min-width: 0;
}
.proj-menu {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0;
  z-index: 40;
  min-width: 14rem;
  max-width: 22rem;
  background: #121820;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .35rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
}
.proj-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  padding: .45rem .6rem;
  border-radius: 8px;
  cursor: pointer;
}
.proj-menu button:hover,
.proj-menu button.is-on {
  background: rgba(94,234,212,.12);
}
.pkg-cluster {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-right: auto;
  min-width: 0;
}
.pkg-trigger {
  display: flex; align-items: center; gap: .7rem;
  background: rgba(26, 35, 50, .72);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 999px;
  padding: .28rem .7rem .28rem .28rem;
  cursor: pointer;
  min-width: 13rem;
  max-width: 22rem;
  text-align: left;
}
.catalog-icon {
  flex: 0 0 auto;
  width: 2.55rem;
  height: 2.55rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 32% 22%, rgba(94,234,212,.26), transparent 58%),
    rgba(26, 35, 50, .72);
  color: var(--accent2);
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.catalog-icon svg {
  width: 1.32rem;
  height: 1.32rem;
  display: block;
}
.catalog-icon:hover,
.catalog-icon:focus-visible {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(94,234,212,.16);
  transform: translateY(-1px);
  outline: none;
}
.pkg-trigger:hover, .pkg-trigger[aria-expanded="true"] {
  border-color: var(--accent2);
}
.pkg-photo {
  width: 2.35rem; height: 2.35rem; border-radius: 50%;
  object-fit: cover; display: block; flex: 0 0 auto;
  background: #121922;
}
.pkg-photo-empty {
  background:
    radial-gradient(circle at 30% 20%, rgba(94,234,212,.28), transparent 55%),
    #121922;
  border: 1px solid var(--border);
}
.pkg-copy { display: flex; flex-direction: column; gap: .05rem; min-width: 0; flex: 1; }
.pkg-kicker {
  font-size: .62rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.pkg-name {
  font-size: .92rem; font-weight: 650; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.pkg-chevron {
  width: .45rem; height: .45rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  margin: 0 .25rem .2rem 0;
}
.pkg-modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(7, 10, 16, .72);
  display: grid; place-items: center;
  padding: 1.2rem;
}
.pkg-modal[hidden] { display: none !important; }
.pkg-sheet {
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(38rem, calc(100vh - 2.4rem));
  overflow: auto;
  background: #141c28;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.15rem 1.2rem 1.3rem;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.pkg-sheet-h {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: .85rem;
}
.pkg-sheet-h h2 { margin: .1rem 0 0; font-size: 1.25rem; font-weight: 650; }
.pkg-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: .1rem .35rem;
}
.pkg-close:hover { color: var(--text); }
.pkg-search input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: .55rem .75rem; font: inherit;
}
.pkg-search input:focus { outline: none; border-color: var(--accent2); }
.pkg-cats {
  display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0 .85rem;
}
.pkg-cats button {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: .22rem .6rem; font-size: .72rem;
  letter-spacing: .06em; text-transform: uppercase; font-weight: 650; cursor: pointer;
}
.pkg-cats button.on, .pkg-cats button:hover { color: var(--text); border-color: var(--accent2); }
.pkg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: .55rem;
}
.pkg-tile {
  display: flex; flex-direction: column;
  background: #101820; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer; color: inherit;
  text-align: left; padding: 0;
}
.pkg-tile:hover, .pkg-tile.on { border-color: var(--accent2); }
.pkg-tile img, .pkg-tile-empty {
  display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  background: #0c1218;
}
.pkg-tile-empty {
  background:
    radial-gradient(circle at 40% 30%, rgba(94,234,212,.18), transparent 60%),
    #0c1218;
}
.pkg-tile-body { padding: .55rem .65rem .65rem; }
.pkg-tile-body strong {
  display: block; font-size: .88rem; font-weight: 650; line-height: 1.25;
}
.pkg-tile-body em {
  display: block; margin-top: .2rem; font-style: normal;
  color: var(--muted); font-size: .72rem;
}
@media (max-width: 720px) {
  .pkg-cluster { margin-right: 0; flex: 1 1 16rem; }
  .pkg-trigger { max-width: 100%; min-width: 0; flex: 1 1 12rem; }
}

/* ---- Factory test suites (read-only glance) ---- */
.tests-list { display: flex; flex-direction: column; gap: .85rem; margin-top: .4rem; }
.tests-suite {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .85rem 1rem 1rem;
}
.tests-suite-h {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.tests-suite-h h3 { margin: 0; font-size: 1.05rem; }
.tests-suite-score { text-align: right; min-width: 5.5rem; }
.tests-ratio {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
}
.tests-ratio.ok { color: var(--ok); }
.tests-ratio.fail { color: var(--fail); }
.tests-ratio.run { color: var(--warn); }
.tests-jobs { display: flex; flex-direction: column; gap: .3rem; margin-top: .55rem; }
.tests-job {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .7rem;
  align-items: center;
  text-align: left;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .65rem;
  cursor: pointer;
  color: inherit;
}
.tests-job:hover { border-color: var(--accent, #5eead4); }
.tests-job .nm { font-weight: 650; flex: 1 1 10rem; }

.context-manifest {
  white-space: pre-wrap;
  font-size: .78rem;
  background: var(--panel2, rgba(0,0,0,.2));
  padding: .7rem .8rem;
  border-radius: 8px;
  overflow: auto;
  max-height: 14rem;
}
.people-board { margin-top: 1.1rem; }
.people-kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.people-col {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel2, rgba(255,255,255,.03));
  padding: .7rem;
  min-height: 12rem;
}
.people-col-h {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0 0 .7rem;
  font-size: .95rem;
}
.people-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0;
}
@media (max-width: 1100px) {
  .people-kanban { grid-template-columns: 1fr; }
}
.people-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.people-card img.people-face {
  width: 100%;
  height: 14rem;
  object-fit: cover;
  background: #0b1220;
}
.people-card .people-body {
  padding: .85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.people-card .people-kws {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.people-card .kw {
  font-size: .72rem;
  padding: .12rem .4rem;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
}
.people-card audio { width: 100%; }
.people-enroll {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--panel);
}
.people-cast-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.people-cast-row {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.people-cast-row img {
  width: 2.4rem;
  height: 2.4rem;
  object-fit: cover;
  border-radius: 6px;
}
.people-cast-row.selected {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px var(--accent2);
}
@media (max-width: 800px) {
  .people-card img.people-face { height: 11rem; }
}
