/* ============================================================
   VERSE v2 design system — Stripe-style scientific dashboard.
   Light by default, dark via [data-theme="dark"] on <html>.
   Single accent (indigo), soft shadows, monospace for numerics.
   ============================================================ */

:root,
[data-theme="light"] {
  --bg:        #f7f8fa;
  --panel:     #ffffff;
  --panel-2:   #fbfbfd;
  --border:    #e6e8eb;
  --border-2:  #eef0f3;

  --text:      #1a1f36;
  --text-2:    #4f566b;
  --text-dim:  #8792a2;

  --primary:    #635bff;
  --primary-50: #f0f0ff;
  --primary-700:#4b46d4;

  --ok:        #1ea672;
  --ok-bg:     #e3f9ef;
  --warn:      #b86b00;
  --warn-bg:   #fff5d4;
  --error:     #cd3500;
  --error-bg:  #ffe9e3;

  --shadow:    0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(20,30,60,.06);
  --shadow-lg: 0 8px 24px rgba(20,30,60,.10);
  --radius:    10px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg:        #0e1018;
  --panel:     #161922;
  --panel-2:   #1a1e29;
  --border:    #2a2f3d;
  --border-2:  #21253033;

  --text:      #e6e8eb;
  --text-2:    #a4a8b3;
  --text-dim:  #6e7280;

  --primary:    #7c75ff;
  --primary-50: #1e1b3a;
  --primary-700:#9c95ff;

  --ok:        #4ade80;
  --ok-bg:     #0f2e22;
  --warn:      #fbbf24;
  --warn-bg:   #2e2510;
  --error:     #f87171;
  --error-bg:  #3a1f1c;

  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono, code, pre, .num, .id { font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   App shell — sidebar + main column
   ============================================================ */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 22px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border-2);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  display: grid; place-items: center; color: #fff; font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(99,91,255,.35);
  flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

.nav-section {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  font-weight: 500; cursor: pointer; user-select: none;
  font-size: 13px; text-decoration: none;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-50); color: var(--primary-700); }
.nav-item .nav-count { margin-left: auto; font-size: 11px; color: var(--text-dim); }
.nav-item .proj-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.nav-icon { width: 16px; height: 16px; opacity: .9; flex-shrink: 0; }

.sidebar-foot {
  margin-top: auto; padding: 12px 10px;
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--border-2);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd29c, #ff8c5b);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.avatar-name { font-size: 13px; font-weight: 500; color: var(--text); }
.avatar-sub  { font-size: 11px; color: var(--text-dim); }

/* ============================================================
   Main column
   ============================================================ */
.main { padding: 28px 40px; max-width: 1280px; }

.pageheader {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; gap: 20px; flex-wrap: wrap;
}
.h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0; color: var(--text); }
.h1-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  cursor: pointer; box-shadow: var(--shadow);
  font-family: inherit; transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(99,91,255,.4);
}
.btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.btn-nav-back {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
}
.btn-nav-back:hover {
  background: #bae6fd;
  border-color: #38bdf8;
  color: #075985;
}
.btn-upload {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  box-shadow: 0 1px 3px rgba(22,163,74,.35);
}
.btn-upload:hover {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}
[data-theme="dark"] .btn-nav-back {
  background: rgba(14, 165, 233, .16);
  border-color: rgba(125, 211, 252, .42);
  color: #7dd3fc;
}
[data-theme="dark"] .btn-nav-back:hover {
  background: rgba(14, 165, 233, .26);
  border-color: #38bdf8;
  color: #bae6fd;
}
[data-theme="dark"] .btn-upload {
  background: #22c55e;
  border-color: #22c55e;
  color: #052e16;
}
[data-theme="dark"] .btn-upload:hover {
  background: #4ade80;
  border-color: #4ade80;
  color: #052e16;
}
.btn-ghost { box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; pointer-events: none;
}

/* ============================================================
   Stat cards
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.stat-num { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat-sub.up { color: var(--ok); }
.stat-sub.down { color: var(--error); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .app   { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main  { padding: 18px 16px; }
}

/* ============================================================
   Two-column layout
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================================
   Panel / card
   ============================================================ */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
  gap: 8px;
}
.panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.panel-body { padding: 14px 18px; }

/* ============================================================
   Project cards
   ============================================================ */
.proj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 18px; }
.proj-card {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px;
  background: var(--panel); cursor: pointer; transition: box-shadow .12s, transform .12s;
  text-decoration: none; color: inherit; display: block;
}
.proj-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; }
.proj-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.proj-name { font-weight: 600; font-size: 14px; color: var(--text); }
.proj-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.proj-card.empty {
  border-style: dashed; background: transparent; box-shadow: none;
  display: grid; place-items: center; color: var(--text-dim);
  text-align: center; min-height: 90px;
}
.proj-card.empty:hover { border-color: var(--primary); color: var(--primary-700); transform: none; }

/* ============================================================
   Job table
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 11px 18px; text-align: left; font-size: 13px; }
.tbl th {
  font-weight: 500; color: var(--text-dim); text-transform: uppercase;
  font-size: 11px; letter-spacing: .04em; border-bottom: 1px solid var(--border-2);
  background: var(--panel-2);
}
.tbl td { border-bottom: 1px solid var(--border-2); color: var(--text); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--bg); }
.tbl td.id, .tbl td.num { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text-2); }
.project-cell-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 120px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.project-cell-btn:hover {
  border-color: var(--border);
  background: var(--panel-2);
}
.project-cell-btn.is-empty {
  color: var(--text-dim);
}
.project-cell-btn span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-cell-btn.is-empty + .muted {
  display: none;
}
.tbl-empty {
  padding: 28px; text-align: center; color: var(--text-dim); font-size: 13px;
}

/* ============================================================
   Pills
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .03em;
  border: 1px solid transparent;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-done    { background: var(--ok-bg);   color: var(--ok); }
.pill-running { background: var(--primary-50); color: var(--primary-700); }
.pill-queued  { background: var(--warn-bg); color: var(--warn); }
.pill-failed,
.pill-timed_out { background: var(--error-bg); color: var(--error); }
.pill-muted   { background: var(--panel-2); color: var(--text-dim); border-color: var(--border); }

/* ============================================================
   Form
   ============================================================ */
.form-field { display: block; margin-bottom: 12px; }
.form-label {
  font-size: 12px; color: var(--text-2); font-weight: 500;
  margin-bottom: 5px; display: block;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50);
}
.form-textarea { min-height: 110px; font-family: "JetBrains Mono", monospace;
  font-size: 12px; resize: vertical; }

/* The HTML `hidden` attribute is supposed to set display:none, but our
 * .btn rule sets display:inline-flex which has higher specificity than
 * the user-agent default for [hidden]. Force [hidden] to actually hide. */
[hidden] { display: none !important; }

/* File-drop zone. Contains a hidden <input type="file"> + label text only.
 * The "clear" button lives outside the label (see .file-drop-wrap) so we
 * don't get nested-interactive-element focus weirdness. */
.file-drop-wrap { display: flex; flex-direction: column; gap: 8px; }

.file-drop {
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 18px;
  text-align: center; color: var(--text-dim); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s, box-shadow .12s;
  display: block; margin: 0;
}
.file-drop:hover { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.file-drop.has-file { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }

/* Kill ALL default keyboard-focus indicators on every child of the drop
 * zone. They were stacking dashed-line fragments around each text run.
 * Focus is shown once, on the wrapper itself, via :focus-within. */
.file-drop, .file-drop * { outline: none !important; -webkit-tap-highlight-color: transparent; }
.file-drop:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.file-drop-reset {
  font-size: 12px; padding: 4px 10px; height: auto;
  align-self: center;
}

/* Make the drop-zone prompt match the "browse" link color. The size hint
 * below it stays muted because it has class="small muted". */
.file-drop-label { color: var(--primary); font-weight: 500; }
.file-drop:hover .file-drop-label { color: var(--primary-700); }

.divider {
  text-align: center; color: var(--text-dim); font-size: 12px;
  position: relative; margin: 8px 0;
}
.divider::before, .divider::after {
  content: ""; position: absolute; top: 50%; width: 42%;
  border-top: 1px solid var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }
.divider span { background: var(--panel); padding: 0 8px; }

/* Inline error display */
.field-error {
  color: var(--error); font-size: 12px; margin-top: 4px; min-height: 1em;
}

/* ============================================================
   Topbar (used on pages without the sidebar layout, e.g. /share)
   Compatible with the current base.html as we transition.
   ============================================================ */
.topbar-v2 {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.theme-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); width: 30px; height: 30px;
  cursor: pointer; display: grid; place-items: center;
  transition: background .12s, border-color .12s;
}
.theme-toggle:hover { background: var(--bg); }

/* ============================================================
   Toast / inline notice
   ============================================================ */
.notice {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.notice-error { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.notice-ok    { background: var(--ok-bg);    color: var(--ok);    border-color: var(--ok); }
.notice-warn  { background: var(--warn-bg);  color: var(--warn);  border-color: var(--warn); }

/* ============================================================
   Loading spinner (used by HTMX swaps)
   ============================================================ */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* HTMX request indicator: show .htmx-indicator only during requests */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ============================================================
   Job detail page — header, tabs, plot, logbox, file list,
   profile-browser controls. Class names preserved so the
   existing dashboard.js continues to drive this page.
   ============================================================ */

/* Header card — breadcrumb, title, meta, action buttons */
.job-header-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px 24px;
}
.job-header-copy {
  min-width: 0;
}
.crumb { font-size: 12px; color: var(--text-dim); }
.crumb a { color: var(--text-dim); }
.crumb a:hover { color: var(--text); }
.job-title-v2 {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  margin: 4px 0 6px; color: var(--text);
}

/* Editable-title affordance: hovering the wrapper reveals a pencil
 * button next to the title; click (or double-click the title) to rename. */
.job-title-wrap {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.job-title-edit {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); padding: 6px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
.job-title-wrap:hover .job-title-edit { opacity: .75; }
.job-title-edit:hover { opacity: 1 !important; background: var(--bg); color: var(--primary); }
.job-title-input {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 4px 10px; outline: none; font-family: inherit;
  min-width: 280px; max-width: 100%;
}
.job-title-input:focus { box-shadow: 0 0 0 3px var(--primary-50); }
.job-meta-v2 {
  display: flex; gap: 18px; flex-wrap: wrap;
  color: var(--text-dim); font-size: 12px;
}
.job-meta-v2 strong, .job-meta-v2 .num { color: var(--text-2); font-weight: 500; }
.job-header-actions {
  justify-self: end;
  align-self: end;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  max-width: 760px;
}
.job-header-actions .btn {
  min-width: 0;
  min-height: 36px;
  padding: 7px 12px;
  justify-content: center;
  white-space: nowrap;
}
#duplicate-btn { min-width: 124px; }
#compare-btn { min-width: 112px; }
#export-xlsx-btn { min-width: 88px; }
#share-btn { min-width: 78px; }
@media (max-width: 1180px) {
  .job-header-card {
    grid-template-columns: 1fr;
  }
  .job-header-actions {
    justify-self: stretch;
  }
}

/* Tabs (drives dashboard.js tab switching). The button + .tab-panel
 * class names have to match what wireJobPage() looks for. */
.tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 4px;
  border-bottom: 1px solid var(--border-2);
  background: var(--panel-2);
}
.tab {
  padding: 11px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-dim); background: transparent; border: none;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit;
  min-width: 112px;
  text-align: center;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-700); border-bottom-color: var(--primary); background: var(--panel); }
.job-chart-pills {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px 0 10px;
}
.tab-panel { padding: 18px 20px; }

/* Plotly chart container */
.plot { width: 100%; height: 440px; }

/* Pre-formatted log + input boxes */
.logbox {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; font-size: 12px; overflow: auto; max-height: 520px;
  white-space: pre-wrap; word-break: break-word;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  margin: 0;
}

/* Files tab */
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 4px;
  background: var(--panel-2);
  font-family: "JetBrains Mono", monospace; font-size: 12px;
}

/* Profile Browser playback controls (Bo-Chuan loved these — preserve them) */
.profile-controls {
  padding: 6px 0 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.pc-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pc-row-playback .pc-slider {
  flex: 1 1 300px; min-width: 200px; vertical-align: middle;
}
.pc-play {
  width: 36px; height: 32px; padding: 0; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.pc-time {
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
  font-family: "JetBrains Mono", monospace;
}
.pc-field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
}
.pc-field input[type=number] {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 6px; width: 64px; font-size: 12px;
  font-family: "JetBrains Mono", monospace;
}
.pc-field-label { text-transform: uppercase; letter-spacing: 0.05em; }
.pc-field-loop input { margin: 0; }

.pc-view-toggle {
  display: inline-flex; gap: 2px; margin-left: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--panel-2);
}
.pc-view-opt {
  position: relative; padding: 6px 12px; font-size: 12px;
  color: var(--text-dim); cursor: pointer; user-select: none;
  transition: background 0.1s, color 0.1s;
}
.pc-view-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pc-view-opt:hover { color: var(--text); }
.pc-view-opt:has(input:checked) { background: var(--primary); color: #fff; }
.pc-actions {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pc-actions .btn {
  padding: 6px 10px; font-size: 12px; white-space: nowrap;
}

/* ============================================================
   AI/ML workbench
   ============================================================ */
.ai-grid { align-items: start; }
.ai-workbench-form { margin: 0; }
.ai-train-form {
  display: grid;
  grid-template-columns: minmax(160px, .75fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}
.ai-train-form .form-field { margin-bottom: 0; }
.ai-queue-actions {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.ai-job-check { cursor: pointer; }
.ai-sequence-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.ai-sequence-card > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 10px 12px;
}
.ai-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-2);
}
.ai-metrics > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel-2);
}
.importance-list { display: grid; gap: 8px; }
.importance-row {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(120px, 1fr) 56px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.importance-label {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.importance-track {
  height: 8px;
  border-radius: 99px;
  background: var(--border-2);
  overflow: hidden;
}
.importance-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--primary);
}
.importance-num {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
  text-align: right;
}
.ai-token-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ai-compact-table th,
.ai-compact-table td { padding: 9px 12px; }
.ai-details summary {
  cursor: pointer;
  list-style: none;
}
.ai-details summary::-webkit-details-marker { display: none; }
@media (max-width: 900px) {
  .ai-train-form,
  .ai-metrics,
  .ai-sequence-card,
  .importance-row {
    grid-template-columns: 1fr;
  }
  .importance-num { text-align: left; }
}

/* ============================================================
   Modal — used for share-link reveal. Show via .open class.
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); width: 92%; max-width: 480px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.copy-row {
  display: flex; gap: 6px;
}
.copy-row input {
  flex: 1; padding: 8px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-family: "JetBrains Mono", monospace;
}

/* ============================================================
   Builder page — VERSE.exe-style form layout.
   Section headers, two-column field grids, components/initial-
   conditions tables with dynamic rows.
   ============================================================ */
.build-section { margin-bottom: 18px; }
.build-section-h {
  font-size: 13px; font-weight: 700; color: var(--primary-700);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px;
}
.build-section-h .build-help {
  margin-left: auto; font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--text-dim); font-size: 12px;
}
.build-subheader {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 14px 0 8px;
}
.build-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 18px; }
.build-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.build-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.build-row > .form-label { flex: 1; margin: 0; font-weight: 500; color: var(--text); font-size: 13px; }
.build-row > .form-input { flex: 0 0 200px; max-width: 200px; }
/* Selects often hold longer "A: Axial dispersion with CSTRs"-style
 * descriptive options — give them more horizontal room than text inputs. */
.build-row > .form-select { flex: 0 0 280px; max-width: 280px; }
.build-row .build-default-btn {
  font-size: 11px; padding: 4px 10px; height: auto;
  border-radius: var(--radius-sm); white-space: nowrap;
}
.build-row .build-help {
  font-size: 11px; color: var(--text-dim); margin-left: 6px;
}

/* Greek subscript labels */
.build-greek { font-style: italic; }
.build-greek sub { font-style: normal; font-size: 0.8em; }

/* Dynamic table for components / initial concentrations */
.build-table {
  width: 100%; border-collapse: collapse;
  margin-top: 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.build-table th {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.04em; text-align: left;
  padding: 9px 12px; background: var(--panel-2);
  border-bottom: 1px solid var(--border-2); font-weight: 500;
}
.build-table td {
  padding: 6px 12px; border-bottom: 1px solid var(--border-2);
  font-size: 13px;
}
.build-table tbody tr:last-child td { border-bottom: none; }
.build-table input.form-input {
  padding: 5px 8px; font-size: 12px;
}
.build-table .row-num {
  color: var(--text-dim); font-family: "JetBrains Mono", monospace;
  font-size: 12px; width: 28px;
}

/* "Note: not yet generated" tag for sections we display but don't wire */
.build-stub-note {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  background: var(--warn-bg); color: var(--warn);
  border-radius: 99px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* Sticky submit bar at the bottom of the build page */
.build-submit-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky; bottom: 14px; z-index: 20;
  margin-top: 18px;
}
.build-submit-bar .form-error { flex: 1; margin: 0; color: var(--error); font-size: 13px; }

/* ============================================================
   Compare bay — sticky bottom bar that surfaces the running
   selection of jobs to compare. Hidden when count = 0.
   ============================================================ */
.compare-bay {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 99px; padding: 8px 8px 8px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg); z-index: 50;
  transition: opacity .15s, transform .15s;
}
.compare-bay[hidden] { display: none !important; }
.compare-bay-count {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.compare-bay-sub {
  font-size: 12px; color: var(--text-dim);
}

/* Compare-page selected-run chips */
.chip-row {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 4px 6px 10px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  transition: background .12s, border-color .12s;
}
.chip-row:hover { background: var(--bg); border-color: var(--text-dim); text-decoration: none; }
.chip-dot { width: 8px; height: 8px; border-radius: 2px; }
.chip-name { font-weight: 500; font-size: 13px; }
.chip-id   { color: var(--text-dim); }
.chip-remove {
  border: none; background: transparent; color: var(--text-dim);
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 11px; display: grid; place-items: center;
  transition: background .12s, color .12s;
}
.chip-remove:hover { background: var(--error-bg); color: var(--error); }

/* Job-row checkbox column on the dashboard's recent jobs table.
 * Stop the row's onclick from navigating when the checkbox is clicked. */
.tbl td.row-check { width: 32px; padding-right: 0; }
.tbl input[type=checkbox].row-check-input {
  cursor: pointer;
  /* Make the click target slightly larger than the visible box */
  margin: 0; padding: 6px;
}

/* ============================================================
   Utility helpers
   ============================================================ */
.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.flex  { display: flex; align-items: center; gap: 8px; }
.flex-end { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.no-margin { margin: 0; }
