/* =====================================================================
   JIA v2 — Admin redesign + registration drawers (물결 / Mulgyeol)
   Layered on top of base styles.css. New classes only — base untouched.
   Light-first. Implements: tab sections · right-drawer registration ·
   dual-track · description-first · validation/status · AI assist ·
   org-register ↔ personal-activate governance.
   ===================================================================== */

/* ---- a few extra tokens ---- */
:root {
  --field: var(--surface);
  --field-2: var(--surface-2);
  --drawer-w: 580px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}
:root[data-theme="dark"] { --field: oklch(0.25 0.016 238); }

/* hidden must always win over class-level display rules */
[hidden] { display: none !important; }

/* icon sizing inside fixed holders (inline SVGs have no intrinsic size) */
.search svg { width: 18px; height: 18px; flex: none; }
.gi svg { width: 17px; height: 17px; }
.dh-ic svg { width: 22px; height: 22px; }
.item-ic svg { width: 22px; height: 22px; }
.lc-ic svg { width: 18px; height: 18px; }
.role-badge svg { width: 12px; height: 12px; }
.kebab, .sw-label { user-select: none; }

/* user menu (avatar dropdown) */
.usermenu-wrap { position: relative; display: flex; flex: none; }
.usermenu {
  position: absolute;
  top: calc(100% + 9px); right: 0;
  width: 240px;
  z-index: 55;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.usermenu .um-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.usermenu .av-sm {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  font-size: 12px; font-weight: 700;
}
.um-id { min-width: 0; }
.um-id b { display: block; font-size: 13.5px; color: var(--ink); }
.um-id span { display: block; font-size: 11px; color: var(--ink-3); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px; font-weight: 540;
  text-align: left;
}
.um-item:hover { background: var(--surface-2); color: var(--ink); }
.um-item svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.um-item.danger { color: var(--error); }
.um-item.danger:hover { background: oklch(from var(--error) l c h / .08); }
.um-item.danger svg { color: var(--error); }
.um-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* inline notice ticker (beside brand) — vertical roll-up, one at a time */
body[data-ui="b"] .ntick {
  display: inline-flex; align-items: center; gap: 8px;
  width: clamp(180px, 24vw, 320px); height: 32px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2);
  margin-left: 6px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
body[data-ui="b"] .ntick:hover { border-color: var(--primary-line); background: var(--surface); }
.ntick-tag { flex: none; display: inline-flex; align-items: center; height: 20px; line-height: 1; font-size: 11px; font-weight: 700; color: var(--primary); padding-right: 10px; margin-right: 2px; border-right: 1px solid var(--line-2); }
.ntick-vp { position: relative; flex: 1; min-width: 0; height: 20px; overflow: hidden; }
.ntick-roll { display: flex; flex-direction: column; will-change: transform; }
.ntick-line {
  display: flex; align-items: center; gap: 7px;
  height: 20px; min-height: 20px; line-height: 1;
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.ntick-line b { color: var(--ink); font-weight: 600; }
.ntick-line .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ntick-line.important, .ntick-line.important b { color: var(--warn-2); }
.ntick-badge {
  flex: none; display: inline-flex; align-items: center; height: 15px; line-height: 1;
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  padding: 0 6px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn-2); border: 1px solid var(--warn-line);
}

/* notice detail modal */
.nmodal-scrim {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  background: oklch(0.15 0.02 240 / .42); backdrop-filter: blur(3px);
}
.nmodal {
  width: min(460px, calc(100vw - 40px));
  padding: 20px 22px 22px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.nmodal-head { display: flex; align-items: flex-start; gap: 12px; }
.nm-titrow { flex: 1; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.nmodal h3 { margin: 0; font-size: 18px; font-weight: 680; color: var(--ink); }
.nm-badge { font-family: var(--mono); font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-2); border: 1px solid var(--warn-line); }
.nm-period { margin-top: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.nm-content { margin-top: 14px; color: var(--ink-2); font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.nm-listlabel { margin: 18px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; }
.nm-list { display: grid; gap: 4px; max-height: 208px; overflow-y: auto; }
.nm-litem { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; text-align: left; }
.nm-litem:hover { background: var(--surface-2); }
.nm-litem.on { background: var(--primary-soft); border-color: var(--primary-line); }
.nm-lt { flex: 1; min-width: 0; font-size: 13px; color: var(--ink); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm-ld { flex: none; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

/* awaiting-confirmation status — blink so users notice it needs action */
body[data-ui="b"] .pill[data-s="awaiting_confirmation"] {
  animation: await-blink 1.15s ease-in-out infinite;
}
@keyframes await-blink {
  0%, 100% { box-shadow: 0 0 0 0 oklch(from var(--warn) l c h / .55); opacity: 1; }
  50% { box-shadow: 0 0 0 5px oklch(from var(--warn) l c h / 0); opacity: .5; }
}

/* workspace switcher */
.ws-switch { position: relative; }
body[data-ui="b"] .ws-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; height: 34px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink);
  font-family: var(--mono); font-size: 11.5px;
}
.ws-btn .k { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.ws-btn .ws-name { white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.ws-btn .ws-chev { width: 14px; height: 14px; color: var(--ink-3); }
.ws-menu {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: 244px; z-index: 55; padding: 6px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.ws-mlabel { padding: 8px 10px 6px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; }
.ws-opt { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 13px; text-align: left; }
.ws-opt:hover { background: var(--surface-2); color: var(--ink); }
.ws-opt .k { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.ws-opt .k.off { background: var(--ink-4); }
.ws-opt.on { color: var(--ink); font-weight: 600; }
.ws-opt.ws-new { color: var(--primary-2); font-weight: 600; }

/* 개인설정 controls */
.pref-row { display: flex; align-items: center; gap: 14px; }
.scope-seg.wrap { flex-wrap: wrap; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 9px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink-2); font-size: 13px;
}
.swatch .sw-name { white-space: nowrap; }
.sw-tip {
  position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 230px;
  padding: 8px 11px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font-size: 11.5px; font-weight: 500; line-height: 1.45; text-align: center;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .14s ease, transform .14s ease; z-index: 20;
}
.sw-tip::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }
.swatch:hover .sw-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.swatch:hover { border-color: var(--line-2); }
.swatch.on { border-color: var(--primary); box-shadow: 0 0 0 2px oklch(from var(--primary) l c h / .25); color: var(--ink); font-weight: 600; }
.swatch .sw-chip { width: 20px; height: 20px; border-radius: 6px; box-shadow: inset 0 0 0 1px oklch(0 0 0 / .08); flex: none; }
.pref-range { width: 100%; accent-color: var(--primary); height: 4px; }

/* brand-consistent icons in chat avatar + artifact card */
body[data-ui="b"] .who .ava svg { width: 14px; height: 14px; }
body[data-ui="b"] .openart .pv svg { width: 22px; height: 22px; }
body[data-ui="b"] .openart .t { min-width: 0; }
body[data-ui="b"] .openart .t b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#theme-toggle svg { width: 17px; height: 17px; }
body[data-ui="b"] .rail .ritem svg { width: 19px; height: 19px; }

/* runs history panel — docked (expand) or popup (collapsed) */
body[data-ui="b"] .runs-panel {
  flex: none;
  width: 270px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}
body[data-ui="b"] .runs-panel.popup {
  position: fixed;
  left: 60px; top: 64px;
  width: 300px;
  max-height: min(64vh, 520px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 45;
}
body[data-ui="b"] .runs-panel.resource-panel {
  width: min(420px, calc(100vw - 72px));
  background: var(--bg);
}
.rp-head {
  display: flex; align-items: center; gap: 4px;
  padding: 13px 10px 11px 15px;
  border-bottom: 1px solid var(--line);
}
.rp-head b { flex: 1; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.rp-ico {
  width: 28px; height: 28px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3);
  display: grid; place-items: center;
}
.rp-ico:hover { background: var(--surface-2); color: var(--ink); }
.rp-ico.on { background: var(--primary-soft); color: var(--primary-2); }
.rp-ico svg { width: 16px; height: 16px; }
.rp-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.resource-panel .rp-body { display: block; padding: 10px; }
.rp-list { padding: 8px; display: grid; gap: 5px; align-content: start; }
.rp-item { position: relative; }
.rp-main {
  width: 100%;
  display: grid; gap: 5px;
  padding: 10px 11px;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; text-align: left;
}
.rp-main:hover { background: var(--surface); border-color: var(--line); }
.rp-acts {
  position: absolute; right: 7px; top: 7px;
  display: flex; gap: 2px;
  opacity: 0; transition: opacity .12s;
}
.rp-item:hover .rp-acts { opacity: 1; }
.rp-act {
  width: 26px; height: 26px;
  border: 0; border-radius: 7px;
  background: var(--surface-2); color: var(--ink-3);
  display: grid; place-items: center;
}
.rp-act:hover { background: var(--line); color: var(--ink); }
.rp-act svg { width: 14px; height: 14px; }
.rp-act[data-fav].on { color: var(--sand); }
.rp-act[data-fav].on svg { fill: var(--sand); }
.rp-act[data-del]:hover { color: var(--error); }
.rp-item .rp-top { display: flex; align-items: center; gap: 7px; }
.rp-item .rp-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-4); }
.rp-item .rp-dot.succeeded { background: var(--ok); }
.rp-item .rp-dot.awaiting { background: var(--warn); }
.rp-item .rp-dot.failed { background: var(--error); }
.rp-item strong { flex: 1; min-width: 0; font-size: 13px; font-weight: 560; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-item .meta { display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); padding-left: 14px; }
.rp-empty { padding: 30px 12px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* usage popup */
body[data-ui="b"] .usage-pop {
  position: fixed;
  left: 60px; top: 108px;
  width: 264px;
  z-index: 45;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.up-body { padding: 8px; display: grid; gap: 1px; }
.up-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 9px; border-radius: 8px; }
.up-row:hover { background: var(--surface-2); }
.up-row span { color: var(--ink-3); font-size: 12.5px; }
.up-row b { font-family: var(--mono); font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.up-foot { padding: 8px; border-top: 1px solid var(--line); }
.up-foot .btn { width: 100%; justify-content: center; }

/* personal memory/schedule panels */
.res-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.res-search .search {
  max-width: none;
  height: 36px;
  flex: 1;
}
.res-count {
  margin: 8px 2px 9px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
}
.res-list {
  display: grid;
  gap: 9px;
}
.res-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.res-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}
.res-id {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
}
.res-trash {
  position: static;
  opacity: 1;
  flex: none;
}
.res-trash svg { width: 14px; height: 14px; }
.res-trash:hover { color: var(--error); }
.memory-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.res-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}
.res-meta {
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-4);
}
.res-error {
  margin: 9px 0;
  padding: 9px 10px;
  border: 1px solid oklch(from var(--error) l c h / .35);
  border-radius: 9px;
  background: oklch(from var(--error) l c h / .07);
  color: var(--error);
  font-size: 12.5px;
}
.res-error.compact {
  margin: 8px 0 0;
  padding: 7px 8px;
}
.schedule-create {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.schedule-create .fg { margin-bottom: 0; }
.schedule-create .fg-label {
  min-height: 24px;
  align-items: center;
}
.schedule-create .ta {
  min-height: 78px;
  resize: vertical;
}
.schedule-create .row2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.res-form-actions,
.res-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.res-form-actions {
  padding-top: 2px;
}
.res-form-actions .sp { flex: 1; }
.schedule-title {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.45;
  word-break: break-word;
}
.schedule-line {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}
.schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}
.schedule-grid .kv {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.schedule-grid .kv span {
  display: block;
  margin-bottom: 2px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-4);
}
.schedule-grid .kv b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}
.schedule-card .res-actions {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

/* rail bottom status indicator */
.rail-status {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 0; background: transparent;
  padding: 6px 0 2px;
}
.rail-status .rs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-4); }
.rail-status .rs-txt { font-family: var(--mono); font-size: 9px; letter-spacing: .03em; color: var(--ink-3); }
.rail-status.done .rs-dot { background: var(--ok); }
.rail-status.stop .rs-dot { background: var(--ink-4); }
.rail-status.run .rs-dot { background: var(--primary); animation: rs-pulse 1.4s infinite; }
@keyframes rs-pulse {
  0% { box-shadow: 0 0 0 0 oklch(from var(--primary) l c h / .5); }
  70% { box-shadow: 0 0 0 7px oklch(from var(--primary) l c h / 0); }
  100% { box-shadow: 0 0 0 0 oklch(from var(--primary) l c h / 0); }
}

/* draggable resizer for the artifact panel (mouse-adjustable layout) */
body[data-ui="b"] .artifact { position: relative; }
.art-resize {
  position: absolute;
  left: -4px; top: 0; bottom: 0;
  width: 9px;
  z-index: 6;
  cursor: col-resize;
}
.art-resize::after {
  content: "";
  position: absolute;
  left: 3px; top: 0; bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background .15s;
}
.art-resize:hover::after, .art-resize.drag::after { background: var(--primary); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* simplified brand lockup — icon + "JIA" wordmark */
body[data-ui="b"] .brand .wm {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .16em;
  padding-bottom: 0;
  color: var(--ink);
}
.btn { white-space: nowrap; }
.btn svg, .magic svg, .scope-seg svg { width: 14px; height: 14px; flex: none; }
.mc-input .btn svg { width: 16px; height: 16px; }

/* =====================================================================
   ADMIN v2 SHELL — tab-based sections
   ===================================================================== */
body[data-ui="b"] .av2 {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.av2-head {
  flex: none;
  padding: 22px 32px 0;
  border-bottom: 1px solid var(--line);
}
.av2-titlerow {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.av2-title { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.av2-title h1 {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--ink);
}
.av2-title .sub {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
}
.av2-meta { display: flex; align-items: center; gap: 10px; flex: none; }
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--primary-line);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.role-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}
.av2-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.av2-nav::-webkit-scrollbar { display: none; }
.av2-tab {
  position: relative;
  flex: none;
  padding: 11px 15px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.av2-tab:hover { color: var(--ink); }
.av2-tab .n {
  min-width: 18px;
  padding: 0 5px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10.5px;
}
.av2-tab.on { color: var(--ink); font-weight: 680; }
.av2-tab.on .n { background: var(--primary); color: var(--primary-ink); }
.av2-tab.on::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--primary);
}
.av2-main {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px 60px;
}
.av2-section { max-width: 1600px; margin: 0 auto; }
.av2-section[hidden] { display: none; }

/* =====================================================================
   REGISTRY — list of registered items (Tools/MCP/Agents/Personas/Skills)
   ===================================================================== */
.reg-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.reg-intro h2 {
  margin: 0 0 5px;
  font-size: 22px;
  font-weight: 680;
  color: var(--ink);
}
.reg-intro p { margin: 0; max-width: none; color: var(--ink-2); font-size: 14px; }

/* governance scope switch: org registry (admin) vs personal activation */
.gov {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 15px;
  border: 1px solid var(--primary-line);
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--primary-soft), transparent 80%);
}
.gov .gi {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary-line);
}
.gov p { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.gov b { color: var(--ink); font-weight: 650; }
.gov .sp { flex: 1; }
.scope-seg {
  display: inline-flex;
  flex: none;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.scope-seg button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
}
.scope-seg button.on { background: var(--ink); color: var(--bg); }

.reg-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.search {
  flex: 1;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-3);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
}
.reg-toolbar .sp { flex: 1; }

.item-list { display: grid; gap: 10px; }
.item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.item:hover { border-color: var(--line-2); box-shadow: var(--shadow-md); }
.item-ic {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-size: 20px;
}
.item-ic.mono { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.item-main { min-width: 0; }
.item-name {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.item-name b { font-size: 15px; color: var(--ink); font-weight: 650; }
.item-name code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-3);
}
.item-desc {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.item-tags { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.item-act { display: flex; align-items: center; gap: 12px; flex: none; }

/* badges / trust signals */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge.verified { border-color: oklch(from var(--ok) l c h / .5); background: var(--ok-soft); color: var(--ok); }
.badge.custom { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn-2); }
.badge.mcp { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary-2); }
.badge.builtin { border-color: var(--line-2); }
.badge.remote { color: var(--ink-2); }
.badge.local { color: var(--ink-2); }
.badge.off { color: var(--ink-4); }

/* activation toggle switch */
.sw {
  position: relative;
  width: 40px; height: 23px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: var(--line-2);
  transition: background .18s;
  cursor: pointer;
}
.sw::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease);
}
.sw.on { background: var(--primary); }
.sw.on::after { transform: translateX(17px); }
.sw-label { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }

.kebab {
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
}
.kebab:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

.reg-empty {
  padding: 46px 20px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--ink-3);
  background: oklch(from var(--surface) l c h / .5);
}

/* =====================================================================
   POLICY / MEMBERS / OVERVIEW
   ===================================================================== */
.ov-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat .v {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat .v .u { font-size: 14px; color: var(--ink-3); margin-left: 3px; }
.stat .l { margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }
.stat .d { margin-top: 6px; font-size: 11.5px; font-family: var(--mono); }
.stat .d.up { color: var(--ok); }

.card2 {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.card2-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card2-head h3 { margin: 0; font-size: 15px; font-weight: 650; color: var(--ink); }
.card2-body { padding: 18px; }

.t2 { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t2 th {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.t2 td { padding: 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.t2 tr:last-child td { border-bottom: 0; }
.t2 .who2 { display: flex; align-items: center; gap: 10px; }
.t2 .av-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink);
  font-size: 11px; font-weight: 700;
}

.pol-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.pol-field { display: grid; gap: 7px; }
.pol-field > label { font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.pol-field .ipair { display: flex; align-items: center; gap: 8px; }
.pol-field input {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--field); color: var(--ink); font-family: var(--mono);
}
.pol-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.pol-row:first-of-type { border-top: 0; }
.pol-row .ptxt b { display: block; color: var(--ink); font-size: 13.5px; }
.pol-row .ptxt span { color: var(--ink-3); font-size: 12px; }
.pol-row .sp { flex: 1; }

/* =====================================================================
   DRAWER — right-side registration panel
   ===================================================================== */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: oklch(0.15 0.02 240 / .42);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s var(--ease);
}
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 61;
  width: min(var(--drawer-w), 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .34s var(--ease);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head .dh-ic {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-size: 20px;
}
.drawer-head .dh-t { flex: 1; min-width: 0; }
.drawer-head h2 { margin: 0; font-size: 19px; font-weight: 680; color: var(--ink); }
.drawer-head p { margin: 3px 0 0; color: var(--ink-3); font-size: 13px; }
.drawer-head .x {
  flex: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 18px;
}
.drawer-head .x:hover { background: var(--surface-2); }

/* dual-track segmented control */
.track {
  flex: none;
  display: flex;
  gap: 4px;
  margin: 14px 22px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.track button {
  flex: 1;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.track button .sub { font-weight: 400; font-size: 11px; color: var(--ink-4); }
.track button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.track button.on .sub { color: var(--primary-2); }

.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 30px;
}
.dpane[hidden] { display: none; }
.drawer-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: oklch(from var(--bg) l c h / .9);
  backdrop-filter: blur(8px);
}
.drawer-foot .footnote {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-3);
  font-size: 11.5px;
}
.drawer-foot .footnote svg { width: 14px; height: 14px; flex: none; color: var(--ink-4); }

/* =====================================================================
   FORM PRIMITIVES (drawer)
   ===================================================================== */
.fg { margin-bottom: 18px; }
.fg-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.fg-label label { font-size: 13px; font-weight: 620; color: var(--ink); }
.fg-label .req { color: var(--error); font-size: 12px; }
.fg-label .opt { color: var(--ink-4); font-size: 11px; font-family: var(--mono); }
.fg-label .sp { flex: 1; }
.inp, .ta, .sel {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.inp.mono, .ta.mono { font-family: var(--mono); font-size: 13px; }
.inp:focus, .ta:focus, .sel:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px oklch(from var(--primary) l c h / .14);
}
.inp.bad, .ta.bad { border-color: var(--error); box-shadow: 0 0 0 3px oklch(from var(--error) l c h / .12); }
.ta { resize: vertical; min-height: 80px; line-height: 1.6; }
.ta.hero { min-height: 168px; }
.ta.code { font-family: var(--mono); font-size: 12.5px; white-space: pre; line-height: 1.6; }
.fg-hint { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.fg-err { margin-top: 6px; font-size: 12px; color: var(--error); display: none; align-items: center; gap: 5px; }
.fg-err.show { display: flex; }
.fg-err svg { width: 13px; height: 13px; }
.charcount { font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 .fg { margin-bottom: 0; }

/* the "why this matters" help callout — used on description/instructions */
.help-callout {
  display: flex;
  gap: 9px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--primary-line);
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
}
.help-callout svg { width: 15px; height: 15px; flex: none; color: var(--primary); margin-top: 1px; }
.help-callout b { color: var(--ink); }

/* magic wand AI button */
.magic {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--primary-line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary-2);
  font-size: 11.5px;
  font-weight: 600;
}
.magic:hover { background: var(--primary-soft); }
.magic:disabled { opacity: .6; }
.magic svg { width: 13px; height: 13px; }
.magic.spin svg { animation: mg-spin 1s linear infinite; }
@keyframes mg-spin { to { transform: rotate(360deg); } }

/* AI suggestion result block */
.ai-out {
  margin-top: 9px;
  padding: 12px 13px;
  border: 1px dashed var(--primary-line);
  border-radius: 10px;
  background: linear-gradient(120deg, var(--primary-soft), transparent 90%);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
}
.ai-out .ai-h {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 7px;
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ai-out .ai-acts { display: flex; gap: 7px; margin-top: 10px; }

/* skeleton shimmer for AI loading */
.shimmer { position: relative; overflow: hidden; color: transparent !important; border-radius: 6px; }
.shimmer::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%;
  animation: sh 1.3s infinite;
}
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =====================================================================
   LIBRARY / MARKETPLACE cards (easy track)
   ===================================================================== */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
/* Quick-register row (admin overview): stretch cards to fill the full width
   (auto-fit collapses empty tracks so 5 cards span edge-to-edge). */
.lib.lib-fill { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.libcard {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.libcard:hover { border-color: var(--primary-line); box-shadow: var(--shadow-sm); }
.libcard.sel { border-color: var(--primary); box-shadow: 0 0 0 2px oklch(from var(--primary) l c h / .25); }
.libcard .lc-ic {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-size: 17px;
}
.libcard .lc-t b { display: block; font-size: 13.5px; color: var(--ink); }
.libcard .lc-t span { display: block; margin-top: 2px; font-size: 11.5px; color: var(--ink-3); line-height: 1.4; }
.libcard .lc-badge { position: absolute; top: 10px; right: 10px; }
.lib-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px;
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: 11px;
}
.lib-divider::before, .lib-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* collapsible advanced section */
.collapse { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 18px; overflow: hidden; }
.collapse > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2);
}
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary .chev { transition: transform .2s; color: var(--ink-3); }
.collapse > summary svg { width: 16px; height: 16px; flex: none; }
.collapse > summary .chev { display: inline-flex; }
.collapse[open] > summary .chev { transform: rotate(90deg); }
.collapse .collapse-body { padding: 16px 14px; }

/* scope / permission chips */
.scopes { display: flex; flex-wrap: wrap; gap: 7px; }
.scope {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px; color: var(--ink-2);
}
.scope svg { width: 13px; height: 13px; color: var(--ink-3); }

/* =====================================================================
   STATUS / VALIDATION feedback
   ===================================================================== */
.status-card {
  margin-top: 16px;
  border: 1px solid oklch(from var(--ok) l c h / .45);
  border-radius: var(--r-md);
  background: var(--ok-soft);
  overflow: hidden;
}
.status-card.err { border-color: oklch(from var(--error) l c h / .45); background: oklch(from var(--error) l c h / .08); }
.status-card .sc-head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px;
  font-size: 13.5px; font-weight: 650; color: var(--ok);
}
.status-card.err .sc-head { color: var(--error); }
.status-card .sc-head svg { width: 17px; height: 17px; }
.status-card .sc-body { padding: 0 14px 13px; }
.toollist { display: flex; flex-wrap: wrap; gap: 6px; }
.toollist .tl {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}

/* ZIP / structure validation checklist */
.checks { display: grid; gap: 7px; margin-top: 12px; }
.check {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13px; color: var(--ink-2);
}
.check .ck { width: 18px; height: 18px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.check.ok .ck { background: var(--ok); color: #fff; }
.check.bad .ck { background: var(--error); color: #fff; }
.check.bad { border-color: oklch(from var(--error) l c h / .4); }
.check .ck svg { width: 11px; height: 11px; }

/* dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 30px 18px;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-ic { width: 38px; height: 38px; color: var(--primary); }
.dropzone b { font-size: 14px; color: var(--ink); }
.dropzone span { font-size: 12px; color: var(--ink-3); }
.dropzone.has { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }

/* mini chat (conversational agent builder + agent preview) */
.minichat {
  display: grid; gap: 10px;
  margin-bottom: 14px;
}
.mc-log {
  display: flex; flex-direction: column; gap: 9px;
  max-height: 230px; overflow-y: auto;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.mc-msg { max-width: 86%; padding: 9px 12px; border-radius: 13px; font-size: 13px; line-height: 1.5; }
.mc-msg.u { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
.mc-msg.a { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.mc-input { display: flex; gap: 8px; }
.mc-input input { flex: 1; }
.mc-empty { color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 18px 8px; }

/* preview disclosure */
.preview-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.preview-box .pv-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.preview-box .pv-head .dot-ok { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.preview-box .pv-body { padding: 14px; }

/* small helper buttons inside drawer */
.btn.tiny { min-height: 26px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn.full { width: 100%; }
.btn.send2 { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.btn.send2:hover { filter: brightness(1.05); background: var(--primary); }

/* tag input (tool allowlist, constraints) */
.taginput {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--field);
}
.taginput .tg {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 6px 3px 9px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary-2);
  font-family: var(--mono);
  font-size: 11.5px;
}
.taginput .tg button { border: 0; background: transparent; color: var(--primary-2); font-size: 13px; line-height: 1; padding: 0; }
.taginput input { flex: 1; min-width: 90px; border: 0; background: transparent; outline: none; color: var(--ink); font-family: var(--mono); font-size: 12.5px; }

/* trait / chip selector (persona) */
.chipset { display: flex; flex-wrap: wrap; gap: 7px; }
.chipset .ch {
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
}
.chipset .ch.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-2); font-weight: 600; }

/* responsive */
@media (max-width: 760px) {
  .av2-head { padding: 16px 18px 0; }
  .av2-main { padding: 18px; }
  .ov-grid { grid-template-columns: 1fr 1fr; }
  .lib, .pol-grid, .row2 { grid-template-columns: 1fr; }
  .item { grid-template-columns: 40px 1fr; }
  .item-act { grid-column: 1 / -1; justify-content: flex-end; }
  :root { --drawer-w: 100vw; }
  .gov { flex-wrap: wrap; }
}

/* execution-face selector (sandbox / ML N-spaces / desktop) — popover */
.face-switch { position: relative; }
body[data-ui="b"] .face-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; height: 34px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  color: var(--ink); font-size: 13px; cursor: pointer;
}
body[data-ui="b"] .face-btn:hover { border-color: var(--ink-4); }
.face-btn .pin { color: var(--primary-2); font-size: 13px; line-height: 1; }
.face-btn .face-label { white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.face-btn .face-chev { width: 14px; height: 14px; color: var(--ink-3); flex: none; }

.face-menu {
  position: absolute; top: calc(100% + 8px); left: 0; width: 290px; z-index: 55; padding: 6px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.face-mlabel { padding: 8px 10px 6px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; }
.face-opt {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); text-align: left; cursor: pointer;
}
.face-opt:hover:not(.off) { background: var(--surface-2); color: var(--ink); }
.face-opt .fo-ico { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink-2); }
.face-opt .fo-ico svg { width: 16px; height: 16px; }
.face-opt.on .fo-ico { border-color: var(--primary); color: var(--primary-2); background: oklch(from var(--primary) l c h / .08); }
.face-opt .fo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.face-opt .fo-main b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.face-opt .fo-main span { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.face-opt.on .fo-main span { color: var(--primary-2); font-family: var(--mono); font-size: 11px; }
.face-opt .fo-check { width: 17px; height: 17px; flex: none; color: var(--primary-2); opacity: 0; }
.face-opt.on .fo-check { opacity: 1; }
.face-opt .fo-check svg { width: 17px; height: 17px; }
.face-opt .fo-chev { width: 16px; height: 16px; flex: none; color: var(--ink-3); transition: transform .16s ease; }
.face-group.open .face-parent .fo-chev { transform: rotate(180deg); }
.face-opt.off { cursor: not-allowed; opacity: .62; }
.face-opt .fo-tag { font-family: var(--mono); font-size: 9.5px; color: var(--ink-4); border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px; text-transform: uppercase; letter-spacing: .04em; flex: none; }

/* nested ML spaces */
.face-spaces { padding: 4px 0 4px 14px; margin-left: 24px; border-left: 1.5px solid var(--line); display: grid; gap: 2px; }
.space-opt {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); text-align: left; cursor: pointer;
}
.space-opt:hover:not(.off) { background: var(--surface-2); }
.space-opt .sp-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-4); }
.space-opt .sp-dot.running { background: var(--ok); }
.space-opt .sp-dot.busy { background: var(--warn, #d08700); }
.space-opt .sp-dot.stopped { background: var(--ink-4); }
.space-opt .sp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.space-opt .sp-main b { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-opt .sp-main span { font-size: 11px; color: var(--ink-3); }
.space-opt.on { background: oklch(from var(--primary) l c h / .07); }
.space-opt.on .sp-main b { color: var(--primary-2); }
.space-opt .fo-check { width: 15px; height: 15px; flex: none; color: var(--primary-2); opacity: 0; }
.space-opt.on .fo-check { opacity: 1; }
.space-opt .fo-check svg { width: 15px; height: 15px; }
.space-opt.off { cursor: not-allowed; opacity: .5; }
