/* archive-mirror.css — verbatim copy of a_mirror's mirror.css.
   The source pages never load sov-tokens/sov-base standalone: mirror.css's
   var(--sov-*) references intentionally fall back (borders -> currentColor,
   dim text -> inherited ink). Adding token definitions breaks the light
   rendering with dark-theme values — do not concatenate them back in. */
/* mirror.css — Page-specific styles for the main dashboard. Base reset and document layout are in sov-base.css. */

/* ── Canvas / visualization containers ── */
.viz {
  margin: 2em 0;
  position: relative;
}

.viz canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--sov-border-light);
}

.viz-caption {
  font-size: 0.75rem;
  color: var(--sov-text-muted);
  text-align: center;
  margin-top: 0.6em;
  font-style: italic;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.85rem;
}

th {
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--sov-text);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sov-text-secondary);
}

td {
  padding: 6px 12px;
  border-top: 1px solid var(--sov-border-light);
  font-family: var(--sov-font-mono);
  font-size: 0.78rem;
  color: var(--sov-text);
}

td:first-child {
  font-family: var(--sov-font-serif);
  font-size: 0.85rem;
  color: var(--sov-text);
}

tr:hover { background: var(--sov-bg-alt); }

.domain-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── Aside / blockquote ── */
.aside {
  border-left: 1px solid var(--sov-border);
  padding-left: 1.2em;
  margin: 1.5em 0 1.5em 1em;
  color: var(--sov-text-secondary);
  font-size: 0.9rem;
}

/* ── Mono / code ── */
code {
  font-family: var(--sov-font-mono);
  font-size: 0.8em;
  background: var(--sov-bg-hover);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--sov-text-secondary);
}

/* ── Status indicators ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot.active { background: var(--sov-healthy); }
.status-dot.warning { background: #f39c12; }
.status-dot.inactive { background: var(--sov-unhealthy); }
.status-dot.unknown { background: #bdc3c7; }

/* ── Connection indicator ── */
#conn-status {
  position: fixed;
  top: 12px;
  right: 16px;
  font-family: var(--sov-font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sov-text-dim);
  transition: color 0.3s;
}

#conn-status.connected { color: var(--sov-healthy); }
#conn-status.disconnected { color: var(--sov-unhealthy); }

/* ── Scroll editor ── */
.scroll-editor {
  margin: 2em 0;
}

.scroll-editor textarea {
  width: 100%;
  min-height: 200px;
  font-family: var(--sov-font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 16px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg-alt);
  color: var(--sov-text);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.scroll-editor textarea:focus {
  border-color: var(--sov-text-muted);
}

.scroll-editor .validation-result {
  font-family: var(--sov-font-mono);
  font-size: 0.75rem;
  padding: 8px 12px;
  margin-top: 4px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg);
  min-height: 2em;
  color: var(--sov-text-secondary);
  transition: color 0.3s, border-color 0.3s;
}

.scroll-editor .validation-result.valid {
  color: var(--sov-healthy);
  border-color: var(--sov-healthy);
}

.scroll-editor .validation-result.invalid {
  color: var(--sov-unhealthy);
  border-color: var(--sov-unhealthy);
}

/* ── Lexicon search ── */
.lex-search {
  display: flex;
  gap: 8px;
  margin: 1.5em 0 1em;
}

.lex-search input {
  flex: 1;
  font-family: var(--sov-font-mono);
  font-size: 0.8rem;
  padding: 8px 12px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg-alt);
  color: var(--sov-text);
  outline: none;
  transition: border-color 0.2s;
}

.lex-search input:focus {
  border-color: var(--sov-text-muted);
}

.lex-search select {
  font-family: var(--sov-font-mono);
  font-size: 0.75rem;
  padding: 8px 12px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg-alt);
  color: var(--sov-text-secondary);
  outline: none;
  cursor: pointer;
}

/* ── Legend ── */
.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.2em;
  margin: 1em 0;
  font-size: 0.75rem;
  color: var(--sov-text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Footer ── */
.colophon {
  text-align: center;
  color: var(--sov-text-dim);
  font-size: 0.7rem;
  margin-top: 6em;
  padding-top: 2em;
  border-top: 1px solid var(--sov-border-light);
}

/* ── Pulse animation ── */
@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1.0; }
}

.pulse-active {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* ── Sovereign Menu (mind-map) ── */
#sov-menu-btn {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--sov-border);
  background: var(--sov-bg);
  color: var(--sov-text);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  align-items: center;
  justify-content: center;
  transition: border-color 0.25s, background 0.25s, transform 0.25s, box-shadow 0.25s;
}
#sov-menu-btn:hover {
  border-color: var(--sov-text-muted);
  transform: translateX(-50%) scale(1.08);
  box-shadow: 0 3px 12px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
}
#sov-menu-btn.open {
  background: #2a2a2a;
  color: var(--sov-bg);
  border-color: #2a2a2a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
}

#sov-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 999990;
  pointer-events: none;
}
#sov-menu-overlay.active {
  pointer-events: auto;
  background: rgba(254, 254, 254, 0.82);
  backdrop-filter: blur(2px);
}

#sov-menu-canvas {
  position: fixed;
  inset: 0;
  z-index: 999991;
  pointer-events: none;
}

.sov-node {
  position: fixed;
  z-index: 999992;
  font-family: var(--sov-font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--sov-border);
  background: var(--sov-bg);
  color: var(--sov-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s, background 0.2s, color 0.2s;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  pointer-events: none;
}
.sov-node.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.sov-node:hover {
  border-color: var(--sov-text-muted);
  background: var(--sov-bg-alt);
  color: var(--sov-text);
}
.sov-node.has-children::after {
  content: ' +';
  color: var(--sov-text-dim);
  font-size: 0.6rem;
}
.sov-node.expanded::after {
  content: ' −';
  color: var(--sov-text-muted);
}
.sov-node.leaf {
  border-color: var(--sov-border);
  color: var(--sov-text-muted);
}
.sov-node.leaf:hover {
  border-color: var(--sov-text);
  color: var(--sov-text);
}

/* ── Focus Ring Menu States ── */
.sov-node.center {
  font-weight: 600;
  border-color: #2a2a2a;
  background: var(--sov-bg-alt);
  color: var(--sov-text-strong);
  z-index: 999994;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 6px 16px;
}
.sov-node.ring {
  transition: left 400ms ease-out, top 400ms ease-out,
              opacity 300ms ease-out, transform 300ms ease-out;
}
.sov-node.orbit {
  transform: scale(0.55);
  opacity: 0.4;
  pointer-events: auto;
  cursor: pointer;
  transition: left 350ms ease-in-out, top 350ms ease-in-out,
              transform 350ms ease-in-out, opacity 350ms ease-in-out;
}
.sov-node.orbit:hover {
  opacity: 0.7;
  transform: scale(0.65);
}
.sov-node.exit {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  transition: opacity 250ms ease-in, transform 250ms ease-in;
}
.sov-back-btn {
  position: fixed;
  z-index: 999994;
  font-family: var(--sov-font-mono);
  font-size: 0.6rem;
  color: var(--sov-text-muted);
  background: transparent;
  border: 1px solid var(--sov-border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 300ms ease-out, transform 300ms ease-out;
  pointer-events: none;
}
.sov-back-btn.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.sov-back-btn:hover {
  border-color: var(--sov-text-muted);
  color: var(--sov-text);
}
.sov-lens-bar {
  position: fixed;
  z-index: 999993;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 300ms ease-out;
  pointer-events: none;
}
.sov-lens-bar.visible {
  opacity: 1;
  pointer-events: auto;
}
.sov-lens-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--sov-text-dim);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 200ms, border-color 200ms;
}
.sov-lens-dot:hover {
  border-color: var(--sov-text-secondary);
}
.sov-lens-dot.active {
  background: #2a2a2a;
  border-color: #2a2a2a;
}

/* ── Shape Cards (Book of Shapes) ── */
.shape-card {
  border: 1px solid var(--sov-border-light);
  margin: 2.5em 0;
  transition: border-color 0.3s;
}
.shape-card:hover {
  border-color: var(--sov-border-strong);
}
.shape-card-header {
  padding: 1.2em 1.5em 1em;
  border-bottom: 1px solid var(--sov-bg-hover);
}
.shape-card-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  font-style: normal;
  text-align: left;
  margin: 0;
  color: var(--sov-text-strong);
}
.shape-card-header .shape-badges {
  display: flex;
  gap: 6px;
  margin-top: 0.4em;
}
.shape-badge {
  font-family: var(--sov-font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--sov-bg-hover);
  color: var(--sov-text-muted);
}
.shape-badge.layer-0 { background: #f0e6ff; color: #7c3aed; }
.shape-badge.layer-1 { background: #fce7f3; color: #db2777; }
.shape-badge.layer-2 { background: #dbeafe; color: #2563eb; }
.shape-badge.layer-3 { background: #d1fae5; color: #059669; }
.shape-badge.layer-4 { background: #fef3c7; color: #d97706; }
.shape-badge.layer-5 { background: #fee2e2; color: #dc2626; }
.shape-card-desc {
  padding: 0 1.5em;
  font-size: 0.88rem;
  color: var(--sov-text-secondary);
  line-height: 1.6;
}
.shape-card-desc p {
  margin: 0.6em 0;
  text-align: left;
}
.shape-viz-wrap {
  padding: 1em 1.5em;
}
.shape-viz-wrap canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--sov-bg-hover);
}
.shape-viz-wrap .viz-caption {
  font-size: 0.72rem;
  color: var(--sov-text-dim);
  text-align: center;
  margin-top: 0.5em;
  font-style: italic;
}
.shape-math {
  padding: 0.8em 1.5em;
  border-top: 1px solid var(--sov-bg-hover);
}
.shape-math .eq {
  text-align: center;
  font-family: var(--sov-font-mono);
  font-size: 0.8rem;
  color: var(--sov-text-secondary);
  margin: 0.6em 0;
  line-height: 1.8;
}
.shape-math .eq .label {
  color: var(--sov-text-muted);
  font-size: 0.65rem;
  margin-left: 0.8em;
}
.shape-math p {
  font-size: 0.85rem;
  color: var(--sov-text-secondary);
  text-align: left;
}
.shape-code {
  border-top: 1px solid var(--sov-bg-hover);
}
.shape-code summary {
  padding: 0.7em 1.5em;
  font-family: var(--sov-font-mono);
  font-size: 0.72rem;
  color: var(--sov-text-muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.2s;
  list-style: none;
}
.shape-code summary::-webkit-details-marker { display: none; }
.shape-code summary::before {
  content: '▸ ';
  transition: transform 0.2s;
  display: inline-block;
}
.shape-code[open] summary::before {
  content: '▾ ';
}
.shape-code summary:hover { color: var(--sov-text-secondary); }
.shape-code-inner {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--sov-bg-hover);
}
.shape-code-bare,
.shape-code-filled {
  flex: 1;
  padding: 1em 1.2em;
  font-family: var(--sov-font-mono);
  font-size: 0.7rem;
  line-height: 1.7;
  color: var(--sov-text);
  white-space: pre;
  overflow-x: auto;
  background: var(--sov-bg-alt);
}
.shape-code-bare {
  border-right: 1px solid var(--sov-bg-hover);
}
.shape-code-filled {
  background: var(--sov-bg-alt);
  color: var(--sov-text-secondary);
}
.shape-code-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sov-text-dim);
  margin-bottom: 0.5em;
  display: block;
}
.lex-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0.7em 1.5em;
  border-top: 1px solid var(--sov-bg-hover);
}
.lex-tag {
  font-family: var(--sov-font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 2px;
  background: var(--sov-bg-hover);
  color: var(--sov-text-muted);
  white-space: nowrap;
}
.lex-tag.kind { background: #eef2ff; color: #4f46e5; }
.lex-tag.domain { background: #f0fdf4; color: #16a34a; }
.lex-tag.node { background: #fff7ed; color: #ea580c; }
.lex-tag.boundary { background: #fef2f2; color: #dc2626; }
.lex-tag.layer { background: #f5f3ff; color: #7c3aed; }

/* ── Shape search ── */
.shape-search {
  display: flex;
  gap: 8px;
  margin: 1.5em 0 1em;
}
.shape-search input {
  flex: 1;
  font-family: var(--sov-font-mono);
  font-size: 0.8rem;
  padding: 10px 14px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg-alt);
  color: var(--sov-text);
  outline: none;
  transition: border-color 0.2s;
}
.shape-search input:focus {
  border-color: var(--sov-text-muted);
}
.shape-count {
  font-family: var(--sov-font-mono);
  font-size: 0.7rem;
  color: var(--sov-text-dim);
  text-align: center;
  margin: 0.5em 0;
}

/* ── Layer nav ── */
.layer-nav {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin: 1.5em 0;
  flex-wrap: wrap;
}
.layer-nav a {
  font-family: var(--sov-font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 6px 14px;
  border: 1px solid var(--sov-border-light);
  color: var(--sov-text-muted);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.layer-nav a:hover {
  border-color: var(--sov-text-muted);
  color: var(--sov-text);
}
.layer-nav a.active {
  border-color: var(--sov-text);
  color: var(--sov-text);
  background: var(--sov-bg-alt);
}

/* ── Builder ── */
.builder-tabs {
  display: flex; gap: 0; margin: 1.5rem 0 0; border-bottom: 2px solid var(--sov-border-light);
}
.builder-tab {
  padding: 0.5rem 1.2rem; border: none; background: none; cursor: pointer;
  font-family: var(--sov-font-mono); font-size: 0.8rem; color: var(--sov-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.builder-tab:hover { color: var(--sov-text-secondary); }
.builder-tab.active { color: var(--sov-text); border-bottom-color: var(--sov-text); }
.builder-panel { margin-top: 1rem; }
.builder-panel.hidden { display: none; }
.builder-form { display: flex; flex-direction: column; gap: 0.6rem; }
.builder-form label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-family: var(--sov-font-mono); font-size: 0.75rem; color: var(--sov-text-secondary);
}
.builder-form input[type="text"],
.builder-form input[type="number"],
.builder-form select {
  padding: 0.4rem 0.6rem; border: 1px solid var(--sov-border); border-radius: 3px;
  font-family: var(--sov-font-mono); font-size: 0.8rem;
  background: var(--sov-bg-alt); transition: border-color 0.2s;
}
.builder-form input:focus, .builder-form select:focus {
  border-color: var(--sov-text-muted); outline: none; background: var(--sov-bg);
}
.checkbox-label {
  flex-direction: row !important; align-items: center; gap: 0.5rem !important;
}
.checkbox-label input[type="checkbox"] { width: auto; }
.builder-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-build, .btn-preview, .btn-deploy {
  padding: 0.4rem 1rem; border: 1px solid var(--sov-text); border-radius: 3px;
  font-family: var(--sov-font-mono); font-size: 0.75rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-build { background: var(--sov-text); color: var(--sov-bg); }
.btn-build:hover { background: var(--sov-text-secondary); }
.btn-preview { background: var(--sov-bg); color: var(--sov-text); }
.btn-preview:hover { background: var(--sov-bg-hover); }
.btn-deploy { background: #2a5a2a; color: var(--sov-bg); border-color: #2a5a2a; }
.btn-deploy:hover { background: #3a7a3a; }
.btn-sm { padding: 0.2rem 0.6rem; border: 1px solid var(--sov-border-strong); border-radius: 3px;
  font-size: 0.7rem; background: var(--sov-bg); cursor: pointer; font-family: var(--sov-font-mono); }
.btn-sm:hover { border-color: var(--sov-text-muted); }
.builder-output {
  margin-top: 0.75rem; padding: 0.75rem; background: var(--sov-bg-alt); border: 1px solid var(--sov-border-light);
  border-radius: 3px; font-family: var(--sov-font-mono); font-size: 0.75rem;
  max-height: 400px; overflow-y: auto; white-space: pre-wrap; color: var(--sov-text);
  min-height: 2rem;
}
.builder-route-header {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--sov-font-mono); font-size: 0.75rem; color: var(--sov-text-secondary);
  margin-bottom: 0.3rem;
}
.route-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 0.3rem;
  margin-bottom: 0.3rem; align-items: center;
}
.route-row input { padding: 0.3rem 0.5rem; border: 1px solid var(--sov-border); border-radius: 3px;
  font-family: var(--sov-font-mono); font-size: 0.75rem; }
.route-row button { padding: 0.2rem 0.5rem; border: 1px solid var(--sov-border); border-radius: 3px;
  background: var(--sov-bg); cursor: pointer; font-size: 0.7rem; color: var(--sov-text-muted); }
.route-row button:hover { border-color: #c00; color: #c00; }

.build-valid { color: #2a5a2a; }
.build-invalid { color: #a33; }
.build-warning { color: #a80; }

/* ── Responsive ── */
@media (max-width: 700px) {
  #write { padding: 30px 20px 80px; }
  h1 { font-size: 2rem; }
  .cards { flex-direction: column; align-items: center; }
  .sov-node { font-size: 0.6rem; padding: 4px 9px; }
  .sov-node.orbit { transform: scale(0.45); }
  .sov-back-btn { width: 20px; height: 20px; font-size: 0.5rem; }
  #sov-menu-btn { width: 38px; height: 38px; font-size: 18px; }
}

/* ── Manifold Visualization ── */

.manifold-canvas-wrap {
  width: 100%;
  position: relative;
  margin: 1em 0;
}

.manifold-canvas-wrap canvas {
  width: 100%;
  display: block;
  cursor: grab;
}

.manifold-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 1em 0;
  font-family: var(--sov-font-mono);
  font-size: 0.72rem;
}

.manifold-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--sov-border-light);
  background: var(--sov-bg-alt);
  font-family: inherit;
  font-size: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.manifold-search:focus {
  border-color: var(--sov-text-muted);
}

.manifold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--sov-border-light);
  background: none;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--sov-text-muted);
  user-select: none;
}

.manifold-toggle:hover {
  border-color: var(--sov-border-strong);
}

.manifold-toggle.active {
  border-color: var(--sov-text);
  color: var(--sov-text);
  background: var(--sov-bg-alt);
}

.manifold-toggle .toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.manifold-toggle .toggle-dot.diamond {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* ── Manifold Detail Panel ── */

.manifold-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--sov-bg);
  border-left: 1px solid var(--sov-border);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 20px rgba(0,0,0,0.05);
}

.manifold-panel.open {
  transform: translateX(0);
}

.manifold-panel-header {
  padding: 1.2em 1.5em;
  border-bottom: 1px solid var(--sov-bg-hover);
  flex-shrink: 0;
  position: relative;
}

.manifold-panel-header h3 {
  margin: 0.2em 0 0;
  font-size: 1.1rem;
  font-weight: 600;
  font-style: normal;
  text-align: left;
}

.manifold-panel-type {
  font-family: var(--sov-font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sov-text-muted);
}

.manifold-panel-close {
  position: absolute;
  top: 1em;
  right: 1em;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--sov-text-dim);
  transition: color 0.2s;
}

.manifold-panel-close:hover {
  color: var(--sov-text);
}

.manifold-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.2em 1.5em;
  font-size: 0.85rem;
  line-height: 1.6;
}

.manifold-panel-body p {
  margin: 0 0 1em;
  text-align: left;
}

.manifold-panel-body h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sov-text-muted);
  margin: 1.5em 0 0.5em;
  font-family: var(--sov-font-mono);
  font-style: normal;
}

.manifold-panel-neighbors {
  padding: 1em 1.5em;
  border-top: 1px solid var(--sov-bg-hover);
  flex-shrink: 0;
  max-height: 140px;
  overflow-y: auto;
}

/* ── Manifold Chips ── */

.manifold-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--sov-border-light);
  font-family: var(--sov-font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.2s;
  margin: 2px;
  color: var(--sov-text-secondary);
}

.manifold-chip:hover {
  border-color: var(--sov-text-muted);
  color: var(--sov-text-strong);
}

.manifold-chip .chip-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Signature Equation ── */

.sig-equation {
  text-align: center;
  margin: 1em 0;
  padding: 1em;
  background: var(--sov-bg-alt);
  border: 1px solid var(--sov-bg-hover);
  overflow-x: auto;
}

.sig-equation pre {
  font-family: var(--sov-font-mono);
  font-size: 0.75rem;
  color: var(--sov-text-secondary);
  white-space: pre-wrap;
  margin: 0;
}

/* ── Signature Params Table ── */

.sig-params {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin: 0.5em 0;
}

.sig-params th {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--sov-border-light);
  font-weight: 600;
  color: var(--sov-text-secondary);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: normal;
}

.sig-params td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--sov-bg-hover);
  border-top: none;
  color: var(--sov-text-secondary);
  font-size: 0.75rem;
}

/* ── Signature Used-By ── */

.sig-usedby {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0.5em 0;
}

/* ── Status Badges ── */

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--sov-font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 2px;
}

.status-badge.implemented {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.status-badge.specified {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

/* ── Merkle Badge ── */

.merkle-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--sov-border);
  font-family: var(--sov-font-mono);
  font-size: 0.65rem;
  color: var(--sov-text-muted);
  margin: 1em 0;
}

/* ── Manifold Responsive ── */
@media (max-width: 900px) {
  .manifold-panel { width: 100%; }
  .manifold-controls { flex-direction: column; }
}

/* ═══════ Agent Protocol Sidebar ═══════ */
.agent-sidebar {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 100;
  display: flex; flex-direction: row; transition: transform 0.25s ease;
}
.agent-sidebar.collapsed { transform: translateX(calc(100% - 36px)); }
.agent-toggle-btn {
  width: 36px; background: var(--sov-text); color: var(--sov-bg); border: none; cursor: pointer;
  font-family: var(--sov-font-mono); font-size: 0.85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: 4px 0 0 4px; writing-mode: vertical-lr; letter-spacing: 0.1em;
}
.agent-toggle-btn:hover { background: var(--sov-text-secondary); }
.agent-sidebar-content {
  width: 320px; background: var(--sov-bg); border-left: 1px solid var(--sov-border-light);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: -2px 0 8px rgba(0,0,0,0.06);
}
.agent-sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--sov-border-light);
  font-family: var(--sov-font-mono); font-size: 0.8rem; font-weight: 600; color: var(--sov-text);
}
.agent-close-btn { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--sov-text-muted); padding: 0; }
.agent-close-btn:hover { color: var(--sov-text); }
.agent-sidebar-messages {
  flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem;
}
.agent-sidebar .agent-msg {
  padding: 0.4rem 0.6rem; border-radius: 4px;
  font-family: var(--sov-font-mono); font-size: 0.72rem; line-height: 1.4;
  max-width: 90%; word-wrap: break-word;
}
.agent-sidebar .agent-msg.system { background: var(--sov-bg-hover); color: var(--sov-text-muted); align-self: center; text-align: center; font-size: 0.65rem; max-width: 100%; }
.agent-sidebar .agent-msg.user { background: var(--sov-text); color: var(--sov-bg); align-self: flex-end; }
.agent-sidebar .agent-msg.assistant { background: #e8f0e8; color: var(--sov-text); align-self: flex-start; }
.agent-sidebar .agent-input-row { display: flex; gap: 0.3rem; padding: 0.4rem; border-top: 1px solid var(--sov-border-light); flex-shrink: 0; }
.agent-sidebar .agent-input {
  flex: 1; padding: 0.35rem 0.6rem; border: 1px solid var(--sov-border); border-radius: 3px;
  font-family: var(--sov-font-mono); font-size: 0.75rem;
}
.agent-sidebar .agent-input:focus { border-color: var(--sov-text-muted); outline: none; }

/* ═══════ Sov Sidebar (Left Icon Bar) ═══════ */

#sov-sidebar {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 999985;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--sov-bg);
  border: 1px solid var(--sov-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.04), 1px 0 4px rgba(0,0,0,0.03);
  padding: 4px 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

#sov-sidebar .sb-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s, color 0.15s;
  color: var(--sov-text-muted);
}
#sov-sidebar .sb-btn:hover {
  background: var(--sov-bg-hover);
  color: var(--sov-text);
}
#sov-sidebar .sb-btn.active {
  color: var(--sov-text-strong);
  background: var(--sov-bg-hover);
}
#sov-sidebar .sb-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--sov-text);
  border-radius: 0 1px 1px 0;
}

#sov-sidebar .sb-icon {
  width: 18px;
  height: 18px;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

#sov-sidebar .sb-divider {
  width: 24px;
  height: 1px;
  background: var(--sov-border-light);
  margin: 2px auto;
}

/* Icon masks */
.sb-icon-search {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
}
.sb-icon-library {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9H9V9h10v2zm-4 4H9v-2h6v2zm4-8H9V5h10v2z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9H9V9h10v2zm-4 4H9v-2h6v2zm4-8H9V5h10v2z'/%3E%3C/svg%3E");
}
.sb-icon-notes {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H4.99C3.89 3 3 3.9 3 5l.01 14c0 1.1.89 2 1.99 2h10l6-6V5c0-1.1-.9-2-2-2zM7 8h10v2H7V8zm5 6H7v-2h5v2zm2 5.5V15c0-.55.45-1 1-1h4.5L14 19.5z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H4.99C3.89 3 3 3.9 3 5l.01 14c0 1.1.89 2 1.99 2h10l6-6V5c0-1.1-.9-2-2-2zM7 8h10v2H7V8zm5 6H7v-2h5v2zm2 5.5V15c0-.55.45-1 1-1h4.5L14 19.5z'/%3E%3C/svg%3E");
}
.sb-icon-scribe {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
}
.sb-icon-system {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 00.12-.61l-1.92-3.32a.49.49 0 00-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 00-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.07.62-.07.94s.02.64.07.94l-2.03 1.58a.49.49 0 00-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6A3.6 3.6 0 1115.6 12 3.61 3.61 0 0112 15.6z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 00.12-.61l-1.92-3.32a.49.49 0 00-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 00-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.07.62-.07.94s.02.64.07.94l-2.03 1.58a.49.49 0 00-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6A3.6 3.6 0 1115.6 12 3.61 3.61 0 0112 15.6z'/%3E%3C/svg%3E");
}
.sb-icon-home {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
}

/* Tooltip on hover */
#sov-sidebar .sb-btn::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--sov-text);
  color: var(--sov-bg);
  font-family: var(--sov-font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#sov-sidebar .sb-btn:hover::after {
  opacity: 1;
}

/* Search overlay */
#sov-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 999994;
  background: rgba(254,254,254,0.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#sov-search-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

#sov-search-box {
  width: 560px;
  max-width: 90vw;
  background: var(--sov-bg);
  border: 1px solid var(--sov-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sov-search-box .search-input-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sov-border-light);
}
#sov-search-box .search-icon {
  width: 18px;
  height: 18px;
  background: var(--sov-text-muted);
  flex-shrink: 0;
  mask-size: contain; mask-repeat: no-repeat;
  -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat;
}
#sov-search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 12px;
  font-family: var(--sov-font-mono);
  font-size: 0.85rem;
  color: var(--sov-text);
  background: transparent;
}
#sov-search-input::placeholder { color: var(--sov-text-dim); }

#sov-search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0;
}
.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sov-bg-hover);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.search-result-item:hover {
  background: var(--sov-bg-alt);
}
.search-result-title {
  font-family: var(--sov-font-serif);
  font-size: 0.9rem;
  color: var(--sov-text);
}
.search-result-meta {
  font-family: var(--sov-font-mono);
  font-size: 0.6rem;
  color: var(--sov-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}
.search-no-results {
  padding: 20px 16px;
  text-align: center;
  font-family: var(--sov-font-mono);
  font-size: 0.72rem;
  color: var(--sov-text-dim);
}

.search-hint {
  padding: 8px 16px;
  border-top: 1px solid var(--sov-bg-hover);
  font-family: var(--sov-font-mono);
  font-size: 0.55rem;
  color: var(--sov-text-dim);
  text-align: center;
  letter-spacing: 0.04em;
}

body.pencil-mode .search-result-title {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
}

@media (max-width: 700px) {
  #sov-sidebar { display: none; }
}

/* ═══════ Pencil Mode (Handwriting Toggle) ═══════ */

@keyframes pencil-dissolve {
  0%   { opacity: 1; filter: blur(0); }
  40%  { opacity: 0.3; filter: blur(2px); }
  100% { opacity: 1; filter: blur(0); }
}

body.pencil-transitioning * {
  animation: pencil-dissolve 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.pencil-mode {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

body.pencil-mode h1 {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  letter-spacing: 0.02em;
}

body.pencil-mode h2 {
  font-family: 'Caveat', cursive;
  font-weight: 600;
}

body.pencil-mode h3 {
  font-family: 'Caveat', cursive;
  font-weight: 500;
  font-style: normal;
}

body.pencil-mode p,
body.pencil-mode li,
body.pencil-mode .subtitle,
body.pencil-mode .aside,
body.pencil-mode blockquote {
  font-family: 'Caveat', cursive;
}

body.pencil-mode td:first-child {
  font-family: 'Caveat', cursive;
  font-size: 1rem;
}

body.pencil-mode .card .label {
  font-family: 'Caveat', cursive;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
}

body.pencil-mode .viz-caption {
  font-family: 'Caveat', cursive;
  font-size: 0.95rem;
}

body.pencil-mode .colophon {
  font-family: 'Caveat', cursive;
}

body.pencil-mode .shape-card-desc,
body.pencil-mode .shape-card-desc p {
  font-family: 'Caveat', cursive;
}

body.pencil-mode .manifold-panel-body,
body.pencil-mode .manifold-panel-body p {
  font-family: 'Caveat', cursive;
}

/* Sketch-style border overrides in pencil mode */
body.pencil-mode .card,
body.pencil-mode .shape-card,
body.pencil-mode .scroll-editor textarea,
body.pencil-mode .builder-output {
  border-style: dashed;
}

body.pencil-mode h2::after {
  background: repeating-linear-gradient(
    90deg, var(--sov-text-dim) 0, var(--sov-text-dim) 4px, transparent 4px, transparent 8px
  );
  height: 1px;
}

/* ═══════ Scribe Sidebar ═══════ */

#sov-scribe-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--sov-border);
  background: var(--sov-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.25s ease;
  font-size: 0;
}
#sov-scribe-btn:hover {
  border-color: var(--sov-text-muted);
  transform: scale(1.08);
  box-shadow: 0 3px 14px rgba(0,0,0,0.12);
}
#sov-scribe-btn.open {
  background: #2a2a2a;
  border-color: #2a2a2a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
#sov-scribe-btn .scribe-icon {
  width: 22px;
  height: 22px;
  background: currentColor;
  color: var(--sov-text-secondary);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
}
#sov-scribe-btn.open .scribe-icon {
  color: var(--sov-bg);
}

#sov-scribe-panel {
  position: fixed;
  bottom: 76px;
  right: 20px;
  width: 340px;
  max-height: calc(100vh - 120px);
  background: var(--sov-bg);
  border: 1px solid var(--sov-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#sov-scribe-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.scribe-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--sov-bg-hover);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.scribe-header-title {
  font-family: var(--sov-font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sov-text);
}
.scribe-header-status {
  font-family: var(--sov-font-mono);
  font-size: 0.55rem;
  color: var(--sov-text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.scribe-tools {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--sov-bg-hover);
}
.scribe-tool-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--sov-font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sov-text-muted);
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}
.scribe-tool-btn:hover { color: var(--sov-text-secondary); }
.scribe-tool-btn.active {
  color: var(--sov-text);
  border-bottom-color: var(--sov-text);
}

/* Pencil toggle row */
.scribe-pencil-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--sov-bg-hover);
}
.scribe-pencil-label {
  font-family: var(--sov-font-mono);
  font-size: 0.65rem;
  color: var(--sov-text-secondary);
  letter-spacing: 0.04em;
}
.scribe-pencil-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  border: 1.5px solid var(--sov-border-strong);
  background: var(--sov-bg-hover);
  cursor: pointer;
  transition: all 0.2s;
}
.scribe-pencil-toggle.on {
  background: var(--sov-text);
  border-color: var(--sov-text);
}
.scribe-pencil-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sov-bg);
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.scribe-pencil-toggle.on::after {
  transform: translateX(16px);
}

.scribe-pencil-preview {
  font-family: 'Caveat', cursive;
  font-size: 0.85rem;
  color: var(--sov-text-muted);
  padding: 0 1rem 0.5rem;
  border-bottom: 1px solid var(--sov-bg-hover);
  display: none;
}
.scribe-pencil-preview.visible {
  display: block;
}

/* Scribe messages */
.scribe-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 120px;
  max-height: 300px;
}
.scribe-msg {
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
}
.scribe-msg.system {
  font-family: var(--sov-font-mono);
  font-size: 0.62rem;
  color: var(--sov-text-dim);
  align-self: center;
  text-align: center;
  max-width: 100%;
}
.scribe-msg.user {
  background: var(--sov-text);
  color: var(--sov-bg);
  align-self: flex-end;
  font-family: var(--sov-font-serif);
}
.scribe-msg.assistant {
  background: #f5f5f0;
  color: var(--sov-text);
  align-self: flex-start;
  font-family: var(--sov-font-serif);
  border: 1px solid var(--sov-border-light);
}

body.pencil-mode .scribe-msg.user,
body.pencil-mode .scribe-msg.assistant {
  font-family: 'Caveat', cursive;
  font-size: 0.95rem;
}

/* Scribe input */
.scribe-input-row {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--sov-border-light);
  flex-shrink: 0;
}
.scribe-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sov-border);
  background: var(--sov-bg-alt);
  font-family: var(--sov-font-mono);
  font-size: 0.72rem;
  outline: none;
  transition: border-color 0.2s;
}
.scribe-input:focus { border-color: var(--sov-text-muted); }
.scribe-send-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--sov-text);
  background: var(--sov-text);
  color: var(--sov-bg);
  font-family: var(--sov-font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: background 0.15s;
}
.scribe-send-btn:hover { background: var(--sov-text-secondary); }
