/* ═══════════════════════════════════════════════════════════════════
   promptlibretto — Registry Assistant (chatbuilder)
   Inherits the Manuscript palette from templatebuilder.css
   ═══════════════════════════════════════════════════════════════════ */

/* Ensure the HTML `hidden` attribute always wins over display:flex/grid rules */
[hidden] { display: none !important; }

:root {
  --bg: #0b0907;
  --panel: #131008;
  --panel-2: #1a1510;
  --panel-3: #221c14;
  --border: #2d2820;
  --border-subtle: #1e1912;
  --text: #eee8de;
  --text-dim: #c0b49f;
  --muted: #7a6e5e;
  --muted-soft: #524a3c;
  --accent: #c98b40;
  --accent-glow: rgba(201, 139, 64, 0.12);
  --accent-2: #8db0cc;
  --accent-rose: #c06060;
  --warn: #d4a84c;
  --error: #c45858;
  --gold: #c8a856;
  --green: #6ab07a;
  --pill-bg: #1a1710;
  --font-display: "Crimson Pro", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, monospace;
  --noise: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top right, rgba(141, 176, 204, 0.05), transparent 28%),
    radial-gradient(circle at top left, rgba(201, 139, 64, 0.05), transparent 30%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-repeat: repeat;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* ── Header ────────────────────────────────────────────────────── */
header {
  padding: 0 20px;
  height: 50px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

header::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--warn) 30%, rgba(212,145,92,0.08) 70%, transparent);
}

.header-brand, .header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

header h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  font-style: italic;
  margin: 0;
  color: var(--accent);
}

.header-page-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.header-page-link {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 4px;
  transition: all 140ms ease;
}

.header-page-link:hover:not(.active) {
  color: var(--text-dim);
  background: rgba(201, 139, 64, 0.06);
}

.header-page-link.active {
  color: var(--accent);
  background: var(--panel);
  font-weight: 600;
}

.header-nav-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 5px 12px;
  border-radius: 4px;
  transition: all 140ms ease;
}

.header-nav-btn:hover {
  color: var(--text);
  background: rgba(201, 139, 64, 0.08);
}

.export-btn {
  color: var(--accent) !important;
  border: 1px solid rgba(201, 139, 64, 0.3);
  background: rgba(201, 139, 64, 0.06) !important;
}

.export-btn:hover:not(:disabled) {
  background: rgba(201, 139, 64, 0.14) !important;
}

.export-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.draft-id-badge {
  font-size: 11px;
  color: var(--muted);
  padding: 3px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.draft-id-badge code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-2);
}

.conn-chip {
  appearance: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-body);
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 140ms;
}

.conn-chip:hover {
  border-color: rgba(201,139,64,0.3);
  background: rgba(201,139,64,0.06);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-soft);
  flex-shrink: 0;
  transition: background 300ms;
}

.conn-dot.ok  { background: var(--green); }
.conn-dot.err { background: var(--error); }

/* ── Settings bar ──────────────────────────────────────────────── */
.settings-bar {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.settings-input {
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  width: 200px;
  outline: none;
  transition: border-color 140ms;
}

.settings-input:focus {
  border-color: rgba(201, 139, 64, 0.4);
}

/* ── Main shell ────────────────────────────────────────────────── */
.cb-shell {
  display: grid;
  grid-template-columns: 38% 1fr;
  height: calc(100vh - 50px);
  overflow: hidden;
}

.cb-shell.settings-open {
  height: calc(100vh - 50px - 45px);
}

/* ── Chat panel ────────────────────────────────────────────────── */
.cb-chat-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.cb-chat-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cb-chat-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--text-dim);
}

.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* welcome state */
.cb-welcome {
  margin: auto;
  text-align: center;
  max-width: 280px;
  padding: 32px 0;
}

.cb-welcome-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 12px;
  opacity: 0.7;
}

.cb-welcome-head {
  font-family: var(--font-display);
  font-size: 17px;
  font-style: italic;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.cb-welcome-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

/* messages */
.cb-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msgIn 180ms ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg-role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.cb-msg.user .cb-msg-role { color: var(--accent); opacity: 0.7; }
.cb-msg.assistant .cb-msg-role { color: var(--accent-2); opacity: 0.7; }

.cb-msg-body {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.cb-msg.user .cb-msg-body {
  background: rgba(201, 139, 64, 0.08);
  border: 1px solid rgba(201, 139, 64, 0.14);
  color: var(--text);
}

.cb-msg.assistant .cb-msg-body {
  background: var(--panel-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
}

/* tool call chips inside the message list */
.cb-tool-event {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(141, 176, 204, 0.04);
  border: 1px solid rgba(141, 176, 204, 0.1);
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  animation: msgIn 180ms ease both;
}

.cb-tool-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-top: 3px;
  flex-shrink: 0;
}

.cb-tool-name {
  color: var(--accent-2);
  font-weight: 500;
}

.cb-tool-ok  { color: var(--green); margin-left: auto; }
.cb-tool-err { color: var(--error); margin-left: auto; }

/* thinking indicator */
.cb-thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  animation: msgIn 180ms ease both;
}

.cb-thinking-dots span {
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.cb-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.cb-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Input area ────────────────────────────────────────────────── */
.cb-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.cb-input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 12px;
  resize: none;
  outline: none;
  transition: border-color 140ms;
  max-height: 120px;
  overflow-y: auto;
}

.cb-input:focus {
  border-color: rgba(201, 139, 64, 0.35);
}

.cb-input::placeholder { color: var(--muted-soft); }

.cb-send-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  background: linear-gradient(180deg, #d9a060, var(--accent));
  color: #0d0b09;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 140ms;
  flex-shrink: 0;
  align-self: flex-end;
}

.cb-send-btn:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.cb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ── Registry panel ────────────────────────────────────────────── */
.cb-registry-panel {
  display: grid;
  grid-template-columns: 210px 1fr;
  overflow: hidden;
  background: var(--panel);
}

/* ── Sections column (left) ────────────────────────────────────── */
.cb-sections-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  min-height: 0;
}

.cb-sections-col-header {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-soft);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cb-sections-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ── Details column (right) ────────────────────────────────────── */
.cb-details-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

#detail-overview {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#detail-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Section detail header + body ──────────────────────────────── */
.cb-sec-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel-2);
  flex-shrink: 0;
}

.cb-sec-back-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 140ms;
}

.cb-sec-back-btn:hover {
  color: var(--text-dim);
  border-color: rgba(201,139,64,0.3);
  background: rgba(201,139,64,0.05);
}

.cb-sec-detail-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.cb-sec-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.cb-detail-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  padding: 12px 0;
  margin: 0;
}

.cb-detail-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

/* detail item cards */
.cb-detail-item {
  background: var(--panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  overflow: hidden;
  animation: itemIn 200ms ease both;
}

.cb-detail-item.selected {
  border-color: rgba(201,139,64,0.35);
  box-shadow: 0 0 0 1px rgba(201,139,64,0.06) inset;
}

.cb-detail-item-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel-3);
}

.cb-detail-item-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2);
}

.cb-detail-item-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(201,139,64,0.12);
  border: 1px solid rgba(201,139,64,0.25);
  padding: 1px 6px;
  border-radius: 3px;
}

.cb-detail-item-text {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* template variable highlight */
.cb-tvar {
  color: var(--accent-2);
  background: rgba(141,176,204,0.1);
  border-radius: 2px;
  padding: 0 2px;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* fragments */
.cb-detail-fragment {
  margin: 0 10px 8px;
  background: rgba(141,176,204,0.04);
  border: 1px solid rgba(141,176,204,0.1);
  border-radius: 5px;
  overflow: hidden;
}

.cb-detail-frag-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted-soft);
  padding: 3px 8px;
  border-bottom: 1px solid rgba(141,176,204,0.08);
  background: rgba(141,176,204,0.04);
  letter-spacing: 0.04em;
}

.cb-detail-frag-text {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* groups */
.cb-detail-group {
  margin: 0 10px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  overflow: hidden;
}

.cb-detail-group-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--border-subtle);
}

.cb-detail-group-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-2);
  font-weight: 500;
}

.cb-detail-group-mode {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent);
  background: rgba(201,139,64,0.1);
  border: 1px solid rgba(201,139,64,0.2);
  padding: 1px 5px;
  border-radius: 3px;
}

.cb-detail-group-items {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cb-detail-group-item {
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 0;
  line-height: 1.5;
  border-bottom: 1px solid var(--border-subtle);
}

.cb-detail-group-item:last-child { border-bottom: none; }

/* scale row */
.cb-detail-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-top: 1px solid var(--border-subtle);
}

.cb-detail-scale-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.cb-detail-scale-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.cb-reg-header {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cb-reg-title-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.cb-reg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.cb-reg-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-style: italic;
  font-weight: 600;
  color: var(--text);
  transition: color 300ms;
}

.cb-reg-title.populated { color: var(--accent); }

.cb-reg-desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.cb-section-card {
  background: var(--panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 7px 9px;
  transition: border-color 220ms, box-shadow 220ms, opacity 220ms, background 140ms;
  opacity: 0.38;
  position: relative;
  overflow: hidden;
  width: 100%;
  cursor: default;
  flex-shrink: 0;
}

.cb-section-card.has-items {
  opacity: 1;
  border-color: rgba(201, 139, 64, 0.2);
  box-shadow: 0 0 0 1px rgba(201, 139, 64, 0.06) inset;
  cursor: pointer;
}

.cb-section-card.has-items:hover {
  border-color: rgba(201, 139, 64, 0.38);
  background: rgba(201, 139, 64, 0.03);
}

.cb-section-card.just-updated {
  border-color: rgba(201, 139, 64, 0.55) !important;
  box-shadow: 0 0 12px rgba(201, 139, 64, 0.1) !important;
}

.cb-section-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cb-section-card.has-items .cb-section-name {
  color: var(--accent);
}

.cb-section-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-sec-item {
  font-size: 11px;
  color: var(--text-dim);
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 100ms, border-color 100ms;
  animation: itemIn 250ms ease both;
}

.cb-sec-item:hover {
  background: rgba(201,139,64,0.05);
  border-color: rgba(201,139,64,0.14);
}

.cb-sec-item.selected {
  background: rgba(201,139,64,0.09);
  border-color: rgba(201,139,64,0.3);
}

.cb-sec-item-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  overflow: hidden;
}

.cb-sel-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid var(--muted-soft);
  flex-shrink: 0;
  transition: background 140ms, border-color 140ms;
}

.cb-sec-item.selected .cb-sel-dot {
  background: var(--accent);
  border-color: var(--accent);
}

@keyframes itemIn {
  from { opacity: 0; transform: translateX(-5px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* groups mode controls */
.cb-item-group {
  padding: 3px 6px 4px 17px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 1px solid var(--border-subtle);
}

.cb-group-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted-soft);
  letter-spacing: 0.04em;
}

.cb-group-modes {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.cb-mode-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 100ms;
}

.cb-mode-pill:hover {
  color: var(--text-dim);
  border-color: rgba(201,139,64,0.3);
}

.cb-mode-pill.active {
  background: rgba(201,139,64,0.14);
  border-color: rgba(201,139,64,0.4);
  color: var(--accent);
}

/* scale slider */
.cb-item-scale {
  padding: 4px 6px 5px 17px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
}

.cb-scale-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  height: 2px;
}

.cb-scale-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  min-width: 14px;
  text-align: right;
}

.cb-sec-item .item-id {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent-2);
  margin-right: 4px;
  flex-shrink: 0;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-sec-item .item-text {
  color: var(--muted-soft);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.cb-section-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 4px;
}

.cb-var-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--accent-2);
  background: rgba(141, 176, 204, 0.08);
  border: 1px solid rgba(141, 176, 204, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  animation: itemIn 200ms ease both;
}

.cb-sec-empty {
  font-size: 11px;
  color: var(--muted-soft);
  font-style: italic;
}

/* ── Assembly order ────────────────────────────────────────────── */
.cb-assembly-row {
  flex-shrink: 0;
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
}

.cb-assembly-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.cb-assembly-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cb-asm-token {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--panel-3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  animation: itemIn 200ms ease both;
}

/* ── Extras row (generation / policy / memory / blend) ─────────── */
.cb-extras-row {
  flex-shrink: 0;
  padding: 6px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
  min-height: 0;
}

.cb-extras-row:empty { display: none; }

.cb-extra-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  animation: itemIn 200ms ease both;
}

.cb-extra-pill .pill-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.cb-extra-pill .pill-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-2);
}

/* ── Activity strip ────────────────────────────────────────────── */
.cb-activity-strip {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  padding: 6px 14px;
  max-height: 96px;
  overflow-y: auto;
}

.cb-activity-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-soft);
  display: block;
  margin-bottom: 4px;
}

.cb-activity-empty {
  font-size: 11px;
  color: var(--muted-soft);
  font-style: italic;
}

.cb-activity-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-activity-item {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: itemIn 160ms ease both;
}

.cb-activity-item .act-arrow { color: var(--accent); }
.cb-activity-item .act-tool  { color: var(--accent-2); }
.cb-activity-item .act-ok    { color: var(--green); margin-left: auto; }
.cb-activity-item .act-err   { color: var(--error); margin-left: auto; }

/* ── Shared buttons ────────────────────────────────────────────── */
.ghost-btn-sm {
  appearance: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-body);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 140ms;
}

.ghost-btn-sm:hover {
  color: var(--text);
  border-color: rgba(201, 139, 64, 0.3);
  background: rgba(201, 139, 64, 0.05);
}

.primary-btn-sm {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  background: linear-gradient(180deg, #d9a060, var(--accent));
  color: #0d0b09;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 140ms;
}

.primary-btn-sm:hover { filter: brightness(1.06); }

/* ── Export modal ──────────────────────────────────────────────── */
.cb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cb-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(720px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.cb-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cb-modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-style: italic;
  font-weight: 600;
  margin: 0;
  color: var(--accent);
}

.cb-modal-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.cb-modal-close:hover { color: var(--text); }

.cb-modal-sub {
  margin: 0;
  padding: 8px 18px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.cb-modal-pre {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
  white-space: pre;
}

.cb-modal-actions {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Load modal list ───────────────────────────────────────────── */
.cb-load-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  max-height: 360px;
}

.cb-load-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

.cb-load-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--panel-2);
  transition: border-color 0.15s, background 0.15s;
}

.cb-load-row:hover {
  border-color: var(--border);
  background: var(--panel-3);
}

.cb-load-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cb-load-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cb-load-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.cb-load-btn {
  flex-shrink: 0;
}

/* ── Detail panel edit interactions ───────────────────────────── */
.cb-detail-item-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

.cb-detail-item:hover .cb-detail-item-actions {
  opacity: 1;
}

.cb-detail-action-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.cb-detail-delete-btn:hover {
  color: var(--error, #c45858);
  border-color: var(--error, #c45858);
  background: rgba(196,88,88,0.08);
}

/* clickable text fields */
.cb-detail-item-text,
.cb-detail-frag-text {
  cursor: text;
}

.cb-detail-item-text:hover,
.cb-detail-frag-text:hover {
  background: rgba(255,255,255,0.03);
  border-radius: 3px;
}

/* inline editor */
.cb-detail-inline-editor {
  width: 100%;
  box-sizing: border-box;
  background: var(--panel-3);
  border: 1px solid var(--accent-2);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 8px;
  resize: vertical;
  outline: none;
  margin-top: 4px;
}

/* fragment header with delete */
.cb-detail-frag-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* group directive row */
.cb-detail-group-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.cb-detail-group-item-text {
  flex: 1;
  cursor: text;
  border-radius: 3px;
  padding: 1px 2px;
}

.cb-detail-group-item-text:hover {
  background: rgba(255,255,255,0.03);
}

.cb-detail-group-del {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
  padding: 0 4px;
  font-size: 11px;
  margin-top: 1px;
}

.cb-detail-group-item:hover .cb-detail-group-del {
  opacity: 1;
}

/* add directive button */
.cb-detail-add-directive {
  appearance: none;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-body);
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 4px;
  width: 100%;
  text-align: left;
  transition: color 0.12s, border-color 0.12s;
}

.cb-detail-add-directive:hover {
  color: var(--text-dim);
  border-color: var(--border);
}
