/* neurodigineration training mode — styles.
 * Inherits the scientific-clean look of index.html.  Three-column layout
 * collapses to single-column on narrow viewports. */

:root {
  --ink: #14202b;
  --ink-soft: #3a4a5c;
  --mute: #6a7787;
  --rule: #e3e8ee;
  --rule-strong: #cdd6e0;
  --panel: #f7f9fb;
  --panel-2: #f0f4f8;
  --accent: #0b3b5a;
  --accent-soft: #e6eef5;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --ok: #155724;
  --ok-soft: #d1f0d8;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --bg: #ffffff;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.06);
  --gold: #b45309;
  --gold-soft: #fff7d6;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: 'SF Mono', Menlo, Consolas, 'Roboto Mono', monospace; font-size: 0.92em; }
hr { border: none; border-top: 1px solid var(--rule); margin: 14px 0; }
input, textarea, select, button { font: inherit; color: inherit; }

/* ===== Header ===== */
header.site {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
header.site .row {
  max-width: 1480px; margin: 0 auto;
  padding: 10px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: white;
  display: grid; place-items: center;
  font-family: Georgia, serif; font-weight: 700; font-size: 18px;
}
.brand .name {
  font-size: 17px;
  display: inline-flex; align-items: baseline; gap: 8px;
}
.brand .name em { font-style: normal; color: var(--mute); font-weight: 500; font-size: 13px; }
.pill {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--panel); color: var(--ink-soft); font-weight: 600;
}
.pill.mode-mock { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.mode-live { background: #f4e3ff; color: #5d2c87; border-color: transparent; }
.pill.version { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.spacer { flex: 1; }

.header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-toggle {
  display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
}
.mode-toggle button {
  padding: 6px 12px; background: var(--bg); color: var(--ink-soft);
  border: 0; cursor: pointer; font-size: 13px; font-weight: 500;
}
.mode-toggle button.active { background: var(--accent); color: white; }

.btn {
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--bg);
  color: var(--ink); font-size: 13px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #0a324d; color: white; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg); border: 1px solid var(--rule);
  border-radius: 8px; box-shadow: var(--shadow-2);
  min-width: 220px; z-index: 50; padding: 6px;
  display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button {
  width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  background: transparent; border: none; cursor: pointer;
  font-size: 13px; color: var(--ink);
}
.dropdown-menu button:hover { background: var(--panel); }

/* ===== Layout ===== */
main.app {
  max-width: 1480px; margin: 0 auto;
  display: grid;
  grid-template-columns: 340px 1fr 360px;
  gap: 18px;
  padding: 18px;
}
@media (max-width: 1200px) {
  main.app { grid-template-columns: 1fr; }
}
section.col {
  display: flex; flex-direction: column; gap: 16px;
}
section.card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
section.card > h2 {
  margin: 0 0 10px;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
section.card > h2 .count {
  font-family: 'SF Mono', monospace; font-size: 11px;
  background: var(--panel); padding: 2px 7px; border-radius: 999px;
  color: var(--mute); font-weight: 500;
}
section.card > h2 .badge {
  font-family: -apple-system, sans-serif;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
section.card .sub {
  font-size: 12px; color: var(--mute); margin: -4px 0 10px;
}

/* ===== Left column ===== */
textarea.system-prompt {
  width: 100%; min-height: 280px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55;
  padding: 10px; border: 1px solid var(--rule); border-radius: 8px;
  resize: vertical; background: var(--panel-2);
}
textarea.system-prompt:focus { border-color: var(--accent); background: var(--bg); outline: none; }

.examples-list, .avoid-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 240px; overflow-y: auto;
}
.example-item, .avoid-item {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 12.5px;
}
.example-item .gene {
  font-family: 'SF Mono', monospace;
  font-weight: 600;
  color: var(--accent);
}
.example-item .meta, .avoid-item .meta {
  font-size: 11px; color: var(--mute); margin-top: 3px;
}
.example-item .snippet, .avoid-item .pattern {
  color: var(--ink-soft); margin-top: 4px; line-height: 1.4;
}
.empty-state {
  font-size: 12.5px; color: var(--mute); font-style: italic;
  padding: 8px 0;
}

.rubric-grid {
  display: grid; grid-template-columns: 110px 1fr 40px; gap: 6px 10px;
  font-size: 12.5px; align-items: center;
}
.rubric-grid .name { color: var(--ink-soft); }
.rubric-grid .bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.rubric-grid .bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.rubric-grid .val { font-family: 'SF Mono', monospace; font-size: 11.5px; text-align: right; color: var(--mute); }

/* ===== Center column — brief + rating ===== */
.gene-picker {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px;
}
.gene-picker select, .gene-picker input {
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px;
  font-size: 14px;
}
.gene-picker label { font-size: 12px; color: var(--mute); }

.brief-frame {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 22px 26px;
  background: var(--bg);
  min-height: 320px;
  font-size: 14px;
  line-height: 1.65;
}
.brief-frame.empty { color: var(--mute); font-style: italic; display: grid; place-items: center; min-height: 220px; }
.brief-frame h1 { font-size: 22px; margin: 0 0 8px; font-family: Georgia, serif; }
.brief-frame h2, .brief-frame h3 { font-family: Georgia, serif; }
.brief-frame h2 { font-size: 17px; margin: 18px 0 6px; }
.brief-frame h3 { font-size: 15px; margin: 14px 0 4px; }
.brief-frame p { margin: 8px 0; }
.brief-frame ul { padding-left: 22px; margin: 8px 0; }
.brief-frame strong { color: var(--ink); }
.brief-frame em { font-style: italic; }
.brief-frame code { background: var(--panel); padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }
.brief-meta {
  font-size: 11px; color: var(--mute); margin-top: 6px;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.brief-meta .tag { padding: 2px 7px; border-radius: 999px; background: var(--panel); border: 1px solid var(--rule); }
.brief-meta .tag.live { background: #f4e3ff; color: #5d2c87; border-color: transparent; }
.brief-meta .tag.mock { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.rating-block {
  margin-top: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.rating-block h3 {
  margin: 0 0 12px; font-size: 14px;
  font-family: Georgia, serif;
}
.dim-grid {
  display: grid;
  grid-template-columns: 140px 1fr 30px;
  gap: 10px 14px;
  align-items: center;
}
.dim-grid .dim-name { font-size: 13px; color: var(--ink-soft); }
.dim-grid .dim-name .hint { font-size: 11px; color: var(--mute); font-weight: 400; display: block; }
.dim-grid .stars { display: inline-flex; gap: 4px; }
.dim-grid .star {
  width: 28px; height: 28px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 16px; color: var(--mute);
  transition: all 0.1s;
}
.dim-grid .star:hover { border-color: var(--accent); color: var(--accent); }
.dim-grid .star.selected { background: var(--accent); border-color: var(--accent); color: white; }
.dim-grid .star.in-range { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dim-grid .dim-val { font-family: 'SF Mono', monospace; font-size: 12px; text-align: right; color: var(--mute); }

.rating-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.rating-actions input.comment {
  flex: 1; min-width: 200px;
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px;
}

/* ===== A/B preference mode ===== */
.ab-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 900px) { .ab-pair { grid-template-columns: 1fr; } }
.ab-side {
  border: 2px solid var(--rule); border-radius: 10px;
  padding: 14px 18px; cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
  background: var(--bg);
}
.ab-side:hover { border-color: var(--accent); }
.ab-side.chosen { border-color: var(--ok); background: var(--ok-soft); }
.ab-label { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--mute); font-weight: 700; margin-bottom: 6px; }
.ab-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ===== Right column — panel + metrics ===== */
table.panel-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
table.panel-table th {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--rule);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--mute);
  font-weight: 600;
}
table.panel-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.panel-table td .sym {
  font-family: 'SF Mono', monospace; font-weight: 600; color: var(--accent);
}
table.panel-table td .notes { color: var(--mute); font-size: 11.5px; }
table.panel-table td.actions { text-align: right; white-space: nowrap; }
table.panel-table td.actions button {
  font-size: 11px; padding: 3px 6px; margin-left: 4px;
  background: transparent; border: 1px solid var(--rule); border-radius: 4px;
  color: var(--ink-soft); cursor: pointer;
}
table.panel-table td.actions button:hover { color: var(--accent); border-color: var(--accent); }
table.panel-table td.actions button.del { color: var(--danger); border-color: var(--danger-soft); }

.metric-stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.metric-stat {
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--panel);
}
.metric-stat .n {
  font-size: 20px; font-weight: 600; font-family: Georgia, serif; color: var(--accent);
}
.metric-stat .k {
  font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.05em;
}

.version-timeline {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 240px; overflow-y: auto;
}
.version-row {
  display: flex; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--rule); border-radius: 6px;
  font-size: 12px; background: var(--bg);
}
.version-row .v {
  font-family: 'SF Mono', monospace; font-weight: 600; color: var(--accent);
  min-width: 44px;
}
.version-row .what { color: var(--ink-soft); flex: 1; }
.version-row .when { color: var(--mute); font-size: 11px; }

/* ===== Modal ===== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 32, 43, 0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg); border-radius: 12px; padding: 22px;
  max-width: 480px; width: 90vw;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}
.modal h3 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 18px; }
.modal-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.modal-row label { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.05em; }
.modal-row input, .modal-row textarea, .modal-row select {
  padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px;
}
.modal-row textarea { min-height: 80px; font-family: inherit; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* ===== Toast ===== */
.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.2s ease-out;
  max-width: 460px;
}
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.toast.danger { background: var(--danger); }
.toast.bump { background: var(--accent); border: 2px solid var(--gold); }
@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Key field ===== */
.key-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
}
.key-field input {
  padding: 5px 9px; border: 1px solid var(--rule); border-radius: 6px;
  font-family: 'SF Mono', monospace; font-size: 11.5px;
  min-width: 220px;
}
.key-field .status { font-size: 11px; padding: 2px 7px; border-radius: 999px; }
.key-field .status.ok { background: var(--ok-soft); color: var(--ok); }
.key-field .status.bad { background: var(--danger-soft); color: var(--danger); }
.key-field .status.none { background: var(--panel); color: var(--mute); }

/* ===== SVG charts ===== */
.chart { width: 100%; height: 120px; }
.chart .bar { fill: var(--accent); }
.chart .bar.low { fill: var(--danger); }
.chart .bar.mid { fill: var(--warn); }
.chart .bar.high { fill: var(--ok); }
.chart .label { font-size: 10px; fill: var(--mute); font-family: -apple-system, sans-serif; }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.chart .trend-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .trend-dot { fill: var(--accent); }

/* ===== A/B mode toggle ===== */
.center-mode {
  display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
  font-size: 12px;
}
.center-mode button {
  padding: 6px 10px; background: var(--bg); color: var(--ink-soft);
  border: none; cursor: pointer;
}
.center-mode button.active { background: var(--ink); color: white; }

/* Sub-mode chips inside the Train-connection pane */
.conn-submode {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card, #fff);
}
.conn-submode button {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--ink-soft, #475569);
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, font-weight 0.12s;
}
.conn-submode button.active {
  background: var(--accent, #0b3b5a);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(11, 59, 90, 0.25);
}
.conn-submode button:hover:not(.active) {
  background: rgba(11, 59, 90, 0.08);
  color: var(--ink, #14202b);
}
#conn-aisuggest-list li {
  padding: 8px 12px; border-bottom: 1px solid var(--rule);
  display: flex; gap: 10px; align-items: baseline; cursor: pointer;
  transition: background 0.12s;
}
#conn-aisuggest-list li:hover { background: var(--soft, rgba(0,0,0,0.04)); }
#conn-aisuggest-list li:last-child { border-bottom: none; }
#conn-aisuggest-list .ais-pair {
  font-family: 'SF Mono', 'Menlo', monospace; font-weight: 600;
  color: var(--accent); font-size: 13px; white-space: nowrap;
}
#conn-aisuggest-list .ais-reason {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.4;
}
