:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: #f2f4fd;
  background: #090d18;
  --accent: #bfc4ff;
  --accent-ink: #151931;
  --muted: #aab6d0;
  --line: #29334d;
  --panel: #111829;
  --field: #0c1322;
  --focus: #b7c3ff;
  --success: #a7efd0;
  --error: #ffaaa9;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.shell { width: min(1490px, calc(100% - 64px)); margin-inline: auto; }
.masthead { position: sticky; top: 0; z-index: 3; background: #0a0f1deb; backdrop-filter: blur(18px); border-bottom: 1px solid #242d42; }
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 67px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 1.14rem;
  font-weight: 750;
  letter-spacing: -.045em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.brand > span { color: var(--accent); }
.brand .brand-mark {
  display: inline-flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  width: 35px;
  height: 35px;
  padding-bottom: 9px;
  margin-right: 10px;
  border: 1px solid #6270bf;
  border-radius: 10px;
  background: linear-gradient(145deg,#303962,#1e2546);
  box-shadow: inset 0 1px 0 #ffffff1a;
}
.brand-mark i { width: 3px; height: 6px; border-radius: 2px; background: currentColor; }
.brand-mark i:nth-child(2) { height: 11px; }
.brand-mark i:nth-child(3) { height: 15px; }
.header-state { display: flex; gap: 13px; align-items: center; }
.access-link, .research-link { color: #c6cff0; text-decoration: none; font-size: .84rem; font-weight: 650; }
.access-link { border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; white-space: nowrap; }
.access-link:hover, .research-link:hover { color: #fff; border-color: #56618b; }
.workspace-frame { display: grid; gap: clamp(19px, 2.25vw, 34px); grid-template-columns: 178px minmax(0, 1fr); align-items: start; }
.workspace-nav { min-width: 0; padding-top: 26px; position: sticky; top: 67px; }
.workspace-nav nav { display: grid; gap: 6px; padding-right: 13px; border-right: 1px solid #242d42; }
.workspace-nav a { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border-radius: 8px; color: var(--muted); font-size: .84rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.workspace-nav a::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border: 1px solid #8797bc; border-radius: 2px; }
.workspace-nav a:hover { color: #fff; background: #161e33; }
.workspace-nav a[aria-current] { color: #e5e8ff; background: #222b49; }
.workspace-nav a[aria-current]::before { background: #aebcff; border-color: #aebcff; }
.mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid #2f5149;
  background: #152923;
  color: var(--success);
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.mode span { width: 7px; height: 7px; border-radius: 50%; background: #8becbd; }

main { min-width: 0; padding-block: 26px 54px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.14fr);
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
  margin-bottom: 16px;
  padding: clamp(17px, 3vw, 32px);
  border: 1px solid #35426a;
  border-radius: 18px;
  background: radial-gradient(ellipse at 86% -30%, #394984 0%, transparent 68%), linear-gradient(135deg,#1f2549,#10182b 74%);
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.16; }
h1 { font-size: clamp(2rem, 4.25vw, 4.1rem); letter-spacing: -.06em; line-height: 1.02; margin-bottom: 14px; }
h2 { font-size: 1.18rem; letter-spacing: -.017em; }
h3 { font-size: 1.02rem; }
h1[tabindex], h2[tabindex], h3[tabindex], #workspace-access { scroll-margin-top: 85px; }
p { margin: 0 0 13px; line-height: 1.5; color: var(--muted); }
.intro p { margin: 0; }
.hero-copy > p { max-width: 34ch; color: #cad3ed; }
.intro-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 15px; margin-top: 22px; }
.workspace-action { padding: 10px 13px; display: inline-flex; gap: 7px; align-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-size: .84rem; font-weight: 750; }
.workspace-action:hover { filter: brightness(1.1); }
.workspace-analytics { min-width: 0; border: 1px solid #58699f91; background: #10182dd6; border-radius: 14px; padding: 15px 15px 11px; }
.analytics-top { display: flex; gap: 8px; justify-content: space-between; align-items: start; flex-wrap: wrap; }
.analytics-top h2 { font-size: .87rem; margin: 0 0 3px; }
.analytics-top p:not(.analytics-value) { font-size: .74rem; }
.analytics-top .analytics-value { color: #eef0ff; font-weight: 750; font-size: clamp(1rem, 1.8vw, 1.33rem); font-variant-numeric: tabular-nums; }
.workspace-analytics canvas { display: block; width: 100%; height: clamp(96px, 10vw, 142px); margin-block: 7px 1px; }
.analytics-foot { display: flex; justify-content: space-between; gap: 10px; font-size: .7rem; color: #a6b2ce; }
.access label, .access p { font-size: .79rem; }
.access #connection { margin: 8px 0 0; }
.access p[data-state="connected"] { color: var(--success); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0 0 18px; }
.metrics div { min-width: 0; padding: 13px 16px; }
.metrics dt { color: var(--muted); font-size: .8rem; font-weight: 600; }
.metrics dd { margin: 4px 0 0; font-size: clamp(1rem, 2vw, 1.36rem); font-weight: 720; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview { border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(140deg,#172039,#11182a); }
.overview > div + div { border-left: 1px solid var(--line); }

.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
.workspace { align-items: start; }
.strategy-stack { min-width: 0; display: grid; gap: 16px; }
.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: clamp(16px, 2vw, 22px); }
.copilot {
  background: radial-gradient(ellipse at 85% -18%, #30376a, transparent 75%), #171c35;
  border-color: #3b4a76;
}
.copilot-title { display: flex; align-items: start; gap: 11px; margin-bottom: 13px; }
.copilot-title h2 { margin-bottom: 3px; }
.copilot-title p { margin: 0; font-size: .88rem; color: #d1cbea; }
.copilot-mark {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  height: 32px;
  border: 1px solid #696095;
  border-radius: 8px;
  background: #4b4175;
}
.copilot-mark::before { content: ""; width: 12px; height: 12px; background: #e0daff; transform: rotate(45deg); border-radius: 3px; }
.prompt-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.draft-source { display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.draft-source select { margin: 0; min-height: 33px; width: auto; padding: 5px 8px; background: #25213e; color: #e3dcff; border-color: #635783; font-size: .8rem; }
.mode-help { margin: 8px 0 0; font-size: .78rem; color: #d1cbea; }
.copilot-actions, .editor-actions, .examples { display: flex; flex-wrap: wrap; gap: 8px; }
.copilot-actions { justify-content: space-between; align-items: center; margin-top: 9px; }
.copilot .example { background: #2c2947; color: #ded8f5; border-color: #635783; min-height: 34px; padding: 5px 9px; font-size: .76rem; }
.draft-button { background: #cfc7ff; color: #1e1932; border-color: #cfc7ff; }
.draft-button span { margin-left: .6em; }
.draft-preview { margin-top: 12px; padding: 14px; border: 1px solid #5d527d; border-radius: 11px; background: #211d36; }
.draft-rules { display: grid; gap: 10px; margin: 0; }
.draft-rules div { display: grid; grid-template-columns: minmax(84px, .35fr) minmax(0, 1fr); gap: 10px; }
.draft-rules dt { color: #bdb2df; font-size: .8rem; font-weight: 650; }
.draft-rules dd { margin: 0; font-size: .85rem; }
.draft-preview p { margin: 0 0 10px; font-size: .86rem; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.full { grid-column: 1 / -1; }
.indicator-help { margin: 0; font-size: .87rem; }
label { display: block; font-size: .82rem; font-weight: 650; color: #dce4f5; }
input, select, textarea, button { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .88rem; }
input, select, textarea { width: 100%; min-width: 0; padding: 9px 11px; background: var(--field); color: inherit; }
textarea { display: block; resize: vertical; min-height: 62px; line-height: 1.45; border-color: #655988; background: #17152a; }
input::placeholder, textarea::placeholder { color: #9aacc3; }
label > input, label > select, label + .inline, label + textarea { margin-top: 5px; }
button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); padding: 8px 13px; cursor: pointer; font-weight: 730; }
button:hover:enabled { filter: brightness(1.10); }
button:disabled, fieldset:disabled button { opacity: .50; cursor: default; }
input:disabled, textarea:disabled, select:disabled { opacity: .74; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.inline { display: flex; gap: 8px; }
.inline button, .panel-top button { flex-shrink: 0; }
.secondary { background: #242e41; color: #e2eaff; border-color: #43516e; }
.danger { background: #3c2332; color: #ffbcca; border-color: #724353; }
.section-gap, .actions, .ledger { margin-top: 16px; }
.feedback { margin: 9px 0 0; font-size: .84rem; overflow-wrap: anywhere; }
.feedback:empty { margin: 0; }
.feedback[data-error="true"], .access p[data-error="true"] { color: var(--error); }
.panel-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 11px 9px; border-top: 1px solid var(--line); text-align: left; }
th { color: var(--muted); }
#backtest-result { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 16px; }
#backtest-result .metrics { background: var(--field); border-radius: 10px; }
.editor-title { margin-bottom: 12px; }
.editor-title p, .bridge .panel-top p { margin-bottom: 0; font-size: .84rem; }
.bridge .panel-top { margin-bottom: 12px; }
.visual-builder { padding: 12px 0 16px; }
.formula-guide { margin: 0 0 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.formula-guide p { font-size: .82rem; margin-bottom: 0; }
.formula-guide code { color: var(--focus); overflow-wrap: anywhere; }
.voice-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-block: 10px; }
.voice-toolbar .mode-help { flex-basis: 100%; margin: 0; }
.voice-toolbar select { width: auto; }
#explorer-panel > .fields { margin-block: 10px; }
#rule-boards { display: grid; gap: 14px; }
#rule-boards > section { padding: 13px; border: 1px solid #44516a; border-radius: 11px; background: #192235; min-width: 0; }
#rule-boards h3 { color: #d7d2ff; }
.group-rules { display: grid; gap: 8px; margin: 8px 0; }
.subgroup { min-width: 0; padding-left: 10px; border-left: 2px solid #7567a6; }
.condition-card { min-width: 0; padding: 9px; border: 1px solid #33405a; border-radius: 8px; background: #131b2b; }
.comparison-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1fr); gap: 7px; align-items: start; }
.comparison-fields label, .logic-group label { font-size: .75rem; }
.comparison-fields input, .comparison-fields select { padding: 6px 7px; min-height: 35px; font-size: .81rem; }
.operand-parameters { display: grid; grid-template-columns: repeat(auto-fit, minmax(62px, 1fr)); gap: 6px; }
.operand-parameters:not(:empty) { margin-top: 6px; }
.operand-parameters input { width: 100%; min-width: 0; }
.rule-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.condition-card .rule-actions { margin-top: 7px; justify-content: end; }
.data-import { margin-top: 12px; padding: 10px; border: 1px dashed #4d5b79; border-radius: 8px; }
.data-import input { margin-top: 5px; }
.data-import p { margin: 6px 0 0; font-size: .78rem; }
.rule-actions button { font-size: .74rem; min-height: 30px; padding: 4px 8px; }
.bridge-accounts, #copy-preview-rows, #copy-receipt-rows { list-style: none; display: grid; gap: 8px; padding: 0; margin: 12px 0 0; }
.bridge-accounts li { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 10px 8px; border-top: 1px solid var(--line); }
.broker-toolbar { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.broker-toolbar button { min-height: 33px; font-size: .8rem; }
.broker-toolbar a { color: var(--focus); font-size: .8rem; }
.bridge-panel { margin-top: 12px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.bridge-panel summary { cursor: pointer; color: #dce4f5; font-size: .87rem; font-weight: 650; }
.handoff { margin-block: 0 16px; padding: 12px; }
.handoff-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 125px), 1fr)); gap: 9px; }
.handoff-research { display: grid; margin-block: 12px; padding-block: 8px; border-block: 1px solid var(--line); }
.handoff-research label { display: block; margin-block: 8px; }
.handoff-research button { margin-top: 2px; }
.handoff-result { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.handoff-result textarea { min-height: 9.5rem; background: var(--field); border-color: var(--line); }
#static-ip-form input[type="checkbox"] { width: auto; margin-inline-end: .4rem; }
#consent-list li { overflow-wrap: anywhere; }
.sandbox { margin-bottom: 16px; }
.sandbox .handoff-fields { margin-block: 8px 12px; }
.sandbox #sandbox-destination { overflow-wrap: anywhere; }
.sandbox #sandbox-payload { font-family: ui-monospace, monospace; }
.bridge-accounts span, #copy-preview-form p, #copy-preview-rows, #copy-receipt-rows { color: var(--muted); display: block; font-size: .81rem; }
#copy-preview-form { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
#copy-preview-form p { margin-block: 7px; }
.copy-targets { display: grid; gap: 8px; margin-bottom: 13px; }
.copy-target { border: 1px solid var(--line); padding: 8px; border-radius: 8px; gap: 8px; }
.copy-target legend { color: #d7d2ff; padding: 0 4px; font-size: .84rem; font-weight: 650; }
.copy-preview-result { padding: 10px; background: var(--field); border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.copy-preview-result p { font-size: .85rem; margin: 0; }
#record-paper-copy { margin-top: 10px; }
.copy-batch-link { display: block; min-height: 22px; border: 0; padding: 0; background: transparent; color: var(--focus); font-size: .76rem; text-decoration: underline; }
.equity-replay { padding: 12px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; }
.equity-replay canvas { display: block; width: 100%; height: auto; background: #111625; border-radius: 8px; margin-bottom: 9px; }
.equity-replay input { min-height: 25px; accent-color: var(--focus); }
.equity-replay p { font-size: .85rem; margin: 0 0 6px; }

@media (max-width: 1040px) {
  .shell { width: calc(100% - 36px); }
  .workspace-frame { grid-template-columns: 150px minmax(0, 1fr); }
  .workspace-nav nav { padding-right: 8px; }
}
@media (max-width: 840px) {
  .workspace-frame { display: block; }
  .workspace-nav { top: 67px; z-index: 2; padding: 6px 0; background: #090e1afa; }
  .workspace-nav nav { display: flex; overflow-x: auto; padding: 0 4px; border: 0; scrollbar-width: thin; }
  .workspace-nav a { padding: 8px 9px; font-size: .78rem; }
  h1[tabindex], h2[tabindex], h3[tabindex], #workspace-access { scroll-margin-top: 125px; }
  main { padding-top: 9px; }
}
@media (max-width: 680px) {
  .intro { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid .strategy-stack:has(.access) { display: contents; }
  .grid .access { grid-row: 1; }
}
@media (max-width: 640px) {
  .shell { width: calc(100% - 25px); }
  .header { min-height: 58px; gap: 7px; }
  .header-state { gap: 5px; }
  .access-link, .mode { font-size: .68rem; padding: 5px 7px; gap: 5px; }
  .brand { font-size: 1rem; }
  .brand .brand-mark { margin-right: 7px; }
  .workspace-nav { top: 58px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview > div:nth-child(3) { border-left: 0; }
  .overview > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .metrics div { padding: 10px 11px; }
  .draft-preview .panel-top { display: grid; }
  .draft-preview .panel-top button { justify-self: start; }
  .editor-title, .bridge .panel-top { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .comparison-fields { grid-template-columns: minmax(0, 1fr); }
}
