/* Wick — demo site styles: a light trading terminal, lit by one flame */
:root {
  --bg: #f1f1ee;
  --panel: #ffffff;
  --line: #e1e1db;
  --line-soft: #ededea;
  --text: #16181b;
  --muted: #6a6e75;
  --dim: #9a9ea5;
  --long: #0b8a55;
  --long-bg: #e6f4ed;
  --short: #d23f39;
  --short-bg: #fbeceb;
  --flame: #ff5a1f;
  --flame-bg: #fff1ea;
  --index: #5d6f94;
  --closed: #f6f2ea;
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
svg, canvas { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--flame); outline-offset: 2px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--long); } .down { color: var(--short); }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 .4em; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: -0.03em; }
.logo svg { width: 18px; height: 28px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 12px; border: 0; background: none; cursor: pointer; border-radius: 8px; white-space: nowrap; line-height: 1.25; }
.tab:hover { background: var(--bg); }
.tab[aria-selected="true"] { background: var(--text); color: #fff; }
.tab b { font-weight: 600; font-size: .85rem; }
.tab span { font-family: var(--mono); font-size: .75rem; opacity: .8; }
.mode { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; margin-left: auto; }
.mode button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: .85rem; color: var(--muted); }
.mode button[aria-pressed="true"] { background: var(--bg); color: var(--text); font-weight: 600; }
.acct { display: flex; gap: 16px; font-size: .8rem; }
.acct div { line-height: 1.2; }
.acct .k { color: var(--muted); font-size: .72rem; }
.acct .v { font-family: var(--mono); font-weight: 500; }
.top-links { display: flex; gap: 4px; }
.top-links a, .linkbtn { text-decoration: none; color: var(--muted); padding: 6px 8px; border-radius: 6px; font-size: .85rem; background: none; border: 0; cursor: pointer; }
.top-links a:hover, .linkbtn:hover { color: var(--text); background: var(--bg); }
.paperbar { background: var(--flame-bg); color: #7a2e10; font-size: .8rem; padding: 6px 16px; border-bottom: 1px solid #ffd9c7; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.paperbar strong { color: #5c2008; }
.paperbar .replay-state { margin-left: auto; font-family: var(--mono); }

/* ---------- terminal grid ---------- */
.term { display: grid; grid-template-columns: minmax(0, 1fr) 268px 340px; grid-template-rows: auto auto 1fr; grid-template-areas: "head head side" "chart book side" "bottom bottom side"; gap: 8px; padding: 8px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.p-head h2, .p-head h3 { font-size: .9rem; margin: 0; }
.p-body { padding: 12px 14px; }
.m-head { grid-area: head; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; padding: 12px 16px; }
.m-head .sym { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.03em; }
.m-head .sym small { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.m-head .big { font-family: var(--mono); font-size: 1.6rem; font-weight: 500; letter-spacing: -0.03em; }
.stat .k { color: var(--muted); font-size: .72rem; }
.stat .v { font-family: var(--mono); font-size: .9rem; }
.chart-panel { grid-area: chart; }
.book-panel { grid-area: book; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 62px; }
.bottom { grid-area: bottom; }

/* segmented controls */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: .8rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--text); color: #fff; }

/* chart */
.chart-wrap { position: relative; height: 430px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .75rem; color: var(--muted); padding: 8px 14px 10px; border-top: 1px solid var(--line-soft); }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }

/* order book */
.book { font-family: var(--mono); font-size: .76rem; }
.book-row { position: relative; display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 2px 14px; cursor: pointer; }
.book-row:hover { background: var(--bg); }
.book-row span { position: relative; z-index: 1; text-align: right; }
.book-row span:first-child { text-align: left; }
.book-row .bar { position: absolute; top: 1px; bottom: 1px; right: 0; z-index: 0; border-radius: 2px; }
.book-row.ask span:first-child { color: var(--short); } .book-row.ask .bar { background: var(--short-bg); }
.book-row.bid span:first-child { color: var(--long); } .book-row.bid .bar { background: var(--long-bg); }
.book-row.mine span:first-child::after { content: " you"; color: var(--flame); font-family: var(--sans); font-size: .68rem; font-weight: 600; }
.book-head { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 6px 14px; color: var(--dim); font-size: .7rem; font-family: var(--sans); }
.book-head span { text-align: right; } .book-head span:first-child { text-align: left; }
.off-book { padding: 6px 14px; font-size: .72rem; color: var(--flame); font-family: var(--sans); }
.spread { display: flex; justify-content: space-between; padding: 6px 14px; margin: 3px 0; background: var(--bg); font-size: .78rem; }
.trades .tr { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 2px 14px; font-family: var(--mono); font-size: .74rem; }
.trades .tr span { text-align: right; } .trades .tr span:first-child { text-align: left; }

/* ticket */
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.sides button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px; font-weight: 600; cursor: pointer; }
.sides .long[aria-pressed="true"] { background: var(--long); border-color: var(--long); color: #fff; }
.sides .short[aria-pressed="true"] { background: var(--short); border-color: var(--short); color: #fff; }
.field { margin-bottom: 12px; }
.field label, .field .label { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; margin-bottom: 5px; }
.inp { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.inp:focus-within { border-color: var(--text); }
.inp input { flex: 1; min-width: 0; border: 0; background: none; padding: 9px 10px; font-family: var(--mono); outline: none; }
.inp .unit { padding: 0 10px; color: var(--muted); font-size: .8rem; }
.inp button { border: 0; border-left: 1px solid var(--line); background: none; padding: 9px 10px; cursor: pointer; font-size: .75rem; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.quick button { border: 1px solid var(--line); background: none; border-radius: 6px; padding: 4px 0; font-size: .75rem; cursor: pointer; color: var(--muted); }
.quick button:hover { color: var(--text); border-color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--flame); }
.levs { display: flex; justify-content: space-between; font-size: .68rem; color: var(--dim); font-family: var(--mono); }
.calc { margin: 4px 0 12px; border-top: 1px solid var(--line-soft); }
.calc div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: .8rem; }
.calc dt { color: var(--muted); }
.calc dd { margin: 0; font-family: var(--mono); text-align: right; }
.calc .flame { color: var(--flame); font-weight: 600; }
details.more summary { cursor: pointer; color: var(--muted); font-size: .8rem; margin-bottom: 8px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.submit { width: 100%; border: 0; border-radius: 10px; padding: 12px; font-weight: 600; font-size: .95rem; cursor: pointer; color: #fff; }
.submit.long { background: var(--long); } .submit.short { background: var(--short); }
.submit:disabled { opacity: .45; cursor: not-allowed; }
.err { color: var(--short); font-size: .78rem; min-height: 1.2em; margin: 8px 0 0; }
.tip { background: var(--flame-bg); border-radius: 8px; padding: 8px 10px; font-size: .78rem; color: #7a2e10; margin-bottom: 12px; }

/* risk panel: the wick */
.risk .pct { font-family: var(--mono); font-size: 2.6rem; font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.risk .pct.hot { color: var(--flame); }
.risk .sub { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.risk-top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.candle { flex: none; }
.hist svg { width: 100%; height: auto; }
.hist .ax { font-family: var(--mono); font-size: 9.5px; fill: var(--dim); }
.scen { width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: 10px; }
.scen th { text-align: left; font-weight: 400; color: var(--muted); font-size: .72rem; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.scen td { padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); }
.scen td:last-child, .scen th:last-child { text-align: right; }
.scen .liq { color: var(--flame); font-family: var(--sans); font-weight: 600; }
.empty-note { color: var(--muted); font-size: .82rem; }

/* bottom tabs + tables */
.btabs { display: flex; gap: 2px; }
.btabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: .85rem; }
.btabs button[aria-selected="true"] { background: var(--bg); color: var(--text); font-weight: 600; }
.btabs .count { font-family: var(--mono); font-size: .72rem; margin-left: 4px; }
.table-wrap { overflow-x: auto; }
table.rows { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rows th { text-align: left; font-weight: 400; color: var(--muted); font-size: .72rem; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.rows td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-family: var(--mono); }
.rows td.t { font-family: var(--sans); }
.rows th:first-child, .rows td:first-child { padding-left: 14px; }
.rows tr.click { cursor: pointer; }
.rows tr.click:hover td { background: var(--bg); }
.pill { display: inline-block; font-family: var(--sans); font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.pill.long { background: var(--long-bg); color: var(--long); } .pill.short { background: var(--short-bg); color: var(--short); }
.pill.liq { background: var(--flame-bg); color: var(--flame); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 4px 10px; cursor: pointer; font-size: .78rem; font-family: var(--sans); }
.btn:hover { border-color: var(--muted); }
.btn.dark { background: var(--text); color: #fff; border-color: var(--text); }
.btn.big { padding: 9px 16px; font-size: .9rem; border-radius: 9px; }
.tpsl { display: inline-flex; gap: 4px; align-items: center; }
.tpsl input { width: 78px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-family: var(--mono); font-size: .75rem; }
.no-rows { padding: 22px 14px; color: var(--muted); font-size: .85rem; }

/* replay panel */
.replay-panel .win { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.replay-panel .win:last-child { border-bottom: 0; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(22,24,27,.45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px; position: relative; }
.modal .x { position: absolute; top: 10px; right: 10px; border: 0; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.modal ol { padding-left: 1.2em; margin: 12px 0; }
.modal li { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 12px 0; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 120; max-width: min(360px, calc(100% - 32px)); }
.toast { background: var(--text); color: #fff; padding: 9px 14px; border-radius: 9px; font-size: .82rem; box-shadow: 0 8px 24px -10px rgba(0,0,0,.4); }
.toast.liq { background: var(--flame); }

/* doc pages */
.doc-top { display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); }
.doc-top nav { margin-left: auto; display: flex; gap: 4px; }
.doc-top nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.doc-top nav a:hover, .doc-top nav a[aria-current="page"] { color: var(--text); background: var(--bg); }
.doc { max-width: 780px; margin: 0 auto; padding: 48px 20px 80px; font-size: 15.5px; line-height: 1.65; }
.doc h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.doc h2 { font-size: 1.5rem; margin-top: 1.6em; }
.doc p, .doc li { color: #2e3137; }
.doc pre { background: var(--text); color: #f1f1ee; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: .85rem/1.6 var(--mono); }
.doc code { font-family: var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: .88em; }
.doc .lead { font-size: 1.15rem; color: var(--muted); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.plan.active { border: 2px solid var(--flame); padding: 17px; }
.plan .hold { font-family: var(--mono); font-size: 1.3rem; margin: 4px 0 10px; }
.plan ul { padding: 0; margin: 0; list-style: none; color: var(--muted); font-size: .9rem; }
.plan li { padding: 6px 0; border-top: 1px solid var(--line-soft); }
.burn { font-family: var(--mono); font-size: clamp(2.6rem, 8vw, 4.6rem); letter-spacing: -0.04em; color: var(--flame); line-height: 1; }
.note { border-left: 3px solid var(--flame); background: var(--panel); padding: 10px 14px; border-radius: 0 8px 8px 0; color: var(--muted); }
.doc-foot, .term-foot { color: var(--dim); font-size: .75rem; padding: 14px 16px 24px; max-width: 980px; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .term { grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto auto 1fr auto; grid-template-areas: "head side" "chart side" "book side" "bottom bottom"; }
  .acct .opt { display: none; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px 12px; position: static; }
  .tabs { order: 3; width: 100%; }
  .mode { margin-left: auto; }
  .acct { order: 4; width: 100%; justify-content: space-between; }
  .acct .opt { display: block; }
  .top-links { order: 2; }
  .term { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "head" "chart" "side" "book" "bottom"; padding: 6px; gap: 6px; }
  .side { position: static; }
  .chart-wrap { height: 300px; }
  .m-head { gap: 8px 18px; }
  .plans { grid-template-columns: 1fr; }
  .doc-top { flex-wrap: wrap; height: auto; padding: 10px 16px; }
}
