/* ============================================================
   EABuilder — trading-desk workbench
   display: Bricolage Grotesque · body: Hanken Grotesk · data: IBM Plex Mono
   ============================================================ */
:root {
  --ink: #0A0F1A;
  --ink-2: #0C1320;
  --panel: #101A2B;
  --panel-2: #0D1422;
  --line: #1C2740;
  --line-2: #243352;
  --paper: #EAEFF7;
  --mute: #7E8CA6;
  --brass: #DDA24E;     /* the build/forge action */
  --brass-2: #F0BD6C;
  --bull: #46C08D;      /* valid / go-live */
  --bear: #EB6A5E;      /* error / loss */
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --body: "Hanken Grotesk", system-ui, sans-serif;
  --disp: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
  --r: 14px;
}

* { box-sizing: border-box; min-width: 0; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden; /* backstop against incidental horizontal scroll */
}
img, pre, textarea, canvas, svg { max-width: 100%; }
a { color: inherit; }

/* chart-paper backdrop + instrument glows */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(820px 460px at 86% -6%, rgba(221,162,78,.10), transparent 60%),
    radial-gradient(720px 520px at 4% 8%, rgba(70,140,200,.07), transparent 55%),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.018) 0 1px, transparent 1px 38px),
    repeating-linear-gradient(to right, rgba(255,255,255,.013) 0 1px, transparent 1px 84px);
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(10,15,26,.74);
  backdrop-filter: blur(10px);
}
.bar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.wordmark {
  font-family: var(--disp); font-weight: 700; font-size: 20px; letter-spacing: -.5px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 9px;
}
.wordmark b { color: var(--brass); font-weight: 700; }
.wordmark .mark { color: var(--brass); font-size: 15px; transform: translateY(1px); }
.wordmark.small { font-size: 15px; }
.bar-meta { display: flex; align-items: center; gap: 18px; }
.readout {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .5px; color: var(--mute);
  text-decoration: none;
}
.readout b { color: var(--paper); font-weight: 500; }
.readout.pulse::before {
  content: "●"; color: var(--bull); margin-right: 5px; font-size: 9px;
}
.readout.pulse.down::before { color: var(--bear); }
.barlink { font-family: var(--mono); font-size: 12px; color: var(--mute); text-decoration: none; }
.barlink:hover { color: var(--paper); }

/* ---------- hero ---------- */
.hero { padding: 70px 0 30px; max-width: 800px; }
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 3.5px; text-transform: uppercase;
  color: var(--brass); margin: 0 0 20px;
}
.headline {
  font-family: var(--disp); font-weight: 800; font-size: clamp(34px, 6vw, 62px);
  line-height: .98; letter-spacing: -2px; margin: 0 0 22px;
}
.headline em { font-style: italic; color: var(--brass); font-weight: 700; }
.lede { font-size: 18px; color: var(--mute); margin: 0; max-width: 660px; }

/* ---------- signature: pipeline rail ---------- */
.rail {
  position: relative; display: flex; align-items: center; gap: 0;
  margin: 14px 0 40px; padding: 18px 22px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  overflow: hidden;
}
.node {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--ink-2);
  flex: none; transition: border-color .3s, background .3s, box-shadow .3s, color .3s;
}
.node-k { font-family: var(--mono); font-size: 11px; color: var(--mute); transition: color .3s; }
.node-l { font-family: var(--disp); font-weight: 600; font-size: 15px; letter-spacing: -.2px; }
.wire {
  flex: 1; height: 2px; min-width: 26px;
  background: linear-gradient(to right, var(--line-2), var(--line-2));
  position: relative; transition: background .3s;
}
.wire.hot { background: linear-gradient(to right, var(--brass), var(--brass-2)); }
.wire.done { background: linear-gradient(to right, var(--bull), var(--bull)); }

.node.is-active { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(221,162,78,.12); }
.node.is-active .node-k { color: var(--brass); }
.node.is-done { border-color: var(--bull); background: rgba(70,192,141,.08); }
.node.is-done .node-k { color: var(--bull); }
.node.is-error { border-color: var(--bear); background: rgba(235,106,94,.08); }
.node.is-error .node-k { color: var(--bear); }

/* signal dot powers across once on load */
.signal {
  position: absolute; top: 50%; left: 22px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brass); box-shadow: 0 0 12px 2px rgba(221,162,78,.7);
  transform: translateY(-50%); opacity: 0;
  animation: power-on 1.7s ease-in-out .25s 1 forwards;
}
@keyframes power-on {
  0% { left: 24px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: calc(100% - 30px); opacity: 0; }
}

/* ---------- panels ---------- */
.panel {
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  padding: 20px; margin-bottom: 20px;
}
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-title {
  font-family: var(--mono); font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--paper);
}
.muted { color: var(--mute); font-family: var(--mono); font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; }

/* ---------- BYO ---------- */
.byo-text { max-width: 680px; }
.kicker { font-family: var(--mono); font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--brass); }
.byo-text h2 { font-family: var(--disp); font-weight: 700; font-size: 22px; letter-spacing: -.5px; margin: 8px 0 6px; }
.byo-text p { color: var(--mute); font-size: 14.5px; margin: 0; }
.desc-in {
  width: 100%; min-height: 78px; resize: vertical; margin: 14px 0 12px;
  background: var(--ink-2); color: var(--paper); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 12px 14px; font-family: var(--body); font-size: 14.5px; line-height: 1.5;
}
.desc-in:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(221,162,78,.12); }
.byo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.web-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); cursor: pointer; user-select: none; }
.web-toggle input { accent-color: var(--brass); width: 15px; height: 15px; flex: none; }

/* ---------- bench (editor + result) ---------- */
.bench { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .bench { grid-template-columns: 1fr; } }

.picker { font-family: var(--mono); font-size: 11.5px; color: var(--mute); display: flex; align-items: center; gap: 8px; letter-spacing: .5px; }
select, .field {
  background: var(--ink-2); color: var(--paper); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 11px; font-family: var(--mono); font-size: 12.5px; min-width: 0; max-width: 100%;
}
.editor-wrap {
  position: relative; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--ink-2);
}
.editor-wrap::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 38px;
  background: rgba(255,255,255,.02); border-right: 1px solid var(--line);
}
textarea#spec {
  display: block; width: 100%; height: 380px; resize: vertical;
  background: transparent; color: var(--paper); border: 0; padding: 16px 16px 16px 52px;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 2;
}
select:focus, .field:focus, textarea#spec:focus { outline: none; }
.editor-wrap:focus-within { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(221,162,78,.12); }
select:focus-visible, .field:focus-visible, .btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--body); font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: 9px; padding: 9px 17px; border: 1px solid var(--line-2);
  background: var(--ink-2); color: var(--paper); transition: transform .12s, border-color .2s, box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-neutral:hover { border-color: var(--paper); }
.btn-forge { background: linear-gradient(180deg, var(--brass-2), var(--brass)); color: #221606; border-color: var(--brass); font-weight: 700; }
.btn-forge:hover { box-shadow: 0 6px 22px -8px rgba(221,162,78,.7); filter: brightness(1.04); }
.btn-go { background: linear-gradient(180deg, #54cf9a, var(--bull)); color: #052015; border-color: var(--bull); font-weight: 700; }
.btn-go:hover:not(:disabled) { box-shadow: 0 6px 22px -8px rgba(70,192,141,.6); }
.btn-ghost { background: transparent; color: var(--mute); }
.btn-ghost:hover { color: var(--paper); border-color: var(--line-2); }
.file { display: inline-flex; align-items: center; }

/* ---------- result badges ---------- */
.result { display: flex; flex-direction: column; }
.badge { font-family: var(--mono); font-size: 11px; letter-spacing: .6px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); text-transform: lowercase; }
.badge-idle { color: var(--mute); }
.badge-ok { color: var(--bull); border-color: rgba(70,192,141,.5); background: rgba(70,192,141,.08); }
.badge-bad { color: var(--bear); border-color: rgba(235,106,94,.5); background: rgba(235,106,94,.08); }
.badge-warn { color: var(--brass); border-color: rgba(221,162,78,.5); background: rgba(221,162,78,.08); }
.out { flex: 1; min-height: 130px; }
.out.compact { min-height: 0; margin-top: 4px; }
.empty { color: var(--mute); font-size: 14px; }
.empty code { font-family: var(--mono); color: var(--brass); }

/* ---------- diagnostics ---------- */
.diag { border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: 9px; padding: 12px 14px; margin-bottom: 10px; background: var(--ink-2); }
.diag.error { border-left-color: var(--bear); }
.diag.warning { border-left-color: var(--brass); }
.diag-top { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; flex-wrap: wrap; }
.diag-code { font-family: var(--mono); font-size: 10.5px; color: var(--mute); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 7px; letter-spacing: .5px; }
.diag-path { font-family: var(--mono); font-size: 12.5px; color: var(--brass-2); }
.diag-problem { font-size: 14px; margin: 2px 0; }
.diag-fix { font-size: 13px; color: var(--mute); }
.diag-fix b { color: var(--paper); font-weight: 600; }
.diag-dym { font-size: 12.5px; margin-top: 4px; color: var(--mute); }
.diag-dym code { font-family: var(--mono); color: var(--bull); }
.notice { font-size: 13.5px; color: var(--mute); margin: 2px 0 12px; }
.clamp { font-family: var(--mono); font-size: 12.5px; color: var(--brass); margin: 2px 0; }

/* ---------- generated code ---------- */
.codewrap { border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--ink-2); }
.codebar { display: flex; align-items: center; justify-content: space-between; padding: 9px 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02); }
.codebar .fn { font-family: var(--mono); font-size: 12.5px; color: var(--brass); }
.codebar .dl-group { display: flex; gap: 8px; align-items: center; flex: none; }
pre.code { margin: 0; padding: 15px; max-height: 440px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.55; color: #C7D2E4; }

/* ---------- backtest ---------- */
.badge-price { color: var(--brass); border-color: rgba(221,162,78,.5); background: rgba(221,162,78,.08); letter-spacing: .5px; }
.bt-note { color: var(--mute); font-size: 13.5px; margin: 0 0 16px; }
.muted-inline { color: var(--mute); }
.bt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
@media (max-width: 760px) { .bt-grid { grid-template-columns: repeat(2, 1fr); } }
.bt-grid label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-family: var(--mono); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--mute); }
.bt-grid .field { width: 100%; text-transform: none; }
.bt-grid select { width: 100%; }
.bt-actions { margin-top: 16px; }

/* live status line during a run */
.bt-status { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 13px; color: var(--paper); margin: 6px 0; }
.bt-status .spin { width: 11px; height: 11px; border: 2px solid var(--line-2); border-top-color: var(--brass); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* metrics readout */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 6px; }
@media (max-width: 620px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--ink-2); padding: 13px 15px; display: flex; flex-direction: column; gap: 5px; }
.stat-l { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--mute); }
.stat-v { font-family: var(--mono); font-size: 19px; font-weight: 500; color: var(--paper); letter-spacing: -.3px; }
.stat-v.pos { color: var(--bull); }
.stat-v.neg { color: var(--bear); }
.bt-meta { font-family: var(--mono); font-size: 12px; color: var(--mute); margin: 10px 0 0; }

/* ---------- deploy ---------- */
.deploy-note { color: var(--mute); font-size: 13.5px; margin: 0 0 14px; max-width: 640px; }
.deploy-row { display: flex; flex-wrap: wrap; gap: 10px; }
.deploy-row .field { flex: 1; min-width: min(240px, 100%); }

/* ---------- alerts ---------- */
.alerts-intro { margin: 0 0 16px; }
.alert-row { margin-bottom: 16px; }
.alert-label { font-family: var(--mono); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--mute); display: block; margin-bottom: 8px; }
.alert-label b { color: var(--brass); font-weight: 500; }
.copy-field { display: flex; gap: 8px; }
.copy-field .field { flex: 1; }
.sub-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; background: var(--ink-2); font-size: 14px; }
.sub-status .pill-ok { color: var(--bull); font-family: var(--mono); font-size: 12.5px; }
.sub-status .pill-bad { color: var(--bear); font-family: var(--mono); font-size: 12.5px; }
.pay-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.channels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 6px 0 16px; }
@media (max-width: 760px) { .channels { grid-template-columns: 1fr; } }
.channel { border: 1px solid var(--line-2); border-radius: 10px; padding: 13px; background: var(--ink-2); display: flex; flex-direction: column; gap: 9px; }
.ch-head { display: flex; align-items: center; justify-content: space-between; }
.ch-name { font-family: var(--disp); font-weight: 600; font-size: 15px; }
.ch-toggle { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--mute); cursor: pointer; }
.ch-toggle input { accent-color: var(--brass); width: 15px; height: 15px; flex: none; }
.ch-tg { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ch-note { font-family: var(--mono); font-size: 11px; color: var(--brass); }
.alert-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0; }
.foot-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foot-chain { font-family: var(--mono); font-size: 12px; color: var(--mute); letter-spacing: .5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--panel); border: 1px solid var(--brass); color: var(--paper);
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px; opacity: 0; transition: .25s; z-index: 40; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- overflow safety (long mono content) ---------- */
.diag-path, .diag-problem, .diag-fix, .diag-dym, .notice, .clamp, .bt-meta, .stat-v, .empty { overflow-wrap: anywhere; }
.codebar .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-status { flex-wrap: wrap; }
.foot-chain { overflow-wrap: anywhere; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 46px 0 22px; }
  .headline { font-size: clamp(27px, 8.5vw, 44px); letter-spacing: -1px; }
  .lede { font-size: 16px; }
  .panel { padding: 16px; }
  .bar-meta { gap: 12px; }
  .bar-meta .readout:first-child { display: none; }   /* hide "spec v1.0" */
  .tag { display: none; }                              /* drop the header tagline */

  /* pipeline rail: wrap the nodes into a 2×2 grid, drop the connector wires */
  .rail { flex-wrap: wrap; gap: 8px; justify-content: center; padding: 14px; }
  .rail .wire, .rail .signal { display: none; }
  .node { flex: 1 1 calc(50% - 8px); justify-content: center; padding: 10px 12px; }

  /* one set of inputs per the available width */
  .bt-grid { grid-template-columns: 1fr 1fr; }
  .byo { gap: 16px; }
}

@media (max-width: 440px) {
  .bar-meta .barlink { display: none; }               /* keep just the live-api status */
  .headline { font-size: clamp(25px, 9vw, 40px); }
  .byo-actions { width: 100%; }
  .byo-actions .btn { flex: 1 1 auto; text-align: center; }
  .foot-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ---------- motion / a11y ---------- */
@media (prefers-reduced-motion: reduce) {
  .signal, .readout.pulse::before { animation: none; }
  .signal { display: none; }
  html { scroll-behavior: auto; }
  .btn:hover { transform: none; }
}
