/* Interactive neuron lab demos */
.demo-panel {
  margin: 1.6rem 0 2rem;
  padding: 1.2rem 1.3rem 1.4rem;
  background: var(--diagram-bg, #f7f9fb);
  border: 1px solid var(--line, #d5dbe3);
  border-radius: 14px;
  font-family: var(--sans, "Manrope", sans-serif);
}

.demo-plot-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.6rem;
  margin-bottom: 1rem;
}

.demo-main-plot {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
  touch-action: none;
}

.demo-sub-plot {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
}

.demo-plots-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.demo-plots-row .demo-plot-box {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .demo-plots-row { grid-template-columns: 1fr; }
}

.demo-weights-panel {
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}

.demo-weights-title {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.demo-weights-sub {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.demo-neuron-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}

.demo-neuron-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--nc, #0f6e6a);
  border-radius: 10px;
  padding: 0.65rem 0.75rem 0.5rem;
}

.demo-neuron-card--solo {
  max-width: 280px;
}

.demo-neuron-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
  gap: 0.5rem;
}

.demo-neuron-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
}

.demo-neuron-live {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.demo-neuron-sliders .demo-row {
  grid-template-columns: 3.5rem 1fr 2.8rem;
  font-size: 0.8rem;
  gap: 0.35rem;
}

.demo-check {
  margin: 0.25rem 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.demo-check label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.demo-mode-btns {
  margin-bottom: 0.75rem;
}

.demo-mode-btns button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.demo-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent, #0f6e6a);
}

.demo-hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted, #5c6775);
  line-height: 1.45;
}

.demo-grid {
  display: grid;
  gap: 1rem;
}

.demo-grid-2 {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 720px) {
  .demo-grid-2 { grid-template-columns: 1fr; }
}

.demo-canvas-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  overflow: auto;
}

.demo-canvas-wrap canvas,
.demo-canvas-wrap svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.demo-plot-caption {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  text-align: center;
}

.demo-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.demo-row {
  display: grid;
  grid-template-columns: 7rem 1fr 3.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.demo-row label {
  color: var(--muted);
  font-weight: 600;
}

.demo-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.demo-row .val {
  font-family: var(--mono, monospace);
  font-size: 0.8rem;
  text-align: right;
}

.demo-formula {
  margin: 0.8rem 0 0;
  padding: 0.65rem 0.85rem;
  background: var(--code-bg, #f0f3f7);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
}

.demo-out {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.demo-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.demo-btns button,
.demo-btns select {
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.demo-btns button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.demo-btns button:hover { filter: brightness(0.97); }

.demo-neuron-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.demo-chip {
  padding: 0.25rem 0.55rem;
  background: var(--accent-soft, #d8efed);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.demo-goal-box {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
}

.demo-goal-box strong { color: var(--accent); }

.demo-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

@media (max-width: 520px) {
  .demo-compare { grid-template-columns: 1fr; }
}

.demo-compare-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.demo-compare-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.demo-bar-wrap {
  height: 10px;
  background: #eceff3;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.demo-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.2s ease;
}

.demo-bar-fill--pred { background: var(--accent); }
.demo-bar-fill--target { background: #c0392b; }

.demo-backprop-flow {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
}

.demo-backprop-flow .flow-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0.2rem 0;
}

.demo-backprop-flow .flow-arrow {
  color: var(--muted);
  font-family: var(--sans);
}

.demo-grad-chip {
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  background: #f0f3f7;
  white-space: nowrap;
}

.demo-grad-chip.pos { background: #d8efed; color: #0a524f; }
.demo-grad-chip.neg { background: #fde8e4; color: #8b2e1f; }

.demo-result-box {
  margin-top: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--code-bg, #f0f3f7);
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.55;
}

.demo-neuron-card.is-learning .demo-neuron-sliders input[type="range"] {
  pointer-events: none;
  opacity: 0.85;
}

.demo-neuron-grad {
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.45;
}

.demo-class-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.demo-class-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cc, var(--accent));
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cc, var(--accent));
}

.demo-kernel-panel {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0.85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.demo-kernel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  max-width: 300px;
  margin-top: 0.5rem;
}

.demo-kernel-cell {
  text-align: center;
}

.demo-kernel-cell label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
  font-family: var(--mono);
}

.demo-kernel-cell input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.demo-kernel-val {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.demo-xor-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 1.25rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

@media (max-width: 520px) {
  .demo-xor-layout { grid-template-columns: 1fr; }
}

.demo-xor-map {
  display: block;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.demo-truth-wrap {
  min-width: 0;
}

.demo-truth-table {
  width: 100%;
  max-width: 320px;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.demo-truth-table th,
.demo-truth-table td {
  padding: 0.55rem 0.65rem;
  text-align: center;
  border: 1px solid var(--line);
  font-family: var(--mono);
  line-height: 1.4;
}

.demo-truth-table th {
  background: #f0f3f7;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--muted);
}

.demo-truth-table td.cell-ok {
  background: #d8efed;
  color: #0a524f;
}

.demo-truth-table td.cell-bad {
  background: #fde8e4;
  color: #8b2e1f;
}

.demo-truth-table td.cell-active {
  outline: 2px solid #b86a1a;
  outline-offset: -2px;
}
