/* Explorer — Corpus Inspection Interface
   Dark theme, monospace, information-dense.
   Matches Symposium/Agenticity aesthetic. */

/* ─── Theme Variables ────────────────────────────── */

:root {
  --bg:         #0c1524;
  --bg-subtle:  #10192e;
  --bg-raised:  #152038;
  --bg-inset:   #0e1728;
  --border:     #1c2c48;
  --border-dim: #142038;
  --border-mid: #2a3c58;
  --border-hi:  #3a5070;
  --text:       #c0ccdd;
  --text-hi:    #e4ecf5;
  --text-mid:   #99aac2;
  --text-dim:   #7088a8;
  --text-muted: #3d5570;
  --text-value: #d0daea;
  --accent:     #5cb8e8;
  --ok:         #48c78e;
  --err:        #ef6b6b;
  --warn:       #f0b840;
  --glow:       rgba(92, 184, 232, 0.4);

  /* Zone layout */
  --zone-index-basis:    100%;
  --zone-artifact-basis: 0;
  --zone-sub-basis:      0;
  --section-gap:         1rem;
  --index-row-height:    2.5rem;
  --transition-open:     200ms;
  --transition-close:    150ms;

  --color-identity:      #5cb8e8;
  --color-verification:  #48c78e;
  --color-metadata:      #d4a855;
  --color-session:       #a488cc;
  --color-timeline:      #55b8b0;
  --color-summary:       #cc7888;
  --color-content:       #c0ccdd;
  --color-diagnostics:   #5a7090;
  --color-derived-bg:    rgba(92, 184, 232, 0.06);
  --color-derived-border: rgba(92, 184, 232, 0.2);

  /* Skeleton screen tokens */
  --skeleton-base:    rgba(255, 255, 255, 0.04);
  --skeleton-shimmer: rgba(255, 255, 255, 0.08);
  --skeleton-radius:  4px;
  --skeleton-speed:   1.5s;

  /* Font theme */
  --font-body: 'Courier New', Courier, monospace;
}

[data-theme="carbon"] {
  --bg:         #0a0a0a;
  --bg-subtle:  #111;
  --bg-raised:  #1a1a1a;
  --bg-inset:   #0e0e0e;
  --border:     #222;
  --border-dim: #151515;
  --border-mid: #333;
  --border-hi:  #555;
  --text:       #c0c0c0;
  --text-hi:    #e0e0e0;
  --text-mid:   #999;
  --text-dim:   #6a6a6a;
  --text-muted: #444;
  --text-value: #d0d0d0;
  --accent:     #4fc3f7;
  --ok:         #4caf50;
  --err:        #ef5350;
  --warn:       #ffa726;
  --glow:       rgba(79, 195, 247, 0.6);
  --color-identity:      #4fc3f7;
  --color-verification:  #4caf50;
  --color-metadata:      #cca040;
  --color-session:       #9980bb;
  --color-timeline:      #44aaa0;
  --color-summary:       #bb6677;
  --color-content:       #c0c0c0;
  --color-diagnostics:   #666;
  --color-derived-bg:    rgba(79, 195, 247, 0.06);
  --color-derived-border: rgba(79, 195, 247, 0.2);
}

[data-theme="phosphor"] {
  --bg:         #050a05;
  --bg-subtle:  #0a120a;
  --bg-raised:  #0f1a0f;
  --bg-inset:   #070d07;
  --border:     #1a2a1a;
  --border-dim: #0f1a0f;
  --border-mid: #2a3a2a;
  --border-hi:  #3a5a3a;
  --text:       #88bb88;
  --text-hi:    #aaddaa;
  --text-mid:   #77aa77;
  --text-dim:   #558855;
  --text-muted: #334433;
  --text-value: #99cc99;
  --accent:     #66ff66;
  --ok:         #44dd44;
  --err:        #dd6644;
  --warn:       #ccaa33;
  --glow:       rgba(102, 255, 102, 0.5);
  --color-identity:      #66ff66;
  --color-verification:  #44dd44;
  --color-metadata:      #aacc44;
  --color-session:       #88dd88;
  --color-timeline:      #44ccaa;
  --color-summary:       #cc8866;
  --color-content:       #88bb88;
  --color-diagnostics:   #446644;
  --color-derived-bg:    rgba(102, 255, 102, 0.06);
  --color-derived-border: rgba(102, 255, 102, 0.2);
}

[data-theme="amber"] {
  --bg:         #0a0800;
  --bg-subtle:  #111000;
  --bg-raised:  #1a1500;
  --bg-inset:   #0e0b00;
  --border:     #2a2200;
  --border-dim: #1a1400;
  --border-mid: #3a3000;
  --border-hi:  #5a4a00;
  --text:       #cc9944;
  --text-hi:    #eebb66;
  --text-mid:   #aa8844;
  --text-dim:   #806030;
  --text-muted: #443311;
  --text-value: #ddaa55;
  --accent:     #ffcc33;
  --ok:         #66bb44;
  --err:        #dd4433;
  --warn:       #ffaa22;
  --glow:       rgba(255, 204, 51, 0.5);
  --color-identity:      #ffcc33;
  --color-verification:  #aacc44;
  --color-metadata:      #ddaa33;
  --color-session:       #cc8844;
  --color-timeline:      #bbaa33;
  --color-summary:       #cc7744;
  --color-content:       #cc9944;
  --color-diagnostics:   #664d22;
  --color-derived-bg:    rgba(255, 204, 51, 0.06);
  --color-derived-border: rgba(255, 204, 51, 0.2);
}

[data-theme="frost"] {
  --bg:         #0b0e14;
  --bg-subtle:  #101520;
  --bg-raised:  #161c28;
  --bg-inset:   #0d1018;
  --border:     #1e2838;
  --border-dim: #141c28;
  --border-mid: #2a3648;
  --border-hi:  #3a4a60;
  --text:       #8899bb;
  --text-hi:    #b0c4e0;
  --text-mid:   #7788aa;
  --text-dim:   #556878;
  --text-muted: #334455;
  --text-value: #99aacc;
  --accent:     #5588cc;
  --ok:         #4caf80;
  --err:        #cc5566;
  --warn:       #ccaa55;
  --glow:       rgba(85, 136, 204, 0.5);
  --color-identity:      #5588cc;
  --color-verification:  #4caf80;
  --color-metadata:      #aa8855;
  --color-session:       #8877aa;
  --color-timeline:      #5599aa;
  --color-summary:       #aa6677;
  --color-content:       #8899bb;
  --color-diagnostics:   #445566;
  --color-derived-bg:    rgba(85, 136, 204, 0.06);
  --color-derived-border: rgba(85, 136, 204, 0.2);
}

[data-theme="solar"] {
  --bg:         #fdf6e3;
  --bg-subtle:  #f5eedb;
  --bg-raised:  #eee8d5;
  --bg-inset:   #faf3de;
  --border:     #e0d8c0;
  --border-dim: #ebe3cb;
  --border-mid: #c8bfa5;
  --border-hi:  #a89f85;
  --text:       #52676a;
  --text-hi:    #2e3c3f;
  --text-mid:   #627a7d;
  --text-dim:   #829598;
  --text-muted: #bfcccd;
  --text-value: #3e5255;
  --accent:     #b58900;
  --ok:         #859900;
  --err:        #dc322f;
  --warn:       #cb4b16;
  --glow:       rgba(181, 137, 0, 0.25);
  --color-identity:      #b58900;
  --color-verification:  #859900;
  --color-metadata:      #b07030;
  --color-session:       #7060a0;
  --color-timeline:      #2a8878;
  --color-summary:       #a05060;
  --color-content:       #52676a;
  --color-diagnostics:   #9aadaf;
  --color-derived-bg:    rgba(181, 137, 0, 0.08);
  --color-derived-border: rgba(181, 137, 0, 0.25);
}

[data-theme="overcast"] {
  --bg:         #f0f2f5;
  --bg-subtle:  #e8eaee;
  --bg-raised:  #dfe2e8;
  --bg-inset:   #eceef2;
  --border:     #cdd1d9;
  --border-dim: #dde0e6;
  --border-mid: #b0b6c2;
  --border-hi:  #8a92a2;
  --text:       #3a4050;
  --text-hi:    #1a2030;
  --text-mid:   #4a5468;
  --text-dim:   #707a90;
  --text-muted: #aeb5c2;
  --text-value: #2a3445;
  --accent:     #3366aa;
  --ok:         #2e8b57;
  --err:        #cc3344;
  --warn:       #cc7722;
  --glow:       rgba(51, 102, 170, 0.2);
  --color-identity:      #3366aa;
  --color-verification:  #2e8b57;
  --color-metadata:      #9a7030;
  --color-session:       #6050a0;
  --color-timeline:      #2a7868;
  --color-summary:       #904858;
  --color-content:       #3a4050;
  --color-diagnostics:   #8892a5;
  --color-derived-bg:    rgba(51, 102, 170, 0.08);
  --color-derived-border: rgba(51, 102, 170, 0.2);
}

[data-theme="void"] {
  --bg:         #0a0610;
  --bg-subtle:  #100c18;
  --bg-raised:  #181225;
  --bg-inset:   #0c0812;
  --border:     #221a35;
  --border-dim: #161025;
  --border-mid: #332a48;
  --border-hi:  #4a3d65;
  --text:       #a898c8;
  --text-hi:    #ccbbee;
  --text-mid:   #9080b0;
  --text-dim:   #6e6090;
  --text-muted: #3d3355;
  --text-value: #bbaadd;
  --accent:     #cc66ff;
  --ok:         #66cc88;
  --err:        #ee5577;
  --warn:       #ddaa55;
  --glow:       rgba(204, 102, 255, 0.5);
  --color-identity:      #cc66ff;
  --color-verification:  #66cc88;
  --color-metadata:      #cc9955;
  --color-session:       #bb88dd;
  --color-timeline:      #55bbaa;
  --color-summary:       #cc6688;
  --color-content:       #a898c8;
  --color-diagnostics:   #5a4d78;
  --color-derived-bg:    rgba(204, 102, 255, 0.06);
  --color-derived-border: rgba(204, 102, 255, 0.2);
}

[data-theme="clearday"] {
  --bg:         #ffffff;
  --bg-subtle:  #f8f9fa;
  --bg-raised:  #f0f1f3;
  --bg-inset:   #fafbfc;
  --border:     #e7e7eb;
  --border-dim: #f0f0f4;
  --border-mid: #d5d7e0;
  --border-hi:  #a0a4b0;
  --text:       #1a1a2e;
  --text-hi:    #0d0d1a;
  --text-mid:   #3a3a5a;
  --text-dim:   #6e6e88;
  --text-muted: #b0b0c0;
  --text-value: #0e0e24;
  --accent:     #3498db;
  --ok:         #27ae60;
  --err:        #e74c3c;
  --warn:       #f39c12;
  --glow:       rgba(52, 152, 219, 0.15);
  --color-identity:      #3498db;
  --color-verification:  #27ae60;
  --color-metadata:      #b07828;
  --color-session:       #7050b0;
  --color-timeline:      #1a8878;
  --color-summary:       #a04858;
  --color-content:       #1a1a2e;
  --color-diagnostics:   #8888a0;
  --color-derived-bg:    rgba(52, 152, 219, 0.06);
  --color-derived-border: rgba(52, 152, 219, 0.2);
}


[data-theme="slate"] {
  --bg:         #eaedf2;
  --bg-subtle:  #e2e5ec;
  --bg-raised:  #d8dce4;
  --bg-inset:   #e6e9ef;
  --border:     #c8ced8;
  --border-dim: #d8dce4;
  --border-mid: #aeb6c4;
  --border-hi:  #8892a4;
  --text:       #2c3345;
  --text-hi:    #141a28;
  --text-mid:   #3e4858;
  --text-dim:   #5a6678;
  --text-muted: #98a0b0;
  --text-value: #1e2538;
  --accent:     #3568a8;
  --ok:         #2d8a54;
  --err:        #c83838;
  --warn:       #b87a20;
  --glow:       rgba(53, 104, 168, 0.2);
  --color-identity:      #3568a8;
  --color-verification:  #2d8a54;
  --color-metadata:      #957030;
  --color-session:       #5848a0;
  --color-timeline:      #287868;
  --color-summary:       #8a4050;
  --color-content:       #2c3345;
  --color-diagnostics:   #6e7a90;
  --color-derived-bg:    rgba(53, 104, 168, 0.06);
  --color-derived-border: rgba(53, 104, 168, 0.2);
}

/* Light theme skeleton overrides */
[data-theme="solar"],
[data-theme="overcast"],
[data-theme="slate"],
[data-theme="clearday"] {
  --skeleton-base:    rgba(0, 0, 0, 0.06);
  --skeleton-shimmer: rgba(0, 0, 0, 0.10);
}

/* ─── Font Themes ────────────────────────────────── */

[data-font="system"] {
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-font="code"] {
  --font-body: 'Menlo', 'Consolas', 'SF Mono', monospace;
}

[data-font="code"] .hash-value {
  max-width: 490px;
}

[data-font="readable"] {
  --font-body: Georgia, 'Times New Roman', serif;
}

/* Proportional font layout — hide dots, use flexbox spacing.
   Value column bounded by SHA-256 width (~60% of row). */
[data-font="system"] .dots,
[data-font="readable"] .dots {
  display: none;
}

[data-font="system"] .detail-row,
[data-font="readable"] .detail-row {
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-dim);
}

[data-font="system"] .detail-row:last-child,
[data-font="readable"] .detail-row:last-child {
  border-bottom: none;
}

[data-font="system"] .detail-label,
[data-font="readable"] .detail-label {
  white-space: nowrap;
  flex-shrink: 0;
}

[data-font="system"] .detail-value,
[data-font="readable"] .detail-value {
  text-align: right;
}

/* Long values (hash, storage key) — constrained to same width as
   SHA-256 hash so storage key doesn't extend further left than hash.
   71 chars at 11px proportional ≈ 480px. Wraps to next line if longer.
   Text left-aligned within the block; block pushed right by flexbox. */
[data-font="system"] .hash-value,
[data-font="readable"] .hash-value {
  text-align: left;
  max-width: 480px;
  margin-left: auto;
}

[data-font="system"] .detail-value-small,
[data-font="readable"] .detail-value-small {
  text-align: right;
}

/* Long text values (topic) — left-align text, push block right */
[data-font="system"] .detail-value-long,
[data-font="readable"] .detail-value-long {
  text-align: left;
  margin-left: auto;
  max-width: 520px;
}

/* Proportional font mobile: label and value stack vertically.
   Keep label-value pairs tight, add space between pairs. */
@media (max-width: 768px) {
  [data-font="system"] .detail-row,
  [data-font="readable"] .detail-row {
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-dim);
  }

  [data-font="system"] .detail-row:last-child,
  [data-font="readable"] .detail-row:last-child {
    border-bottom: none;
  }

  [data-font="system"] .detail-label,
  [data-font="readable"] .detail-label {
    white-space: normal;
  }

  [data-font="system"] .detail-value,
  [data-font="readable"] .detail-value {
    text-align: left;
  }

  [data-font="system"] .hash-value,
  [data-font="readable"] .hash-value,
  [data-font="system"] .detail-value-long,
  [data-font="readable"] .detail-value-long {
    margin-left: 0;
  }
}

/* ─── Skeleton Screens ───────────────────────────── */

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  display: inline-block;
  height: 12px;
  border-radius: var(--skeleton-radius);
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shimmer) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-speed) ease-in-out infinite;
}

.skeleton-block {
  border-radius: var(--skeleton-radius);
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shimmer) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer var(--skeleton-speed) ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line,
  .skeleton-block {
    animation: none;
    background: var(--skeleton-base);
  }
}

/* Skeleton card — pixel-perfect match to real card dimensions.
   Real cards: monospace font, primary 12px, secondary/tertiary 11px,
   line-height 1.5 (inherited from body). Rows have margin-bottom: 2px.
   Skeleton bars are vertically centered within the same line-height. */
.skeleton-card {
  pointer-events: none;
}

.skeleton-card .card-primary {
  line-height: 18px;  /* 12px * 1.5 */
}

.skeleton-card .card-secondary {
  line-height: 16.5px;  /* 11px * 1.5 */
}

.skeleton-card .card-tertiary {
  line-height: 16.5px;  /* 11px * 1.5 */
}

.skeleton-card .skeleton-line {
  vertical-align: middle;
}

.skeleton-card .card-primary .skeleton-line {
  height: 9px;
}

.skeleton-card .card-secondary .skeleton-line {
  height: 8px;
}

.skeleton-card .card-tertiary .skeleton-line {
  height: 7px;
}

/* ─── Restore Gate ───────────────────────────────── */
/* Covers the zone area during sequential state restoration.
   Purely visual — does not affect data flow or verification.
   Uses theme variables so it matches any color theme. */

/* Pre-paint: hide zones entirely when restoring (set by inline script in <head>).
   This prevents ANY zone content from flashing before JS creates the gate overlay. */
html.restoring .content-constrained {
  visibility: hidden;
}

/* Pre-paint: hide artifact zones when loading non-artifact views.
   Prevents flash of ARTIFACTS header before switchView() runs.
   Activity wrapper stays visible (site-wide element). */
html.view-non-artifacts .content-constrained {
  display: none;
}

.restore-gate {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.3s ease;
  visibility: visible;  /* Override parent's visibility: hidden during restore */
}

.restore-gate-done {
  opacity: 0;
  pointer-events: none;
}

.content-constrained {
  position: relative;
}

.restore-gate-content {
  text-align: center;
}

.restore-gate-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Dot matrix animation — 8 dots in a row, retro staggered pulse */
.restore-gate-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.restore-gate-dots span {
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: var(--text-muted);
  animation: restore-dot 1.2s ease-in-out infinite;
}

.restore-gate-dots span:nth-child(1) { animation-delay: 0s; }
.restore-gate-dots span:nth-child(2) { animation-delay: 0.08s; }
.restore-gate-dots span:nth-child(3) { animation-delay: 0.16s; }
.restore-gate-dots span:nth-child(4) { animation-delay: 0.24s; }
.restore-gate-dots span:nth-child(5) { animation-delay: 0.32s; }
.restore-gate-dots span:nth-child(6) { animation-delay: 0.40s; }
.restore-gate-dots span:nth-child(7) { animation-delay: 0.48s; }
.restore-gate-dots span:nth-child(8) { animation-delay: 0.56s; }

@keyframes restore-dot {
  0%, 60%, 100% { opacity: 0.15; }
  30% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .restore-gate-dots span {
    animation: none;
    opacity: 0.4;
  }
}

/* ─── Reset ──────────────────────────────────────── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Constrained content area — zones, health view */
.content-constrained {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 0;
  flex: 1;
}

/* ─── Header (full-width chrome) ─────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-dim);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-hi);
  letter-spacing: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-raised);
  padding: 2px 8px;
  border-radius: 3px;
}

.badge.healthy {
  color: var(--text-mid);
}

.badge.unhealthy {
  color: var(--err);
}

/* Status indicator dot (right side of badge text) */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.badge.healthy .status-dot {
  background: var(--ok);
  animation: dot-pulse 3s ease-in-out infinite;
}

.badge.unhealthy .status-dot {
  background: var(--err);
  animation: dot-pulse 1.5s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}


/* ─── Menu Button (hamburger — all screen sizes) ── */

.menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 6px 7px;
  cursor: pointer;
}

.menu-btn span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-mid);
  border-radius: 1px;
  transition: transform 150ms, opacity 150ms;
}

.menu-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ─── Menu Panel (slide-in from left — system/global nav) ── */

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-mid);
  z-index: 300;
  font-family: 'Courier New', Courier, monospace;

  /* Slide animation — shadow only when open to prevent bleed */
  transform: translateX(-100%);
  transition: transform 200ms ease, box-shadow 200ms ease;
  pointer-events: none;
  box-shadow: none;
}

.menu-panel.open {
  transform: translateX(0);
  pointer-events: auto;
  box-shadow: 8px 0 32px rgba(0,0,0,.4);
}

/* Backdrop overlay when menu is open */
.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.menu-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Right Panel (slide-in from right — contextual/work) ── */

.right-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(500px, 85vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border-mid);
  z-index: 300;

  transform: translateX(100%);
  transition: transform 200ms ease, box-shadow 200ms ease;
  pointer-events: none;
  box-shadow: none;
}

.right-panel.open {
  transform: translateX(0);
  pointer-events: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}

.right-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.right-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-dim);
}

.right-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.right-panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}

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

.right-panel-content {
  padding: 14px 16px 16px;
}

/* Topic detail inside right panel */
/* Chat box — outlined container for topic text */
.topic-chat-box {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  min-height: 120px;
}

.topic-chat-text {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.5;
}

.typing-cursor {
  color: var(--accent);
  font-weight: 600;
  animation: cursor-blink 1.2s ease-in-out infinite;
  margin-left: 1px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.topic-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.meta-chip {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-subtle);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}

.topic-detail-runs-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-dim);
}

.run-card {
  background: var(--bg-subtle);
  border-left: 3px solid var(--border-dim);
  border-radius: 3px;
  padding: 12px 12px 14px;
  margin-bottom: 10px;
}

.panel-back-row {
  margin-bottom: 12px;
}

.panel-back-btn {
  background: none;
  border: none;
  color: color-mix(in srgb, var(--accent) 60%, var(--text-mid));
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.panel-back-btn:hover {
  color: var(--accent);
}

.run-card-header {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.run-card-summary {
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 6px;
}

.run-card-summary.empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Panel loading state — centered dot matrix with label */
.panel-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 50vh;
  padding-bottom: 10vh;
}

/* Loading state: hide card content, show only dots centered */
.run-card.loading .run-card-header,
.run-card.loading .run-card-footer,
.run-card.loading .run-card-id {
  display: none;
}

.run-card.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.run-loading-dots {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  gap: 3px;
  padding: 10px 0;
  margin: 0 auto;
  width: fit-content;
}

.run-loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.04;
  animation: corpus-dot-scan 0.8s ease-out forwards,
             corpus-dot-breathe 2.5s ease-in-out 0.8s infinite;
}

.run-loading-dots span:nth-child(1) { animation-delay: 0ms, 800ms; }
.run-loading-dots span:nth-child(2) { animation-delay: 60ms, 860ms; }
.run-loading-dots span:nth-child(3) { animation-delay: 120ms, 920ms; }
.run-loading-dots span:nth-child(4) { animation-delay: 180ms, 980ms; }
.run-loading-dots span:nth-child(5) { animation-delay: 240ms, 1040ms; }
.run-loading-dots span:nth-child(6) { animation-delay: 300ms, 1100ms; }
.run-loading-dots span:nth-child(7) { animation-delay: 360ms, 1160ms; }
.run-loading-dots span:nth-child(8) { animation-delay: 420ms, 1220ms; }
.run-loading-dots span:nth-child(9) { animation-delay: 480ms, 1280ms; }
}

.run-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

.run-card-id {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.run-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.run-card-link-sep {
  color: var(--text-muted);
  font-size: 10px;
}

.run-card-link {
  color: color-mix(in srgb, var(--accent) 60%, var(--text-mid));
  cursor: pointer;
  text-decoration: none;
  font-size: 11px;
}

.run-card-link:hover {
  color: var(--accent);
}

/* Convergence accent on run cards */
.run-card.convergence-low { border-left-color: var(--accent); }
.run-card.convergence-mid { border-left-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.run-card.convergence-high { border-left-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ─── Menu Header ────────────────────────────── */

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border-dim);
}

.menu-title {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  font-weight: 600;
}

.menu-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

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

.menu-body {
  padding: 12px 0 16px;
}

.menu-section-label {
  font-size: 10px;
  color: var(--text-mid);
  letter-spacing: 1.5px;
  font-weight: 700;
  padding: 22px 18px 8px;
  margin-top: 6px;
  border-top: 1px solid var(--border-dim);
}

.menu-section-label:first-child {
  border-top: none;
  margin-top: 0;
}

.menu-section-sublabel {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  font-weight: 600;
  padding: 12px 18px 4px;
}

.menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  border-right: 2px solid transparent;
  color: var(--text-mid);
  font-family: inherit;
  font-size: 12px;
  padding: 8px 16px 8px 18px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  transition: color 100ms, border-color 100ms, background 100ms;
}

.menu-item:hover {
  color: var(--text-hi);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.menu-item.active {
  color: var(--text-hi);
  border-right-color: var(--accent);
}

/* Theme list inside menu */
.menu-theme-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px 18px;
}

/* Theme buttons use FIXED colors so they look consistent regardless of
   which theme is active. Only the .active button uses the theme accent. */
.menu-theme-btn {
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid rgba(128, 128, 128, 0.3);
  color: rgba(128, 128, 128, 0.85);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 10px;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 2px;
  text-align: center;
  font-weight: 500;
}

.menu-theme-btn:hover {
  color: rgba(80, 80, 80, 0.95);
  border-color: rgba(100, 100, 100, 0.5);
  background: rgba(128, 128, 128, 0.18);
}

.menu-theme-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Light theme: menu button text needs more contrast against light panel */
[data-theme="solar"] .menu-theme-btn,
[data-theme="overcast"] .menu-theme-btn,
[data-theme="slate"] .menu-theme-btn,
[data-theme="clearday"] .menu-theme-btn {
  color: rgba(40, 40, 60, 0.75);
  border-color: rgba(40, 40, 60, 0.25);
}

[data-theme="solar"] .menu-theme-btn:hover,
[data-theme="overcast"] .menu-theme-btn:hover,
[data-theme="slate"] .menu-theme-btn:hover,
[data-theme="clearday"] .menu-theme-btn:hover {
  color: rgba(20, 20, 40, 0.9);
  border-color: rgba(40, 40, 60, 0.4);
}

/* Menu toggle row (checkboxes) */
.menu-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-mid);
  padding: 6px 18px;
  cursor: pointer;
}

.menu-toggle-row input {
  cursor: pointer;
}

/* Legend visibility — use visibility so panel size doesn't change */
.legend-hidden .heatmap-legend {
  visibility: hidden;
}

/* ─── Telemetry Grid ─────────────────────────── */

.telemetry {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-dim);
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  margin-bottom: 0;
  padding: 0 16px;
  overflow: hidden;
}

.tel-cell {
  background: var(--bg-inset);
  padding: 8px 12px;
}

.tel-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.tel-value {
  font-size: 13px;
  color: var(--text-hi);
}

/* ─── Activity Tag + Heatmap ─────────────────── */

.activity-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 12px;
}

/* Expanded heatmap body — FRAME layer (full width, owns borders, animation) */
.activity-expanded {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms ease;
  background: var(--bg-inset);
  position: relative;
}

/* Full-width border frame via pseudo-element */
.activity-expanded::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-top: none;
  pointer-events: none;
  z-index: 1;
}

/* SCROLL layer — handles horizontal overflow on mobile */
.heatmap-scroll {
  overflow-x: auto;
  text-align: center;
}

/* CONTENT layer — sizes to SVG, centered by parent's text-align */
.heatmap-center {
  display: inline-block;
  text-align: center;
  padding: 10px 12px;
}

.activity-wrapper.expanded .activity-expanded {
  max-height: 250px;
}

/* The capsule tag — always at the bottom, the "handle" */
.activity-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 6px 16px;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

/* When expanded or closing: tag overlaps panel bottom border */
.activity-wrapper.expanded .activity-tag,
.activity-wrapper.closing .activity-tag {
  margin-top: -2px;
}

/* Mini cells — last 7 days */
.activity-mini-cells {
  display: flex;
  gap: 3px;
  align-items: center;
}

.activity-mini-cell {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  opacity: var(--mini-base-opacity, 0.04);
}

/* Summary text */
.activity-summary {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#tag-count {
  display: inline-block;
  min-width: 2.5ch;
  text-align: right;
}

/* Pulsing indicator dot — matches theme accent */
.activity-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: activity-pulse 5s ease-in-out infinite;
}

@keyframes activity-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* SVG heatmap */
.heatmap-svg {
  display: block;
  margin: 0 auto;
}

.heatmap-month-text {
  font-family: inherit;
  font-size: 9px;
  fill: var(--text-dim);
}

.heatmap-rect {
  fill: var(--accent);
}

.heatmap-rect.has-data {
  cursor: pointer;
}

.heatmap-rect:hover {
  stroke: var(--text-dim);
  stroke-width: 1;
}

.heatmap-rect.has-data:hover {
  stroke: var(--accent);
}

/* Custom instant tooltip */
.heatmap-tooltip {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms;
  z-index: 400;
  white-space: nowrap;
}

.heatmap-tooltip.visible {
  opacity: 1;
}
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 18px;
  justify-content: center;
}

.heatmap-legend-label {
  font-size: 9px;
  color: var(--text-dim);
  margin: 0 2px;
}

.heatmap-legend-cell {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

/* ─── Filters ────────────────────────────────── */

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.filter-select {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-mid);
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 3px 8px;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--border-hi);
}


/* ─── Footer ─────────────────────────────────── */

.app-footer {
  padding-top: 12px;
  margin-top: 16px;
}

/* ─── Views ───────────────────────────────────── */

.view-header {
  margin-bottom: 12px;
}

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

h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 1px;
}

.dim {
  color: var(--text-dim);
  font-size: 12px;
}

.hidden {
  display: none;
}

/* ─── Zone Layout ─────────────────────────────── */

#zones {
  display: flex;
  gap: 0;
  min-height: 0;
  align-items: stretch;
}

.zone {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: flex var(--transition-open) ease-out,
              opacity var(--transition-open) ease-out;
}

.zone-index {
  flex: 1 1 auto;
  padding-right: 0;
}

/* Index zone: sidebar appearance when artifact is open */
#zones.artifact-selected .zone-index,
#zones.sub-open .zone-index {
  background: color-mix(in srgb, var(--bg) 85%, var(--bg-raised));
  border-right: 1px solid var(--border);
  padding: 0 12px;
}

.zone-artifact {
  flex: 0 0 0;
  overflow-y: auto;
  display: none;
  opacity: 0;
  padding: 0 16px;
}

.zone-sub {
  flex: 0 0 0;
  display: none;
  opacity: 0;
  padding: 0 16px;
  border-left: 1px solid var(--border);
}

/* When an artifact is selected: index becomes fixed-width sidebar */
#zones.artifact-selected .zone-index {
  flex: 0 0 280px;
}

#zones.artifact-selected .zone-artifact {
  flex: 1 1 0;
  display: block;
  opacity: 1;
}

/* Hide artifact count when zones 2/3 are open */
#zones.artifact-selected #artifact-count {
  display: none;
}

/* Hide time portion in zone 1 cards when artifact is selected */
#zones.artifact-selected .card-time {
  display: none;
}

/* Smooth close transitions: keep zones visible while collapsing */
#zones.artifact-closing .zone-artifact {
  display: block;
}

#zones.sub-closing .zone-sub {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* When a section is open: index fixed sidebar, detail + section share remaining */
#zones.sub-open .zone-index {
  flex: 0 0 220px;
}

#zones.sub-open .zone-artifact {
  flex: 0 0 280px;
}

#zones.sub-open .zone-sub {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  opacity: 1;
}

#zones.sub-open .zone-artifact,
#zones.sub-open .zone-sub,
#zones.sub-open .zone-index {
  min-height: calc(100vh - 220px);
}

/* When zone 3 is open: stack run type + date vertically, hide time */
#zones.sub-open .card-primary {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

#zones.sub-open .card-run {
  order: -1;
}

#zones.sub-open .card-ts {
  font-size: 11px;
  color: var(--text-mid);
}

/* Also align zones when only zone 2 is open */
#zones.artifact-selected .zone-artifact,
#zones.artifact-selected .zone-index {
  min-height: calc(100vh - 220px);
}

/* When health view is active, hide zones entirely */
#zones.zones-hidden {
  display: none;
}

/* ─── Artifact List (scrollable) ─────────────── */

.artifact-scroll {
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.artifact-scroll::-webkit-scrollbar {
  width: 4px;
}

.artifact-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.artifact-scroll::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}

.artifact-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--border-hi);
}

/* ─── L0 Index Cards ─────────────────────────── */

.index-cards {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--border-dim);
  border-bottom: 2px solid var(--bg);  /* Cover the trailing gap background */
}

/* Hide the separator background when cards container is empty */
.index-cards:empty {
  background: none;
  border-bottom: none;
}

.index-card {
  background: var(--bg);
  padding: 10px 14px;
  cursor: pointer;
}

.index-card:hover {
  background: var(--bg-subtle);
}

.index-card.selected {
  background: var(--bg-raised);
  border-left: 2px solid var(--accent);
  padding-left: 12px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.card-primary {
  margin-bottom: 2px;
}

.card-ts {
  color: var(--text-hi);
  font-size: 12px;
}

.card-run {
  font-size: 11px;
}

.card-secondary {
  margin-bottom: 2px;
}

.card-session {
  color: var(--text-mid);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tertiary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.card-sha {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}

.card-meta {
  color: var(--text-dim);
  font-size: 11px;
  text-align: right;
}

.run-runtime { color: var(--text-mid); }
.run-calibration { color: #b39ddb; }
.run-canonical { color: var(--accent); }

/* ─── Pagination ──────────────────────────────── */

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

.pagination:empty {
  display: none;
}

.pagination .page-arrow {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--text-mid);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 3px 8px;
  cursor: pointer;
  border-radius: 3px;
}

.pagination .page-arrow:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-hi);
}

.pagination .page-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.pagination .page-info {
  color: var(--text-dim);
  font-size: 11px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  padding: 3px 10px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ─── Detail View ─────────────────────────────── */

.back-btn {
  background: none;
  border: none;
  color: color-mix(in srgb, var(--accent) 60%, var(--text-mid));
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  padding: 0;
  margin-bottom: 8px;
}

.back-btn .btn-arrow {
  font-size: 16px;
  color: var(--accent);
  vertical-align: middle;
}

.back-btn:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

/* Refresh button in artifact list header */
.refresh-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 3px 6px;
  line-height: 1;
  font-family: system-ui, -apple-system, sans-serif;
}

.refresh-btn:hover {
  color: var(--accent);
}

.view-raw-btn {
  background: none;
  border: 1px solid var(--border-mid);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 3px;
}

.view-raw-btn:hover {
  color: var(--text);
  border-color: var(--border-hi);
}

/* ─── L1 Identity Block ──────────────────────── */

.identity-block {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--bg-subtle);
}

.identity-block .detail-section {
  margin-bottom: 0;
  border-left: none;
  padding: 0;
  background: none;
  border-radius: 0;
}

/* ─── L1 Section Headers ────────────────────── */

.section-headers {
  margin-top: 16px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text);
  font-size: 12px;
}

.section-header-empty {
  color: var(--text-dim);
}

.section-count {
  color: var(--text-mid);
  font-size: 11px;
}

.section-header-empty .section-count {
  color: var(--text-muted);
}

.section-absent {
  font-style: italic;
}

.section-header-clickable {
  cursor: pointer;
}

/* Populated sections: text brightens on hover */
.section-header-clickable:hover {
  background: var(--bg-subtle);
}
.section-populated.section-header-clickable:hover {
  color: var(--text-hi);
}

/* Empty/absent sections: background highlights but text stays dim */
.section-header-empty.section-header-clickable:hover {
  color: var(--text-dim);
}
.section-header-absent.section-header-clickable:hover {
  color: var(--text-dim);
}

.section-header.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Dimmed highlight: section selected but has zero entries.
   Softer than full .active but stronger than .active-ghost (absent). */
.section-header.active-empty {
  color: color-mix(in srgb, var(--accent) 55%, transparent);
  border-bottom-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.section-header.active-empty .section-count {
  color: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Ghost highlight: section selected via affinity but absent from current artifact.
   Distinct from .active (solid border, full color) and .section-header-empty (dimmed text).
   Uses dashed left border + accent at 30% opacity — reads as "selected but hollow." */
.section-header.active-ghost {
  color: color-mix(in srgb, var(--accent) 30%, transparent);
  border-bottom-color: transparent;
  border-left: 2px dashed color-mix(in srgb, var(--accent) 40%, transparent);
  padding-left: 8px;
}

.section-header.active-ghost .section-count {
  color: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ─── L2 Zone 3 Content ─────────────────────── */

.sub-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-dim);
}

.sub-entry:last-child {
  border-bottom: none;
}

.sub-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.sub-entry-speaker {
  font-size: 12px;
  font-weight: 700;
}

/* Model-specific speaker colors for transcript */
.sub-entry-speaker.speaker-deepseek { color: #4fc3f7; }
.sub-entry-speaker.speaker-mistral  { color: #ff8a65; }
.sub-entry-speaker.speaker-groq     { color: #aed581; }
.sub-entry-speaker.speaker-observer { color: #ce93d8; }
.sub-entry-speaker.speaker-default  { color: var(--accent); }

.sub-entry-label {
  color: var(--text);
  font-size: 12px;
}

.sub-entry-meta {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.sub-entry-body {
  color: var(--text-mid);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.sub-entry-flags {
  color: var(--warn);
  font-size: 11px;
  margin-bottom: 4px;
}

/* ─── L3 Raw JSON View ───────────────────────── */

.raw-json-view pre {
  background: var(--bg-inset);
  border: 1px solid var(--bg-raised);
  padding: 12px;
  overflow-x: auto;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-mid);
  max-height: calc(100vh - 280px);
}

.raw-hash-note {
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-dim);
}

.detail-section {
  margin-bottom: 24px;
  border-left: 2px solid var(--border-dim);
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: 3px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.detail-row {
  display: flex;
  gap: 4px;
  line-height: 1.6;
}

.detail-label {
  color: var(--text-mid);
  font-weight: 600;
  font-size: 13px;
  min-width: 200px;
}

.detail-value {
  color: var(--text-mid);
}

.detail-value.verified {
  color: var(--ok);
}

.detail-value.mismatch {
  color: var(--err);
}

.detail-value.pending {
  color: var(--text-dim);
}

/* ─── Phase 5: Typographic Hierarchy ─────────── */

/* Tier 1: Identity fields — highest contrast */
.identity-block .detail-section-title {
  color: var(--color-identity);
  font-size: 12px;
  letter-spacing: 2px;
}

/* Section title colors — each section has a distinct color accent */
[data-section="verification"] > .detail-section-title { color: var(--color-verification); }
[data-section="metadata"] > .detail-section-title { color: var(--color-metadata); }
[data-section="session"] > .detail-section-title { color: var(--color-session); }
[data-section="timeline"] > .detail-section-title { color: var(--color-timeline); }
[data-section="summary"] > .detail-section-title { color: var(--color-summary); }

/* Section left border accents — match title colors */
[data-section="verification"] { border-left: 2px solid var(--color-verification); padding-left: 12px; }
[data-section="metadata"] { border-left: 2px solid var(--color-metadata); padding-left: 12px; }
[data-section="session"] { border-left: 2px solid var(--color-session); padding-left: 12px; }
[data-section="timeline"] { border-left: 2px solid var(--color-timeline); padding-left: 12px; }
[data-section="summary"] { border-left: 2px solid var(--color-summary); padding-left: 12px; }

.identity-block .detail-value {
  color: var(--text-mid);
}

.identity-block .detail-label {
  color: var(--text-mid);
  font-weight: 600;
}

/* Identity block left accent */
.identity-block {
  border-left: 2px solid var(--color-identity);
}

/* Verification section accent — green on match, red on mismatch */
.detail-section:has(.detail-value.verified) {
  border-left: 2px solid var(--color-verification);
  padding-left: 10px;
}

.detail-section:has(.detail-value.mismatch) {
  border-left: 2px solid var(--err);
  padding-left: 10px;
}

.detail-section:has(.detail-value.pending) {
  border-left: 2px solid var(--text-dim);
  padding-left: 10px;
}

/* ─── Derived Value Markers (Strengthened) ───── */

.derived-marker {
  color: var(--color-derived-border);
  font-size: 10px;
  margin-left: 2px;
  cursor: help;
}

.detail-value.derived {
  color: var(--text-mid);
  font-style: italic;
  background: var(--color-derived-bg);
  border-left: 2px solid var(--color-derived-border);
  padding-left: 6px;
  margin-left: -6px;
}

.derived-legend {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border-dim);
}

/* ─── Phase 5: Section Density Encoding ──────── */

.section-header.section-populated {
  color: var(--text-hi);
}

.section-header.section-populated .section-count {
  color: var(--text);
  font-weight: 600;
}

/* ─── Field Guide Overlay ────────────────────── */

.detail-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-title-row h2 {
  margin: 0;
}

.field-guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field-guide-panel {
  background: var(--bg);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  width: min(560px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.field-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.field-guide-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  font-family: inherit;
  line-height: 1;
}

.field-guide-close:hover {
  color: var(--text);
}

.field-guide-body {
  overflow-y: auto;
  padding: 10px 14px 14px;
}

.field-guide-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 12px;
  margin-bottom: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-dim);
}

.field-guide-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.field-guide-row {
  display: flex;
  gap: 8px;
  line-height: 1.7;
}

.field-guide-field {
  color: var(--text-mid);
  min-width: 180px;
  flex-shrink: 0;
  white-space: nowrap;
}

.field-guide-desc {
  color: var(--text-dim);
  font-size: 12px;
}

.onchain-note {
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Hash + Copy Buttons ────────────────────── */

/* Hash and storage key values — left-align text when wrapping.
   max-width set per font type to match SHA-256 hash width. */
.hash-value {
  font-size: 11px;
  word-break: break-all;
  color: var(--text-dim);
  text-align: left;
  max-width: 470px;
}

.detail-value-small {
  font-size: 11px;
}

.copy-btn {
  display: none;
}

/* ─── Expandable Sections ─────────────────────── */

.expandable {
  margin-top: 8px;
}

.expandable summary {
  cursor: pointer;
  color: var(--text-mid);
  font-size: 12px;
  padding: 4px 0;
}

.expandable summary:hover {
  color: var(--text);
}

.expandable pre {
  background: var(--bg-inset);
  border: 1px solid var(--bg-raised);
  padding: 12px;
  margin-top: 4px;
  overflow-x: auto;
  font-size: 12px;
  color: var(--text-mid);
  max-height: 500px;
  overflow-y: auto;
}

/* ─── Health View ─────────────────────────────── */

.health-section {
  margin-bottom: 16px;
}

/* ─── Empty State ─────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 12px;
  max-width: 400px;
  margin: 0 auto;
}

/* Empty/absent section placeholders in Zone 3 */
.section-empty-placeholder p,
.section-absent-placeholder p {
  color: var(--text-dim);
  line-height: 1.5;
}

.section-absent-placeholder p:first-child {
  font-style: italic;
  opacity: 0.7;
}

.section-empty-placeholder .section-desc,
.section-absent-placeholder .section-desc {
  color: var(--text-muted);
  margin-top: 8px;
}

/* ─── Loading ─────────────────────────────────── */

.loading {
  color: var(--text-muted);
  padding: 24px;
  text-align: center;
  font-size: 12px;
}

/* ─── Responsive ──────────────────────────────── */

/* When artifact zone is open, cards show compact layout */
#zones.artifact-selected .zone-index .card-secondary,
#zones.artifact-selected .zone-index .card-tertiary {
  display: none;
}

/* When artifact zone is open, collapse pagination in filter bar */
#zones.artifact-selected .zone-index .pagination {
  display: none;
}

/* When sub-zone is open, Zone 2 shows section navigation only */
#zones.sub-open .zone-artifact #detail-content > .identity-block,
#zones.sub-open .zone-artifact #detail-content > .detail-section,
#zones.sub-open .zone-artifact #detail-content > .derived-legend {
  display: none;
}

/* Active section header indicator when sub-zone is open */
#zones.sub-open .zone-artifact .section-header.active {
  border-left: 2px solid var(--accent);
  padding-left: 0.5rem;
}

/* Hide Zone 2 chrome when sub-zone is open */
#zones.sub-open #view-raw-btn {
  display: none;
}
#zones.sub-open .zone-artifact > .view-header > h2 {
  display: none;
}

/* Zone scrollable content areas */
.zone-artifact {
  max-height: calc(100vh - 200px);
}

.zone-sub {
  max-height: calc(100vh - 200px);
}

/* ─── Mobile Breadcrumb Navigation ───────────── */

.mobile-breadcrumb {
  display: none;
}

.mobile-breadcrumb .crumb {
  font-size: 14px;
}

/* Navigable crumbs — accent-colored, bold (GitHub-style path links) */
.mobile-breadcrumb .crumb-link {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.mobile-breadcrumb .crumb-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

/* Current crumb — plain text, regular weight, not a link */
.mobile-breadcrumb .crumb-current {
  cursor: default;
  color: var(--text);
  font-weight: 400;
}

.mobile-breadcrumb .crumb-sep {
  color: var(--text-dim);
  margin: 0 6px;
  font-size: 14px;
  user-select: none;
}

/* ─── Responsive: Desktop (>1024px) ──────────── */
/* Full three-zone spatial model — default styles handle this */

/* ─── Responsive: Tablet (768–1023px) ────────── */

/* ─── Responsive: Mobile (<768px) ────────────── */
/* Two states only: desktop (above 768) and mobile (below). */
/* No intermediate tablet breakpoint. */

@media (max-width: 768px) {
  .activity-wrapper {
    padding: 0 8px 8px;
  }

  .activity-tag {
    padding: 5px 12px;
    gap: 8px;
  }

  .activity-mini-cell {
    width: 7px;
    height: 7px;
  }

  .activity-summary {
    font-size: 10px;
  }

  .heatmap-cell {
    width: 9px;
    height: 9px;
  }

  .heatmap-month-label {
    font-size: 8px;
  }

  .heatmap-legend-cell {
    width: 9px;
    height: 9px;
  }

  header {
    position: relative;
  }

  /* Show breadcrumb bar on mobile */
  .mobile-breadcrumb {
    display: block;
    padding: 10px 0 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    min-height: 24px;
  }

  /* Single-zone visibility: only active zone shown */
  #zones {
    display: block;
  }

  .zone {
    display: none;
    width: 100%;
  }

  /* L0: no state class — show index */
  #zones .zone-index {
    display: block;
  }

  /* L1: artifact selected — show artifact only */
  #zones.artifact-selected .zone-index {
    display: none;
  }
  #zones.artifact-selected .zone-artifact {
    display: block;
  }

  /* L2: section open — show section only */
  #zones.sub-open .zone-index {
    display: none;
  }
  #zones.sub-open .zone-artifact {
    display: none;
  }
  #zones.sub-open .zone-sub {
    display: block;
  }

  /* Content-level mobile adjustments */
  header {
    padding: 8px;
  }

  .content-constrained {
    padding: 8px;
  }

  .telemetry {
    padding: 0 8px;
    grid-template-columns: repeat(2, 1fr);
  }

  h1 {
    font-size: 13px;
  }

  .tel-cell {
    padding: 6px 10px;
  }

  .tel-value {
    font-size: 12px;
  }

  .detail-row {
    flex-direction: column;
    gap: 0;
  }

  .detail-label {
    min-width: auto;
    font-size: 13px;
  }

  /* Hide dot leaders on mobile — label sits directly above value */
  .detail-label .dots {
    display: none;
  }

  .detail-value {
    margin-bottom: 6px;
  }

  /* Derived value highlight wraps text only, not full width */
  .detail-value.derived {
    align-self: flex-start;
  }

  .artifact-scroll {
    max-height: calc(100vh - 280px);
  }

  .field-guide-panel {
    width: 88vw;
    max-height: 70vh;
  }

  .field-guide-dots {
    display: none;
  }

  .field-guide-row {
    flex-direction: column;
    gap: 2px;
    background: var(--bg-subtle);
    border-left: 2px solid var(--border-dim);
    border-radius: 3px;
    padding: 8px 10px;
    margin-bottom: 6px;
    line-height: 1.5;
  }

  .field-guide-field {
    min-width: auto;
    font-weight: 600;
    font-size: 13px;
  }

  .field-guide-desc {
    font-size: 12px;
    line-height: 1.5;
  }

  .field-guide-section {
    color: var(--text-dim);
    font-size: 11px;
    margin-top: 16px;
    margin-bottom: 6px;
    padding-top: 10px;
  }
}

/* ─── Corpus View ────────────────────────────── */

.corpus-view {
  padding: 16px 16px 16px;
  width: 100%;
}

.corpus-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

.corpus-header {
  margin-bottom: 16px;
}

.corpus-header-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.corpus-header-row h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 2px;
  margin: 0;
}

.corpus-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.corpus-search {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-mid);
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 3px 8px;
  width: 180px;
}

.corpus-search:focus {
  outline: none;
  border-color: var(--border-hi);
}

.corpus-search::placeholder {
  color: var(--text-muted);
}

/* ─── Corpus Grid ────────────────────────────── */

.corpus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

/* ─── Corpus Card ────────────────────────────── */

.corpus-card {
  background: var(--bg-subtle);
  border-radius: 4px;
  border-left: 3px solid var(--border-dim);
  padding: 14px 16px 10px;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}

.corpus-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  outline: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: -1px;
}

.corpus-card.selected {
  background: var(--bg-raised);
  outline: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: -1px;
}

/* Convergence — same accent color, different opacity levels.
   Low convergence (healthy tension) = bright, full accent.
   Mid convergence = moderate opacity.
   High convergence (agreement risk) = soft, muted.
   All pulse at the same 5s speed. Works across all themes. */
.corpus-card.convergence-low {
  border-left-color: var(--accent);
  animation: card-breathe-low 5s ease-in-out infinite;
}

.corpus-card.convergence-mid {
  border-left-color: var(--accent);
  opacity: 1;
  animation: card-breathe-mid 5s ease-in-out infinite;
}

.corpus-card.convergence-high {
  border-left-color: var(--accent);
  animation: card-breathe-high 5s ease-in-out infinite;
}

.corpus-card.convergence-none {
  border-left-color: var(--border-dim);
}

@keyframes card-breathe-low {
  0%, 100% { border-left-color: color-mix(in srgb, var(--accent) 70%, transparent); }
  50%      { border-left-color: var(--accent); }
}

@keyframes card-breathe-mid {
  0%, 100% { border-left-color: color-mix(in srgb, var(--accent) 40%, transparent); }
  50%      { border-left-color: color-mix(in srgb, var(--accent) 65%, transparent); }
}

@keyframes card-breathe-high {
  0%, 100% { border-left-color: color-mix(in srgb, var(--accent) 18%, transparent); }
  50%      { border-left-color: color-mix(in srgb, var(--accent) 35%, transparent); }
}

.corpus-card-header {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.corpus-card-body {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.corpus-card-footer {
  margin-top: 10px;
}

/* ─── Depth Bar ──────────────────────────────── */

.depth-bar {
  display: flex;
  gap: 2px;
}

.depth-square {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--border-dim);
  opacity: 0.15;
}

.depth-square.filled {
  background: var(--accent);
  opacity: 0.6;
}

/* ─── Corpus Loading Animation ───────────────── */

.corpus-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0 80px;
  gap: 16px;
  grid-column: 1 / -1;
}

.corpus-loading-grid {
  display: grid;
  grid-template-columns: repeat(4, 8px);
  gap: 4px;
}

.corpus-loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.04;
  animation: corpus-dot-scan 1.5s ease-out forwards,
             corpus-dot-breathe 5s ease-in-out infinite;
}

@keyframes corpus-dot-scan {
  0%   { opacity: 0.04; }
  100% { opacity: 0.7; }
}

@keyframes corpus-dot-breathe {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.9; }
}

.corpus-loading-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 4px;
  font-weight: 600;
}

/* ─── Corpus Responsive ──────────────────────── */

@media (max-width: 768px) {
  header {
    padding: 18px 16px;
  }

  .corpus-view {
    padding-top: 24px;
  }

  .corpus-controls {
    flex-wrap: nowrap;
  }

  .corpus-search {
    flex: 1;
    min-width: 0;
  }

  .corpus-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Reduced Motion ─────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .zone {
    transition: none;
  }

  .badge.healthy {
    animation: none;
  }
}
