:root {
  --bg: #0b1220;
  --panel: #162337;
  --panel-alt: #1c2d45;
  --accent: #33c4ff;
  --accent-soft: #2d8cff;
  --success: #62f2b8;
  --danger: #ff7f7f;
  --text: #f6f8ff;
  --muted: #9aa6c0;
  --border: rgba(255, 255, 255, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(8, 15, 30, 0.45);
  --font-ui: "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Consolas", "Fira Code", "Source Code Pro", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top, #101d33 0%, #090f1a 60%);
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font-family: inherit;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(6px, 1.6vw, 14px) clamp(16px, 3.5vw, 32px);
  background: linear-gradient(135deg, rgba(28, 44, 72, 0.85), rgba(19, 30, 52, 0.95));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(22px, 2.1vw, 32px);
  letter-spacing: 0.02em;
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 1.6vw, 18px);
  font-size: clamp(13px, 1.2vw, 17px);
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
  gap: clamp(10px, 2.2vw, 20px);
  padding: clamp(6px, 1.8vw, 14px);
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.stage {
  background: rgba(15, 24, 40, 0.76);
  border-radius: var(--radius-lg);
  padding: clamp(10px, 1.6vw, 14px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr) auto;
  row-gap: clamp(6px, 1.2vw, 11px);
  min-height: 0;
}


.network-area {
  position: relative;
  width: 100%;
  height: 100%;
}

.edge-label {
  fill: rgba(246, 251, 255, 0.98);
  font-size: clamp(13px, 1.3vw, 14px);
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(5, 10, 20, 0.6);
  stroke-width: 3px;
  transition: all 0.3s ease;
}

/* SVG elements smooth transitions */
#network-svg path {
  transition: stroke-width 0.4s ease, stroke 0.4s ease;
}

#network-svg circle {
  transition: fill 0.4s ease, r 0.2s ease;
}

#network-svg text {
  transition: fill 0.3s ease;
}

/* Node glow effects */
.node circle {
  filter: drop-shadow(0 0 8px rgba(98, 242, 184, 0.3));
}

.bias-node circle {
  filter: drop-shadow(0 0 6px rgba(255, 193, 7, 0.4));
}

/* Hover effects for nodes */
.node:hover circle,
.bias-node:hover circle {
  transform-origin: center;
  animation: pulse 0.6s ease infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Layer labels */
.layer-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.6;
}

.pill-toggle {
  display: inline-flex;
  background: rgba(26, 44, 70, 0.9);
  border-radius: 999px;
  padding: 6px;
  gap: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.pill-toggle button {
  all: unset;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
  color: var(--muted);
}

.pill-toggle button:hover {
  transform: translateY(-1px);
}

.pill-toggle button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #091021;
  font-weight: 600;
}


.node-toggle {
  position: absolute;
  left: clamp(8px, 3.6vw, 72px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.node-toggle__label {
  font-size: clamp(12px, 1.3vw, 14px);
  color: var(--muted);
}

.node-toggle-a {
  top: 24%;
  transform: translateY(-50%);
}

.node-toggle-b {
  top: 76%;
  transform: translateY(-50%);
}

#network-svg {
  width: 100%;
  height: 100%;
  min-height: clamp(320px, 36vh, 420px);
  max-height: 480px;
  align-self: stretch;
  background: radial-gradient(circle at top, #1b2c45, #101828 70%);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.insight-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(8px, 1.8vw, 14px);
  min-height: 0;
}

.narrative,
.predictions {
  background: rgba(21, 34, 54, 0.9);
  border-radius: var(--radius-md);
  padding: clamp(6px, 1.2vw, 12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.narrative h2,
.predictions h2 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: clamp(16px, 1.8vw, 20px);
}

.narrative p {
  font-size: clamp(13px, 1.3vw, 15px);
  line-height: 1.4;
  color: var(--muted);
  white-space: pre-line;
}

.predictions table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(13px, 1.4vw, 15px);
}

.predictions th,
.predictions td {
  text-align: left;
  padding: 5px 4px;
  color: var(--muted);
}

.predictions tbody tr {
  transition: background 0.2s ease;
}

.predictions tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.2vw, 16px);
  max-width: 340px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
}

.muted {
  color: var(--muted);
}

.card {
  background: rgba(21, 34, 54, 0.9);
  border-radius: var(--radius-lg);
  padding: clamp(10px, 1.6vw, 16px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: clamp(18px, 2vw, 22px);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.button-row button,
#reset-button {
  padding: 9px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: clamp(13px, 1.4vw, 15px);
  background: var(--accent);
  color: #091021;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 25px rgba(51, 196, 255, 0.25);
}

.button-row button:hover,
#reset-button:hover {
  transform: translateY(-2px);
}

#reset-button {
  margin-top: 12px;
  width: 100%;
  background: var(--danger);
  color: #140808;
  box-shadow: 0 10px 25px rgba(255, 127, 127, 0.25);
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: clamp(13px, 1.5vw, 15px);
  color: var(--muted);
}

#learning-rate {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  font-size: clamp(13px, 1.4vw, 15px);
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

#error-sparkline {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 90px;
  background: #111a2a;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 12px;
}

.info-card p {
  font-size: clamp(14px, 1.6vw, 16px);
  line-height: 1.6;
  color: var(--muted);
}

.footnote {
  padding: 6px clamp(16px, 3.2vw, 28px);
  color: rgba(255, 255, 255, 0.45);
  font-size: 13px;
  text-align: center;
}

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

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .card {
    flex: 1 1 min(360px, 100%);
  }
}

@media (max-width: 680px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .status {
    width: 100%;
    justify-content: space-between;
  }

  .input-toggles {
    justify-content: flex-start;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  #network-svg {
    height: clamp(260px, 60vw, 420px);
  }
}
.stage > .input-toggles,
.stage > #network-svg,
.stage > .insight-tray {
  flex: 0 0 auto;
}

.stage > #network-svg {
  flex: 1 1 0;
}

/* Tooltip styling */
.tooltip {
  position: absolute;
  background: rgba(15, 24, 40, 0.98);
  border: 1px solid rgba(98, 242, 184, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  max-width: 300px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip-title {
  font-weight: 600;
  color: var(--success);
  margin-bottom: 6px;
  font-size: 14px;
}

.tooltip-content {
  color: var(--muted);
  line-height: 1.5;
}

.tooltip-value {
  color: var(--accent);
  font-weight: 600;
}
