/* Layout: a trading-floor terminal. The chart owns the page; the order ticket is a rail beside it. */
:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --panel-2: #e9edf6;
  --line: #d3dae8;
  --text: #131a2b;
  --muted: #5a6783;
  --accent: #3556e0;
  --accent-ink: #ffffff;
  --up: #0c9a5b;
  --down: #d23a4d;
  --fvg: #7c3aed;
  --ob: #cc7400;
  --trend: #0284c7;
  --bos: #8c8a00;
  --liq: #d6247a;
  --eq: #526079;
  --chart-bg: #fbfcfe;
  --grid: #dfe5f0;
  --shadow: 0 1px 0 rgba(19, 26, 43, 0.04), 0 8px 24px rgba(19, 26, 43, 0.06);
  --font-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090d14; --panel: #101620; --panel-2: #161e2b; --line: #222d40; --text: #e6ebf5; --muted: #8995ad;
    --accent: #7c9bff; --accent-ink: #0a1020; --up: #27d17c; --down: #f2495c;
    --fvg: #a78bfa; --ob: #f5a524; --trend: #38bdf8; --bos: #e2e052; --liq: #f472b6; --eq: #cbd5e1;
    --chart-bg: #0b1019; --grid: #1a2333; --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 10px 30px rgba(0,0,0,0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090d14; --panel: #101620; --panel-2: #161e2b; --line: #222d40; --text: #e6ebf5; --muted: #8995ad;
  --accent: #7c9bff; --accent-ink: #0a1020; --up: #27d17c; --down: #f2495c;
  --fvg: #a78bfa; --ob: #f5a524; --trend: #38bdf8; --bos: #e2e052; --liq: #f472b6; --eq: #cbd5e1;
  --chart-bg: #0b1019; --grid: #1a2333; --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 10px 30px rgba(0,0,0,0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 32px;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.app { max-width: 1480px; margin: 0 auto; }

/* ---- top bar ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 8px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; border-radius: 4px; background:
  linear-gradient(var(--fvg), var(--fvg)) 0 0 / 100% 28% no-repeat,
  linear-gradient(var(--ob), var(--ob)) 0 50% / 70% 28% no-repeat,
  linear-gradient(var(--trend), var(--trend)) 0 100% / 100% 28% no-repeat; opacity: 0.95; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tab { border: 0; background: transparent; padding: 6px 16px; border-radius: 6px; color: var(--muted); font-weight: 700; letter-spacing: 0.02em; }
.tab.is-active { background: var(--panel-2); color: var(--text); }
.hud { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hud-item { display: flex; flex-direction: column; gap: 2px; }
.hud-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hud-val { font-size: 17px; font-weight: 600; }
.xpbar { height: 4px; width: 120px; background: var(--line); border-radius: 2px; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 16px; }
.icon-btn.is-off { opacity: 0.45; }

/* ---- layout ---- */
.trade-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.chart-card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.chart-card { overflow: hidden; min-width: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sym { display: flex; align-items: baseline; gap: 8px; }
.sym b { font-size: 16px; }
.status { margin-left: auto; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.mini { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.chart-wrap { position: relative; height: clamp(360px, 64vh, 680px); background: var(--chart-bg); }
.chart-wrap canvas { display: block; }
.chart-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; min-height: 44px; }
.rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { padding: 14px; }
.card h3 { margin: 0 0 10px; font-family: var(--font-display); font-weight: 800; font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase; }
.card h4 { margin: 12px 0 4px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card p { margin: 0 0 8px; }
.card p:last-child { margin-bottom: 0; }

/* ---- controls ---- */
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 9px 14px; font-weight: 700; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-wide { width: 100%; }
.dir-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-dir { padding: 14px 8px; font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1; border: 0; color: #fff; }
.btn-dir small { display: block; margin-top: 4px; font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: 0; opacity: 0.9; text-transform: none; }
.btn-buy { background: var(--up); color: #04140c; }
.btn-sell { background: var(--down); color: #fff; }
.btn-dir:hover { filter: brightness(1.08); }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 5px 6px; border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg button.is-on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; }
.field > span:first-child { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 12px; font-weight: 700; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); box-shadow: inset 0 0 0 2px var(--panel-2); border: 1px solid var(--c, var(--muted)); }
.chip.is-on { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--panel)); }
.chip.is-on i { background: var(--c); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.step { display: flex; gap: 8px; align-items: center; }
.step button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; }

/* ---- result + debrief ---- */
.banner { position: absolute; left: 50%; top: 14%; transform: translateX(-50%); text-align: center; padding: 14px 26px; border-radius: 12px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 2px solid var(--line); box-shadow: var(--shadow); pointer-events: none; animation: pop 0.35s cubic-bezier(.2,1.4,.4,1); }
.banner b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 42px; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1; }
.banner span { font-family: var(--font-mono); font-size: 15px; }
.banner.win { border-color: var(--up); } .banner.win b { color: var(--up); }
.banner.loss { border-color: var(--down); } .banner.loss b { color: var(--down); }
.banner.flat { border-color: var(--muted); }
@keyframes pop { from { transform: translateX(-50%) scale(0.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.verdicts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.verdict { border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); }
.verdict.is-absent { border-left-color: var(--line); opacity: 0.85; }
.verdict-head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.verdict-head .tag { margin-left: auto; font-size: 11px; font-family: var(--font-mono); font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.ok { color: var(--up); border-color: var(--up); } .tag.bad { color: var(--down); border-color: var(--down); }
.verdict p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.grade { font-family: var(--font-display); font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: 0.04em; }
.score-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hint-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--accent); color: var(--accent); font-size: 12px; font-weight: 700; }
.note { font-size: 12px; color: var(--muted); }

/* ---- drawing toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tool { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 7px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tool i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.tool:hover { color: var(--text); border-color: var(--muted); }
.tool.is-on { color: var(--text); border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--panel)); }
.tool-sep { flex: none; width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }

/* ---- coach and tips ---- */
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.coach-head h3 { margin: 0; }
.cstep { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; background: var(--panel-2); }
.cstep-head { display: flex; align-items: center; gap: 8px; }
.cstep-head i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.cstep-head b { flex: 1; min-width: 0; }
.cstep p { margin: 4px 0 0; font-size: 13px; }
.chint { color: var(--text); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 6px !important; }
.mini:disabled { opacity: 0.5; cursor: default; }
.coachline { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); font-size: 13px; }
.coachline:empty { display: none; }
.coachline b { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
.weak { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.weak:last-child { border-bottom: 0; }
.weak b { color: var(--c); }
.weak p { margin: 2px 0 0; }
.routine { list-style: decimal; margin: 8px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.routine li::marker { color: var(--c); font-weight: 700; }
.routine li { padding-left: 4px; }
.routine li > div { display: inline; }
.routine .mini { margin-left: 6px; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.rules-grid .rule { margin: 0; }
.mistakes td { white-space: normal; vertical-align: top; min-width: 160px; }
.gloss { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 8px 16px; margin: 0; }
.gloss dt { font-weight: 700; }
.gloss dd { margin: 0; color: var(--muted); }
@media (max-width: 520px) { .gloss { grid-template-columns: 1fr; gap: 2px; } .gloss dd { margin-bottom: 8px; } }

/* ---- trade review ---- */
.pathbar { position: relative; height: 22px; margin: 12px 4px 4px; }
.pb-zone { position: absolute; top: 7px; height: 8px; border-radius: 2px; }
.pb-risk { background: color-mix(in srgb, var(--down) 40%, transparent); }
.pb-reward { background: color-mix(in srgb, var(--up) 40%, transparent); }
.pb-travel { position: absolute; top: 10px; height: 2px; background: var(--text); opacity: 0.7; }
.pb-tick { position: absolute; top: 2px; width: 2px; height: 18px; margin-left: -1px; border-radius: 1px; background: var(--muted); }
.pb-sl { background: var(--down); } .pb-tp { background: var(--up); } .pb-entry { background: var(--accent); }
.pb-dot { position: absolute; top: 7px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--panel); border: 2px solid var(--muted); }
.pb-worst { border-color: var(--down); } .pb-best { border-color: var(--up); }
.pb-exit { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; border: 3px solid var(--panel); background: var(--muted); box-shadow: 0 0 0 1px var(--text); }
.pb-exit.win { background: var(--up); } .pb-exit.loss { background: var(--down); }
.pb-legend { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin: 0 0 10px; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.gtile { border: 1px solid var(--line); border-top: 3px solid var(--g); border-radius: 8px; padding: 6px 6px 7px; background: var(--panel-2); min-width: 0; }
.gtile b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; color: var(--g); }
.gtile span { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.gtile small { display: block; font-size: 11px; line-height: 1.3; color: var(--muted); margin-top: 3px; }
.g-Ap, .g-A { --g: var(--up); } .g-B { --g: var(--trend); } .g-C { --g: var(--ob); } .g-D, .g-F { --g: var(--down); }
.review .seg { margin-bottom: 10px; }
.why { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.why li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; font-size: 13px; }
.why li i { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.why .tone-good i { background: var(--up); } .why .tone-bad i { background: var(--down); } .why .tone-warn i { background: var(--ob); }

/* ---- academy ---- */
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.lesson-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lesson-card:hover { border-color: var(--c); }
.lesson-card h3 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: 0.05em; text-transform: uppercase; }
.lesson-card p { margin: 0; color: var(--muted); font-size: 13px; }
.dots { display: flex; gap: 4px; margin-top: auto; padding-top: 6px; }
.dots i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.dots i.on { background: var(--c); }
.page-title { font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: 0.04em; text-transform: uppercase; margin: 6px 0 4px; line-height: 1.05; text-wrap: balance; }
.lede { max-width: 62ch; color: var(--muted); margin: 0 0 16px; }
.learn-list { margin: 0 0 8px; padding-left: 18px; }
.learn-list li { margin-bottom: 6px; }
.rule { border-radius: 8px; padding: 8px 10px; font-size: 13px; border: 1px solid var(--line); background: var(--panel-2); margin-bottom: 6px; }
.rule b { color: var(--c); }
.tabs-mini { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs-mini button { flex: 1; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 6px; font-weight: 700; color: var(--muted); }
.tabs-mini button.is-on { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--panel)); }
.answer-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.feedback { border-radius: 8px; padding: 10px 12px; margin: 10px 0; border: 1px solid var(--line); background: var(--panel-2); }
.feedback.good { border-color: var(--up); } .feedback.bad { border-color: var(--down); }
.feedback b { display: block; margin-bottom: 2px; }

/* ---- stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat b { display: block; font-family: var(--font-mono); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.barrow { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--c); }
.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th, .log td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.log th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.scroll-x { overflow-x: auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }

@media (max-width: 960px) {
  .trade-grid { grid-template-columns: minmax(0, 1fr); }
  .hud { margin-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .chart-wrap { height: 52vh; min-height: 320px; }
  .barrow { grid-template-columns: 90px 1fr 48px; }
  .brand-name { font-size: 22px; }
  .hud { gap: 10px; flex-wrap: nowrap; }
  .xpbar { width: 84px; }
  .hud-val { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
  .xpbar i { transition: none; }
}
