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

:root {
  --burgundy:   #3f74d4;
  --burgundy-l: #6494e8;
  --burgundy-d: #16294e;
  --bg:         #0a101c;
  --surface:    #141f36;
  --surface-2:  #1a2a4a;
  --border:     #22304d;
  --border-l:   #2c3b5e;
  --text:       #e9eef8;
  --muted:      #6e7f9d;
  --dim:        #9fb0cb;
  --radius:     10px;
}

body {
  font-family: 'Public Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-logo  { display: flex; align-items: center; gap: .65rem; }
.header-title { font-size: .95rem; font-weight: 600; }
.header-sub   { font-size: .72rem; color: var(--muted); }

.header-link {
  display: flex; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--muted);
  text-decoration: none; transition: color .2s;
}
.header-link:hover { color: var(--text); }

/* ── Main layout ─────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
  min-height: 0;
}

/* ── Controls panel ──────────────────────────────────────────────────── */
.controls {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ctrl-section { display: flex; flex-direction: column; gap: .6rem; }

.ctrl-section-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
}

.control-group { display: flex; flex-direction: column; gap: .35rem; }

.control-label {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: .45rem .65rem;
  font-family: inherit;
  font-size: .83rem;
  outline: none;
  transition: border-color .2s;
  cursor: pointer;
  width: 100%;
}
select:focus { border-color: var(--burgundy-d); }

.range-wrap   { display: flex; flex-direction: column; gap: .25rem; }
.range-row    { display: flex; justify-content: space-between; align-items: center; }
.range-val    { font-size: .78rem; font-family: 'JetBrains Mono', monospace; color: var(--burgundy-l); }
.range-limits { font-size: .65rem; color: var(--muted); display: flex; justify-content: space-between; }

input[type=range] { width: 100%; accent-color: var(--burgundy); cursor: pointer; }

/* ── Architecture builder ─────────────────────────────────────────────── */
.arch-fixed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .78rem;
}

.arch-fixed-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.arch-fixed-count { color: var(--dim); font-family: 'JetBrains Mono', monospace; font-size: .72rem; }

.arch-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: .4rem;
  padding: .3rem .3rem .3rem .55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: .3rem;
}

.arch-row-label {
  font-size: .75rem;
  color: var(--dim);
  white-space: nowrap;
}

.arch-neuron-ctrl {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.arch-btn {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border-l);
  background: var(--surface-2);
  color: var(--text);
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
.arch-btn:hover:not(:disabled) { border-color: var(--burgundy-d); background: #16294e; }
.arch-btn:disabled { opacity: .35; cursor: not-allowed; }

.arch-count {
  width: 28px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  color: var(--burgundy-l);
}

.arch-rm {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: .7rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.arch-rm:hover { color: #f87171; border-color: #3d1515; }

.arch-rm-placeholder { width: 20px; height: 20px; flex-shrink: 0; }

.add-layer-btn {
  width: 100%;
  padding: .4rem;
  border-radius: 6px;
  border: 1px dashed var(--border-l);
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  cursor: pointer;
  font-family: inherit;
  transition: color .2s, border-color .2s;
  margin-top: .15rem;
}
.add-layer-btn:hover:not(:disabled) { color: var(--text); border-color: var(--burgundy-d); }
.add-layer-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Metrics ─────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .4rem;
  text-align: center;
}
.metric-val {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--burgundy-l);
  min-height: 1.4em;
}
.metric-lbl {
  font-size: .6rem;
  color: var(--muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Progress bar ─────────────────────────────────────────────────────── */
.progress-wrap { }
.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--burgundy);
  border-radius: 2px;
  transition: width .15s linear;
}

/* ── Train button ─────────────────────────────────────────────────────── */
.train-btn {
  width: 100%;
  padding: .7rem;
  background: var(--burgundy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
  letter-spacing: .02em;
}
.train-btn:hover:not(:disabled) { background: var(--burgundy-l); }
.train-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Right panel ─────────────────────────────────────────────────────── */
.right-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ── Network diagram ─────────────────────────────────────────────────── */
.net-diagram-box {
  flex-shrink: 0;
  height: 195px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem .5rem;
  display: flex;
  flex-direction: column;
}

.panel-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .5rem;
  flex-shrink: 0;
}

.net-svg {
  flex: 1;
  width: 100%;
  min-height: 0;
}

/* ── Plots ───────────────────────────────────────────────────────────── */
.plots {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  min-height: 0;
  overflow: hidden;
}

.plot-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.plot-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .6rem;
  flex-shrink: 0;
}

.plot-inner { flex: 1; min-height: 0; }
