/* ── FONTS ── */
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* ── PROGRESS BAR ── */
.progress-bar-wrap {
  position: fixed;
  top: 52px;
  left: 0; right: 0;
  z-index: 199;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 56px;
  height: 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--navy);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.progress-label {
  font-size: 0.7rem;
  font-family: 'Roboto Mono', monospace;
  color: var(--muted);
  width: 32px;
  text-align: right;
}

/* push the article down to clear the progress bar */
.proj-wrap { padding-top: 108px; }

code, .file-tag, .file-tag-sm {
  font-family: 'Roboto Mono', monospace;
  color: var(--navy-lit);
  font-size: 0.88em;
}

/* ── LAYOUT ── */
.proj-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 88px 48px 100px;
}

.proj-header {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.proj-title {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  margin: 16px 0 8px;
}

.proj-stack {
  font-size: 0.78rem;
  color: var(--navy-lit);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: 'Roboto Mono', monospace;
  margin-bottom: 20px;
}

.proj-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 8px;
}

.proj-lede {
  font-size: 1.08rem;
  color: var(--text);
  line-height: 1.85;
  font-weight: 400;
}

.proj-section p {
  font-size: 0.96rem;
  color: var(--muted);
  line-height: 1.85;
}

.proj-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 52px 0;
}

/* ── HEADINGS ── */
.proj-h2 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.proj-h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
}

.proj-h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: 8px;
  margin-bottom: -8px;
}

.proj-stage {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-tag {
  font-size: 0.78rem;
  background: rgba(26,58,122,0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: 400;
}

.file-tag-sm {
  font-size: 0.72rem;
  background: rgba(26,58,122,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 7px;
  font-weight: 400;
}

/* ── LISTS ── */
.proj-list {
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.proj-list li {
  font-size: 0.96rem;
  color: var(--muted);
  line-height: 1.75;
}

/* ── CODE TRANSFORM BOX ── */
.code-transform {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin: 8px 0;
}

.code-transform code {
  font-size: 0.93rem;
  display: block;
  margin-top: 4px;
}

.code-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  margin-bottom: 4px;
}

.code-before, .code-after { flex: 1; }
.code-arrow-h { font-size: 1.5rem; color: var(--border); flex-shrink: 0; }
.code-after code { color: #1a7a3a; }

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto;
  margin: 8px 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.proj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--white);
}

.proj-table th {
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px;
  text-align: left;
}

.proj-table td {
  padding: 14px 16px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.6;
}

.proj-table tr:last-child td { border-bottom: none; }

.proj-table tr:hover td { background: rgba(26,58,122,0.03); }

.highlight-row td {
  background: rgba(26,58,122,0.04);
}

.result-cell {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
}
.result-cell.neutral { color: var(--muted); }
.result-cell.win { color: #1a7a3a; }

/* ── DIAGRAMS ── */
.diagram-fig,
.diagram-fig * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* except Roboto Mono for code inside diagrams */
.diagram-fig code {
  font-family: 'Roboto Mono', monospace !important;
}

.diagram-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy);
  margin-bottom: 20px;
  font-family: Arial, Helvetica, sans-serif;
}

.diagram-fig {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 24px 20px;
  margin: 8px 0;
}

.diagram-fig figcaption {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 20px;
  line-height: 1.5;
}

/* Diagram 1 — two graphs */
.diagram-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.diagram-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.diagram-label-top {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}
.fused-label { color: #1a7a3a; }

.graph-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.graph-node {
  width: 100%;
  max-width: 220px;
  padding: 9px 14px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.82rem;
}

.input-node, .output-node {
  background: #eef0f5;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: 0.78rem;
}

.op-node {
  background: rgba(255,200,50,0.1);
  border: 1px solid rgba(200,150,0,0.25);
  color: var(--navy);
}

.fused-node {
  background: rgba(26,122,58,0.07);
  border: 1px solid rgba(26,122,58,0.3);
  color: #155a2a;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  max-width: 220px;
  width: 100%;
  border-radius: 6px;
  text-align: center;
  font-size: 0.82rem;
}

.kernel-badge {
  font-size: 0.67rem;
  background: rgba(26,122,58,0.12);
  border-radius: 4px;
  padding: 2px 6px;
  color: #1a7a3a;
  font-family: 'Roboto Mono', monospace;
}

.registers-note {
  font-size: 0.67rem;
  color: #1a7a3a;
  opacity: 0.8;
}

.graph-arrow {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
}

.graph-trips {
  margin-top: 6px;
  font-size: 0.72rem;
  color: #b04040;
  font-weight: 600;
  font-family: 'Roboto Mono', monospace;
}
.fused-trips { color: #1a7a3a; }

.diagram-vs {
  font-size: 1.4rem;
  color: var(--border);
  flex-shrink: 0;
  align-self: center;
}

/* Diagram 2 — memory traffic */
.memory-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mem-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 120px;
}

.mem-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 2px;
}

.fused-mem-label { color: #1a7a3a; }

.mem-box {
  width: 100%;
  text-align: center;
  padding: 7px 10px;
  font-size: 0.75rem;
  border-radius: 5px;
  font-family: 'Roboto Mono', monospace;
}

.vram-box {
  background: rgba(180,40,40,0.07);
  border: 1px solid rgba(180,40,40,0.2);
  color: #7a2020;
}

.mem-compute {
  font-size: 0.75rem;
  color: var(--navy-lit);
  font-family: 'Roboto Mono', monospace;
  padding: 5px 0;
}

.mem-vs {
  font-size: 1.1rem;
  color: var(--border);
  padding: 0 6px;
  align-self: center;
}

.fused-col .mem-box { background: rgba(26,122,58,0.07); border-color: rgba(26,122,58,0.25); color: #155a2a; }

/* Diagram 3 — FX graph */
.fx-graph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 280px;
  margin: 0 auto;
}

.fx-node {
  width: 100%;
  padding: 9px 18px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.83rem;
}

.placeholder-node {
  background: #eef0f5;
  border: 1px solid var(--border);
  color: var(--muted);
}
.placeholder-node .fx-name {
  font-family: 'Roboto Mono', monospace;
  color: var(--navy-lit);
}

.call-node {
  background: rgba(26,58,122,0.06);
  border: 1px solid rgba(26,58,122,0.2);
  color: var(--navy);
}

.output-fx-node {
  background: #eef0f5;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: 0.78rem;
}

.fx-arrow {
  font-size: 0.85rem;
  color: var(--border);
}

/* Diagram 4 — MLP */
.mlp-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 260px;
  margin: 0 auto;
}

.mlp-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.mlp-node {
  width: 100%;
  padding: 9px 18px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.83rem;
}

.linear-node {
  background: rgba(26,58,122,0.07);
  border: 1px solid rgba(26,58,122,0.2);
  color: var(--navy);
}

.act-node {
  background: rgba(26,122,58,0.07);
  border: 1px solid rgba(26,122,58,0.25);
  color: #155a2a;
}

.mlp-arrow { font-size: 0.8rem; color: var(--border); }

.fuse-arrow { display: flex; align-items: center; gap: 6px; color: var(--border); font-size: 0.78rem; }

.fuse-badge {
  font-size: 0.62rem;
  background: rgba(26,122,58,0.1);
  border: 1px solid rgba(26,122,58,0.25);
  color: #1a7a3a;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Roboto Mono', monospace;
  white-space: nowrap;
}

/* Diagram 5 — graph rewrite */
.rewrite-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.rewrite-half {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.rewrite-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.rewrite-nodes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.rewrite-node {
  width: 100%;
  max-width: 200px;
  padding: 12px 16px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.5;
}

.linear-rw-node {
  background: rgba(26,58,122,0.07);
  border: 1px solid rgba(26,58,122,0.2);
  color: var(--navy);
}

.act-rw-node {
  background: rgba(180,100,0,0.07);
  border: 1px solid rgba(180,100,0,0.2);
  color: #6a3a00;
}

.fused-rw-node {
  background: rgba(26,122,58,0.07);
  border: 1px solid rgba(26,122,58,0.28);
  color: #155a2a;
}

.rw-note {
  display: block;
  font-size: 0.67rem;
  opacity: 0.7;
  margin-top: 2px;
}

.rw-arrow { font-size: 0.85rem; color: var(--border); }

.rewrite-vs { font-size: 1.4rem; color: var(--border); flex-shrink: 0; }

/* ── HARDWARE BLOCK DIAGRAM ── */
.hw-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hw-sensors {
  display: flex;
  gap: 32px;
  justify-content: center;
  margin-bottom: 4px;
}

.hw-sensor-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hw-node {
  padding: 10px 18px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
}

.sensor-node {
  background: rgba(26,58,122,0.07);
  border: 1px solid rgba(26,58,122,0.22);
  color: var(--navy);
  min-width: 160px;
}

.converter-node {
  background: rgba(180,100,0,0.06);
  border: 1px solid rgba(180,100,0,0.2);
  color: #6a3a00;
  min-width: 160px;
  font-size: 0.76rem;
}

.cpu-node {
  background: rgba(26,122,58,0.08);
  border: 1px solid rgba(26,122,58,0.3);
  color: #155a2a;
  min-width: 240px;
}

.display-node {
  background: #f0f1f5;
  border: 1px solid var(--border);
  color: var(--muted);
  min-width: 240px;
}

.hw-note {
  display: block;
  font-size: 0.68rem;
  opacity: 0.75;
  margin-top: 2px;
}

.hw-arrow-down {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  text-align: center;
}

.hw-arrow-merge {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  text-align: center;
  margin: 4px 0;
}

/* ── SIGNAL PIPELINE ── */
.signal-pipeline { width: 100%; }

.pipeline-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 560px;
  margin: 0 auto;
}

.pipeline-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}

.pipeline-step-accent {
  background: rgba(26,58,122,0.05);
  border-color: rgba(26,58,122,0.2);
}

.pipeline-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.pipeline-num-accent {
  background: var(--navy);
  color: #fff;
}

.pipeline-content { display: flex; flex-direction: column; gap: 3px; }

.pipeline-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--navy);
}

.pipeline-step-accent .pipeline-name { color: var(--navy); }

.pipeline-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.pipeline-connector {
  text-align: center;
  font-size: 0.8rem;
  color: var(--border);
  padding: 2px 0;
  margin-left: 28px;
}

/* ── WAVEFORM ── */
.waveform-container {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.waveform-y-label {
  font-size: 0.7rem;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.08em;
  align-self: center;
}

.waveform-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.waveform-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.wf-stat {
  font-size: 0.7rem;
  font-family: 'Roboto Mono', monospace;
  padding: 2px 6px;
  border-radius: 4px;
}

.wf-skew { background: rgba(26,122,58,0.1); color: #155a2a; }
.wf-kurt { background: rgba(26,122,58,0.1); color: #155a2a; }

.waveform-svg {
  width: 100%;
  height: auto;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.waveform-x-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

.waveform-x-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: #9ca3af;
  font-family: 'Roboto Mono', monospace;
  padding: 0 2px;
}

.waveform-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 130px;
  padding-top: 8px;
}

.wf-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
}

.wf-line {
  display: inline-block;
  width: 22px;
  height: 2px;
  flex-shrink: 0;
}

.wf-line-blue { background: #2a52a8; }
.wf-line-green { background: #2a7a3a; border-top: 2px dashed #2a7a3a; background: none; }
.wf-line-blue-dash { border-top: 2px dashed #2a52a8; background: none; }
.wf-line-red { border-top: 2px dashed #b04040; background: none; }
.wf-line-green-dash { border-top: 2px dashed #2a7a3a; background: none; }

/* ── CONFUSION MATRIX ── */
.confusion-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}

.confusion-matrix-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cm-y-axis-label {
  font-size: 0.7rem;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.08em;
}

.cm-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cm-col-headers {
  display: flex;
  align-items: center;
}

.cm-blank { width: 80px; }

.cm-col-head {
  width: 100px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 6px;
}

.cm-row {
  display: flex;
  align-items: center;
}

.cm-row-head {
  width: 80px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  padding-right: 10px;
}

.cm-cell {
  width: 100px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  border: 1px solid rgba(255,255,255,0.3);
}

.cm-cell-dark  { background: #1a5c2a; color: #fff; }
.cm-cell-mid   { background: #4a9c5a; color: #fff; }
.cm-cell-empty { background: #f0f7f1; color: #9ca3af; font-size: 1rem; }
.cm-cell-dark2 { background: #1a5c2a; color: #fff; }
.cm-cell-light2 { background: #b8dcbe; color: #2a5a32; }

.cm-x-label {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  padding-top: 8px;
  padding-left: 80px;
}

.cm-scale {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding-top: 24px;
}

.cm-scale-bar {
  width: 14px;
  height: 140px;
  background: linear-gradient(to bottom, #1a5c2a, #4a9c5a, #b8dcbe, #f0f7f1);
  border-radius: 3px;
}

.cm-scale-ticks {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.65rem;
  color: #9ca3af;
  font-family: 'Roboto Mono', monospace;
}

/* ── TRAINING LOSS CHART ── */
.loss-chart-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.loss-y-label {
  font-size: 0.7rem;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.08em;
  align-self: center;
}

.loss-chart-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loss-svg {
  width: 100%;
  height: auto;
  background: #0d0d0d;
  border-radius: 6px;
}

.loss-x-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

.loss-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  min-width: 100px;
}

.loss-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
}

.loss-swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.loss-green { background: #4ade80; }
.loss-yellow { background: #facc15; }

/* ── PROJECT IMAGES ── */
.proj-img {
  width: 100%;
  border-radius: 6px;
  display: block;
}

.proj-img-sm {
  max-width: 520px;
  margin: 0 auto;
}

/* ── REFERENCES ── */
.ref-list li {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .proj-wrap { padding: 80px 22px 60px; }
  .diagram-row { flex-direction: column; }
  .diagram-vs { transform: rotate(90deg); }
  .memory-diagram { flex-direction: column; }
  .rewrite-diagram { flex-direction: column; }
  .code-transform { flex-direction: column; gap: 10px; }
  .code-arrow-h { transform: rotate(90deg); }
  .hw-sensors { flex-direction: column; align-items: center; }
  .confusion-wrap { flex-direction: column; align-items: center; }
  .waveform-container { flex-direction: column; }
  .waveform-legend { flex-direction: row; flex-wrap: wrap; }
  .loss-chart-wrap { flex-direction: column; }
}
