/* ==========================================================================
   Regolo components · Redline world, Ledger form.
   Every form value reads from tokens.css. Red appears only on findings.
   ========================================================================== */

/* ---------- Shell: top bar, context bar, page ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-5);
  padding: 0 var(--gutter); background: var(--surface); border-bottom: var(--rule-strong);
}
.brand { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; color: var(--ink); flex: none; }
.brand .word { font-family: var(--font-display); font-weight: 700; font-size: 1.375rem; letter-spacing: 0.16em; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; align-self: stretch; gap: var(--s-1); overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3); white-space: nowrap;
  font-weight: 600; font-size: var(--t-14); color: var(--ink-2); text-decoration: none;
  box-shadow: inset 0 -2px 0 transparent; transition: box-shadow var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.nav a:hover { color: var(--ink); box-shadow: inset 0 -2px 0 var(--line); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.nav .count { font-family: var(--font-mono); font-size: var(--t-11); color: var(--muted); }
.topbar .tools { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.cmdk {
  display: inline-flex; align-items: center; gap: var(--s-2); height: var(--h-ctl); min-width: 240px; padding: 0 var(--s-2) 0 var(--s-3);
  border: var(--rule); border-radius: var(--r-ctl); background: var(--bg); color: var(--muted); font-size: var(--t-14); cursor: pointer;
}
.cmdk:hover { border-color: var(--muted-2); }
.cmdk kbd { margin-left: auto; }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-full); display: inline-grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--ink); font: 600 var(--t-12)/1 var(--font-body); border: var(--rule);
}
.avatar.sm { width: 24px; height: 24px; font-size: var(--t-11); }
.ctxbar {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; min-height: 44px;
  padding: var(--s-2) var(--gutter); border-bottom: var(--rule); background: var(--bg); font-size: var(--t-13);
}
.ctxbar .crumbs { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); min-width: 0; }
.ctxbar .crumbs a { color: var(--ink-2); text-decoration: none; }
.ctxbar .crumbs a:hover { color: var(--ink); text-decoration: underline; }
.page { padding: var(--s-5) var(--gutter) var(--s-8); }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-h p { color: var(--muted); margin-top: var(--s-1); }

/* ---------- Sheet: the square drawing surface, with zone markers ---------- */
.sheet { position: relative; background: var(--surface); border: var(--rule-strong); border-radius: var(--r-card); }
.sheet-h {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 48px; padding: var(--s-2) var(--pad-card); border-bottom: var(--rule-strong);
}
.sheet-h h2, .sheet-h h3 { font-size: var(--t-18); }
.sheet-b { padding: var(--pad-card); }
.sheet.zoned { padding: 18px 0 0 18px; }
.zones-x, .zones-y { position: absolute; display: grid; pointer-events: none; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.zones-x { left: 18px; right: 0; top: 0; height: 18px; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: var(--rule-strong); }
.zones-y { top: 18px; bottom: 0; left: 0; width: 18px; grid-auto-flow: row; grid-auto-rows: 1fr; border-right: var(--rule-strong); }
.zones-x span, .zones-y span { display: grid; place-items: center; }
.zones-x span + span { border-left: var(--rule); }
.zones-y span + span { border-top: var(--rule); }
.zone-ref { font-family: var(--font-mono); font-size: var(--t-11); color: var(--npb-ink); }

/* Cartiglio: the title block */
.cartiglio { display: grid; grid-template-columns: 1fr 1fr; border-top: var(--rule-strong); background: var(--surface); }
.cartiglio > div { padding: var(--s-2) var(--s-3); border-bottom: var(--rule); min-width: 0; }
.cartiglio > div:nth-child(even) { border-left: var(--rule); }
.cartiglio > .wide { grid-column: 1 / -1; border-left: 0 !important; }
.cartiglio .label { display: block; margin-bottom: 2px; }
.cartiglio .v { font-size: var(--t-14); font-weight: 500; overflow-wrap: anywhere; }
.cartiglio .verdict { font: 700 var(--t-28)/1.1 var(--font-display); letter-spacing: var(--tracking-display); }
.cartiglio .verdict.fail { color: var(--danger-ink); }
.cartiglio .verdict.ok { background: linear-gradient(transparent 14%, var(--hl) 14%, var(--hl) 90%, transparent 90%); display: inline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--h-ctl); padding: 0 var(--s-4); border: var(--rule-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font: 600 var(--t-14)/1 var(--font-body); white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger-ink); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: var(--h-ctl-sm); padding: 0 var(--s-3); font-size: var(--t-13); }
.btn-lg { height: 44px; padding: 0 var(--s-5); font-size: var(--t-15); }
.btn-icon { width: var(--h-ctl); padding: 0; }
.btn-icon.btn-sm { width: var(--h-ctl-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { pointer-events: none; color: transparent; position: relative; }
.btn.is-loading::after {
  content: ''; position: absolute; left: 22%; right: 22%; top: 50%; height: 2px; background: currentColor;
  color: var(--on-primary); background: linear-gradient(90deg, transparent, currentColor 40%, currentColor 60%, transparent) 0 0 / 50% 100% no-repeat;
  animation: plot 900ms var(--ease) infinite;
}
.btn:not(.btn-primary).is-loading::after { color: var(--ink); }
@keyframes plot { from { background-position: -100% 0; } to { background-position: 200% 0; } }

/* ---------- Form controls ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font-size: var(--t-13); font-weight: 600; color: var(--ink); }
.field .hint { font-size: var(--t-12); color: var(--muted); }
.field .err { display: flex; gap: 6px; align-items: center; font-size: var(--t-12); color: var(--danger-ink); font-weight: 500; }
.input, .select, textarea.input {
  width: 100%; height: var(--h-ctl); padding: 0 var(--s-3); border: var(--bw) solid var(--muted-2); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font-size: var(--t-14); transition: border-color var(--dur-1) var(--ease);
}
textarea.input { height: auto; min-height: 88px; padding: var(--s-2) var(--s-3); line-height: var(--lh-body); resize: vertical; }
.input:hover, .select:hover { border-color: var(--ink-2); }
.input:focus, .select:focus { outline: 2px solid var(--npb); outline-offset: 0; border-color: var(--npb-ink); }
.input.is-error, .is-error .input { border-color: var(--danger); }
.input[disabled] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.mono { font-family: var(--font-mono); font-size: var(--t-13); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23332e2b' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.search { position: relative; }
.search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; }
.check, .radio { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--t-14); min-height: 28px; }
.check input, .radio input {
  appearance: none; width: 16px; height: 16px; margin: 0; flex: none; border: var(--rule-strong); background: var(--surface);
  border-radius: var(--r-ctl); display: grid; place-items: center; cursor: pointer;
}
.radio input { border-radius: var(--r-full); }
.check input:checked { background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M1.8 5.2 4 7.3l4.2-4.6' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E") center no-repeat; }
.check input:indeterminate { background: var(--ink) linear-gradient(white, white) center / 8px 1.6px no-repeat; }
.radio input:checked { box-shadow: inset 0 0 0 4px var(--surface); background: var(--ink); }
.switch { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--t-14); }
.switch input { appearance: none; width: 34px; height: 18px; margin: 0; border: var(--rule-strong); border-radius: var(--r-ctl); background: var(--surface); position: relative; cursor: pointer; transition: background var(--dur-2) var(--ease); }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--ink); transition: transform var(--dur-2) var(--ease); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { background: var(--surface); transform: translateX(16px); }
.seg { display: inline-flex; border: var(--rule-strong); border-radius: var(--r-ctl); overflow: hidden; background: var(--surface); }
.seg button { height: calc(var(--h-ctl-sm) + 2px); padding: 0 var(--s-3); border: 0; background: transparent; font-size: var(--t-13); font-weight: 600; color: var(--ink-2); }
.seg button + button { border-left: var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-primary); }
.seg button:not([aria-pressed="true"]):hover { background: var(--surface-2); }
.range { width: 100%; accent-color: var(--ink); }

/* Drop zone: drawn in construction blue */
.drop {
  display: grid; place-items: center; gap: var(--s-2); text-align: center; padding: var(--s-7) var(--s-5);
  border: 1px dashed var(--npb-ink); border-radius: var(--r-card); background: var(--surface); cursor: pointer;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.drop:hover, .drop.is-over { background: var(--npb-soft); border-style: solid; }
.drop .drop-t { font: 700 var(--t-22)/1.2 var(--font-display); }
.drop .drop-s { color: var(--muted); font-size: var(--t-14); }

/* ---------- Status vocabulary ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; white-space: nowrap;
  border: var(--rule); border-radius: var(--r-ctl); background: var(--surface);
  font: 600 var(--t-12)/1 var(--font-body); color: var(--ink-2);
}
.pill .ico { width: 12px; height: 12px; }
.pill.err  { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
.pill.warn { background: var(--warning-soft); border-color: var(--warning); color: var(--warning-ink); }
.pill.info { background: var(--info-soft); border-color: var(--npb); color: var(--info-ink); }
.pill.ok   { background: var(--hl); border-color: var(--hl-edge); color: var(--ink); }
.pill.draft { border-style: dashed; border-color: var(--npb-ink); color: var(--npb-ink); }
.pill.dark { background: var(--ink); border-color: var(--ink); color: var(--on-primary); }
.code { font-family: var(--font-mono); font-size: var(--t-12); font-weight: 450; color: var(--ink-2); letter-spacing: -0.01em; }
.code, .gid { overflow-wrap: anywhere; }
.gid { font-family: var(--font-mono); font-size: var(--t-12); color: var(--muted); letter-spacing: -0.02em; }

/* Severity glyphs: drawn SVG (Components.sev). Shape carries meaning as much as colour. */
.sev { display: inline-block; width: 14px; height: 14px; flex: none; vertical-align: -2px; overflow: visible; }

/* Revision triangle: the issue number as a drawing revision */
.rev { position: relative; display: inline-grid; place-items: center; width: 30px; height: 26px; flex: none; font: 700 11px/1 var(--font-display); color: var(--danger-ink); padding-top: 7px; }
.rev svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rev b { position: relative; font-weight: 700; }
.rev svg path { fill: var(--surface); stroke: var(--danger); stroke-width: 1.5; }
.rev.warn { color: var(--warning-ink); } .rev.warn svg path { stroke: var(--warning); }
.rev.info { color: var(--info-ink); }   .rev.info svg path { stroke: var(--npb-ink); }
.rev.closed { color: var(--muted); }    .rev.closed svg path { stroke: var(--muted-2); stroke-dasharray: 3 2; }

/* Highlighter: verified. Swipes in once. */
.hl { background: linear-gradient(100deg, transparent 0.2em, var(--hl) 0.25em, var(--hl) calc(100% - 0.2em), transparent) 0 55% / 100% 78% no-repeat; padding: 0 0.15em; }
.hl.draw { animation: swipe var(--dur-draw) var(--ease-out) both; }
@keyframes swipe { from { background-size: 0% 78%; } to { background-size: 100% 78%; } }

/* ---------- Tables: ruled grid ---------- */
.tbl-wrap { overflow-x: auto; border: var(--rule-strong); background: var(--surface); }
.tbl { width: 100%; font-size: var(--t-14); }
.tbl th, .tbl td { height: var(--h-row); padding: 0 var(--s-3); border-bottom: var(--row-rule); text-align: left; vertical-align: middle; }
.tbl th + th, .tbl td + td { border-left: var(--cell-rule); }
.tbl thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); border-bottom: var(--rule-strong);
  font: 600 var(--t-12)/1.2 var(--font-body); color: var(--ink-2); white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border: solid var(--muted-2); border-width: 0 1.4px 1.4px 0; transform: translateY(-2px) rotate(45deg); }
.tbl th[aria-sort="ascending"]::after { border-color: var(--ink); transform: translateY(1px) rotate(225deg); }
.tbl th[aria-sort="descending"]::after { border-color: var(--ink); }
.tbl tbody tr { transition: background var(--dur-1) var(--ease); }
.tbl tbody tr:hover { background: var(--npb-soft); }
.tbl tbody tr.is-selected { background: var(--npb-soft); }
.tbl tbody tr.is-lit { animation: lit 2.4s var(--ease-out) both; }
@keyframes lit { 0%, 40% { background: var(--hl); } 100% { background: transparent; } }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.c-chk, .tbl th.c-chk { width: 40px; text-align: center; padding: 0; }
.tbl tr[data-href] { cursor: pointer; }
.tbl .title { font-weight: 600; color: var(--ink); }
.tbl .sub { display: block; }
.tbl.compact th, .tbl.compact td { height: 30px; font-size: var(--t-13); }
.bulkbar {
  display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 6px var(--s-3);
  background: var(--drench); color: var(--on-drench); font-size: var(--t-14);
}
.bulkbar .btn { background: transparent; color: var(--on-drench); border-color: var(--drench-line); }
.bulkbar .btn:hover { background: var(--drench-2); }
.toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-3); border: var(--rule-strong); border-bottom: 0; background: var(--surface); }
.toolbar + .tbl-wrap { border-top: var(--rule); }
.chipf { display: inline-flex; align-items: center; gap: 6px; height: var(--h-ctl-sm); padding: 0 var(--s-3); border: var(--rule); border-radius: var(--r-ctl); background: var(--surface); font-size: var(--t-13); font-weight: 500; cursor: pointer; }
.chipf[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-primary); }
.chipf .n { font-family: var(--font-mono); font-size: var(--t-11); opacity: 0.8; }

/* Lists */
.lrow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--pad-card); border-bottom: var(--rule); text-decoration: none; color: inherit; }
.lrow:last-child { border-bottom: 0; }
a.lrow:hover, .lrow[data-href]:hover { background: var(--npb-soft); cursor: pointer; }
.lrow > * { min-width: 0; }
.lrow .t { font-weight: 600; } .lrow .m { font-size: var(--t-13); color: var(--muted); }

/* Key–value ledger */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; font-size: var(--t-14); }
.kv dt, .kv dd { padding: 7px 0; border-bottom: var(--rule); }
.kv dt { color: var(--muted); padding-right: var(--s-3); }
.kv dd { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Tabs, accordion ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: var(--rule-strong); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { height: 40px; padding: 0 var(--s-3); border: 0; background: none; font-weight: 600; font-size: var(--t-14); color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.acc { border-top: var(--rule); }
.acc details { border-bottom: var(--rule); }
.acc summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; cursor: pointer; font-weight: 600; list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: ''; width: 10px; height: 10px; flex: none; background: linear-gradient(var(--ink), var(--ink)) center / 10px 1.4px no-repeat, linear-gradient(var(--ink), var(--ink)) center / 1.4px 10px no-repeat; transition: transform var(--dur-2) var(--ease); }
.acc details[open] summary::after { transform: rotate(45deg); }
.acc .acc-b { padding: 0 0 var(--s-4); }

/* ---------- Layers: tracing paper ---------- */
.scrim { position: fixed; inset: 0; z-index: var(--z-layer); background: oklch(0.235 0.008 30 / 0.28); opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--z-layer) + 1); width: min(520px, 100vw);
  background: var(--surface); border-left: var(--rule-strong); box-shadow: var(--elev-modal);
  transform: translateX(104%); transition: transform var(--dur-3) var(--ease-out); display: flex; flex-direction: column;
}
.drawer-b { overflow-y: auto; padding: var(--pad-card); flex: 1; }
body.layer-open .scrim { opacity: 1; pointer-events: auto; }
body.layer-open .drawer { transform: none; }
dialog.modal { width: min(560px, calc(100vw - 2rem)); padding: 0; border: var(--rule-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--elev-modal); }
dialog.modal::backdrop { background: oklch(0.235 0.008 30 / 0.32); }
dialog.modal[open] { animation: lift var(--dur-3) var(--ease-out); }
@keyframes lift { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal-f { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--pad-card); border-top: var(--rule); }
.menu { min-width: 200px; padding: 4px 0; background: var(--surface); border: var(--rule-strong); box-shadow: var(--elev-pop); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: var(--s-2); min-height: 34px; padding: 0 var(--s-3); border: 0; background: none; text-align: left; font-size: var(--t-14); color: var(--ink); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--npb-soft); }
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: var(--z-toast);
  padding: 5px 8px; background: var(--ink); color: var(--on-primary); font: 500 var(--t-12)/1.3 var(--font-body); white-space: nowrap; border-radius: var(--r-ctl); pointer-events: none;
}

/* ---------- Feedback & states ---------- */
.banner { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: var(--rule); background: var(--surface); font-size: var(--t-14); }
.banner .grow { flex: 1; min-width: 0; }
.banner.info { background: var(--info-soft); border-color: var(--npb); color: var(--info-ink); }
.banner.warn { background: var(--warning-soft); border-color: var(--warning); color: var(--warning-ink); }
.banner.err  { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
.banner.ok   { background: var(--hl); border-color: var(--hl-edge); color: var(--ink); }
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-2); padding: var(--s-7) var(--s-5); }
.empty svg { width: 120px; height: 84px; color: var(--npb-ink); margin-bottom: var(--s-2); }
.empty svg.sev { width: 28px; height: 24px; }
.empty h3 { font-size: var(--t-18); }
.empty p { color: var(--muted); max-width: 44ch; font-size: var(--t-14); }
.skel { position: relative; overflow: hidden; background: var(--surface-2); min-height: 12px; }
.skel::after { content: ''; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--npb-ink); box-shadow: 0 0 0 1px var(--npb-soft); animation: scan 1.6s var(--ease) infinite; }
@keyframes scan { from { left: 0; } to { left: 100%; } }
.skel.line { height: 12px; margin: 8px 0; } .skel.block { height: 120px; }

/* ---------- Domain: Pset source ---------- */
.src { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--r-ctl); font: 500 var(--t-11)/1 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.src-occ  { border: var(--rule-strong); color: var(--ink); }
.src-type { border: 1px dashed var(--npb-ink); color: var(--npb-ink); }
.src-ovr  { border: 1px solid var(--warning); color: var(--warning-ink); background: var(--warning-soft); }
.pset { border: var(--rule-strong); background: var(--surface); }
.pset-h { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-bottom: var(--rule-strong); background: var(--surface-2); font: 600 var(--t-13)/1.3 var(--font-mono); }
.pset-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 1.2fr) auto; gap: var(--s-3); align-items: center; padding: 7px var(--s-3); border-bottom: var(--rule); font-size: var(--t-14); }
.pset-row:last-child { border-bottom: 0; }
.pset-row .pn { color: var(--ink-2); }
.pset-row .pv { font-weight: 600; overflow-wrap: anywhere; }
.pset-row .was { color: var(--muted); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--warning); margin-right: 6px; }
.pset-row.missing .pv { color: var(--danger-ink); }

/* ---------- Domain: IDS ---------- */
.spec { display: grid; grid-template-columns: auto minmax(0, 1fr) 160px auto; gap: var(--s-4); align-items: center; padding: var(--s-3) var(--pad-card); border-bottom: var(--rule); }
.spec:last-child { border-bottom: 0; }
.spec .t { font-weight: 600; }
.spec .d { font-size: var(--t-13); color: var(--muted); }
.ratio { display: grid; gap: 4px; font-size: var(--t-12); color: var(--muted); }
.ratio .bar { display: flex; height: 6px; background: var(--surface-3); }
.ratio .bar i { display: block; height: 100%; background: var(--ink); }
.ratio .bar b { display: block; height: 100%; background: var(--danger); }
.facet { display: grid; grid-template-columns: 116px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: var(--s-3); border: var(--rule-strong); background: var(--surface); }
.facet + .facet { border-top: 0; }
.facet .fk { font: 600 var(--t-11)/1.2 var(--font-mono); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--npb-ink); }
.facet .fv { font-size: var(--t-14); }
.facet .fv code { background: var(--surface-2); padding: 1px 5px; }
.xsd { display: inline-flex; align-items: center; gap: 6px; font: 500 var(--t-12)/1 var(--font-mono); }

/* ---------- Domain: pipeline (stations on a drawn line) ---------- */
.pipe { --n: 5; position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); padding-top: 6px; }
.pipe::before { content: ''; position: absolute; left: calc(50% / var(--n)); right: calc(50% / var(--n)); top: 15px; height: 1px; background: var(--line); }
.pipe .track { position: absolute; left: calc(50% / var(--n)); top: 14px; height: 3px; width: 0; background: var(--ink); transition: width var(--dur-scene) var(--ease-out); }
.pstage { position: relative; display: grid; justify-items: center; text-align: center; gap: 4px; padding: 0 var(--s-2); }
.pstage .dot { width: 20px; height: 20px; border-radius: var(--r-full); border: 1.5px solid var(--muted-2); background: var(--surface); display: grid; place-items: center; z-index: 1; transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease); }
.pstage .n { font: 700 var(--t-15)/1.2 var(--font-display); margin-top: 6px; }
.pstage .tm { font: 450 var(--t-12)/1 var(--font-mono); color: var(--muted); min-height: 1em; }
.pstage .ct { font-size: var(--t-12); color: var(--muted); }
.pstage.done .dot { background: var(--ink); border-color: var(--ink); }
.pstage.done .dot::after { content: ''; width: 5px; height: 9px; margin-top: -2px; border: solid var(--on-primary); border-width: 0 1.6px 1.6px 0; transform: rotate(40deg); }
.pstage.run .dot { border: 1.5px dashed var(--npb-ink); box-shadow: 0 0 0 4px var(--npb-soft); animation: turn 2.4s linear infinite; }
.pstage.fault .dot { border-color: var(--warning); background: var(--warning-soft); }
.pstage.fail .dot { border-color: var(--danger); background: var(--danger-soft); }
.pstage.skip .dot { border-style: dashed; }
@keyframes turn { to { transform: rotate(360deg); } }

/* ---------- Domain: UNI 11337 gates ---------- */
.gates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: var(--rule-strong); background: var(--surface); }
.gate { padding: var(--s-4); display: grid; gap: var(--s-2); align-content: start; min-height: 150px; }
.gate + .gate { border-left: var(--rule-strong); }
.gate .lv { font: 700 var(--t-40)/1 var(--font-display); }
.gate .pill { justify-self: start; }
.gate .gn { font-weight: 600; } .gate .gd { font-size: var(--t-13); color: var(--muted); }
.gate.passed .lv { background: linear-gradient(transparent 18%, var(--hl) 18%, var(--hl) 86%, transparent 86%); justify-self: start; padding: 0 4px; }
.gate.blocked .lv { color: var(--danger-ink); }
.gate.pending .lv { color: var(--muted-2); }
.stamp { width: 148px; height: 148px; color: var(--danger-ink); transform: rotate(-9deg); }
.stamp.ok { color: var(--npb-ink); }
.stamp.press { animation: press 520ms var(--ease-out) both; }
@keyframes press { from { opacity: 0; transform: rotate(-9deg) scale(1.35); } 60% { opacity: 1; } to { opacity: 1; transform: rotate(-9deg) scale(1); } }

/* ---------- Domain: spatial tree ---------- */
.tree { font-size: var(--t-14); }
.tree ul { margin-left: 7px; padding-left: 11px; border-left: 1px dashed var(--npb); }
.tree li { position: relative; }
.tree li > ul { margin-top: 2px; }
.tnode { display: flex; align-items: center; gap: var(--s-2); min-height: 30px; padding: 0 var(--s-2); position: relative; cursor: pointer; }
.tree ul > li > .tnode::before { content: ''; position: absolute; left: -11px; top: 50%; width: 9px; border-top: 1px dashed var(--npb); }
.zoned-in { position: relative; padding: 18px 0 0 18px; }
.tnode { flex-wrap: wrap; row-gap: 2px; }
.tnode:hover { background: var(--npb-soft); }
.tnode.is-sel { background: var(--ink); color: var(--on-primary); }
.tnode.is-sel .code { color: var(--on-drench-muted); }
.tnode .cls { font: 450 var(--t-11)/1 var(--font-mono); color: var(--muted); }
.xref { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border: 1px solid var(--npb-ink); border-radius: var(--r-full); font: 500 var(--t-11)/1 var(--font-mono); color: var(--npb-ink); background: var(--surface); }

/* ---------- Domain: model viewer ---------- */
.viewer { position: relative; background: var(--surface); border: var(--rule-strong); overflow: hidden; min-height: 360px; }
.viewer canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.viewer .overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; z-index: 1; }
.viewer .cloud { fill: none; stroke: var(--danger); stroke-width: 2.2; stroke-linejoin: round; }
.viewer .cloud.draw { animation: drawon var(--dur-draw) var(--ease-out) both; }
.viewer .cloud-tag { font: 700 13px var(--font-display); fill: var(--danger-ink); }
.viewer .ghost { fill: none; stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 5 4; }
@keyframes drawon { from { stroke-dashoffset: var(--len, 1200); } to { stroke-dashoffset: 0; } }
.viewer .vtools { position: absolute; left: var(--s-3); top: var(--s-3); display: flex; gap: var(--s-2); flex-wrap: wrap; z-index: 2; }
.viewer .vlegend { position: absolute; left: var(--s-3); bottom: var(--s-3); display: flex; gap: var(--s-3); flex-wrap: wrap; padding: 6px 10px; background: var(--surface); border: var(--rule); font-size: var(--t-12); z-index: 2; }
.viewer .vlegend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -2px; border: 1px solid var(--ink); }
.viewer .vpick { position: absolute; right: var(--s-3); top: var(--s-3); width: min(264px, calc(100% - 24px)); z-index: 2; background: var(--surface); border: var(--rule-strong); box-shadow: var(--elev-pop); }
.viewer .vhint { position: absolute; right: var(--s-3); bottom: var(--s-3); font-size: var(--t-12); color: var(--muted); z-index: 2; }
.viewer .nogl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: var(--s-5); }

/* ---------- Shell extras ---------- */
.foot { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); padding: var(--s-4) var(--gutter); border-top: var(--rule); font-size: var(--t-12); color: var(--muted); }
.foot a { color: var(--muted); }
.bell { position: relative; }
.dotn { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent); font: 700 10px/16px var(--font-body); }
.shell-menu { z-index: var(--z-layer); width: min(380px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; }
.shell-menu .notif { align-items: flex-start; padding: var(--s-2) var(--s-3); min-height: 0; white-space: normal; border-bottom: var(--rule); }
.unread { width: 8px; height: 8px; margin-top: 6px; flex: none; border-radius: var(--r-full); background: var(--accent); }
.unread.is-read { background: transparent; }
dialog.cmdk-dlg { width: min(640px, calc(100vw - 2rem)); margin-top: 12vh; }
.cmdk-list { max-height: 52vh; overflow-y: auto; }
.cmdk-it { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); min-height: 40px; padding: 0 var(--s-3); text-decoration: none; color: var(--ink); border-bottom: var(--rule); }
.cmdk-it[aria-selected="true"], .cmdk-it:hover { background: var(--npb-soft); }
.cmdk-f { display: flex; gap: var(--s-4); padding: var(--s-2) var(--s-3); font-size: var(--t-12); color: var(--muted); border-top: var(--rule-strong); }
@media (max-width: 1100px) { .hide-md { display: none !important; } }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* ==========================================================================
   Prototype chrome
   ========================================================================== */
.pocbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-pocbar);
  height: var(--pocbar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4); font-size: var(--t-12); background: var(--drench); color: var(--on-drench);
}
.pocbar .tagword { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--hl); }
.pocbar .roles { display: flex; gap: 2px; }
.pocbar .roles a { padding: 4px 10px; border-radius: var(--r-ctl); color: var(--on-drench-muted); text-decoration: none; white-space: nowrap; }
.pocbar .roles a:hover { color: var(--on-drench); background: var(--drench-2); }
.pocbar .roles a[aria-current="true"] { background: var(--on-drench); color: var(--ink); }
.pocbar .mods { display: flex; gap: 4px; }
.pocbar .tag-module { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--drench-line); border-radius: var(--r-ctl); color: var(--on-drench-muted); text-decoration: none; }
.pocbar .spacer { flex: 1; }
.pocbar button.link { background: none; border: 0; color: var(--on-drench-muted); font: inherit; cursor: pointer; padding: 4px 6px; white-space: nowrap; }
.pocbar button.link:hover { color: var(--on-drench); }
@media (max-width: 720px) {
  .pocbar .hide-sm { display: none; }
  .pocbar { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .pocbar::-webkit-scrollbar { display: none; }
  .pocbar > * { flex: none; }
  .pocbar .spacer { flex: 1 0 var(--s-4); }
}
body.show-sow [data-module] { outline: 1px dashed var(--npb-ink); outline-offset: 2px; position: relative; }
body.show-sow [data-module]::after { content: attr(data-module); position: absolute; top: -8px; right: -6px; z-index: 2; font-family: var(--font-mono); font-size: 9px; line-height: 1; padding: 3px 5px; background: var(--npb-ink); color: var(--on-primary); }

.toaster { position: fixed; right: var(--s-4); bottom: calc(var(--pocbar-h) + var(--s-4)); z-index: var(--z-toast); display: flex; flex-direction: column-reverse; gap: var(--s-2); pointer-events: none; }
body:not(.has-pocbar) .toaster { bottom: var(--s-4); }
.toast { max-width: 44ch; padding: var(--s-3) var(--s-4); background: var(--drench); color: var(--on-drench); border-radius: var(--r-ctl); box-shadow: var(--elev-pop); font-size: var(--t-14); animation: toast-in var(--dur-3) var(--ease-out); transition: opacity var(--dur-3) var(--ease); }
.toast.ok { background: var(--hl); color: var(--ink); }
.toast.warn { background: var(--warning-soft); color: var(--warning-ink); border: 1px solid var(--warning); }
.toast.err { background: var(--danger); color: var(--on-accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tour-scrim { position: fixed; inset: 0; z-index: var(--z-tour); background: oklch(0.235 0.008 30 / 0.5); }
.tour-hole { position: fixed; z-index: calc(var(--z-tour) + 1); box-shadow: 0 0 0 9999px oklch(0.235 0.008 30 / 0.5), 0 0 0 2px var(--hl); pointer-events: none; }
.tour-pop { position: fixed; z-index: calc(var(--z-tour) + 2); max-width: 36ch; padding: var(--s-4); background: var(--surface); color: var(--ink); border: var(--rule-strong); box-shadow: var(--elev-modal); }
.tour-pop .step { font-family: var(--font-mono); font-size: var(--t-11); color: var(--muted); }
.tour-pop h3 { font-size: var(--t-18); margin: var(--s-1) 0 var(--s-2); }
.tour-pop p { font-size: var(--t-14); color: var(--ink-2); }
.tour-pop .row { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

.rv.pre { opacity: 0; transform: translateY(12px); }
.rv.in  { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: var(--z-tour); padding: var(--s-3) var(--s-4); background: var(--ink); color: var(--on-primary); }
.skip-link:focus { left: 0; }

.navbtn { display: none; }
@media (max-width: 760px) {
  .topbar { gap: var(--s-3); }
  .navbtn { display: inline-flex; }
  .topbar .nav { display: none; }
  .nav-open .topbar .nav { display: flex; flex-direction: column; position: absolute; top: var(--topbar-h); left: 0; right: 0; padding: var(--s-2) 0; background: var(--surface); border-bottom: var(--rule-strong); box-shadow: var(--elev-modal); }
  .nav-open .topbar .nav a { padding: var(--s-3) var(--gutter); box-shadow: none; }
  .nav-open .topbar .nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
  .cmdk { min-width: 0; width: var(--h-ctl); padding: 0; justify-content: center; }
  .cmdk span, .cmdk kbd { display: none; }
  .spec { grid-template-columns: auto minmax(0, 1fr); }
  .spec .ratio, .spec > :last-child { grid-column: 2; }
  .gates { grid-template-columns: 1fr; }
  .gate + .gate { border-left: 0; border-top: var(--rule-strong); }
  .facet { grid-template-columns: 1fr; }
  .pset-row { grid-template-columns: 1fr auto; }
  .pset-row .pv { grid-column: 1 / -1; grid-row: 2; }
  .pstage { padding: 0 2px; }
  .pstage .ct { display: none; }
  .cartiglio .verdict { font-size: var(--t-22); }
}
