:root {
  --bg: #0e1116;
  --panel: #151a22;
  --panel-2: #1b222d;
  --border: #2a3341;
  --text: #e8edf5;
  --muted: #8b97a8;
  --accent: #3d9cf0;
  --good: #2fbe7b;
  --warn: #d4a017;
  --bad: #e2584d;
  --sidebar-w: 220px;
  --msg-background: #666;
  --top-h: 56px;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
  /* Flat semi-transparent scrollbars (Firefox) */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
}

/* Flat semi-transparent scrollbars — Chromium / Safari */
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 65%, transparent);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.topbar {
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #141922, var(--bg));
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: #1e3a5f;
  color: var(--accent);
  font-weight: 700;
}
.brand-title { font-weight: 650; font-size: 14px; }
.brand-sub { color: var(--muted); font-size: 14px; }
.topbar-meta { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }

.field { display: flex; align-items: center; gap: 0.35rem; color: var(--muted); }
.field input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: var(--mono);
  font-size: 16px;
}
.field.compact input { width: 90px; }
#oracleUrl { width: min(200px, 28vw); }
#apiKey { width: min(200px, 28vw); }

.btn {
  background: var(--accent);
  color: #041018;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost.btn-danger {
  color: var(--bad, #e85d5d);
  border-color: color-mix(in srgb, var(--bad, #e85d5d) 45%, var(--border));
}
.btn-ghost.btn-danger:hover {
  filter: none;
  background: color-mix(in srgb, var(--bad, #e85d5d) 14%, transparent);
  color: var(--bad, #e85d5d);
}
.btn.btn-danger {
  background: color-mix(in srgb, var(--bad, #e85d5d) 88%, #000);
  border-color: color-mix(in srgb, var(--bad, #e85d5d) 70%, var(--border));
  color: #fff;
}
.btn.btn-danger:hover {
  filter: brightness(1.06);
}
.btn.btn-danger:disabled {
  opacity: 0.55;
  filter: none;
}
.lab-delete-list {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.75rem;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2, var(--panel));
  font-size: 16px;
  line-height: 1.45;
}
.lab-delete-list li + li {
  margin-top: 0.25rem;
}
.sidebar-head-actions .btn-icon svg {
  display: block;
}
.btn-xs { padding: 0.2rem 0.45rem; font-size: 14px; }

.strategy-label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-help {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.btn-help:hover {
  color: var(--text);
  border-color: var(--accent);
}

.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, 0.72);
}
.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(70vh, 520px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  padding: 1rem 1.1rem 0.9rem;
}
.modal-card-wide {
  width: min(580px, 100%);
  max-height: min(90vh, 720px);
}
.modal-card-tape {
  width: min(960px, 100%);
  max-height: min(92vh, 860px);
}
.modal-card-indicators {
  width: min(920px, 96vw);
  max-height: min(92vh, 880px);
  display: flex;
  flex-direction: column;
}
.modal-card-indicators .lab-indicators-table-wrap {
  flex: 1 1 auto;
  min-height: 12rem;
  max-height: min(72vh, 40rem);
}
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.settings-group {
  padding: 0.75rem 0.8rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel, #1a1d24) 92%, #000);
}
.settings-group h4,
.settings-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}
.settings-help {
  margin: 0 0 0.65rem;
  font-size: 16px;
  line-height: 1.4;
}
.settings-venue {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed color-mix(in srgb, var(--border) 80%, transparent);
}
.settings-venue:first-of-type {
  margin-top: 0.25rem;
  padding-top: 0;
  border-top: none;
}
.settings-venue-title {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.think-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0 0 0.45rem;
}
.think-stage-head .settings-venue-title {
  margin: 0;
}
.settings-field {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  align-items: center;
}
.settings-field-wide {
  grid-template-columns: 64px 1fr;
}
.llm-model-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  align-items: center;
}
.llm-model-row > span {
  color: var(--muted);
}
.llm-model-input-wrap {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}
.llm-model-input-wrap input,
.llm-model-input-wrap select {
  flex: 1;
  min-width: 0;
}
.settings-field input,
.settings-field select {
  width: 100%;
  min-width: 0;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}
.think-stage-list {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin: 0 0 0.45rem;
}
.think-stage {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.84rem;
  line-height: 1.35;
  cursor: pointer;
}
.think-stage input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.think-stage small {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}
.settings-pre {
  margin: 0.5rem 0 0;
  max-height: 9rem;
  overflow: auto;
  padding: 0.45rem 0.55rem;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  background: color-mix(in srgb, var(--panel, #1a1d24) 88%, #000);
  border-radius: 6px;
}
#liveRuntimeHint,
.live-runtime-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  width: 1.9rem;
  height: 1.9rem;
  color: var(--muted);
  flex-shrink: 0;
  box-sizing: border-box;
}
.live-runtime-hint svg {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.live-runtime-hint.is-cloud {
  color: var(--accent, #3d9cf0);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.modal-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}
.modal-body {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  gap: 0.5rem;
}
.modal-foot-split {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.modal-foot-left,
.modal-foot-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.modal-card-code {
  width: min(960px, 96vw);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
}
.strategy-code-hint {
  margin: 0 0 0.5rem;
  font-size: 16px;
  line-height: 1.35;
}
.strategy-code-path-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  min-width: 0;
}
.strategy-code-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel, #1a1d24) 88%, #000);
  user-select: all;
  cursor: text;
}
.strategy-code-status {
  margin: 0.45rem 0 0;
  font-size: 16px;
  line-height: 1.35;
  min-height: 1.2em;
  white-space: pre-wrap;
  word-break: break-word;
}
.strategy-code-status.is-ok {
  color: var(--good, #3dba7a);
}
.strategy-code-status.is-err {
  color: var(--bad, #e85d5d);
}
.strategy-code-status.is-busy {
  color: var(--muted);
}
.strategy-code-editor {
  flex: 1 1 auto;
  min-height: min(62vh, 560px);
  width: 100%;
  resize: vertical;
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 14px;
  line-height: 1.45;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel, #1a1d24) 82%, #000);
  color: var(--text);
  tab-size: 2;
}

.pill {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 14px;
  border: 1px solid var(--border);
}
.pill-off { color: var(--muted); }
.pill-on { color: var(--good); border-color: #245c42; background: #143326; }
.pill-err { color: var(--bad); border-color: #5c2a26; background: #2a1614; }
.pill-quota {
  font-family: var(--mono);
  background: var(--panel-2);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-quota.exhausted {
  border-color: #c44;
  color: #f88;
}
.pill-quota.low {
  color: var(--bad);
  border-color: #5c2a26;
  background: #2a1614;
}
.oracle-quota-panel {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 16px;
  line-height: 1.45;
}
.oracle-quota-panel .settings-help {
  margin: 0.35rem 0 0;
}

.shell-panel {
  height: calc(100% - var(--top-h));
  min-height: 0;
}
.btn-ui-shell {
  font-weight: 650;
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.btn-ui-shell:hover {
  color: var(--accent);
  border-color: var(--accent);
}
body.shell-lab .btn-ui-shell {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

/* —— Laboratory shell (phase O) —— */
.lab-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1.35fr) minmax(260px, 0.9fr);
  height: 100%;
  min-height: 0;
}
.lab-sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lab-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.lab-sidebar-sort {
  padding: 0.35rem 0.75rem 0.15rem;
  font-size: 14px;
}
.lab-strategy-list {
  flex: 1;
  overflow: auto;
  padding: 0.35rem 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.lab-strategy-list.is-locked {
  opacity: 0.62;
}
.lab-strategy-list.is-locked .lab-strat-item:not(.active) {
  cursor: not-allowed;
  opacity: 0.55;
}
.lab-strategy-list.is-locked .lab-strat-item:not(.active):hover {
  background: transparent;
  border-color: transparent;
}
.lab-strat-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  font: inherit;
}
.lab-strat-item:hover {
  background: var(--panel-2);
  border-color: var(--border);
}
.lab-strat-item:disabled {
  cursor: not-allowed;
}
.lab-strat-item.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.lab-strat-file {
  display: block;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.3;
}
.lab-strat-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}
.lab-code-pane,
.lab-chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.lab-code-pane {
  border-right: 1px solid var(--border);
  position: relative;
}
.lab-view-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}
.lab-view-btn.is-active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.lab-code-pane:not(.is-flow-view) #btnLabStrategyBrief {
  display: none;
}
.modal-card-brief {
  width: min(640px, 94vw);
  max-height: 85vh;
}
.lab-brief-meta {
  margin: 0 0 0.75rem;
  font-size: 13px;
}
.lab-brief-body {
  max-height: 58vh;
  overflow: auto;
  font-size: 15px;
  font-weight: 200;
  letter-spacing: 1px;
  line-height: 1.75;
}
.lab-brief-body .lab-chat-md-p,
.lab-brief-body .lab-chat-md-h,
.lab-brief-body .lab-chat-md-h2,
.lab-brief-body .lab-chat-md-h3,
.lab-brief-body .lab-chat-md-h4 {
  font-size: 15px;
  font-weight: 200;
  letter-spacing: 1px;
}
.lab-brief-body .lab-chat-md-p {
  margin: 0 0 0.85rem;
  line-height: 1.75;
}
.lab-brief-body .lab-chat-md-h {
  margin: 1.15rem 0 0.5rem;
}
.lab-brief-body .lab-chat-md-code {
  letter-spacing: 0;
}
.lab-brief-body .lab-chat-md-h:first-child {
  margin-top: 0;
}
.lab-flow-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 20% 0%, #1a2230 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, #1c1828 0%, transparent 50%),
    var(--bg);
}
.lab-flow-canvas {
  flex: 1;  
  min-height: 0;
  overflow: auto;
  padding: 0.75rem 1rem 1.25rem;
}
@media (hover: hover) and (pointer: fine) {
  .lab-flow-canvas.is-flow-nav {
    cursor: grab;
  }
  .lab-flow-canvas.is-flow-nav.is-panning {
    cursor: grabbing;
    user-select: none;
  }
  .lab-flow-canvas.is-picking,
  .lab-flow-canvas.is-picking.is-flow-nav {
    cursor: default;
  }
  .lab-flow-canvas.is-picking .sf-node {
    cursor: pointer;
  }
}
#btnLabPickBlock.is-active {
  border-color: var(--accent-hover, #f0b90b);
  color: var(--text);
  background: var(--warning-bg, rgba(240, 185, 11, 0.12));
}
.lab-flow-canvas .strategy-flow-svg {
  display: block;
  margin: 0;
  max-width: none;
  font-family: var(--font);
}
.lab-flow-canvas .sf-node-label,
.lab-flow-canvas .sf-edge-label,
.lab-flow-canvas .sf-title {
  font-family: var(--font);
  user-select: none;
}
.lab-flow-status {
  flex-shrink: 0;
  margin: 0;
  padding: 0.35rem 0.75rem 0.55rem;
  font-size: 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.lab-flow-status.err {
  color: var(--bad);
}
.lab-chat-deliverable {
  list-style: none;
  margin: 0.65rem 0 0.25rem;
  padding: 0.45rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-2) 80%, transparent);
}
.lab-chat-deliverable li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 14px;
  line-height: 1.35;
}
.lab-chat-deliverable .lab-check {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.lab-chat-deliverable li.ok {
  color: color-mix(in srgb, var(--good) 85%, var(--text));
}
.lab-chat-deliverable li.ok .lab-check {
  background: color-mix(in srgb, var(--good) 22%, transparent);
  color: var(--good);
}
.lab-chat-deliverable li.warn {
  color: color-mix(in srgb, var(--warn) 88%, var(--text));
}
.lab-chat-deliverable li.warn .lab-check {
  background: color-mix(in srgb, var(--warn) 22%, transparent);
  color: var(--warn);
}
.lab-chat-deliverable li.bad {
  color: color-mix(in srgb, var(--bad) 88%, var(--text));
}
.lab-chat-deliverable li.bad .lab-check {
  background: color-mix(in srgb, var(--bad) 22%, transparent);
  color: var(--bad);
}
.lab-chat-deliverable li.muted {
  color: var(--muted);
}
.lab-chat-deliverable li.muted .lab-check {
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
}
.lab-code-pane.is-flow-view .lab-code-editor,
.lab-code-pane.is-flow-view #labCodeStatus {
  display: none;
}
.lab-code-pane.is-flow-view .lab-flow-pane {
  display: flex;
}
.lab-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}
.lab-pane-titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.lab-pane-titles strong {
  font-size: 15px;
}
.lab-code-path {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(48vw, 520px);
}
.lab-pane-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.lab-code-editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: none;
  resize: none;
  background: #0c0f14;
  color: #d7e0ec;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  tab-size: 2;
}
.lab-code-editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.lab-code-status {
  margin: 0;
  padding: 0.35rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 14px;
  white-space: pre-wrap;
  max-height: 4.5rem;
  overflow: auto;
  flex-shrink: 0;
  background: var(--panel);
}
.lab-code-status.is-ok { color: var(--good); }
.lab-code-status.is-err { color: var(--bad); }
.lab-code-status.is-busy { color: var(--warn); }
.lab-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.lab-chat-placeholder {
  max-width: 28rem;
  line-height: 1.45;
  font-size: 16px;
}
.lab-chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 95%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: #cfcdcd;
  border: 1px solid #484848;
  font-size: 14px;
  line-height: 1.62;
  white-space: normal;
  word-break: break-word;
}
.lab-chat-text {
  line-height: 1.62;
}
.lab-chat-md-p {
  margin: 0 0 0.65rem;
}
.lab-chat-md-p:last-child {
  margin-bottom: 0;
}
.lab-chat-md-caution {
  margin: 0.85rem 0 0.9rem;
  padding: 0.7rem 0.8rem 0.75rem;
  border: 1px solid color-mix(in srgb, #fcd535 62%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, #fcd535 14%, transparent);
}
.lab-chat-md-caution-label {
  display: inline-block;
  margin: 0 0 0.4rem;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #181a20;
  background: #fcd535;
}
.lab-chat-md-caution .lab-chat-md-p {
  margin: 0;
}
.lab-chat-md-h {
  margin: 0.85rem 0 0.45rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}
.lab-chat-md-h:first-child {
  margin-top: 0;
}
.lab-chat-md-h2 { font-size: 1.05rem; }
.lab-chat-md-h3 { font-size: 0.98rem; }
.lab-chat-md-h4 { font-size: 0.94rem; }
.lab-chat-md-code {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  color: #181a20;
  font-weight: 500;
  border-radius: 4px;
  background: color-mix(in srgb, #ffd656 85%, var(--border));
}
.lab-chat-md-ul,
.lab-chat-md-ol {
  margin: 0.35rem 0 0.65rem;
  padding-left: 1.25rem;
}
.lab-chat-md-ul li,
.lab-chat-md-ol li {
  margin: 0.35rem 0;
  line-height: 1.55;
}
.lab-chat-md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}
.lab-chat-md-table-wrap {
  overflow-x: auto;
  margin: 0.65rem 0;
  max-width: 100%;
}
.lab-chat-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}
.lab-chat-md-table th,
.lab-chat-md-table td {
  border: 1px solid var(--muted);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.lab-chat-md-table th {
  background: var(--panel-2);
  font-weight: 600;
}
.lab-chat-md-table td code.lab-chat-md-code {
  font-size: 12px;
}
.lab-chat-bubble.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--msg-background) 14%, var(--panel));
}
.lab-chat-bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
}
.lab-chat-bubble.system,
.lab-chat-bubble.error {
  align-self: stretch;
  background: unset;
  border-color: #8f98a1;
  color: #d2e0ef;
}
.lab-chat-role {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.lab-chat-tokens {
  margin-top: 0.45rem;
  font-size: 14px;
  line-height: 1.35;
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
}
.lab-chat-apply {
  margin-top: 0.45rem;
  align-self: flex-start;
}
.lab-chat-build {
  margin-top: 0.55rem;
  margin-right: 0.4rem;
  align-self: flex-start;
  font-weight: 500;
  min-width: 7.5rem;
}
.lab-chat-drop-plan {
  margin-top: 0.55rem;
  vertical-align: middle;
  opacity: 0.75;
}
.lab-chat-applied {
  margin-top: 0.45rem;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.9;
}
.lab-next-chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
  align-self: flex-start;
}
.lab-next-chip {
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.3;
  font-family: inherit;
}
.lab-next-chip:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--panel-2));
  border-color: var(--accent);
}
.lab-chat-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  margin-top: 0.35rem;
  align-self: stretch;
}
.lab-chat-actions-retry {
  justify-content: flex-start;
}
.lab-chat-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    background 0.15s ease;
}
.lab-chat-bubble:hover .lab-chat-action,
.lab-chat-action:focus-visible {
  opacity: 1;
}
.lab-chat-action:hover {
  color: var(--text);
  border-color: var(--border);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}
.lab-chat-action.is-copied {
  opacity: 1;
  color: var(--accent, #3d8bfd);
}
.lab-chat-action-svg {
  width: 0.9rem;
  height: 0.9rem;
  display: block;
}
.lab-chat-retry {
  margin-top: 0;
}
.lab-chat-bubble.system .lab-chat-retry {
  border-color: color-mix(in srgb, var(--accent, #3d8bfd) 40%, var(--border));
}
.lab-chat-thinking {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  margin-top: 0.15rem;
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent, #3d8bfd) 40%, var(--border));
  background: color-mix(in srgb, var(--accent, #3d8bfd) 12%, var(--panel));
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  max-width: 95%;
  min-width: min(280px, 92%);
}
.lab-chat-thinking-pct {
  font-weight: 600;
  color: var(--accent, #3d8bfd);
  min-width: 2.4em;
}
.lab-chat-thinking-label {
  color: var(--muted);
  flex: 1;
  min-width: 8rem;
  white-space: normal;
}
.lab-chat-thinking-bar {
  order: 5;
  flex: 1 1 100%;
  height: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
}
.lab-chat-thinking-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent, #3d8bfd);
  transition: width 0.25s ease;
}
.lab-chat-thinking-dots {
  display: inline-flex;
  gap: 0.18rem;
  margin-left: 0.05rem;
}
.lab-chat-thinking-dots span {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: var(--accent, #3d8bfd);
  opacity: 0.35;
  animation: lab-chat-dot 1.2s ease-in-out infinite;
}
.lab-chat-thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.lab-chat-thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes lab-chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
.lab-chat-bubble[data-has-proposal="1"] {
  border-color: color-mix(in srgb, var(--accent, #3d8bfd) 45%, transparent);
}
.lab-chat-bubble pre {
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  background: #0c0f14;
  overflow: auto;
  max-height: 16rem;
  font-family: var(--mono);
  font-size: 14px;
}
.lab-chat-compose {
  border-top: 1px solid var(--border);
  padding: 0.55rem 0.65rem 0.65rem;
  background: var(--panel);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
}
.lab-chat-input {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  min-height: 2.6rem;
  max-height: 240px;
  overflow-y: hidden;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0.45rem 0.55rem;
  font: inherit;
}
.lab-chat-input:disabled {
  opacity: 0.55;
}
.lab-chat-compose-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
}
.lab-chat-compose-btns {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}
.lab-voice-status {
  font-size: 13px;
  line-height: 1.2;
}
.lab-chat-input.is-listening {
  border-color: #c45c5c;
  box-shadow: 0 0 0 1px color-mix(in srgb, #c45c5c 45%, transparent);
  animation: lab-voice-pulse 1.5s ease-in-out infinite;
}
@keyframes lab-voice-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px color-mix(in srgb, #c45c5c 35%, transparent);
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, #c45c5c 22%, transparent);
  }
}
#btnLabVoiceOk.lab-voice-ok {
  color: #8fd4a8;
}
#btnLabVoiceCancel.lab-voice-cancel {
  color: #e6a0a0;
}
#btnLabChatSend.btn-lab-stop {
  background: #5c2a2a;
  border-color: #8a3f3f;
  color: #f2dede;
}
.lab-indicators-table-wrap {
  max-height: min(60vh, 28rem);
  overflow: auto;
  margin: 0.5rem 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.lab-indicators-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
.lab-indicators-table th,
.lab-indicators-table td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.lab-indicators-table th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lab-indicators-table .mono {
  font-family: var(--mono);
  font-size: 14px;
}
.lab-ind-src {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
}
.lab-ind-src.oracle {
  border-color: #8a6a2a;
  color: #e6c56a;
}
.oracle-tape-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  margin: 0 0 0.55rem;
}
.oracle-tape-controls .field {
  margin: 0;
  min-width: 8rem;
}
.oracle-tape-wrap {
  max-height: min(58vh, 28rem);
}
.oracle-tape-table td[data-status="ok"] {
  color: color-mix(in srgb, #6dcf8a 80%, var(--text));
}
.oracle-tape-table td[data-status="ok_sparse"] {
  color: color-mix(in srgb, #6dcf8a 55%, var(--muted));
}
.oracle-tape-table td[data-status="partial"] {
  color: #e6c56a;
}
.oracle-tape-table td[data-status="hole"],
.oracle-tape-table td[data-status="error"] {
  color: #e07a7a;
  font-weight: 600;
}
.oracle-tape-table td[data-status="no_tape"] {
  color: var(--muted);
}
.oracle-tape-notes {
  margin: 0.45rem 0 0;
  max-height: 7rem;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 14px;
}
.lab-chat-apply.has-ind-note {
  /* Soft catalog notes (oracle_only etc.) — not an error state */
  border-color: color-mix(in srgb, var(--accent, #3d8bfd) 45%, var(--border));
}
@media (max-width: 1100px) {
  .lab-layout {
    grid-template-columns: minmax(160px, 200px) 1fr;
    grid-template-rows: 1fr minmax(220px, 34vh);
  }
  .lab-sidebar { grid-row: 1 / span 2; }
  .lab-code-pane { grid-column: 2; grid-row: 1; border-right: none; border-bottom: 1px solid var(--border); }
  .lab-chat-pane { grid-column: 2; grid-row: 2; }
}
@media (max-width: 720px) {
  .lab-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 28vh) 1fr minmax(200px, 32vh);
  }
  .lab-sidebar,
  .lab-code-pane,
  .lab-chat-pane {
    grid-column: 1;
    grid-row: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.sidebar-head-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.btn-icon {
  min-width: 1.75rem;
  padding: 0.25rem 0.45rem;
  font-size: 14px;
  line-height: 1;
}
.session-list {
  flex: 1;
  overflow: auto;
  padding: 0.35rem;
}
.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.5rem 0.75rem 0.2rem;
}
.runtime-session-list {
  max-height: 42%;
  border-top: 1px solid var(--line, #2a2a2a);
  flex: 0 1 auto;
}
.runtime-session-list .ses-id {
  font-size: 0.65rem;
  padding: 0 0.5rem 0.25rem;
  word-break: break-all;
  opacity: 0.75;
}
.runtime-session-list .ses-actions {
  display: flex;
  gap: 0.35rem;
  padding: 0 0.5rem 0.45rem;
}
.btn-tiny {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
}
.journal-session-actions {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.journal-session-actions .btn {
  width: 100%;
}
.ses-empty {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
}
.live-target-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  padding: 0.35rem 0 0.6rem;
  border-bottom: 1px solid var(--line, #2a2a2a);
  margin-bottom: 0.5rem;
}
.live-target-bar .check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}
.legacy-node-opt {
  opacity: 0.85;
}
.ses-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.2rem;
}
.ses-item:hover { background: var(--panel-2); }
.ses-item.active {
  border-color: #2a4a6e;
  background: #132033;
}
.ses-item .ses-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  word-break: break-word;
}
.ses-item .ses-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.ses-item .ses-status.running { color: var(--good); }
.ses-item .ses-status.stop_buy { color: var(--warn); }
.ses-item .ses-del {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 0.15rem;
}
.ses-item .ses-del:hover { color: var(--bad); }
.session-title-inline { font-weight: 500; font-size: 15px; text-transform: none; letter-spacing: 0; }
.symbol-pick-field {
  flex: 1 1 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.55rem 0.45rem;
  background: var(--panel);
  max-width: 100%;
  min-width: 12rem;
}
.symbol-pick-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.symbol-pick-head .mono { font-size: 12px; }
.symbol-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.55rem;
  max-height: 7.5rem;
  overflow: auto;
}
.symbol-checklist label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 14px;
  font-family: var(--mono);
  color: var(--text);
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 4px;
}
.symbol-checklist label.is-primary {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.symbol-checklist label .sym-star {
  font-size: 9px;
  opacity: 0.85;
}
.symbol-checklist input {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin: 0;
  flex: 0 0 auto;
  border: 1.5px solid #6b7585;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}
.symbol-checklist input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231e2329' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}
.symbol-checklist input:disabled,
.symbol-checklist input:disabled:checked {
  opacity: 1;
  background-color: transparent;
  border-color: #6b7585;
  cursor: not-allowed;
}
.symbol-checklist input:disabled:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.symbol-checklist label:has(input:disabled) {
  cursor: not-allowed;
}
/* legacy class kept for any leftover markup */
.symbol-list {
  flex: 1;
  overflow: auto;
  padding: 0.35rem;
}
.sym-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.sym-item:hover { background: var(--panel-2); }
.sym-item.active {
  border-color: #2a4a6e;
  background: #132033;
}
.sym-item .sym-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.sym-item .name { font-weight: 600; font-size: 15px; }
.sym-item .badge {
  font-size: 12px;
  color: var(--muted);
}
.sym-item.ready .badge { color: var(--good); }
.sym-item .sym-meta {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.sym-item .sym-meta .dot { opacity: 0.45; }
.sym-item .sym-meta .vol { font-weight: 600; }
.sym-item .sym-meta .corr.loose { color: #7eb8ff; }
.sym-item.vol-hot .sym-meta .vol { color: #e8a23a; }
.sym-item.vol-warm .sym-meta .vol { color: #c4b06a; }
.sym-item.vol-cool .sym-meta .vol { color: var(--muted); }
.sym-item.vol-hot {
  box-shadow: inset 2px 0 0 #e8a23a66;
}
.sidebar-foot {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.main {
  display: grid;
  grid-template-rows: minmax(320px, 50vh) 1fr;
  min-width: 0;
  min-height: 0;
}
.chart-panel {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: #0c1016;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 2.35rem;
  overflow: hidden;
}
.run-progress {
  margin-left: auto;
  min-width: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}
.warmup-bar {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
  background: #1a2230;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.warmup-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--bad);
  transition: width 0.12s linear;
}
.warmup-bar.is-indeterminate .warmup-bar-fill {
  width: 32%;
  transition: none;
  animation: warmup-slide 1.05s ease-in-out infinite;
}
@keyframes warmup-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(420%); }
}
.chart-tf-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.chart-tf-label {
  margin-right: 4px;
  color: var(--muted);
  font-size: 14px;
}
.tf-chip {
  appearance: none;
  border: 1px solid transparent;
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.tf-chip:hover:not(.active):not(:disabled) {
  color: var(--text);
}
.tf-chip.active {
  border-color: var(--warn);
  color: var(--text);
  background: var(--panel);
}
.tf-chip:disabled {
  opacity: 0.45;
  cursor: default;
}
.live-pulse {
  font-size: 16px;
  color: var(--good);
  padding: 0.15rem 0.45rem;
  border: 1px solid color-mix(in srgb, var(--good) 45%, transparent);
  border-radius: 999px;
  white-space: nowrap;
}
.live-pulse.is-waiting {
  color: var(--muted);
  border-color: var(--border);
}
.live-pulse.is-stale {
  color: var(--bad, #e85d5d);
  border-color: color-mix(in srgb, var(--bad, #e85d5d) 50%, transparent);
}
.live-countdown {
  font-size: 16px;
  color: var(--accent, #6af);
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.live-countdown.is-stale {
  color: var(--bad, #e85d5d);
}
/* Multi-symbol: 1 → full; 2–4 → columns. overflow:hidden — иначе 2 колонки
   дают ResizeObserver↔scrollbar flicker (±1–2px). */
.chart-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 1px;
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr);
}
.chart-grid[data-count="0"],
.chart-grid[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
}
.chart-grid[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.chart-grid[data-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.chart-grid[data-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.chart-grid[data-count="5"],
.chart-grid[data-count="6"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.chart-grid[data-count="7"],
.chart-grid[data-count="8"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .chart-grid[data-count="3"],
  .chart-grid[data-count="4"],
  .chart-grid[data-count="5"],
  .chart-grid[data-count="6"],
  .chart-grid[data-count="7"],
  .chart-grid[data-count="8"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.chart-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0c1016;
}
.chart-pane.is-primary {
  box-shadow: inset 0 2px 0 var(--accent);
}
.chart-pane-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.5rem;
  border-bottom: 1px solid #1a2230;
  font-size: 14px;
  cursor: default;
  user-select: none;
  flex-shrink: 0;
}
.chart-pane-head:hover { background: #121820; }
.chart-pane-sym { letter-spacing: 0.02em; }
.chart-pane-star {
  color: var(--accent);
  font-size: 12px;
}
.chart-pane-star[hidden] { display: none !important; }
.chart-pane-inds {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  opacity: 0.85;
}
.chart-pane-price { margin-left: auto; flex-shrink: 0; }
.chart-pane-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.chart { flex: 1; min-height: 200px; } /* legacy */
.empty {
  position: absolute;
  inset: 40px 0 0 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}
.empty.hidden { display: none; }

.session-panel {
  overflow: auto;
  padding: 0.75rem 1rem 1.25rem;
  background: var(--bg);
  min-width: 0;
}
.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.session-head h2 { margin: 0; font-size: 15px; }
.strategy-run-row {
  flex: 1 1 100%;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.75rem;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
.session-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
#btnStopBuy.is-armed {
  color: #d4a017;
  border-color: color-mix(in srgb, #d4a017 55%, transparent);
}
tr.trade-session-end td {
  opacity: 0.85;
  font-style: italic;
}

.live-resume-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(47, 190, 123, 0.35);
  background: rgba(47, 190, 123, 0.08);
}
.live-resume-banner[hidden] { display: none !important; }
.live-resume-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}
.live-resume-text strong { font-size: 15px; }
.live-resume-text .mono { font-size: 14px; word-break: break-word; }
.live-resume-actions { display: flex; gap: 0.45rem; flex-shrink: 0; }

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.mode-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
}
.mode-btn:hover { color: var(--text); background: var(--panel-2); }
.mode-btn.active {
  background: #1e3a5f;
  color: var(--accent);
}
.run-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.run-controls select,
.field select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: var(--mono);
  font-size: 16px;
  min-width: 110px;
}
.sandbox-opts {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* EMA period selects sit in .run-controls row (display:contents) */
.indicator-params {
  display: contents;
}
.indicator-params[hidden] {
  display: none !important;
}
.indicator-params .field.compact select {
  min-width: 4.5rem;
}
.sandbox-opts input[type="date"] {
  font-family: var(--mono);
  font-size: 16px;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel, #111);
  color: var(--text);
  min-width: 9.5rem;
}
/* Launch knobs for C.* thresholds — column + hint (learn-by-tweaking) */
.strategy-threshold-knobs {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.7rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  color: var(--muted);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
}
.strategy-threshold-knobs[hidden] {
  display: none !important;
}
.strategy-threshold-knobs legend {
  padding: 0 0.35rem;
  font-size: 14px;
  color: color-mix(in srgb, var(--accent) 75%, var(--text));
}
.strategy-threshold-knobs-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.15rem;
  align-items: start;
  width: 100%;
}
.strategy-threshold-knobs-fields[data-cols="1"] {
  grid-template-columns: 1fr;
}
.strategy-threshold-knobs-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}
.strategy-threshold-knobs-col[data-role="exit"] {
  padding-left: 0.85rem;
  border-left: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
}
.strategy-threshold-knobs-col-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}
.strategy-threshold-knob {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}
.strategy-threshold-knob-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.strategy-threshold-knob-name {
  flex: 0 1 9.5rem;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
}
.strategy-threshold-knob-input {
  flex: 0 0 5.25rem;
  font-family: var(--mono);
  font-size: 16px;
  padding: 0.3rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 6px;
  background: var(--panel-2, #1b222d);
  color: var(--text);
}
.strategy-threshold-knob-input:focus {
  outline: none;
  border-color: var(--accent);
}
.strategy-threshold-knob-unit {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.strategy-threshold-knob-hint {
  margin: 0;
  padding-left: 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: color-mix(in srgb, var(--muted) 92%, var(--text));
}
.strategy-threshold-knobs > small {
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 900px) {
  .strategy-threshold-knobs-fields {
    grid-template-columns: 1fr;
  }
  .strategy-threshold-knobs-col[data-role="exit"] {
    padding-left: 0;
    padding-top: 0.35rem;
    border-left: none;
    border-top: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  }
}
.trading-sessions {
  display: flex;
  align-items: center;
  gap: 0.45rem 0.85rem;
  flex-wrap: wrap;
  margin: 0 0 0.55rem;
  padding: 0.4rem 0.65rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
}
.trading-sessions legend {
  padding: 0 0.3rem;
  font-size: 14px;
}
.trading-sessions label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
}
.trading-sessions label span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.trading-sessions input { accent-color: var(--accent); }
.trading-sessions small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
}
.trading-weekdays label {
  min-width: 2.1rem;
  justify-content: center;
}
.mode-hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 16px;
}
.field.compact {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}
.field.compact span { font-size: 14px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
.metric span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 0.2rem; }
.metric strong { font-family: var(--mono); font-size: 15px; }
.metric strong.good { color: var(--good); }
.metric strong.bad { color: var(--bad); }

.deposit-live {
  margin-bottom: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(47, 190, 123, 0.08), rgba(47, 120, 190, 0.06));
}
.deposit-live-inner { display: flex; flex-direction: column; gap: 0.35rem; }
.deposit-live-label {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.deposit-live-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.deposit-live-title { font-size: 15px; color: var(--muted); }
.deposit-live-value {
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.deposit-live-value.good { color: var(--good); }
.deposit-live-value.bad { color: var(--bad); }
.deposit-live-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  font-size: 16px;
  color: var(--muted);
}
.deposit-live-sub strong {
  font-family: var(--mono);
  color: var(--text);
  font-weight: 600;
}

.tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 1100px) {
  .tables { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 180px; }
}
.table-wrap, .journal-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-width: 0;
}
.table-wrap h3, .journal-wrap h3 {
  margin: 0 0 0.45rem;
  font-size: 16px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.trade-summary {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.65rem;
  font-size: 16px;
  line-height: 1.45;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
}
.trade-summary strong { font-family: var(--mono); color: var(--text); }
.table-wrap-scroll .table-scroll {
  max-height: 420px;
  overflow: auto;
}
.table-wrap-scroll .table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 0.3rem 0.35rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; font-family: var(--font); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.trade-sum td {
  border-top: 1px solid var(--border);
  padding-top: 0.45rem;
  font-weight: 600;
}

.journal {
  margin: 0;
  max-height: 180px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  color: #c5d0de;
  white-space: pre-wrap;
}
.journal-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.journal-head-row h3 { margin: 0; }
.btn-journal {
  position: relative;
  gap: 0.35rem;
}
.btn-journal.has-alert {
  color: var(--bad);
  border-color: #5c2a26;
}
.journal-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #8b2e2a;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.journal-badge[hidden] { display: none !important; }
.run-progress-err { color: var(--bad) !important; }
.modal-card-journal {
  width: min(820px, 100%);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.journal-modal-hint {
  margin: 0.15rem 0 0.55rem;
  font-size: 16px;
  line-height: 1.35;
}
.journal-modal-body {
  flex: 1;
  min-height: 200px;
  max-height: min(58vh, 520px);
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, #000);
}
.journal-modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}
.journal-line-err { color: #f0b4ae; }
.journal-line-ok { color: #9fd4a8; }
.journal-line-warn { color: #e6c07b; }
.journal-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.journal-head-row h3 { margin: 0; }
.btn-journal {
  position: relative;
  gap: 0.35rem;
}
.journal-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #8b2e28;
  color: #ffe8e4;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.journal-badge[hidden] { display: none !important; }
.runtime-alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.35rem 0.55rem 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid #6b2f2a;
  border-radius: 8px;
  background: #2a1614;
  color: #ffd4ce;
  font-size: 16px;
  line-height: 1.35;
}
.runtime-alert-banner[hidden] { display: none !important; }
.runtime-alert-text {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  word-break: break-word;
}
.run-progress-err {
  color: var(--bad) !important;
  font-weight: 600;
}
.modal-card-journal {
  width: min(860px, 100%);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.journal-modal-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0.35rem 0 0.55rem;
}
.journal-tab {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 6px;
  padding: 0.28rem 0.65rem;
  font-size: 16px;
  cursor: pointer;
}
.journal-tab.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}
.journal-tab-panel {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.journal-modal-body {
  max-height: min(52vh, 480px);
  height: min(52vh, 480px);
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, #000);
}
.journal-line-err { color: #ff8f84; }
.journal-line-warn { color: #e6c07b; }
.journal-trades-scroll {
  max-height: min(52vh, 480px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, #000);
}
.auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.auth-card h1 {
  margin: 0;
  font-size: 1.25rem;
}
.auth-card p {
  margin: 0;
  color: var(--muted);
}
.auth-error {
  color: var(--bad);
}
.auth-google {
  align-self: flex-start;
  text-decoration: none;
}
.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 14px;
}
.login-form input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}
.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.login-actions .btn-ghost {
  color: var(--text);
}
