/* paper.css — MIRR Living Research Artifact
   Mission Control Dark — 5-level surface depth system
   GPL-3.0 — same license as the compiler. */

*, *::before, *::after { box-sizing: border-box; }

/* Elegant auto-hiding scrollbars — invisible until hover */
#search-results,
pre.output,
#citation-block,
.pipeline-viz,
.sim-output,
.viz-error,
.listing pre {
  scrollbar-width: none;
}
#search-results:hover,
pre.output:hover,
#citation-block:hover,
.pipeline-viz:hover,
.sim-output:hover,
.viz-error:hover,
.listing pre:hover {
  scrollbar-width: thin;
}
#search-results::-webkit-scrollbar,
pre.output::-webkit-scrollbar,
#citation-block::-webkit-scrollbar,
.pipeline-viz::-webkit-scrollbar,
.sim-output::-webkit-scrollbar,
.viz-error::-webkit-scrollbar,
.listing pre::-webkit-scrollbar {
  width: 6px; height: 6px;
  background: transparent;
}
#search-results::-webkit-scrollbar-thumb,
pre.output::-webkit-scrollbar-thumb,
#citation-block::-webkit-scrollbar-thumb,
.pipeline-viz::-webkit-scrollbar-thumb,
.sim-output::-webkit-scrollbar-thumb,
.viz-error::-webkit-scrollbar-thumb,
.listing pre::-webkit-scrollbar-thumb {
  background: transparent; border-radius: 4px;
  transition: background 200ms;
}
#search-results:hover::-webkit-scrollbar-thumb,
pre.output:hover::-webkit-scrollbar-thumb,
#citation-block:hover::-webkit-scrollbar-thumb,
.pipeline-viz:hover::-webkit-scrollbar-thumb,
.sim-output:hover::-webkit-scrollbar-thumb,
.viz-error:hover::-webkit-scrollbar-thumb,
.listing pre:hover::-webkit-scrollbar-thumb {
  background: var(--border-medium);
}

:root {
  --surface-0: #060a14;
  --surface-1: #0c1222;
  --surface-2: #121a30;
  --surface-3: #162040;
  --surface-4: #1a2340;
  --text-primary: #f1f5f9;
  --text-secondary: #b0bec5;
  --text-tertiary: #64748b;
  --text-ghost: #475569;
  --border-subtle: rgba(148,163,184,.12);
  --border-medium: rgba(148,163,184,.2);
  --border-strong: rgba(148,163,184,.3);
  --cyan: #00E5FF;
  --violet: #8B5CF6;
  --green: #22C55E;
  --amber: #f59e0b;
  --error: #ef4444;
  --glow-cyan: rgba(0,229,255,.08);
  --glow-violet: rgba(139,92,246,.08);
  --glow-green: rgba(34,197,94,.08);
  --glow-error: rgba(239,68,68,.08);
  --accent: #4db8d9;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-primary);
  background: var(--surface-0);
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.011em;
}

h1 { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; margin-bottom: 0.5rem; }
h2 { font-size: 1.625rem; font-weight: 700; margin-top: 2.5rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem; }
h3 { font-size: 1.25rem; font-weight: 600; margin-top: 1.5rem; }

header { margin-bottom: 0; }
.meta  { font-family: var(--mono); font-size: 0.8rem; color: var(--text-ghost); }
.paper-title { margin-bottom: 2rem; padding-top: 6rem; }

/* ── Sticky Header Bar (Jekyll-style) ── */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  isolation: isolate;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0;
  font-family: var(--sans);
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 860px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
}

.header-home {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-right: 0.75rem;
  flex-shrink: 0;
}
.header-home:hover { color: var(--cyan); text-decoration: none; }

.header-brand {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--cyan);
  text-decoration: none;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.header-brand:hover { text-decoration: none; opacity: 0.85; }

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 0.75rem;
}

.header-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  min-width: 0;
  flex: 1;
}

.header-search {
  position: relative;
  flex-shrink: 0;
  width: 220px;
}

.header-search #site-search {
  width: 100%;
  padding: 0.35rem 0.6rem 0.35rem 2rem;
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.header-search #site-search::placeholder { color: var(--text-ghost); }
.header-search #site-search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.12);
}

.search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-ghost);
  pointer-events: none;
}

#search-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface-1);
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 110;
  isolation: isolate;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--mono);
  transition: background 100ms;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-3); text-decoration: none; }
.search-result-item:hover .search-result-title { color: var(--cyan); }
.search-result-active { background: var(--surface-3); outline: 2px solid var(--cyan); outline-offset: -2px; }
.search-result-active .search-result-title { color: var(--cyan); }
.search-result-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.search-result-snippet { font-size: 0.7rem; color: var(--text-tertiary); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-no-results { color: var(--text-ghost); font-style: italic; padding: 0.5rem 0.75rem; font-size: 0.8rem; }
#search-results mark { background: rgba(0, 229, 255, 0.2); color: var(--cyan); border-radius: 2px; padding: 0 1px; }

/* Keyboard shortcut hint badge */
.search-kbd {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-ghost);
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  pointer-events: none;
  line-height: 1.4;
}

/* ── Header Nav ── */
#site-header nav[aria-label] {
  font-family: var(--mono);
  font-size: 0.72rem;
  max-width: 860px;
  margin: 0 auto;
  padding: 0.3rem 1.5rem 0.35rem;
  background: transparent;
  border-bottom: none;
  border-radius: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  border-top: 1px solid var(--border-subtle);
}
#site-header nav[aria-label] a {
  color: var(--text-tertiary);
  text-decoration: none;
  padding: 0.1rem 0;
  transition: color 100ms;
}
#site-header nav[aria-label] a:hover { color: var(--cyan); text-decoration: none; }

/* Active section highlight (set by JS) */
#site-header nav[aria-label] a.nav-active {
  color: var(--cyan);
  border-bottom: 2px solid var(--cyan);
}

p { margin-bottom: 1.5rem; max-width: 70ch; }
li { margin-bottom: 0.5rem; line-height: 1.65; }
ol, ul { padding-left: 1.5rem; }
a { color: var(--cyan); }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Sections — overflow visible so figure min-width SVGs can scroll */
section { overflow: visible; }

/* Claims */
#claims ol { padding-left: 1.25rem; }
#claims li { margin-bottom: 0.5rem; }

/* Demo sections */
.demo {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  overflow: hidden;
  transition: background 150ms;
}
.demo:hover { background: var(--surface-3); }
.demo h2 { border-bottom-color: var(--border-subtle); margin-top: 0; }
.claim-refs { font-size: 0.8rem; font-weight: normal; color: var(--text-ghost); }

/* Controls */
.demo-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
select, button {
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
button:hover { background: var(--cyan); color: var(--surface-0); border-color: var(--cyan); }
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Split pane — ALWAYS stacked (editor on top, output below).
   DO NOT add a media query for side-by-side layout.
   This has been reverted 3 times. The user wants vertical stacking only. */
.split-pane {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.pane label, .pane .pane-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-ghost);
  margin-bottom: 0.25rem;
}
pre.output {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface-1);
  color: var(--text-primary);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin: 0;
  min-height: 300px;
  max-height: 500px;
}
pre.output.error { color: var(--error); }

/* Data tables — one class for all paper tables */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.85rem;
  margin-top: 1rem;
}
.data-table th, .data-table td {
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.data-table th { background: var(--surface-2); color: var(--text-secondary); }
.data-table td { background: var(--surface-1); }
.data-table tr:hover td { background: var(--surface-3); }
.data-table tr.error td { color: var(--error); }

/* Figures */
figure {
  margin: 1.5rem 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
figure:hover { scrollbar-width: thin; }
figure::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
figure::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
figure:hover::-webkit-scrollbar-thumb { background: var(--border-medium); }
figure svg, figure img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}
figure svg.architecture-svg {
  min-width: 600px;
}
figcaption {
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Code listings (numbered with line gutters) */
.listing {
  margin: 1.5rem 0;
}
.listing-caption {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}
.listing pre {
  margin: 0;
  font-size: 0.78rem;
  border-radius: 8px;
  padding: 0;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  counter-reset: line;
  position: relative;
}
.listing pre .line {
  display: block;
  padding: 0 0.8rem 0 3.2rem;
  min-height: 1.4em;
  line-height: 1.5;
}
.listing pre .line::before {
  counter-increment: line;
  content: counter(line);
  position: absolute;
  left: 0;
  width: 2.4rem;
  padding-right: 0.5rem;
  text-align: right;
  font-size: 0.68rem;
  color: var(--text-ghost);
  user-select: none;
  border-right: 1px solid var(--border-subtle);
}
.listing pre .line:first-child { padding-top: 0.6rem; }
.listing pre .line:first-child::before { padding-top: 0.6rem; }
.listing pre .line:last-child { padding-bottom: 0.6rem; }
.listing pre .line:last-child::before { padding-bottom: 0.6rem; }
/* Syntax token colors for listings */
.listing .kw { color: var(--cyan); font-weight: 600; }
.listing .type { color: #22C55E; }
.listing .str { color: #f59e0b; }
.listing .num { color: #f59e0b; }
.listing .cmt { color: #6b7280; font-style: italic; }
.listing .dir { color: #8B5CF6; }
.listing .tactic { color: #c084fc; }
.listing .op { color: #94a3b8; }

/* Natural deduction inference rules */
.inference-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.inference-rules:hover { scrollbar-width: thin; }
.inference-rules::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
.inference-rules::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; transition: background 200ms; }
.inference-rules:hover::-webkit-scrollbar-thumb { background: var(--border-medium); }
.inference-rule {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}
.inference-rule .rule-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.inference-rule .premises {
  padding: 0 0.25rem 0.25rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  min-height: 1.2em;
}
.inference-rule .premises:empty { min-height: 0; padding: 0; }
.inference-rule .rule-line {
  width: 100%;
  height: 1px;
  background: var(--text-secondary);
  min-width: 4rem;
}
.inference-rule .conclusion {
  padding: 0.25rem 0.25rem 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
}
.inference-rule .rule-name {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  font-variant: small-caps;
  letter-spacing: 0.03em;
  white-space: nowrap;
  align-self: center;
}

/* References */
.references {
  font-size: 0.9rem;
  line-height: 1.6;
  padding-left: 2rem;
}
.references li { margin-bottom: 0.5rem; }

/* Citation */
#citation-block {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.85rem;
  overflow: auto;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-ghost);
  text-align: center;
}
footer a { color: var(--text-tertiary); }

/* Proof status badges */
.proof-badge {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--mono);
}
.proof-badge.proven {
  background: var(--glow-green);
  color: var(--green);
  border: 1px solid var(--green);
}
.proof-badge.admitted {
  background: var(--glow-error);
  color: var(--amber);
  border: 1px solid var(--amber);
}

/* Pipeline visualization */
.pipeline-viz {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  overflow-x: auto;
  padding: 1rem 0;
}
.pipeline-stage {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  transition: all 150ms;
  white-space: nowrap;
}
.pipeline-arrow { color: var(--text-ghost); font-size: 0.75rem; }

/* Proof dashboard grid */
.proof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.proof-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.proof-bar { display: flex; flex-wrap: wrap; height: 24px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border-medium); margin: 1rem 0; }
.proof-bar-proven { background: #4caf50; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; }
.proof-bar-admitted { background: #ff9800; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; }
/* Simulation panels */
.sim-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}
.sim-panel h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.sim-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.75rem;
}
.sim-output {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface-0);
  border-radius: 6px;
  padding: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
  body { padding: 1rem; }
  h1 { font-size: 1.75rem; }
  .proof-grid { grid-template-columns: 1fr; }
  .paper-title { padding-top: 5.5rem; }
  .header-subtitle { display: none; }
  .header-search { width: 160px; }
  .header-top { padding: 0.4rem 1rem; }
  #site-header nav[aria-label] { padding: 0.25rem 1rem 0.3rem; font-size: 0.65rem; gap: 0.1rem 0.35rem; }
}
@media (max-width: 480px) {
  .demo-controls { flex-direction: column; }
  .demo { border-radius: 0; margin-left: -1rem; margin-right: -1rem; padding: 1rem; }
  .pipeline-viz { gap: 0.25rem; }
  .pipeline-stage { font-size: 0.65rem; padding: 0.3rem 0.5rem; }
  .paper-title { padding-top: 5rem; }
  .header-search { width: 120px; }
  .header-search #site-search { font-size: 0.7rem; padding-left: 1.6rem; }
  .search-icon { width: 12px; height: 12px; left: 0.4rem; }
  .inference-rules { gap: 1rem 1.5rem; padding: 0.75rem; font-size: 0.7rem; }
  .inference-rule .premises,
  .inference-rule .conclusion { font-size: 0.7rem; }
  .inference-rule .rule-name { font-size: 0.6rem; }
}
@media (min-width: 1400px) {
  body { padding-left: 3rem; padding-right: 3rem; }
}

/* .sr-only — accessible screen-reader-only class */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Print — paper renders as readable static page */
@media print {
  #site-header { display: none; }
  .paper-title { padding-top: 0; }
  .demo-controls, button, select, .pipeline-viz, .sim-panel, .sim-controls,
  .editor-container { display: none; }
  pre.output { border: none; padding: 0; color: #1a1a1a; background: #f8f8f8; }
  .split-pane { display: block; }
  body { max-width: 100%; font-size: 11pt; color: #000; background: #fff; padding: 0; }
  h1, h2, h3 { color: #000; }
  a { color: #000; }
  .demo { background: #f8f8f8; border-color: #ccc; }
  .data-table th { background: #eee; }
  .data-table td { background: #fff; word-break: break-all; }
  .meta { color: #1a1a1a; }
  .claim-refs { color: #333; }
  footer, footer a { color: #333; }
  figcaption { color: #333; }
  code { background: #f5f5f5; color: #1a1a1a; }
  .listing pre { background: #f8f8f8; color: #000; border-color: #ccc; }
  #citation-block { background: #f8f8f8; color: #000; border-color: #ccc; }
  .proof-item { background: #eee; color: #000; }
  pre.output.error { color: #b91c1c; }
  .data-table tr.error td { color: #b91c1c; }
  .proof-bar-proven { background: #333; color: #fff; }
  .proof-bar-admitted { background: #666; color: #fff; }
  .proof-badge.proven { color: #166534; border-color: #166534; }
  .proof-badge.admitted { color: #92400e; border-color: #92400e; }
  .inference-rules { background: #fff; border-color: #ccc; overflow: visible; }
  figure { overflow: visible; }
  figure svg.architecture-svg { min-width: auto; }
  .inference-rule .premises,
  .inference-rule .conclusion { color: #000; }
  .inference-rule .rule-line { background: #000; }
  .inference-rule .rule-name { color: #333; }
  .listing pre .line::before { color: #555; border-right-color: #ccc; }
  .listing .kw, .listing .type, .listing .dir, .listing .tactic, .listing .op { color: #000; font-weight: 600; }
  .listing .str, .listing .num { color: #b45309; }
  .listing .cmt { color: #555; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
  @page { margin: 2cm; }
}

/* ===== CodeMirror playground editor ===== */
.editor-container {
  border-radius: 8px;
  overflow: hidden;
}
.editor-container .CodeMirror {
  height: 350px;
  font-family: var(--mono);
  font-size: 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}
.editor-container .CodeMirror-focused {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
/* Fallback textarea (when CodeMirror CDN fails) */
.editor-container textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface-1);
  color: var(--text-primary);
  resize: vertical;
  min-height: 350px;
}

/* ── Waveform Visualization ── */

.waveform-svg {
    background: var(--bg-secondary, #1a1a2e);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    display: block;
    max-width: 100%;
}

.waveform-grid {
    stroke: var(--border-color, #333);
    stroke-width: 0.5;
    stroke-dasharray: 2,4;
}

.waveform-signal-input { stroke: #4fc3f7; fill: none; stroke-width: 2; }
.waveform-signal-guard { stroke: #66bb6a; fill: none; stroke-width: 2; }
.waveform-signal-output { stroke: #ffb74d; fill: none; stroke-width: 2; }

.waveform-signal-label {
    fill: var(--text-primary, #e0e0e0);
    font-size: 12px;
    dominant-baseline: middle;
}

.waveform-value-label {
    fill: var(--text-secondary, #b0b0b0);
    font-size: 10px;
    text-anchor: middle;
    dominant-baseline: middle;
}

.waveform-cycle-label {
    fill: var(--text-secondary, #888);
    font-size: 10px;
    text-anchor: middle;
}

/* ── Circuit Graph Visualization ── */

.circuit-graph-svg {
    background: var(--bg-secondary, #1a1a2e);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    display: block;
    max-width: 100%;
}

.circuit-node-Input { fill: #1565c0; stroke: #42a5f5; }
.circuit-node-Output { fill: #2e7d32; stroke: #66bb6a; }
.circuit-node-Guard { fill: #e65100; stroke: #ff9800; }
.circuit-node-Reflex { fill: #6a1b9a; stroke: #ab47bc; }
.circuit-node-Internal { fill: #37474f; stroke: #78909c; }

.circuit-node-label {
    fill: white;
    font-size: 11px;
    text-anchor: middle;
    dominant-baseline: middle;
}

.circuit-edge {
    stroke: var(--text-secondary, #666);
    stroke-width: 1.5;
    fill: none;
    marker-end: url(#arrowhead);
}

.circuit-edge-label {
    fill: var(--text-secondary, #888);
    font-size: 9px;
    text-anchor: middle;
}

.viz-panel {
    margin-top: 1rem;
    min-height: 100px;
    overflow: hidden;
}

.viz-error {
    color: #ef5350;
    padding: 1rem;
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* W3: Print overrides for visualization */
@media print {
    .waveform-svg { background: white; }
    .waveform-signal-input { stroke: #1565c0; }
    .waveform-signal-guard { stroke: #2e7d32; }
    .waveform-signal-output { stroke: #e65100; }
    .waveform-signal-label { fill: #000; }
    .waveform-value-label { fill: #333; }
    .waveform-cycle-label { fill: #333; }
    .waveform-grid { stroke: #ccc; }
    .circuit-graph-svg { background: white; }
    .circuit-node-label { fill: #000; }
    .circuit-edge { stroke: #333; }
    .circuit-edge-label { fill: #333; }
}
