/* Layout: a trading desk on chart paper. The live board sits in the hero next to the thesis;
   sections below alternate paper and sheet, one accent ink for actions, green and red only for markets. */
:root {
  --paper: #f3f5f2;
  --sheet: #ffffff;
  --ink: #111a22;
  --ink-2: #4b5761;
  --rule: #d9dfda;
  --grid: rgba(17, 26, 34, 0.055);
  --accent: #1f47b8;
  --accent-ink: #ffffff;
  --up: #12855a;
  --down: #c43d35;
  --focus: #e0a100;
  /* The rules panel is a terminal in both themes. */
  --term-bg: #0f171e;
  --term-fg: #e6ece9;
  --term-key: #9fb7ff;
  --term-val: #7fe0b0;
  --term-dim: #7d8a93;

  --f-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", "PingFang SC", "Hiragino Sans", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem);
  --step-4: clamp(2.1rem, 1.4rem + 2.6vw, 3.4rem);

  --radius: 6px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1115;
    --sheet: #131a20;
    --ink: #e7ece9;
    --ink-2: #9aa6ae;
    --rule: #26313a;
    --grid: rgba(231, 236, 233, 0.045);
    --accent: #7fa2ff;
    --accent-ink: #0c1115;
    --up: #3cc48a;
    --down: #f06a5e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c1115;
  --sheet: #131a20;
  --ink: #e7ece9;
  --ink-2: #9aa6ae;
  --rule: #26313a;
  --grid: rgba(231, 236, 233, 0.045);
  --accent: #7fa2ff;
  --accent-ink: #0c1115;
  --up: #3cc48a;
  --down: #f06a5e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
img, canvas { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; inset-inline-start: 8px; top: 8px; background: var(--sheet); padding: 8px 12px; z-index: 20; transform: translateY(-300%); }
.skip:focus { transform: none; }

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); }
.narrow { max-width: 760px; }
.eyebrow { font: 500 var(--step--1)/1.4 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.lead { font-size: var(--step-1); color: var(--ink-2); max-width: 62ch; }
.fine { font-size: var(--step--1); color: var(--ink-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font: 600 var(--step-0)/1 var(--f-body); text-decoration: none; cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: var(--step--1); }

/* Header */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.top-in { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.logo { display: inline-flex; text-decoration: none; }
.logo svg { display: block; }
.logo-pin { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: square; }
.logo-out { stroke: var(--accent); stroke-width: 3; stroke-linecap: square; }
.logo-dot { fill: var(--accent); }
.logo-name { fill: var(--ink); font: 700 34px "JetBrains Mono", ui-monospace, Consolas, monospace; }
.nav { display: flex; gap: 22px; margin-inline-start: auto; }
.nav a { text-decoration: none; font-size: var(--step--1); font-weight: 500; color: var(--ink-2); }
.nav a:hover { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.lang select {
  appearance: none; background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 7px 10px; font: 500 var(--step--1)/1 var(--f-body); cursor: pointer;
}
/* The open list takes its colors from the options: without them a dark page gets light text on a white list. */
.lang option { background: var(--sheet); color: var(--ink); }
.lang select:hover, .lang select:focus-visible { border-color: var(--accent); outline: none; }
.menu { display: none; width: 40px; height: 38px; border: 1px solid var(--rule); border-radius: var(--radius); background: transparent; cursor: pointer; position: relative; }
.menu i, .menu i::before, .menu i::after { position: absolute; left: 11px; right: 11px; height: 2px; background: var(--ink); content: ""; }
.menu i { top: 18px; }
.menu i::before { top: -6px; left: 0; right: 0; }
.menu i::after { top: 6px; left: 0; right: 0; }

/* Hero: thesis on the left, the live board on the right */
.hero {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  border-bottom: 1px solid var(--rule);
}
.hero-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(28px, 5vw, 64px); padding-block: clamp(40px, 7vw, 88px); align-items: center; }
.hero-copy { display: grid; gap: 22px; min-width: 0; }

.join { display: flex; flex-wrap: wrap; gap: 10px; max-width: 520px; }
.join input {
  flex: 1 1 220px; min-width: 0; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); font: 400 var(--step-0)/1 var(--f-body);
}
.join input::placeholder { color: var(--ink-2); opacity: 0.7; }
.join-msg { flex-basis: 100%; font-size: var(--step--1); min-height: 1.4em; }
.join-msg[data-kind="ok"] { color: var(--up); }
.join-msg[data-kind="error"] { color: var(--down); }

.board { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 18px; display: grid; gap: 14px; min-width: 0; box-shadow: 0 18px 50px -30px rgba(17, 26, 34, 0.35); }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.board-head h2 { font-size: var(--step-1); }
.status { display: inline-flex; align-items: center; gap: 8px; font: 500 var(--step--1)/1 var(--f-mono); color: var(--ink-2); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); }
.status[data-state="live"] { color: var(--up); }
.status[data-state="live"] i { background: var(--up); animation: pulse 1.6s ease-out infinite; }
.status[data-state="stale"] i { background: var(--focus); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 55%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card { border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; display: grid; gap: 4px; min-width: 0; background: var(--paper); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-sym { font: 600 var(--step-0)/1.2 var(--f-display); letter-spacing: 0.02em; }
.card-sym small { font: 400 var(--step--1)/1 var(--f-mono); color: var(--ink-2); margin-inline-start: 2px; }
.card-chg { font: 500 var(--step--1)/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.card-chg[data-dir="up"] { color: var(--up); }
.card-chg[data-dir="down"] { color: var(--down); }
.card-price { font: 500 var(--step-2)/1.15 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; transition: color 0.4s ease; }
.card-price[data-flash="up"] { color: var(--up); }
.card-price[data-flash="down"] { color: var(--down); }
.card canvas { width: 100%; height: 92px; margin-top: 4px; }
.card-vol { font: 400 0.75rem/1.2 var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.card.is-empty { min-height: 168px; opacity: 0.6; }
.card.is-empty canvas { background: linear-gradient(90deg, transparent, var(--grid), transparent); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.board-note { font-size: 0.75rem; color: var(--ink-2); }
.board-live { font-family: var(--f-mono); color: var(--ink); }

/* Sections */
.section { padding-block: clamp(56px, 8vw, 104px); }
.section-alt { background: var(--sheet); border-block: 1px solid var(--rule); }
.section-head { display: grid; gap: 12px; margin-bottom: clamp(28px, 4vw, 44px); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--rule); }
.steps li { padding: 22px 22px 22px 0; display: grid; gap: 8px; align-content: start; min-width: 0; }
.steps li + li { padding-inline-start: 22px; border-inline-start: 1px solid var(--rule); }
.step-n { font: 500 var(--step--1)/1 var(--f-mono); color: var(--accent); }
.steps p { color: var(--ink-2); }

.demo { margin-top: clamp(32px, 5vw, 56px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--sheet); }
.demo-in, .demo-out { padding: 22px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.demo-out { background: var(--term-bg); color: var(--term-fg); }
.demo-out .fine { color: var(--term-dim); }
.demo-label { font: 500 var(--step--1)/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.75; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button {
  border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 999px;
  padding: 8px 14px; font: 500 var(--step--1)/1.2 var(--f-body); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.prompt { margin: 0; padding: 16px 18px; border-inline-start: 3px solid var(--accent); background: var(--paper); font-size: var(--step-1); line-height: 1.5; }
.params { margin: 0; font: 400 0.9rem/1.65 var(--f-mono); white-space: pre-wrap; overflow-x: auto; min-height: 14em; }
.params .k { color: var(--term-key); }
.params .v { color: var(--term-val); }
.params .c { color: var(--term-dim); }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 32px; }
.feat { display: grid; gap: 8px; align-content: start; min-width: 0; padding-top: 16px; border-top: 1px solid var(--rule); }
.feat p:not(.feat-k) { color: var(--ink-2); }
.feat-k { font: 500 0.75rem/1 var(--f-mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.checks li { position: relative; padding-inline-start: 30px; }
.checks li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.45em; width: 16px; height: 9px; border-inline-start: 2px solid var(--up); border-bottom: 2px solid var(--up); transform: rotate(-45deg); }
[dir="rtl"] .checks li::before { transform: rotate(45deg); }

.bt { margin: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.bt canvas { width: 100%; height: 240px; }
.bt-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.bt-stats div { display: grid; gap: 2px; }
.bt-stats dt { font-size: var(--step--1); color: var(--ink-2); }
.bt-stats dd { margin: 0; font: 500 var(--step-2)/1.1 var(--f-mono); font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); padding: 3px; gap: 3px; background: var(--paper); justify-self: start; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 8px 14px; border-radius: 4px; font: 500 var(--step--1)/1.2 var(--f-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 3px rgba(17, 26, 34, 0.15); }
.seg-center { display: flex; width: fit-content; margin: 0 auto 28px; }

.locks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.locks li { padding: 22px; display: grid; gap: 6px; align-content: start; min-width: 0; border-bottom: 1px solid var(--rule); border-inline-end: 1px solid var(--rule); background: var(--sheet); }
.locks li:nth-child(3n) { border-inline-end: 0; }
.locks li:nth-last-child(-n+3) { border-bottom: 0; }
.locks p { color: var(--ink-2); }

.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.plan { border: 1px solid var(--rule); border-radius: 10px; padding: 24px; display: grid; gap: 14px; align-content: start; background: var(--paper); min-width: 0; }
.plan h3 { font-size: var(--step-2); }
.plan-price { display: flex; align-items: baseline; gap: 6px; }
.plan-price b { font: 600 var(--step-3)/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.plan-price span { color: var(--ink-2); font-size: var(--step--1); }
.plan ul { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; color: var(--ink-2); }

details { border-bottom: 1px solid var(--rule); padding-block: 16px; }
details:first-of-type { border-top: 1px solid var(--rule); }
summary { cursor: pointer; font-weight: 600; font-size: var(--step-1); list-style: none; display: flex; justify-content: space-between; gap: 16px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-family: var(--f-mono); color: var(--accent); }
details[open] summary::after { content: "−"; }
details p { margin-top: 10px; color: var(--ink-2); max-width: 62ch; }

.cta .narrow { display: grid; gap: 18px; justify-items: start; }

.foot { border-top: 1px solid var(--rule); padding-block: 36px; background: var(--sheet); }
.foot-in { display: grid; gap: 10px; }
.foot-legend { font: 500 var(--step-0)/1.4 var(--f-display); }

@media (max-width: 1020px) {
  .nav { display: none; position: absolute; top: 64px; inset-inline: 0; flex-direction: column; gap: 0; background: var(--sheet); border-bottom: 1px solid var(--rule); padding: 8px var(--gutter); }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px 0; font-size: var(--step-0); }
  .menu { display: inline-block; }
  .top-in { position: relative; }
  .top-actions { margin-inline-start: auto; }
  .hero-in, .split, .demo { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps li:nth-child(3) { border-inline-start: 0; padding-inline-start: 0; }
  .grid3, .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .locks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .locks li:nth-child(3n) { border-inline-end: 1px solid var(--rule); }
  .locks li:nth-child(2n) { border-inline-end: 0; }
  .locks li:nth-last-child(-n+3) { border-bottom: 1px solid var(--rule); }
  .locks li:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 640px) {
  .top-actions .btn-small { display: none; }
  .cards { gap: 8px; }
  .card { padding: 10px; }
  .card-price { font-size: var(--step-1); }
  .card canvas { height: 70px; }
  .steps, .grid3, .plans, .locks { grid-template-columns: minmax(0, 1fr); }
  .steps li, .steps li + li { border-inline-start: 0; padding-inline: 0; border-top: 1px solid var(--rule); }
  .steps li:first-child { border-top: 0; }
  .locks li { border-inline-end: 0 !important; border-bottom: 1px solid var(--rule) !important; }
  .locks li:last-child { border-bottom: 0 !important; }
  .bt canvas { height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
