/* Platform palette, mapped onto the shared design tokens (css/tokens.css). */
:root {
  --bg: var(--c-bg);
  --bg-2: var(--c-bg-2);
  --panel: #0d1b2e;
  --panel-2: var(--c-surface);
  --panel-3: var(--c-surface-3);
  --chart: #0a1626;
  --border: rgba(148, 163, 184, 0.14);
  --border-2: rgba(148, 163, 184, 0.26);
  --text: var(--c-text);
  --muted: var(--c-text-2);
  --dim: var(--c-text-3);
  --accent: var(--c-accent);
  --accent-2: #6d93f7;
  --up: #26a69a;
  --up-2: #2fc1b2;
  --down: #ef5350;
  --down-2: #ff6b68;
  --gold: #f2b84b;
  --radius: 10px;
  /* the chart and the bars around it; js/app.js sets body[data-chart-bg] to match the chart background */
  --chart-bar: var(--bg-2);
  --chart-line: var(--border);
  color-scheme: dark;
}
body[data-chart-bg="aurora"] { --chart: #08132a; --chart-bar: linear-gradient(180deg, #0c1b35, #0a172d); --chart-line: rgba(120, 150, 235, 0.13); }
body[data-chart-bg="midnight"] { --chart: #08111f; --chart-bar: linear-gradient(180deg, #0d1b33, #0a1528); --chart-line: rgba(120, 150, 230, 0.12); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
input[type=file] { font-size: 16px; }
/* every control answers a tap at once (no double-tap zoom wait) and draws its own pressed state */
button, a, input, label, [role="button"] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
svg { display: block; }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }

/* ---------- demo banner ---------- */
.demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 12px;
  color: #f6e3b4;
  background: linear-gradient(90deg, rgba(245,185,66,0.10), rgba(245,185,66,0.18), rgba(245,185,66,0.10));
  border-bottom: 1px solid rgba(245,185,66,0.28);
  text-align: center;
}
.demo-banner b { color: #ffe6a6; }
.db-tag {
  flex: none;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #1b1405;
  background: var(--gold);
  border-radius: 4px;
  padding: 2px 6px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; direction: ltr; align-items: center; gap: 9px; flex: none; }
.brand { text-decoration: none; color: var(--text); }
.logo-mark { flex: none; color: var(--c-logo); }
.brand-name { font-family: var(--font-wordmark); font-weight: 700; font-size: 15px; letter-spacing: 0.06em; white-space: nowrap; }
.brand-name b { font-weight: inherit; color: inherit; }
.badge-demo {
  font-size: 11px; font-weight: 800; letter-spacing: 0.1em;
  color: var(--gold); border: 1px solid rgba(245,185,66,0.55); border-radius: 4px; padding: 1px 5px;
}
.coin {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff; flex: none;
}
.coin.BTC { background: linear-gradient(135deg, #f7a531, #e9790f); }
.coin.ETH { background: linear-gradient(135deg, #8a9dff, #5468e0); }
.fx-ico { position: relative; width: 34px; height: 28px; flex: none; }
.fx-ico i {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 10px; color: #fff;
  border: 2px solid var(--bg-2);
}
.fx-ico i:first-child { left: 0; top: 0; z-index: 1; }
.fx-ico i:last-child { right: 0; bottom: 0; }
.ico-sm { display: inline-flex; align-items: center; }
.ico-sm .coin { width: 20px; height: 20px; font-size: 11px; }
.ico-sm .fx-ico { width: 26px; height: 20px; }
.ico-sm .fx-ico i { width: 16px; height: 16px; font-size: 8px; border-width: 1.5px; }
.otc-tag {
  display: inline-block; vertical-align: 1px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; line-height: 1;
  color: var(--dim);
}

.market-btn {
  display: flex; align-items: center; gap: 10px;
  min-width: 270px; padding: 6px 10px 6px 8px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px; text-align: left;
  transition: background .15s, border-color .15s;
}
.market-btn.open { background: var(--panel-3); border-color: var(--accent); }
@media (hover: hover) { .market-btn:hover { background: var(--panel-3); border-color: var(--accent); } }
.mb-main { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mb-pair { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.mb-name { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-quote { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.mb-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.mb-chg { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.market-btn svg.chev, .slot-market svg.chev { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.market-menu {
  position: fixed; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  overflow: hidden;
}
.mm-head { display: none; }
.mm-top { padding: 10px 10px 0; }
.mm-top .search { margin-bottom: 8px; }
.mm-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.mm-tabs::-webkit-scrollbar { display: none; }
.mm-tabs button { flex: none; }
.mm-tabs button {
  border: 0; background: transparent; color: var(--muted); font-weight: 600;
  padding: 6px 12px; border-radius: 7px;
}
@media (hover: hover) { .mm-tabs button:hover { color: var(--text); background: var(--panel-2); } }
.mm-tabs button.active { color: var(--accent-2); background: rgba(61,123,255,0.14); }
.mm-cols, .mm-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px 66px; align-items: center; gap: 8px; }
.mm-cols { padding: 10px 14px 6px; font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); }
.mm-cols span:nth-child(n+2) { text-align: right; }
.mm-list { overflow-y: auto; padding: 4px 6px 6px; flex: 1; min-height: 0; }
.mm-group { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 8px 4px; display: flex; align-items: center; gap: 6px; }
.mm-row {
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 7px 8px; border-radius: 8px;
}
@media (hover: hover) { .mm-row:hover { background: var(--panel-2); } }
.mm-row.active { background: rgba(61,123,255,0.14); }
.mm-mk { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mm-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mm-name b { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.mm-name small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-price { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.mm-chg { text-align: right; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- favourite markets: a star on every picker row and beside the market button, and the strip of small charts ---------- */
.mm-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; }
.mm-item .mm-row { padding-left: 4px; }
.mm-cols { padding-left: 40px; }
.mm-star { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--dim); }
.mm-star svg, .mm-group-fav svg, .mm-tab-fav svg, .mm-fav-empty svg, .fs-unstar svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.mm-star svg { width: 16px; height: 16px; }
@media (hover: hover) { .mm-star:hover { color: #f5c451; background: var(--panel-2); } }
.mm-star.on, .fav-btn.on, .fs-unstar, .mm-group-fav, .mm-fav-empty svg { color: #f5c451; }
.mm-star.on svg, .fav-btn.on svg, .fs-unstar svg, .mm-group-fav svg, .mm-fav-empty svg { fill: currentColor; }
.mm-group-fav svg { width: 13px; height: 13px; }
.mm-tab-fav { display: inline-flex; align-items: center; gap: 5px; }
.mm-tab-fav svg { width: 14px; height: 14px; }
.mm-fav-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mm-fav-empty svg { width: 28px; height: 28px; }
.mm-fav-empty b { color: var(--text); font-size: 13.5px; }
.mm-fav-empty span { max-width: 290px; line-height: 1.45; }
.fav-btn.on { border-color: rgba(245, 196, 81, 0.45); }

.fav-strip { display: flex; align-items: center; gap: 8px; padding: 6px 8px; flex: none; background: var(--chart-bar); border-bottom: 1px solid var(--chart-line); }
.fav-strip[hidden] { display: none; }
.fs-list { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
.fs-list::-webkit-scrollbar { display: none; }
.fs-card { position: relative; flex: none; border: 1px solid var(--border); border-radius: 10px; background: rgba(13, 27, 46, 0.72); }
@media (hover: hover) { .fs-card:hover { border-color: var(--border-2); } }
.fs-card.active { border-color: rgba(109, 147, 247, 0.8); background: rgba(61, 123, 255, 0.13); }
.fs-card.closed .fs-open { opacity: 0.6; }
.fs-open {
  display: grid; grid-template-columns: auto 64px; column-gap: 9px; row-gap: 3px; align-items: center;
  padding: 6px 24px 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: start;
}
.fs-top { display: flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.fs-top b { font-weight: 700; }
.fs-pay { font-size: 11px; font-weight: 700; color: var(--up-2); }
.fs-mid { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fs-price { font-weight: 600; }
.fs-chg { font-size: 11.5px; font-weight: 600; }
.fs-chg.up { color: var(--up-2); }
.fs-chg.down { color: var(--down-2); }
.fs-chg.shut { color: var(--dim); }
.fs-chart { grid-column: 2; grid-row: 1 / 3; width: 64px; height: 34px; display: block; }
/* more cards than fit: the strip fades out on the side that scrolls (classes set by js/app.js) */
.fs-list.fade-e { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.fs-list.fade-s { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px); mask-image: linear-gradient(90deg, transparent, #000 32px); }
.fs-list.fade-s.fade-e { -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
[dir="rtl"] .fs-list.fade-e:not(.fade-s) { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(270deg, #000 calc(100% - 32px), transparent); }
[dir="rtl"] .fs-list.fade-s:not(.fade-e) { -webkit-mask-image: linear-gradient(270deg, transparent, #000 32px); mask-image: linear-gradient(270deg, transparent, #000 32px); }
.fs-unstar { position: absolute; top: 3px; inset-inline-end: 3px; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; }
.fs-unstar svg { width: 13px; height: 13px; }
@media (hover: hover) { .fs-unstar:hover { background: var(--panel-3); } }
.fs-type button { padding: 5px 7px; }
.fs-type svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.mstats { display: flex; gap: 18px; padding-left: 8px; border-left: 1px solid var(--border); }
.ms { display: flex; flex-direction: column; line-height: 1.25; }
.ms span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ms b { font-weight: 600; font-variant-numeric: tabular-nums; }

.balance-box {
  display: flex; align-items: center; gap: 10px; line-height: 1.2;
  padding: 5px 6px 5px 12px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
}
.bb-text { display: flex; flex-direction: column; align-items: flex-end; }
.bb-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.bb-reset {
  flex: none; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border-2); border-radius: 8px; background: var(--panel-3); color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.bb-reset svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .45s cubic-bezier(.22, 1, .36, 1); }
.bb-reset:focus-visible { color: var(--text); border-color: var(--accent); outline: none; }
@media (hover: hover) { .bb-reset:hover { color: var(--text); border-color: var(--accent); outline: none; } }
@media (hover: hover) { .bb-reset:hover svg { transform: rotate(-120deg); } }
.bb-reset:active svg { transform: rotate(-300deg); }
.bb-value { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; transition: color .3s; }
.bb-value.flash-up { color: var(--up-2); }
.bb-value.flash-down { color: var(--down-2); }

.btn {
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
@media (hover: hover) { .btn:hover { background: var(--panel-3); } }
.btn.ghost { background: transparent; }
@media (hover: hover) { .btn.ghost:hover { background: var(--panel-2); } }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (hover: hover) { .btn.primary:hover { background: var(--accent-2); } }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.big { padding: 12px 18px; font-size: 14px; width: 100%; }

/* pressed feedback for touch and mouse alike: hover doesn't exist on a phone, so a press shows itself */
.tbtn:not(:disabled):active, .seg button:active, .icon-btn:active, .tool:active, .step:active, .chips button:active,
.expiry-grid button:active, .exp-btn:active, .acct-opt:active, .x:active, .sheet-close:active, .mm-close:active, .bb-reset:active,
.bb-deposit:active, .chart-btn:active, .dp-del:active, .dp-colors button:active, .pm-env button:active, .mode-banner button:active,
.lg-btns button:active, .hot-x:active, .bg-opt:active { transform: scale(0.94); }
.btn:not(:disabled):active { transform: scale(0.97); }
.mm-row:active, .ind-item:active, .pm-item:active, .dd-menu button:active, .st-link:active, .mode-opt:active, .otrade:active,
.tab:active, .st-nav button:active, .market-btn:active, .slot-market:active, .mm-tabs button:active { background: var(--panel-3); }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 330px;
}

/* ---------- drawing toolbar ---------- */
.drawbar {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.tool {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
}
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .tool:hover { background: var(--panel-2); color: var(--text); } }
.tool.active { background: rgba(61,123,255,0.18); color: var(--accent-2); }
.tool-sep { width: 24px; height: 1px; background: var(--border); margin: 5px 0; flex: none; }

/* ---------- chart area ---------- */
.chart-area { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chart); }
.chart-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--chart-line); }
.chart-grid[data-layout="2"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1px; }
.chart-slot { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chart); }
.chart-grid[data-layout="1"] .chart-slot[data-slot="1"] { display: none; }
.slot-head {
  display: none; align-items: center; gap: 8px;
  height: 36px; padding: 0 8px; flex: none;
  background: var(--chart-bar); border-bottom: 1px solid var(--chart-line);
  font-variant-numeric: tabular-nums;
}
.chart-grid[data-layout="2"] .slot-head { display: flex; }
.chart-grid[data-layout="2"] .chart-slot.active .slot-head { box-shadow: inset 0 -2px 0 var(--accent); }
.chart-grid[data-layout="2"] .chart-slot:not(.active) .chart-host { opacity: 0.92; }
.slot-market {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 3px 6px 3px 4px;
  font-weight: 700; white-space: nowrap;
}
@media (hover: hover) { .slot-market:hover { background: var(--panel-2); border-color: var(--border-2); } }
.slot-tf { color: var(--muted); font-size: 12px; font-weight: 600; }
.slot-active { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--accent-2); display: none; }
.chart-slot.active .slot-active { display: inline; }
.slot-price { font-weight: 700; }
.slot-chg { font-size: 12px; font-weight: 600; min-width: 56px; text-align: right; }
.layout-seg svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.chart-toolbar {
  display: flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 10px;
  border-bottom: 1px solid var(--chart-line);
  background: var(--chart-bar);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.chart-toolbar::-webkit-scrollbar { display: none; }
.seg { display: flex; gap: 2px; flex: none; }
.seg button, .tbtn {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 9px; border-radius: 6px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; flex: none;
}
@media (hover: hover) { .seg button:hover, .tbtn:hover { background: var(--panel-2); color: var(--text); } }
.seg button.active { color: var(--accent-2); background: rgba(61,123,255,0.14); }
.tbtn.icon { padding: 5px 7px; }
.tbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tbtn svg.chev { width: 14px; height: 14px; }
.fx { font-style: italic; font-weight: 800; color: var(--accent-2); }
.tb-sep { width: 1px; height: 22px; background: var(--border); flex: none; margin: 0 4px; }
.tb-hint { color: var(--dim); font-size: 11.5px; white-space: nowrap; }

.dd { position: relative; flex: none; }
.dd-menu {
  position: fixed; z-index: 50;
  min-width: 170px; padding: 5px;
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  display: none;
}
.dd.open .dd-menu { display: block; }
.dd-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; text-align: left; color: var(--text);
}
@media (hover: hover) { .dd-menu button:hover { background: var(--panel-3); } }
.dd-menu button.active { color: var(--accent-2); }
.dd-menu button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dd-menu button span { margin-left: auto; font-size: 12px; color: var(--muted); }
.dd-menu button b { min-width: 30px; font-weight: 700; }
/* the timeframe menu and the chart-type icon stand in for the button rows and labels on phones */
.tf-dd, .tb-ic { display: none; }
.tf-dd .tb-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#tfBtn b { color: var(--text); font-weight: 700; }

.chart-host { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
.chart-canvas { position: absolute; inset: 0; display: block; }
.chart-legend {
  position: absolute; top: 6px; left: 8px; z-index: 3;
  display: flex; flex-direction: column; gap: 1px;
  pointer-events: none;
  max-width: calc(100% - 110px);
}
.lg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.lg-sym { font-weight: 700; color: var(--text); }
.lg-ohlc { font-variant-numeric: tabular-nums; }
.lg-ohlc b { font-weight: 600; margin: 0 6px 0 2px; }
.lg-row {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font-size: 11.5px; color: var(--muted);
  padding: 1px 6px 1px 4px; border-radius: 5px;
  pointer-events: auto;
  border: 1px solid transparent;
}
@media (hover: hover) { .lg-row:hover { background: rgba(13,27,56,0.85); border-color: var(--border); } }
.lg-row.off .lg-name { text-decoration: line-through; opacity: 0.6; }
.lg-name { color: var(--text); font-weight: 500; }
.lg-vals { display: inline-flex; gap: 8px; font-variant-numeric: tabular-nums; }
.lg-vals i { font-style: normal; }
.lg-btns { display: none; gap: 2px; }
@media (hover: hover) { .lg-row:hover .lg-btns { display: inline-flex; } }
.lg-row.open .lg-btns, .lg-row:focus-within .lg-btns { display: inline-flex; }
.lg-row.open { background: rgba(13, 27, 56, 0.9); border-color: var(--border); }
.lg-btns button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; font-size: 12px; line-height: 18px; border-radius: 4px; }
@media (hover: hover) { .lg-btns button:hover { background: var(--panel-3); color: var(--text); } }
.pane-legend { position: absolute; left: 8px; z-index: 3; pointer-events: none; }

.chart-btn {
  position: absolute; z-index: 4;
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--muted);
  border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
@media (hover: hover) { .chart-btn:hover { color: var(--text); background: var(--panel-3); } }
.chart-btn.auto { right: 6px; padding: 3px 6px; }
.chart-btn.auto.on { color: var(--accent-2); border-color: rgba(61,123,255,0.6); }
.chart-btn.live { right: 96px; bottom: 40px; padding: 6px 9px; font-size: 11px; display: none; }

.draw-pop {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.dp-colors { display: flex; gap: 4px; }
.dp-colors button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.dp-colors button.active { border-color: #fff; }
.dp-del { border: 0; background: transparent; color: var(--muted); padding: 3px; border-radius: 6px; margin-left: 2px; }
@media (hover: hover) { .dp-del:hover { color: var(--down); background: var(--panel-3); } }
.dp-del svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.loader {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--chart); color: var(--muted);
}
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- trade panel ---------- */
.trade-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.tp-section { padding: 14px; border-bottom: 1px solid var(--border); }
.tp-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.tp-quote {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.tpq-pair { font-weight: 700; }
.tpq-sub { font-size: 11px; color: var(--muted); }
.tpq-price { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; } /* recoloured every tick: no transition, which would restyle it on every frame */
.tp-label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 6px; }

.amount-row { display: flex; gap: 6px; }
.step {
  width: 40px; flex: none; border: 1px solid var(--border-2); background: var(--panel-2);
  border-radius: 8px; font-size: 18px; font-weight: 600;
}
@media (hover: hover) { .step:hover { background: var(--panel-3); } }
.amount-input {
  flex: 1; display: flex; align-items: center; gap: 4px;
  padding: 0 12px; height: 42px;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 8px;
}
.amount-input:focus-within { border-color: var(--accent); }
.amount-input span { color: var(--muted); font-weight: 700; font-size: 16px; }
.amount-input input { width: 100%; height: 100%; border: 0; background: transparent; outline: none; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-input input::-webkit-inner-spin-button { -webkit-appearance: none; }
.amount-input input { -moz-appearance: textfield; appearance: textfield; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin: 7px 0 14px; }
.chips button {
  border: 1px solid var(--border); background: var(--panel); border-radius: 6px; padding: 5px 0;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
@media (hover: hover) { .chips button:hover { color: var(--text); border-color: var(--border-2); } }

.expiry-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 14px; }
.expiry-grid button {
  border: 1px solid var(--border); background: var(--panel); border-radius: 7px; padding: 7px 0 5px;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.expiry-grid button b { font-size: 13px; }
.expiry-grid button small { font-size: 11px; color: var(--muted); }
@media (hover: hover) { .expiry-grid button:hover { border-color: var(--border-2); } }
.expiry-grid button.active { border-color: var(--accent); background: rgba(61,123,255,0.14); }
.expiry-grid button.active small { color: var(--accent-2); }

.payout-box {
  display: grid; gap: 5px; padding: 10px 12px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.payout-box div { display: flex; justify-content: space-between; }
.payout-box span { color: var(--muted); }
.payout-box b { font-variant-numeric: tabular-nums; }

.trade-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trade-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; border: 0; border-radius: 10px;
  font-size: 15px; font-weight: 800; letter-spacing: 0.04em; color: #fff;
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.trade-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.trade-btn.up { background: linear-gradient(180deg, #2bb8a9, #1f8f84); box-shadow: 0 6px 18px rgba(38,166,154,0.25); }
.trade-btn.down { background: linear-gradient(180deg, #f2615e, #d43f3c); box-shadow: 0 6px 18px rgba(239,83,80,0.25); }
@media (hover: hover) { .trade-btn:not(:disabled):hover { filter: brightness(1.08); } }
.trade-btn:not(:disabled):active { transform: translateY(1px) scale(0.97); filter: brightness(0.9); box-shadow: none; }
.trade-btn:disabled { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; box-shadow: none; }
.fineprint { margin: 10px 0 0; font-size: 11px; color: var(--dim); line-height: 1.5; }
.fineprint b { color: var(--muted); }
.broke {
  margin-top: 12px; padding: 12px; border-radius: var(--radius);
  background: rgba(239,83,80,0.1); border: 1px solid rgba(239,83,80,0.35);
  display: grid; gap: 8px; font-size: 12.5px;
}

.tp-tabs { display: flex; padding: 0 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.tab {
  border: 0; background: transparent; color: var(--muted); padding: 11px 10px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px;
}
@media (hover: hover) { .tab:hover { color: var(--text); } }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.count { background: var(--panel-3); border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 17px; }
.tp-list { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--dim); text-align: center; padding: 26px 10px; font-size: 12.5px; }

.otrade {
  padding: 10px 11px; border-radius: 9px; background: var(--panel); border: 1px solid var(--border);
  display: grid; gap: 6px;
}
.ot-top { display: flex; align-items: center; gap: 8px; }
.ot-dir { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: #fff; flex: none; }
.ot-dir.up { background: var(--up); }
.ot-dir.down { background: var(--down); }
.ot-asset { font-weight: 700; }
.ot-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.ot-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ot-row b { color: var(--text); font-weight: 600; }
.ot-bar { height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }
/* stepped by each tick (4 a second) with no transition: a running transition restyled the row on every frame */
.ot-bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.ot-status { font-weight: 700; }
.ot-foot { align-items: center; }
.ot-time { font-weight: 600; color: var(--muted); }
.ot-time::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 6px; vertical-align: 1px; border-radius: 50%; background: var(--gold); opacity: .8; }
.ot-ret { display: inline-flex; align-items: baseline; gap: 7px; }
.ot-ret small { font-size: 11px; font-weight: 600; }
.ot-ret b { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; transition: color .25s; }
.ot-row .ot-ret.win b, .ot-ret.win small { color: var(--up-2); }
.ot-row .ot-ret.lose b, .ot-ret.lose small { color: var(--down-2); }
.ot-row .ot-ret.even b { color: var(--text); }

.htable { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.htable th { text-align: left; color: var(--dim); font-weight: 600; padding: 4px 4px 6px; border-bottom: 1px solid var(--border); }
.htable td { padding: 6px 4px; border-bottom: 1px solid rgba(27,47,88,0.6); white-space: nowrap; vertical-align: top; line-height: 1.35; }
.htable td:last-child, .htable th:last-child { text-align: right; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; }
.stat > span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat.wide { grid-column: span 2; }
.winbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 8px; background: var(--panel-3); }
.winbar i { display: block; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  min-width: 240px; max-width: 340px;
  padding: 11px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border-2);
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  transform: translateX(30px); opacity: 0; transition: transform .25s, opacity .25s;
  font-size: 12.5px;
}
.toast.show { transform: none; opacity: 1; }
.toast.win { border-left: 4px solid var(--up); }
.toast.loss { border-left: 4px solid var(--down); }
.toast.info { border-left: 4px solid var(--accent); }
.toast.tie { border-left: 4px solid var(--muted); }
.toast b.big { font-size: 15px; display: block; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 16px;
  background: rgba(3,8,20,0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3, .modal-card h3 { margin: 0; font-size: 16px; }
.modal-foot { display: flex; gap: 8px; margin-top: 16px; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
@media (hover: hover) { .x:hover { background: var(--panel-3); color: var(--text); } }
/* demo welcome: shown once, before the welcome offer and the tour */
.modal-card.welcome {
  position: relative; max-width: 540px; padding: 0 24px 22px;
  border-color: rgba(109, 147, 247, 0.32); border-radius: 18px;
  background: radial-gradient(120% 46% at 50% 0%, rgba(49, 95, 234, 0.2), transparent 64%), linear-gradient(180deg, #10213a, var(--panel) 46%);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8), 0 0 80px -30px rgba(56, 189, 248, 0.45);
}
.modal-card.welcome:focus { outline: none; }
.w-hero {
  position: relative; height: 92px; margin: 0 -24px 16px; overflow: hidden; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(49, 95, 234, 0.16), rgba(56, 189, 248, 0.03));
}
.w-hero::before { /* chart grid */
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px 7px;
}
.w-candles {
  position: absolute; left: 0; top: 12px; width: 100%; height: 72px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 58%, transparent 92%); mask-image: linear-gradient(90deg, transparent, #000 14%, #000 58%, transparent 92%);
}
.w-candles path { stroke-width: 1.4; fill: none; }
.w-candles rect { fill-opacity: 0.85; }
.w-candles .u path { stroke: #22b39a; } .w-candles .u rect { fill: #22b39a; }
.w-candles .d path { stroke: #f0525a; } .w-candles .d rect { fill: #f0525a; }
.w-candles .w-line { stroke: rgba(122, 162, 255, 0.45); stroke-dasharray: 3 5; }
.w-chip {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%); display: grid; gap: 1px; padding: 8px 14px; line-height: 1.15;
  border-radius: 12px; background: rgba(9, 20, 36, 0.86); border: 1px solid rgba(109, 147, 247, 0.42);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.6), 0 0 24px -6px rgba(56, 189, 248, 0.4);
}
.w-chip small { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.w-chip b { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.w-badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.1em; color: #1b1405; background: var(--gold); padding: 3px 8px; border-radius: 5px; }
.welcome h2 { margin: 10px 0 6px; font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.welcome p { margin: 0 0 10px; color: var(--muted); line-height: 1.55; }
.welcome p b { color: var(--text); }
.welcome ul { list-style: none; padding: 0; margin: 14px 0 16px; display: grid; gap: 8px; }
.welcome li {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; padding: 11px 12px;
  border-radius: 12px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.025); color: var(--muted); line-height: 1.5;
}
.welcome li b { color: var(--text); }
.w-ic {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #9cbcff;
  background: linear-gradient(135deg, rgba(49, 95, 234, 0.3), rgba(56, 189, 248, 0.1)); border: 1px solid rgba(109, 147, 247, 0.3);
}
.welcome li:last-child .w-ic { color: var(--gold); background: rgba(242, 184, 75, 0.12); border-color: rgba(242, 184, 75, 0.35); }
.w-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.welcome .btn.big {
  height: 48px; padding: 0 18px; border: 0; border-radius: 12px; font-size: 14.5px;
  background: linear-gradient(180deg, #4470f0, #315fea); box-shadow: 0 12px 30px -10px rgba(49, 95, 234, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
@media (hover: hover) { .welcome .btn.big:hover { background: linear-gradient(180deg, #5580f5, #3a68ef); } }
.welcome .btn.big:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px; }
/* the welcome's button stays in view at the foot of the window when the text has to scroll (phones, short screens) */
@media (max-height: 640px) and (min-width: 601px) {
  .w-actions { position: sticky; bottom: -22px; z-index: 2; margin: 0 -24px -22px; padding: 14px 24px 22px; background: linear-gradient(rgba(13, 27, 46, 0), var(--panel) 32%); }
}

/* first-visit windows (welcome, welcome offer): a card that rises in; a sheet from the bottom on phones */
.ob-modal { background: rgba(3, 8, 20, 0.78); }
.ob-modal .modal-card { animation: obIn .55s cubic-bezier(.34, 1.3, .64, 1) both; }
@keyframes obIn { from { opacity: 0; transform: perspective(900px) translateY(26px) rotateX(9deg) scale(0.96); } }
@media (max-width: 600px) {
  .ob-modal { place-items: end center; padding: 0; }
  .ob-modal .modal-card {
    max-width: none; max-height: 94vh; max-height: 94dvh; border-bottom: 0; border-radius: 22px 22px 0 0;
    padding-left: 20px; padding-right: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom));
    animation: obSheet .45s cubic-bezier(.22, 1, .36, 1) both;
  }
  .w-hero { margin-left: -20px; margin-right: -20px; height: 84px; }
  .welcome h2 { font-size: 21px; }
  .welcome li { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .w-ic { width: 30px; height: 30px; border-radius: 9px; }
  .w-ic svg { width: 16px; height: 16px; }
  .w-actions {
    position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); z-index: 2;
    margin: 0 -20px calc(-20px - env(safe-area-inset-bottom)); padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(13, 27, 46, 0), var(--panel) 32%);
  }
  @keyframes obSheet { from { transform: translateY(100%); } }
}
/* the welcome's chart draws in from the left once, then the balance chip lands */
.ob-modal .w-candles { animation: wDraw 1.1s .15s cubic-bezier(.4, 0, .2, 1) both; }
.ob-modal .w-chip { animation: wChip .5s .75s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes wDraw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wChip { from { opacity: 0; transform: translateY(-50%) scale(0.86); } }
@media (prefers-reduced-motion: reduce) {
  .ob-modal .modal-card, .ob-modal .w-candles, .ob-modal .w-chip { animation: none; }
}
.confirm p { color: var(--muted); }

.search {
  width: 100%; padding: 9px 12px; margin-bottom: 10px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 8px; outline: none;
}
.search:focus { border-color: var(--accent); }
.ind-list { display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.ind-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  border: 0; background: transparent; text-align: left; width: 100%;
}
@media (hover: hover) { .ind-item:hover { background: var(--panel-2); } }
.ind-item .ii-main { flex: 1; display: flex; flex-direction: column; }
.ind-item .ii-main b { font-weight: 600; }
.ind-item .ii-main small { color: var(--muted); }
.ii-kind { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.ii-on { font-size: 11px; color: var(--accent-2); font-weight: 600; }
.ii-add { color: var(--accent-2); font-weight: 700; font-size: 18px; line-height: 1; }
.ind-group { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; padding: 10px 10px 4px; }

.set-body { display: grid; gap: 10px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row label { color: var(--muted); }
.set-row input[type=number] {
  width: 110px; padding: 7px 10px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 7px; outline: none;
}
.set-row input[type=number]:focus { border-color: var(--accent); }
.set-row input[type=color] { width: 44px; height: 30px; border: 1px solid var(--border-2); border-radius: 7px; background: var(--bg-2); padding: 2px; }
.set-sub { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 6px; }

/* ---------- fullscreen chart ---------- */
body.chart-fs .demo-banner, body.chart-fs .topbar, body.chart-fs .trade-panel { display: none; }
body.chart-fs .layout { grid-template-columns: 48px minmax(0, 1fr); }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .mstats .ms.opt { display: none; }
  .market-btn { min-width: 240px; }
  .tb-hint { display: none; }
}
@media (max-width: 1100px) {
  .mstats { display: none; }
  .layout { grid-template-columns: 46px minmax(0, 1fr) 300px; }
}
/* touch tablets sideways: the bigger toolbar targets only fit with chart type and indicators as icons */
@media (pointer: coarse) and (min-width: 861px) and (max-width: 1100px) {
  .tbtn svg.tb-ic { display: block; width: 20px; height: 20px; }
  .tb-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #typeBtn, #indBtn { gap: 4px; padding: 0 8px; }
}
.toast > b:not(.big) { display: block; margin-bottom: 2px; }

/* ---------- practice modes (demo only) ---------- */
.tp-label-note { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--dim); margin-left: 4px; }
.mode-note {
  margin-bottom: 12px; padding: 9px 11px; border-radius: 9px; font-size: 11.5px; line-height: 1.5;
  color: #f6e3b4; background: rgba(245,185,66,0.09); border: 1px solid rgba(245,185,66,0.35);
}
.mode-note b { color: #ffe6a6; }
.trade-btn.practice { outline: 2px dashed rgba(245,185,66,0.7); outline-offset: 2px; }
.pr-tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; line-height: 1;
  color: #1b1405; background: var(--gold); border-radius: 4px; padding: 2px 5px; vertical-align: 1px; white-space: nowrap;
}
.htable small.adj { color: var(--gold); font-size: 11px; font-weight: 600; }
.stats-title { font-weight: 700; font-size: 12px; margin: 4px 2px 8px; display: flex; align-items: center; gap: 6px; }
.stats-grid + .stats-title { margin-top: 14px; }
.stats-grid + .stats-grid { margin-top: 8px; }
.loader-err { display: grid; gap: 6px; text-align: center; max-width: 360px; padding: 0 16px; }
.loader-err b { color: var(--text); font-size: 15px; }
.loader-err code { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 6px; color: var(--text); }

/* ---------- settings ---------- */
.icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border-2); background: transparent; border-radius: 8px; color: var(--muted);
}
@media (hover: hover) { .icon-btn:hover { background: var(--panel-2); color: var(--text); } }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.modal-card.settings { max-width: 680px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.modal-card.settings .st-layout { flex: 1; }
.modal-card.settings .modal-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--border); }
.st-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-height: min(380px, calc(100vh - 110px)); min-height: min(380px, calc(100dvh - 110px)); overflow: hidden; }
.st-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; border-right: 1px solid var(--border); background: var(--bg-2); }
.st-nav button {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--muted);
  padding: 9px 10px; border-radius: 8px; font-weight: 600; text-align: left;
}
.st-nav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
@media (hover: hover) { .st-nav button:hover { background: var(--panel-2); color: var(--text); } }
.st-nav button.active { background: rgba(61,123,255,0.14); color: var(--accent-2); }
.st-panels { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.st-group + #modeSection:not([hidden]) { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.st-group-head { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.st-desc { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.mode-list { display: grid; gap: 8px; margin-bottom: 12px; }
.mode-opt {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: start; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; text-align: left; width: 100%;
}
@media (hover: hover) { .mode-opt:hover { border-color: var(--border-2); } }
.mode-opt .radio { width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--border-2); display: grid; place-items: center; }
.mode-opt.active .radio { border-color: var(--accent); }
.mode-opt.active .radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mode-opt.practice.active { border-color: var(--gold); background: rgba(245,185,66,0.08); }
.mode-opt.practice.active .radio { border-color: var(--gold); }
.mode-opt.practice.active .radio::after { background: var(--gold); }
.mode-opt.active:not(.practice) { border-color: var(--accent); background: rgba(61,123,255,0.1); }
.mode-opt .mo-text { display: flex; flex-direction: column; gap: 2px; }
.mode-opt .mo-text b { font-size: 13px; }
.mode-opt .mo-text small { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.mode-opt .mo-rate { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.mode-opt.practice .mo-rate { color: var(--gold); }
.st-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.st-item:last-child { border-bottom: 0; }
.st-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st-text b { font-size: 13px; }
.st-text small { color: var(--muted); font-size: 11.5px; }
.st-item.disabled .st-text { opacity: 0.6; }
.tfa-form { display: grid; gap: 8px; margin: 4px 0 6px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2, transparent); }
.tfa-form[hidden] { display: none; }
.tfa-form label { font-size: 12.5px; font-weight: 600; }
.tfa-form input { height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-3); color: inherit; font: inherit; font-size: 14px; }
.tfa-form input:focus { outline: none; border-color: var(--accent); }
.tfa-err { min-height: 0; color: var(--down, #f0525a); font-size: 12px; }
.tfa-err:empty { display: none; }
.tfa-acts { display: flex; justify-content: flex-end; gap: 8px; }
.soon {
  flex: none; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent-2); background: rgba(61,123,255,0.12); border: 1px solid rgba(61,123,255,0.35); border-radius: 4px; padding: 2px 6px;
}
.switch { flex: none; width: 36px; height: 20px; padding: 0; border: 0; border-radius: 10px; background: var(--panel-3); position: relative; opacity: 0.5; }
.switch i { position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .2s cubic-bezier(.22,1,.36,1), background .2s; }
button.switch { opacity: 1; cursor: pointer; box-shadow: inset 0 0 0 1px var(--border-2); transition: background .2s, box-shadow .2s; }
button.switch.on { background: var(--accent); box-shadow: none; }
button.switch.on i { transform: translateX(16px); background: #fff; }
button.switch:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.range { flex: none; width: 110px; accent-color: var(--accent); cursor: pointer; }
.range:disabled { opacity: 0.4; cursor: default; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.fake-range { flex: none; width: 90px; height: 4px; border-radius: 2px; background: var(--panel-3); position: relative; opacity: 0.5; }
.fake-range i { position: absolute; left: 0; top: 0; bottom: 0; width: 60%; border-radius: 2px; background: var(--muted); }

.mode-banner {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  margin-bottom: 12px; padding: 8px 10px; border-radius: 9px; font-size: 11.5px; line-height: 1.45;
  color: #f6e3b4; background: rgba(245,185,66,0.09); border: 1px solid rgba(245,185,66,0.4);
}
.mode-banner b { color: #ffe6a6; }
.mode-banner .mb-text { flex: 1; min-width: 180px; }
.mode-banner button {
  border: 1px solid rgba(245,185,66,0.5); background: transparent; color: var(--gold);
  border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 700;
}
@media (hover: hover) { .mode-banner button:hover { background: rgba(245,185,66,0.14); } }
@media (max-width: 640px) {
  .st-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .st-nav {
    flex-direction: row; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    border-right: 0; border-bottom: 1px solid var(--border); padding: 6px 12px; scroll-padding: 0 12px;
  }
  .st-nav::-webkit-scrollbar { display: none; }
  .st-nav button { flex: none; white-space: nowrap; min-height: 44px; padding: 0 12px; }
}

/* chart background: swatches in Settings > Trading (js/app.js builds them from BG.CHART_BACKGROUNDS) */
.bg-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bg-opt {
  display: grid; gap: 8px; padding: 6px 6px 10px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--muted); font-weight: 600; text-align: center;
  transition: border-color .15s, color .15s, transform .08s;
}
.bg-sw { display: block; height: 58px; border-radius: 8px; border: 1px solid rgba(148, 163, 184, 0.18); background: #0a1626; }
.bg-sw[data-key="aurora"] { background: radial-gradient(circle at 100% 0, rgba(49, 95, 234, 0.8), transparent 62%), radial-gradient(circle at 0 100%, rgba(56, 189, 248, 0.5), transparent 58%), #07111f; }
.bg-sw[data-key="midnight"] { background: linear-gradient(180deg, #0c1a31, #050b16); }
.bg-opt[aria-checked="true"] { border-color: var(--accent); color: var(--text); background: rgba(61, 123, 255, 0.1); box-shadow: inset 0 0 0 1px var(--accent); }
.bg-opt:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
@media (hover: hover) { .bg-opt:hover { border-color: var(--border-2); color: var(--text); } }
.st-link { color: inherit; text-decoration: none; border-radius: 8px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
@media (hover: hover) { .st-link:hover { background: var(--panel-2); } }
.st-open { flex: none; font-size: 12px; font-weight: 700; color: var(--accent-2); }

/* ---------- account type + profile ---------- */
.acct-switch { display: flex; padding: 3px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--bg); }
.acct-opt { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: 0.04em; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.acct-opt.on { background: var(--accent); color: #fff; }
.acct-opt[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.profile { position: relative; }
.profile-btn { border-radius: 50%; overflow: hidden; }
.profile-btn span { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 700; font-size: 14px; color: var(--text); }
.profile-btn.signed-in { background: linear-gradient(135deg, #315fea, #38bdf8); border-color: transparent; }
.profile-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 85; width: 280px; padding: 6px; /* opens toward the page: leftward in English, rightward in Arabic */
  background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.pm-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: grid; gap: 2px; }
.pm-head b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-head span { font-size: 11.5px; color: var(--muted); }
.pm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 13px; text-align: start; text-decoration: none; cursor: pointer; }
.pm-item:focus-visible { background: var(--panel-3); outline: none; }
.pm-invite span { flex: 1; }
.pm-invite em { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; color: #06223a; background: linear-gradient(90deg, #8fe0ff, #7c9bff); }
@media (hover: hover) { .pm-item:hover { background: var(--panel-3); outline: none; } }
.pm-sep { height: 1px; background: var(--border); margin: 4px 0; }


.pm-kyc { align-items: flex-start; }
.pm-kyc > span:last-child { display: grid; gap: 1px; }
.pm-kyc b { font-size: 13px; }
.pm-kyc small { font-size: 11.5px; color: var(--muted); }
.pm-kyc-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; flex: none; background: var(--dim); }
.kyc-pending .pm-kyc-dot { background: var(--gold); }
.kyc-approved .pm-kyc-dot { background: var(--up); }
.kyc-rejected .pm-kyc-dot, .kyc-not_started .pm-kyc-dot { background: var(--down); }
.profile-btn.needs-kyc::after { content: ''; position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--bg-2); }
.profile-btn { position: relative; overflow: visible; }

/* ---------- win moment (calm: ~1s of motion, soft colours, no flashing) ---------- */
.balance-box { position: relative; }
.bb-value { transition: color .6s, text-shadow .6s; }
.bb-value.flash-up { text-shadow: 0 0 16px rgba(47, 193, 178, 0.35); }
.bal-gain {
  position: absolute; right: 12px; top: calc(100% + 4px); z-index: 30; pointer-events: none; white-space: nowrap;
  padding: 3px 8px; border-radius: 6px; background: rgba(13, 27, 46, 0.92); border: 1px solid rgba(47, 193, 178, 0.3);
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--up-2);
  animation: balGain 1.6s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes balGain {
  0% { opacity: 0; transform: translateY(8px); }
  18% { opacity: 1; transform: translateY(0); }
  72% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-6px); }
}

.toast.win-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 12px; border-left-width: 1px; border-color: rgba(47, 193, 178, 0.28); overflow: hidden; position: relative;
  background: linear-gradient(100deg, rgba(38, 166, 154, 0.10), rgba(38, 166, 154, 0) 55%), var(--panel-2); }
.toast.win-card::after { /* one slow, faint sheen across the card */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.06) 50%, transparent 65%);
  transform: translateX(-100%);
}
.toast.win-card.show::after { animation: wcSheen 1.1s .25s ease-out both; }
@keyframes wcSheen { to { transform: translateX(100%); } }
.wc-check { flex: none; width: 36px; height: 36px; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wc-ring { stroke: var(--up-2); stroke-width: 2; stroke-dasharray: 107; stroke-dashoffset: 107; transform: rotate(-90deg); transform-origin: 50% 50%; opacity: .9; }
.wc-tick { stroke: var(--up-2); stroke-width: 2.4; stroke-dasharray: 22; stroke-dashoffset: 22; }
.toast.win-card.show .wc-ring { animation: wcDraw .5s .05s cubic-bezier(.65, 0, .35, 1) forwards; }
.toast.win-card.show .wc-tick { animation: wcDraw .32s .42s cubic-bezier(.22, 1, .36, 1) forwards; }
@keyframes wcDraw { to { stroke-dashoffset: 0; } }
.wc-body { display: grid; gap: 1px; min-width: 0; }
.wc-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.wc-amt { font-size: 18px; font-weight: 800; color: var(--up-2); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.wc-body small { font-size: 11.5px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .bal-gain, .toast.win-card.show::after { animation: none; }
  .bal-gain { display: none; }
  .wc-ring, .wc-tick { stroke-dashoffset: 0; }
  .toast.win-card.show .wc-ring, .toast.win-card.show .wc-tick { animation: none; }
}

/* ---------- profile picture ---------- */
.profile-btn img, .pm-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.profile-btn.has-photo { background: var(--panel-2); padding: 0; }
.profile-btn.has-photo span { overflow: hidden; border-radius: 50%; }
.profile-btn.uploading span { opacity: .45; }
.profile-btn.uploading::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--accent-2); animation: spin .8s linear infinite; }
.pm-user { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; padding: 12px 10px; }
.pm-user-text { display: grid; gap: 2px; min-width: 0; }
.pm-avatar {
  position: relative; width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 20px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #315fea, #38bdf8); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--border-2);
}
.pm-avatar.has-photo { background: var(--panel-3); }
.pm-cam {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(7, 17, 31, 0.6); opacity: 0; transition: opacity .2s;
}
.pm-avatar:not(.has-photo) .pm-cam { inset: auto -2px -2px auto; width: 22px; height: 22px; opacity: 1; background: var(--panel-3); box-shadow: 0 0 0 2px var(--panel); }
.pm-cam svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pm-avatar:not(.has-photo) .pm-cam svg { width: 12px; height: 12px; }
.pm-avatar:focus-visible .pm-cam { opacity: 1; }
@media (hover: hover) { .pm-avatar:hover .pm-cam { opacity: 1; } }
.pm-avatar:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.pm-av-actions { display: flex; gap: 10px; margin-top: 3px; }
.pm-av-actions button { padding: 0; border: 0; background: none; font-size: 12px; font-weight: 600; color: var(--accent-2); cursor: pointer; }
@media (hover: hover) { .pm-av-actions button:hover { text-decoration: underline; } }
.pm-av-actions button[data-avatar-remove] { color: var(--muted); }
.toast a { pointer-events: auto; color: var(--accent-2); font-weight: 600; white-space: nowrap; }

/* =====================================================================================
   Phone layout, trading journal, achievements
   ===================================================================================== */

/* desktop: the phone-only pieces stay out of the way */
.dock-row, .tp-sheet { display: contents; }
.exp-btn, .tb-profit, .draw-toggle, .sheet-head, .sheet-scrim { display: none; }
.htable .rc-link { display: inline-block; padding: 4px 0; font-size: 11px; font-weight: 600; color: var(--accent-2); text-decoration: none; }
@media (hover: hover) { .htable .rc-link:hover { text-decoration: underline; } }
.jr-open { width: 100%; margin-top: 12px; justify-content: center; }

/* ---------- achievements toast ---------- */
.toast.achv { display: flex; gap: 11px; align-items: center; border-left-width: 1px; border-color: rgba(245, 185, 66, 0.32); }
.toast.achv b { display: block; margin-bottom: 1px; }
.ach-ic { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); color: var(--dim); }
.ach-ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.toast.achv .ach-ic { background: rgba(245, 185, 66, 0.14); color: var(--gold); }

/* ---------- journal ---------- */
.modal-card.jr-panel { max-width: 1000px; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.jr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.jr-head h2 { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.jr-sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.jr-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jr-tools .seg { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.jr-tools .btn { display: inline-flex; align-items: center; gap: 6px; }
.jr-tools .btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.jr-body { overflow-y: auto; padding: 18px 20px 22px; display: grid; gap: 20px; align-content: start; }
.jr-loading { display: grid; place-items: center; padding: 70px 0; }
.jr-empty { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 36px 10px; color: var(--muted); }
.jr-empty b { color: var(--text); font-size: 15px; }
.jr-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.jr-card { padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border); display: grid; gap: 2px; align-content: start; }
.jr-card span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.jr-card b { font-family: var(--font-display); font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.jr-card small { font-size: 11.5px; color: var(--dim); }
.jr-sec h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.jr-sec h3 small { font-weight: 400; color: var(--dim); margin-left: 6px; font-size: 11.5px; }
.jr-curve { display: block; width: 100%; height: 150px; background: var(--chart); border: 1px solid var(--border); border-radius: 12px; }
.jr-two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.jr-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.jr-table th { text-align: left; color: var(--dim); font-weight: 600; font-size: 11px; padding: 6px; border-bottom: 1px solid var(--border); }
.jr-table td { padding: 8px 6px; border-bottom: 1px solid rgba(27, 47, 88, 0.6); white-space: nowrap; }
.jr-table td:last-child, .jr-table th:last-child { text-align: right; }
.jr-table tr.none td { color: var(--dim); }
.jr-table td small { color: var(--dim); font-size: 11px; margin-left: 2px; }
.jr-bar { display: inline-block; position: relative; width: 64px; height: 6px; border-radius: 3px; background: var(--panel-3); vertical-align: middle; margin-right: 8px; }
.jr-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent-2); }
.jr-bar em { position: absolute; top: -3px; width: 2px; height: 12px; border-radius: 1px; background: #e6edf7; transform: translateX(-1px); }
.jr-pct { font-weight: 600; }
.jr-pct.up, .jr-table td.up, .jr-card b.up, .jr-dir b.up { color: var(--up-2); }
.jr-pct.down, .jr-table td.down, .jr-card b.down, .jr-dir b.down { color: var(--down-2); }
.jr-hours { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; height: 116px; }
.jr-h { display: grid; grid-template-rows: minmax(0, 1fr) 14px; gap: 4px; }
.jr-h i { align-self: end; display: block; width: 100%; border-radius: 3px 3px 1px 1px; background: var(--panel-3); }
.jr-h.up i { background: rgba(38, 166, 154, 0.75); }
.jr-h.down i { background: rgba(239, 83, 80, 0.7); }
.jr-h.flat i { background: var(--muted); }
.jr-h span { font-size: 11px; color: var(--dim); text-align: center; line-height: 14px; white-space: nowrap; }
.jr-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--dim); }
.jr-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.jr-legend i.up { background: rgba(38, 166, 154, 0.75); }
.jr-legend i.down { background: rgba(239, 83, 80, 0.7); }
.jr-dirs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.jr-dir { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.jr-dir div { flex: 1; display: grid; }
.jr-dir small { color: var(--muted); font-size: 11.5px; }
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); }
.ach:not(.done) { opacity: 0.55; }
.ach.done { border-color: rgba(245, 185, 66, 0.32); background: linear-gradient(135deg, rgba(245, 185, 66, 0.07), transparent 60%), var(--panel-2); }
.ach.done .ach-ic { background: rgba(245, 185, 66, 0.14); color: var(--gold); }
.ach b { display: block; font-size: 12.5px; }
.ach small { font-size: 11px; color: var(--muted); }

/* ---------- hot market alerts ---------- */
.hot-stack {
  position: absolute; z-index: 12; top: 52px; left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100% - 24px)); display: grid; gap: 8px; pointer-events: none;
}
.hot-card {
  position: relative; overflow: hidden; pointer-events: auto; cursor: pointer;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 11px 38px 13px 12px; border-radius: 14px;
  background: linear-gradient(110deg, rgba(255, 138, 61, 0.13), rgba(255, 138, 61, 0) 46%), rgba(13, 27, 46, 0.96);
  border: 1px solid rgba(255, 150, 80, 0.38);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 138, 61, 0.06), 0 0 28px rgba(255, 120, 40, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: hotIn .42s cubic-bezier(.22, 1, .36, 1) both;
  transition: border-color .2s, transform .2s, opacity .25s;
}
.hot-card:focus-visible { border-color: rgba(255, 160, 90, 0.7); outline: none; transform: translateY(-1px); }
@media (hover: hover) { .hot-card:hover { border-color: rgba(255, 160, 90, 0.7); outline: none; transform: translateY(-1px); } }
.hot-card.out { opacity: 0; transform: translateY(-8px); }
@keyframes hotIn { from { opacity: 0; transform: translateY(-14px) scale(0.98); } }
.hot-flame {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 70%, rgba(255, 170, 70, 0.35), rgba(255, 90, 40, 0.12) 70%); color: #ffa24d;
}
.hot-flame svg { width: 22px; height: 22px; fill: currentColor; stroke: none; animation: flicker 1.8s ease-in-out infinite; transform-origin: 50% 90%; }
.hot-flame svg path:last-child { fill: #ffd27a; }
@keyframes flicker { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.06, 0.96); } 70% { transform: scale(0.97, 1.04); } }
.hot-main { min-width: 0; display: grid; gap: 3px; }
.hot-top { display: flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; }
.hot-tag { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; color: #1d0e02; background: linear-gradient(90deg, #ffb35c, #ff7a3d); border-radius: 4px; padding: 2px 5px; }
.hot-move { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.hot-move b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hot-move b.up { color: var(--up-2); }
.hot-move b.down { color: var(--down-2); }
.hot-move span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.hot-why { font-size: 11px; color: var(--dim); line-height: 1.35; }
.hot-spark { width: 96px; height: 36px; display: block; }
.hot-go { font-size: 12px; font-weight: 700; color: #ffc489; white-space: nowrap; }
.hot-go::after { content: ' →'; }
.hot-x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--dim); font-size: 12px; }
@media (hover: hover) { .hot-x:hover { background: var(--panel-3); color: var(--text); } }
.hot-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, #ff7a3d, #ffb35c); transform-origin: left; animation: hotTimer linear both; }
@keyframes hotTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.hot-chip { margin-left: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: #1d0e02; background: linear-gradient(90deg, #ffb35c, #ff7a3d); border-radius: 4px; padding: 1px 4px; vertical-align: 1px; }
.trade-btns.nudge .trade-btn { animation: nudge 1.1s ease-out; }
@keyframes nudge { 0% { box-shadow: 0 0 0 0 rgba(255, 170, 90, 0.55); } 100% { box-shadow: 0 0 0 12px rgba(255, 170, 90, 0); } }

@media (prefers-reduced-motion: reduce) {
  .hot-card, .hot-flame svg, .trade-btns.nudge .trade-btn { animation: none; }
  .hot-timer { animation-name: none; }
}

/* ---------- hot market transition ---------- */
.chart-grid { transition: filter .45s ease, transform .45s cubic-bezier(.22, 1, .36, 1); }
.chart-area.warping .chart-grid { filter: blur(8px) brightness(0.5) saturate(1.4); transform: scale(1.02); transition-duration: .38s; }
.hot-warp { position: absolute; inset: 0; z-index: 14; pointer-events: none; overflow: hidden; }
.hw-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at var(--ox) var(--oy), rgba(255, 196, 120, 0.55) 0%, rgba(255, 120, 50, 0.32) 22%, rgba(150, 40, 18, 0.38) 52%, rgba(14, 8, 14, 0.62) 100%);
  clip-path: circle(0 at var(--ox) var(--oy));
  mix-blend-mode: screen;
}
.hot-warp.ignite .hw-glow { animation: hwIgnite .5s cubic-bezier(.65, 0, .35, 1) forwards; }
.hot-warp.reveal .hw-glow { animation: hwIgnite .5s cubic-bezier(.65, 0, .35, 1) forwards, hwFade .5s ease forwards; }
@keyframes hwIgnite { to { clip-path: circle(160% at var(--ox) var(--oy)); } }
@keyframes hwFade { to { opacity: 0; } }
.hw-embers { position: absolute; inset: 0; width: 100%; height: 100%; }
.hw-title {
  position: absolute; left: 50%; top: 50%; display: grid; justify-items: center; gap: 6px; text-align: center;
  transform: translate(-50%, -50%) scale(0.85); opacity: 0;
}
.hot-warp.ignite .hw-title { animation: hwTitle 1.05s .2s cubic-bezier(.22, 1, .36, 1) forwards; }
@keyframes hwTitle {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(0.85); filter: blur(6px); }
  32% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  72% { opacity: 1; transform: translate(-50%, -52%) scale(1.02); filter: blur(0); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1.06); filter: blur(4px); }
}
.hw-flame svg { width: 58px; height: 58px; fill: #ffa24d; filter: drop-shadow(0 0 22px rgba(255, 140, 60, 0.85)); animation: flicker 0.9s ease-in-out infinite; transform-origin: 50% 90%; }
.hw-flame svg path:last-child { fill: #ffe0a0; }
.hw-pair { font-family: var(--font-display); font-size: clamp(30px, 4vw, 44px); font-weight: 700; letter-spacing: -0.02em; color: #fff; text-shadow: 0 0 32px rgba(255, 140, 60, 0.7), 0 2px 12px rgba(0, 0, 0, 0.5); }
.hw-move { font-size: 14px; font-weight: 800; letter-spacing: 0.12em; padding: 5px 12px; border-radius: 999px; background: rgba(20, 8, 4, 0.55); border: 1px solid rgba(255, 170, 90, 0.45); color: #ffd9a8; }
.hw-move.is-up { color: #7ff0df; }
.hw-move.is-down { color: #ffb0ad; }
.hot-card.launch { animation: hcLaunch .32s cubic-bezier(.65, 0, .35, 1) forwards; pointer-events: none; }
@keyframes hcLaunch {
  0% { opacity: 1; transform: none; }
  35% { opacity: 1; transform: scale(1.04); filter: brightness(1.6) saturate(1.3); box-shadow: 0 0 60px rgba(255, 140, 60, 0.6); }
  100% { opacity: 0; transform: scale(1.18); filter: blur(6px) brightness(2); }
}
@media (prefers-reduced-motion: reduce) {
  .chart-grid { transition: none; }
}

/* ---------- support button ---------- */
.support-btn { position: relative; overflow: visible; }
.support-badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: #ff5a5f; box-shadow: 0 0 0 2px var(--bg-2);
}

/* ---------------------------------------------------------------- real-money account mode */
.bb-deposit {
  flex: none; height: 32px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: 8px;
  background: #1e9c86; color: #fff; font-weight: 700; font-size: 12.5px; text-decoration: none; transition: background .15s;
}
.bb-deposit:focus-visible { background: #22b39a; outline: none; }
@media (hover: hover) { .bb-deposit:hover { background: #22b39a; outline: none; } }
.bb-deposit[hidden] { display: none; }
body.env-real .balance-box { border-color: rgba(47, 193, 178, 0.45); box-shadow: inset 0 0 0 1px rgba(47, 193, 178, 0.08); }
body.env-real .bb-label { color: #5fd3c2; }
body.env-real #realAcctBtn.on { background: #1e9c86; }
.mode-real-note { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(47, 193, 178, 0.35); background: rgba(34, 179, 154, 0.08); font-size: 13px; line-height: 1.55; color: var(--muted); }
.mode-real-note b { color: var(--text); }
.pm-env { display: flex; gap: 4px; padding: 3px; margin: 4px 8px 8px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--bg); }
.pm-env button { flex: 1; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 12.5px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.pm-env button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.pm-env button[data-env="real"][aria-pressed="true"] { background: #1e9c86; }

/* ---------- wallet popup (the /wallet page in a frame) ---------- */
.modal-card.wl-modal-card { max-width: 760px; height: min(860px, calc(100vh - 32px)); height: min(860px, calc(100dvh - 32px)); padding: 0; display: flex; flex-direction: column; overflow: hidden; background: #07111f; }
.wl-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.wl-modal-head h2 { margin: 0; font-size: 16px; }
.wl-modal-card iframe { flex: 1; width: 100%; border: 0; background: transparent; color-scheme: dark; }
@media (max-width: 640px) {
  .wl-modal { padding: 0; }
  .modal-card.wl-modal-card { max-width: none; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .wl-modal-head { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
  .wl-modal-head .icon-btn { width: 44px; height: 44px; }
}

/* market icons (js/market-icons.js) */
.mk-ic { position: relative; display: inline-block; flex: none; line-height: 0; }
.mk-ic > svg { display: block; }
.mk-ic.fx > svg { position: absolute; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--bg-2); }
.mk-ic.fx > svg.a { left: 0; top: 0; z-index: 1; }
.mk-ic.fx > svg.b { right: 0; bottom: 0; }

/* live markets: closed state */
.mm-row.closed .mm-price { color: var(--dim); }
.mm-chg.shut { color: var(--dim); font-weight: 600; }
.mm-pay { color: var(--muted); font-variant-numeric: tabular-nums; }
.trade-btn:disabled { opacity: 0.38; cursor: not-allowed; filter: grayscale(0.6); }
.closed-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.closed-note b { color: var(--text); }

/* account on hold (set by staff for a security review) */
.hold-note { display: flex; gap: 12px; margin: 12px 0 0; padding: 14px; border-radius: 10px; border: 1px solid rgba(242, 184, 75, 0.45); background: rgba(242, 184, 75, 0.08); }
.hold-note > svg { width: 22px; height: 22px; flex: none; fill: none; stroke: #f2b84b; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.hold-note b { display: block; color: var(--text); font-size: 14px; }
.hold-note p { margin: 4px 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.hold-note .btn { height: 34px; padding: 0 14px; font-size: 13px; }
.mm-live { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--up, #22b39a); border: 1px solid rgba(34, 179, 154, 0.45); border-radius: 4px; padding: 1px 4px; }
.mm-group-pay { margin-left: auto; font-size: 11px; letter-spacing: 0.02em; text-transform: none; font-weight: 600; color: var(--muted); }

/* =====================================================================================
   Touch screens, phones and small tablets
   ===================================================================================== */

/* touch screens of any size: bigger hit areas, and no full-screen blur or blend effects to repaint */
@media (pointer: coarse) {
  .icon-btn { width: 40px; height: 40px; }
  .tool { width: 40px; height: 40px; }
  .seg button, .tbtn { min-height: 40px; }
  .seg button { min-width: 40px; justify-content: center; }
  .tbtn.icon { min-width: 40px; justify-content: center; }
  .acct-opt { min-height: 40px; }
  .x { min-width: 40px; min-height: 40px; }
  .btn.sm { min-height: 40px; }
  .mode-banner button { min-height: 40px; }
  .range { height: 28px; }
  .search, .set-row input[type=number] { font-size: 16px; }
  button.switch::before { content: ''; position: absolute; inset: -10px -4px; } /* a 44x40 target around the 36x20 switch */
  .chart-btn::before { content: ''; position: absolute; inset: -9px -6px; }   /* chart.js reads the button's own size, so the target grows with an overlay */
  .chart-btn.auto::before { inset: -15px -8px -3px; } /* it sits on the chart's bottom edge, so it grows upward */
  /* touch screens wide enough for the desktop layout (iPad sideways): bigger targets, same look */
  .brand, .bb-reset, .chips button { position: relative; }
  .brand::before, .bb-reset::before, .chips button::before { content: ''; position: absolute; inset: -6px -4px; }
  .bb-reset::before { inset: -4px; }
  .chips button::before { inset: -6px -2px; }
  .lg-btns button { min-width: 30px; min-height: 26px; font-size: 14px; }
  .dp-colors { gap: 10px; }
  .dp-colors button { position: relative; width: 26px; height: 26px; }
  .dp-colors button::before { content: ''; position: absolute; inset: -7px; border-radius: 50%; }
  .dp-del { width: 40px; height: 40px; display: grid; place-items: center; }
  .hot-x::before { content: ''; position: absolute; inset: -8px; border-radius: 50%; }
  .modal { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(3, 8, 20, 0.82); }
  .hot-card { -webkit-backdrop-filter: none; backdrop-filter: none; background: linear-gradient(110deg, rgba(255, 138, 61, 0.13), rgba(255, 138, 61, 0) 46%), #0d1b2e; }
  /* the hot-market swap dims the chart instead of blurring a full-screen canvas */
  .chart-grid { transition: opacity .38s ease; }
  .chart-area.warping .chart-grid { filter: none; transform: none; opacity: 0.3; }
  .hw-glow { mix-blend-mode: normal; opacity: 0.85; }
}

/* PHONE (also in js/app.js): portrait phones and tablets, and phones held sideways */
@media (max-width: 860px), (max-width: 1024px) and (max-height: 520px) {
  html, body { height: 100%; }
  body { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; font-size: 14px; }

  /* top bar: brand · balance · bell · support · account, then the market picker beside settings */
  .topbar {
    flex-wrap: wrap; gap: 6px; min-height: 0;
    padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  }
  .brand { order: 1; width: 40px; height: 44px; justify-content: center; flex: none; }
  .brand-name, .acct-switch, .mstats, .topbar .spacer { display: none; }
  .balance-box { order: 2; margin-left: auto; min-width: 0; height: 44px; gap: 6px; padding: 1px 1px 1px 10px; }
  .bb-text { min-width: 0; }
  .bb-label, .bb-value { white-space: nowrap; }
  .bb-value { font-size: 16px; }
  .bb-reset { width: 40px; height: 40px; }
  .bb-deposit { height: 40px; padding: 0 12px; }
  .notif { order: 3; }
  .support-btn { order: 4; }
  .profile { order: 5; }
  .notif-btn::before { display: none; }
  .market-btn { order: 6; flex: 1 1 calc(100% - 50px); min-width: 0; min-height: 44px; gap: 8px; padding: 4px 10px 4px 6px; }
  .mb-quote { flex: none; }
  #settingsBtn { order: 7; width: 44px; height: 44px; border-radius: 10px; }

  /* menus that hang from the top bar sit just under it (--tb-h: its height, kept by js/app.js) */
  .profile-menu {
    position: fixed; top: calc(var(--tb-h, 108px) + 6px); right: max(12px, env(safe-area-inset-right)); left: auto;
    width: min(300px, calc(100vw - 24px)); max-height: calc(100vh - var(--tb-h, 108px) - 16px); max-height: calc(100dvh - var(--tb-h, 108px) - 16px - env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain;
  }
  .pm-item { min-height: 44px; }
  .pm-env button { min-height: 40px; }
  .pm-av-actions button { min-height: 36px; }

  /* the chart fills the space between the top bar and the trade dock */
  .layout { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .chart-area { flex: 1; min-height: 0; }
  .chart-toolbar {
    height: 44px; gap: 2px; padding: 0 20px 0 6px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 20px), transparent);
  }
  .seg button, .tbtn { min-height: 40px; padding: 0 10px; }
  .seg button { min-width: 40px; justify-content: center; }
  .tbtn.icon { width: 40px; padding: 0; justify-content: center; }
  .draw-toggle { display: inline-flex; }
  .tb-hint, .layout-seg, .layout-seg + .tb-sep, #shotBtn { display: none; }
  /* chart type and indicators as icons (their names stay for screen readers) */
  .tbtn svg.tb-ic { display: block; width: 20px; height: 20px; }
  .tb-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #typeBtn, #indBtn { gap: 4px; padding: 0 8px; }
  #indBtn { min-width: 44px; justify-content: center; }
  #indBtn .fx { font-size: 15px; }
  .dd-menu { min-width: 210px; padding: 6px; border-radius: 12px; }
  .dd-menu button { min-height: 44px; padding: 0 12px; border-radius: 8px; }
  .chart-legend .lg-vals { display: none; }
  .lg-row { font-size: 11.5px; }
  .chart-grid[data-layout="2"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .slot-market { min-height: 32px; }

  /* drawing tools: a floating strip over the chart */
  .drawbar { display: none; }
  body.draw-open .drawbar {
    display: flex; flex-direction: row; position: absolute; z-index: 8; top: 50px; left: 8px; right: 8px;
    padding: 2px; gap: 2px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
    background: rgba(11, 23, 40, 0.97); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  }
  body.draw-open .drawbar::-webkit-scrollbar { display: none; }
  .tool { width: 40px; height: 40px; }
  .tool-sep { width: 1px; height: 22px; margin: 0 4px; align-self: center; }

  /* trade dock */
  .trade-panel {
    position: relative; flex: none; overflow: visible; border-left: 0; border-top: 1px solid var(--border);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.3);
  }
  .tp-section { padding: 8px 12px; border-bottom: 0; }
  .tp-head, .tp-quote, .tp-label, .chips, .payout-box, .fineprint { display: none; }
  .dock-row { display: flex; gap: 8px; margin-bottom: 8px; }
  .amount-row { flex: 1; min-width: 0; }
  .step { width: 44px; height: 44px; font-size: 20px; }
  .amount-input { height: 44px; min-width: 0; padding: 0 10px; }
  .amount-input input { height: 100%; min-width: 0; font-size: 17px; }
  .exp-btn {
    display: flex; align-items: center; gap: 8px; flex: none; height: 44px; padding: 0 12px 0 10px;
    border: 1px solid var(--border-2); border-radius: 10px; background: var(--panel-2); color: var(--text);
  }
  .exp-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
  .exp-btn span { display: grid; line-height: 1.15; text-align: left; }
  .exp-btn b { font-size: 14px; }
  .exp-btn small { font-size: 11px; color: var(--accent-2); font-weight: 600; }
  .trade-panel.exp-open .exp-btn { border-color: var(--accent); }
  .expiry-grid { display: none; }
  .trade-panel.exp-open .expiry-grid {
    display: grid; position: absolute; z-index: 30; left: 12px; right: 12px; bottom: calc(100% + 8px); margin: 0; padding: 8px; gap: 6px;
    background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
    animation: popUp .18s cubic-bezier(.22, 1, .36, 1) both;
  }
  .trade-panel.exp-open .expiry-grid button { min-height: 48px; padding: 6px 0; justify-content: center; }
  @keyframes popUp { from { opacity: 0; transform: translateY(6px); } }
  .mode-banner { margin-bottom: 8px; padding: 6px 8px; font-size: 11.5px; }
  .trade-btns { gap: 8px; }
  .trade-btn { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; column-gap: 7px; row-gap: 0; height: 56px; border-radius: 12px; font-size: 15px; }
  .trade-btn svg { width: 18px; height: 18px; }
  .tb-profit { display: block; grid-column: 1 / -1; font-size: 11.5px; font-weight: 600; letter-spacing: 0; opacity: 0.85; text-align: center; }
  /* out of funds, closed market, account on hold: one compact row, so the chart keeps its height */
  .broke { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 8px 8px 12px; font-size: 13px; line-height: 1.35; }
  .broke > span { flex: 1; min-width: 0; }
  .broke .btn { flex: none; min-height: 40px; padding: 0 14px; display: inline-flex; align-items: center; text-decoration: none; }
  .closed-note { margin-top: 8px; padding: 8px 10px; font-size: 13px; }
  .hold-note { margin-top: 8px; padding: 10px; gap: 10px; }
  .hold-note p { margin: 2px 0 8px; font-size: 13px; }
  .hold-note .btn { min-height: 40px; }

  /* the bottom tabs open a sheet */
  .tp-tabs { position: static; padding: 0 4px; border-top: 1px solid var(--border); border-bottom: 0; }
  .tp-tabs .tab { flex: 1; justify-content: center; min-height: 44px; padding: 0 4px; border-bottom: 0; border-top: 2px solid transparent; margin: -1px 0 0; }
  .tp-tabs .tab.active { border-bottom: 0; border-top-color: transparent; color: var(--muted); }
  body.sheet-open .tp-tabs .tab.active { border-top-color: var(--accent); color: var(--text); }
  .tp-sheet {
    display: flex; flex-direction: column; position: fixed; z-index: 70; left: 0; right: 0; bottom: 0;
    height: min(74vh, 640px); height: min(74dvh, 640px); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--bg-2); border-top: 1px solid var(--border-2); border-radius: 18px 18px 0 0; box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.5);
    transform: translateY(105%); visibility: hidden;
    transition: transform .34s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .34s;
  }
  .tp-sheet.open { transform: none; visibility: visible; transition: transform .34s cubic-bezier(.22, 1, .36, 1), visibility 0s; }
  .tp-sheet.is-shut { display: none; } /* out of layout once closed, so nothing hangs below the screen */
  .sheet-head { display: flex; position: relative; align-items: center; justify-content: space-between; padding: 18px 12px 8px 16px; border-bottom: 1px solid var(--border); touch-action: none; }
  .sheet-head b { font-size: 15px; }
  .sheet-grip { position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; border-radius: 2px; background: var(--border-2); transform: translateX(-50%); }
  .sheet-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--panel-3); color: var(--muted); }
  .tp-sheet .tp-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px; }
  .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(3, 8, 20, 0.55); animation: fade .2s both; }
  @keyframes fade { from { opacity: 0; } }
  .otrade { padding: 12px; }
  .ot-row { font-size: 12.5px; }
  .ot-time { font-size: 13px; }
  .htable { font-size: 12.5px; }
  .empty { font-size: 13.5px; }
  .stats-title { font-size: 13px; }

  /* messages appear under the top bar, away from the trade dock */
  .toasts { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); top: calc(var(--tb-h, 108px) + 6px); bottom: auto; }
  .toast { min-width: 0; max-width: none; font-size: 13.5px; transform: translateY(-12px); }

  /* hot-market alerts: one at a time, at the foot of the chart */
  .hot-stack { top: auto; bottom: 10px; left: 8px; right: 8px; width: auto; transform: none; }
  .hot-card { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 40px 12px 10px; gap: 10px; }
  .hot-go { display: none; }
  .hot-spark { width: 80px; }
  .hot-x { top: 8px; right: 8px; width: 28px; height: 28px; }
  @keyframes hotIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

  /* journal: full screen */
  .jr-modal { padding: 0; }
  .modal-card.jr-panel { max-width: none; width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; animation: none; }
  .jr-head {
    position: relative; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  }
  .jr-head > div:first-child { padding-right: 48px; }
  .jr-tools { width: 100%; }
  .jr-tools .seg button { min-height: 40px; }
  .jr-tools .btn { min-height: 40px; }
  .jr-tools .icon-btn { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 44px; height: 44px; }
  .jr-body { padding: 14px max(14px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); gap: 18px; overscroll-behavior: contain; }
  .jr-cards { grid-template-columns: 1fr 1fr; }
  .jr-two, .jr-dirs { grid-template-columns: 1fr; }
  .jr-hours { gap: 2px; height: 100px; }

  body.chart-fs .layout { display: flex; }
}

/* NARROW: portrait phones. Modal windows become sheets from the bottom edge. */
@media (max-width: 600px) {
  .modal { place-items: end center; padding: 0; }
  .modal-card {
    max-width: none; max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px - env(safe-area-inset-top));
    border-bottom: 0; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .3s cubic-bezier(.22, 1, .36, 1) both;
  }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
  .modal-head h3, .modal-card h3 { font-size: 17px; }
  .modal-foot { flex-wrap: wrap; }
  /* the top bar: two rows on a grid, so a long balance never pushes a button onto a third row */
  .topbar {
    display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px 40px 44px; align-items: center; gap: 6px;
    grid-template-areas: 'brand bal bell help me' 'pick pick pick pick set';
  }
  .brand { grid-area: brand; }
  .balance-box { grid-area: bal; justify-self: end; max-width: 100%; margin-left: 0; }
  .bb-text { overflow: hidden; }
  .bb-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .notif { grid-area: bell; }
  .support-btn { grid-area: help; }
  .profile { grid-area: me; justify-self: end; }
  .market-btn { grid-area: pick; }
  #settingsBtn { grid-area: set; }
  /* the real account's Deposit button becomes a green "+" beside the balance */
  .bb-deposit { width: 40px; padding: 0; justify-content: center; }
  .bb-deposit svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
  .bb-deposit span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  /* the chart toolbar fits on one line: the timeframes move into a menu */
  #tfSeg { display: none; }
  .tf-dd { display: block; }
  #tfBtn { gap: 4px; padding: 0 8px 0 10px; }
  .chart-toolbar { padding-right: 6px; -webkit-mask-image: none; mask-image: none; }
  .modal-foot .btn { min-height: 44px; }
  .confirm p { font-size: 14px; line-height: 1.5; }
  /* indicators: a tall sheet; its search stays at 16px so iPhone doesn't zoom in on it */
  .modal-card.ind { display: flex; flex-direction: column; height: 86vh; height: 86dvh; padding-bottom: 0; }
  .ind-list { flex: 1; min-height: 0; max-height: none; overscroll-behavior: contain; padding-bottom: calc(12px + var(--kb, 0px) + env(safe-area-inset-bottom)); }
  .ind-item { min-height: 52px; }
  .ind-item .ii-main small { font-size: 12.5px; }
  .search { font-size: 16px; min-height: 44px; }
  .set-row input[type=number] { font-size: 16px; min-height: 40px; }
  .set-row input[type=color] { width: 52px; height: 40px; }
  /* settings: a full-height sheet with its sections as tabs across the top */
  .modal-card.settings { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; border: 0; padding: env(safe-area-inset-top) 0 0; animation: none; }
  .modal-card.settings .modal-head { padding: 8px 8px 8px 16px; }
  .modal-card.settings .modal-head .x { width: 44px; height: 44px; font-size: 18px; }
  .st-panels { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
  .st-desc, .mode-real-note { font-size: 13.5px; }
  .st-text b { font-size: 14px; }
  .st-text small, .mode-opt .mo-text small { font-size: 12.5px; line-height: 1.45; }
  .st-item { min-height: 56px; }
  .st-link { min-height: 56px; }
  .bg-list { gap: 8px; }
  .bg-sw { height: 64px; }
  .bg-opt { min-height: 44px; }

  /* the market picker: a full-screen sheet */
  .market-menu {
    inset: 0; width: auto; max-height: none; border: 0; border-radius: 0; z-index: 95; box-shadow: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
    animation: sheetUp .26s cubic-bezier(.22, 1, .36, 1) both;
  }
  .mm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 0 16px; }
  .mm-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
  .mm-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
  .mm-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .mm-top { padding: 6px 12px 0; }
  .mm-top .search { height: 44px; border-radius: 10px; }
  .mm-tabs { gap: 6px; padding-bottom: 6px; overscroll-behavior-x: contain; }
  .mm-tabs button { min-height: 40px; padding: 0 14px; border-radius: 10px; }
  .mm-cols { padding: 8px 20px 6px; }
  .mm-cols, .mm-row { grid-template-columns: minmax(0, 1fr) auto 64px; }
  .mm-list { padding: 4px 8px calc(12px + var(--kb, 0px) + env(safe-area-inset-bottom)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .mm-row { min-height: 52px; padding: 8px 12px; }
  .mm-price { font-size: 13.5px; }
  .mm-name small { font-size: 12px; }
}
/* the narrowest phones (Galaxy S, Galaxy Z Fold cover screen): tighter gaps, and the balance is just "Demo" / "Real" */
@media (max-width: 374px) {
  .topbar { column-gap: 4px; }
  .bb-word { display: none; }
  .bb-value { font-size: 15.5px; }
}
/* phones held sideways use the same full-screen picker and centered windows */
@media (max-width: 1024px) and (max-height: 520px) {
  .market-menu {
    inset: 0; width: auto; max-height: none; border: 0; border-radius: 0; z-index: 95; box-shadow: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }
  .mm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 6px 0 16px; }
  .mm-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
  .mm-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
  .mm-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .mm-top .search { font-size: 16px; height: 40px; }
  .mm-tabs button { min-height: 40px; }
  .mm-list { overscroll-behavior: contain; padding-bottom: calc(8px + var(--kb, 0px) + env(safe-area-inset-bottom)); }
  .mm-row { min-height: 44px; }
  .modal { padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); }
  .modal-card { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .modal-card.settings { max-width: 720px; height: calc(100vh - 16px); height: calc(100dvh - 16px); }
  .st-layout { min-height: 0; }
  .search { font-size: 16px; }
  .ind-list { max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); overscroll-behavior: contain; }
}

/* short portrait phones (iPhone SE, Galaxy S with the browser bars showing): a slimmer dock, so the chart keeps its height */
@media (max-width: 600px) and (max-height: 700px) {
  .tp-section { padding-top: 6px; padding-bottom: 6px; }
  .dock-row { margin-bottom: 6px; }
  .trade-btn { height: 50px; }
  .tp-tabs .tab { min-height: 42px; }
  .chart-toolbar { height: 42px; }
}

/* tablets in portrait: the whole top bar fits on one line and the dock keeps a comfortable width */
@media (min-width: 601px) and (max-width: 860px) {
  .topbar { flex-wrap: nowrap; }
  .market-btn { order: 2; flex: 1 1 auto; max-width: 420px; }
  .balance-box { order: 3; }
  .notif { order: 4; }
  .support-btn { order: 5; }
  .profile { order: 6; }
  #settingsBtn { order: 7; width: 40px; height: 40px; }
  .tp-section { max-width: 640px; margin: 0 auto; }
  .tp-tabs { justify-content: center; }
  .tp-tabs .tab { flex: 0 1 160px; }
}

/* phones held sideways: chart and trade dock side by side, one slim top bar */
@media (max-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  .topbar { flex-wrap: nowrap; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .market-btn { order: 2; flex: 1 1 auto; max-width: 420px; }
  .balance-box { order: 3; }
  .notif { order: 4; }
  .support-btn { order: 5; }
  .profile { order: 6; }
  #settingsBtn { order: 7; width: 40px; height: 40px; }
  .layout { flex-direction: row; padding-left: env(safe-area-inset-left); }
  .trade-panel {
    width: 272px; border-top: 0; border-left: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain; box-shadow: none;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
  }
  .tp-section { padding: 8px 10px; }
  .dock-row { flex-wrap: wrap; }
  .amount-row { flex: 1 1 100%; }
  .exp-btn { flex: 1; }
  .trade-btn { height: 52px; }
  .trade-panel.exp-open .expiry-grid { left: 8px; right: 8px; grid-template-columns: repeat(3, 1fr); }
  .toasts { left: auto; right: calc(272px + 12px + env(safe-area-inset-right)); width: min(320px, calc(100vw - 300px)); }
  .chart-area { padding-bottom: env(safe-area-inset-bottom); }
}

@media (prefers-reduced-motion: reduce) {
  .tp-sheet, .tp-sheet.open { transition: none; }
  .trade-panel.exp-open .expiry-grid, .sheet-scrim, .modal-card, .market-menu { animation: none; }
  .btn:active, .trade-btn:active, .icon-btn:active, .tbtn:active, .seg button:active, .tool:active, .step:active { transform: none; }
}

/* ---------- trade result pop-ups (losses and ties; wins use .win-card) ---------- */
.toast.result-card { display: flex; align-items: center; gap: 12px; padding: 12px 34px 12px 12px; border-left-width: 1px; position: relative; }
.toast.result-card.loss { border-color: rgba(239, 83, 80, 0.3); background: linear-gradient(100deg, rgba(239, 83, 80, 0.09), rgba(239, 83, 80, 0) 55%), var(--panel-2); }
.toast.result-card.loss .wc-amt { color: var(--down-2); }
.toast.result-card.tie .wc-amt { color: var(--text); font-size: 15px; }
.rc-ic { flex: none; width: 36px; height: 36px; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.toast.loss .rc-ic { stroke: var(--down-2); }
.toast.tie .rc-ic { stroke: var(--muted); }
.toast.win-card { padding-right: 34px; }
.tc-x { pointer-events: auto; position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.tc-x::before { content: ''; position: absolute; inset: -6px; } /* 40px touch area */
.tc-x:focus-visible { outline: 2px solid var(--accent-2); }
@media (hover: hover) { .tc-x:hover { color: var(--text); background: var(--panel-3); } }

/* ---------- AI trade ---------- */
@property --ai-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes aiSpin { to { --ai-a: 360deg; } }
@keyframes aiGlow { 0%, 100% { box-shadow: 0 0 0 0 rgba(90, 140, 255, 0), 0 0 14px rgba(80, 130, 255, 0.35); } 50% { box-shadow: 0 0 0 4px rgba(90, 140, 255, 0.08), 0 0 22px rgba(80, 130, 255, 0.55); } }
@keyframes aiTwinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(0.86) rotate(12deg); } }
@keyframes aiIn { from { opacity: 0; transform: translateY(4px); } }
@keyframes aiShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* the orb: a small glowing sphere that carries the AI sparkle everywhere it appears */
.ai-orb { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, #9fd4ff 0%, #4c7dff 38%, #2a3fb8 72%, #1b2370 100%);
  box-shadow: inset 0 -3px 8px rgba(10, 20, 80, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 0 14px rgba(80, 130, 255, 0.35); }
.ai-orb svg { width: 58%; height: 58%; fill: #fff; filter: drop-shadow(0 0 3px rgba(180, 220, 255, 0.9)); }
.ai-orb.sm { width: 26px; height: 26px; }
.ai-orb.lg { width: 64px; height: 64px; animation: aiGlow 3.2s ease-in-out infinite; }

/* the button: dark glass with a slowly turning blue-cyan-violet edge */
.ai-btn { position: relative; width: 100%; margin-top: 8px; display: flex; align-items: center; gap: 11px; padding: 9px 12px 9px 9px;
  border: 1px solid transparent; border-radius: 12px; color: #fff; font: inherit; text-align: start; cursor: pointer;
  background:
    linear-gradient(180deg, rgba(36, 58, 120, 0.55), rgba(16, 28, 62, 0.9)) padding-box,
    linear-gradient(#0c1730, #0c1730) padding-box,
    conic-gradient(from var(--ai-a), #315fea, #38bdf8, #8b6cff, #315fea 60%, #38bdf8, #315fea) border-box;
  box-shadow: 0 8px 22px rgba(30, 60, 180, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: aiSpin 6s linear infinite; }
.ai-btn::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 140% at 0% 0%, rgba(90, 150, 255, 0.18), transparent 55%); }
.ai-btn .ai-orb svg { animation: aiTwinkle 2.4s ease-in-out infinite; }
.ai-btn-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.ai-btn-text b { font-size: 14.5px; font-weight: 700; letter-spacing: 0.02em;
  background: linear-gradient(90deg, #ffffff, #bcd6ff 60%, #8fe0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ai-btn-text small { font-size: 11.5px; color: #9fb2d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-btn-go { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: rgba(120, 160, 255, 0.14); }
.ai-btn-go svg { width: 16px; height: 16px; fill: none; stroke: #cfe0ff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
html[dir="rtl"] .ai-btn-go svg { transform: scaleX(-1); }
@media (hover: hover) { .ai-btn:not(:disabled):hover { box-shadow: 0 10px 28px rgba(40, 80, 220, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08); } }
.ai-btn:not(:disabled):active { transform: translateY(1px) scale(0.985); }
.ai-btn:focus-visible { outline: 2px solid var(--c-cyan); outline-offset: 2px; }
.ai-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.7); animation: none; }
.ai-btn.busy { display: none; } /* the analysis card takes its place */

/* the analysis card */
.ai-run { position: relative; margin-top: 8px; padding: 12px 12px 12px; overflow: hidden; border-radius: 12px; font-size: 12.5px;
  border: 1px solid rgba(110, 150, 255, 0.28);
  background: radial-gradient(140% 90% at 100% 0%, rgba(56, 189, 248, 0.08), transparent 60%), linear-gradient(180deg, #11203d, #0c1730);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); animation: aiIn .25s ease-out both; }
.ai-run-bar { position: absolute; inset: 0 0 auto; height: 2px; background: rgba(120, 160, 255, 0.12); }
.ai-run-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #315fea, #38bdf8); box-shadow: 0 0 8px #38bdf8; }
.ai-run-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.ai-run-head .ai-orb svg { animation: aiTwinkle 1.2s ease-in-out infinite; }
.ai-run.decided .ai-run-head .ai-orb svg, .ai-run.placed .ai-run-head .ai-orb svg { animation: none; }
.ai-run-title { flex: 1; min-width: 0; display: grid; }
.ai-run-title b { font-size: 13.5px; }
.ai-run-title small { color: var(--c-text-2); font-size: 11.5px; }
.ai-run-head .tc-x { position: relative; top: auto; right: auto; flex: none; }
.ai-signals { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.ai-signals li { display: grid; grid-template-columns: 76px 1fr 56px; gap: 8px; align-items: center; color: var(--c-text-2); animation: aiIn .2s ease-out both; }
.ai-signals li b { color: var(--c-text); font-weight: 600; }
.ai-signals li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-signals li.pending span { color: transparent; border-radius: 4px; height: 10px;
  background: linear-gradient(90deg, rgba(120, 160, 255, 0.08) 30%, rgba(120, 160, 255, 0.22) 50%, rgba(120, 160, 255, 0.08) 70%) 0 0 / 200% 100%;
  animation: aiShimmer 1.2s linear infinite; }
/* the lean meter: centre line, filled right for Higher and left for Lower */
.ai-vote { position: relative; height: 6px; border-radius: 3px; background: rgba(148, 163, 184, 0.14); direction: ltr; }
.ai-vote::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(200, 215, 240, 0.35); }
.ai-vote em { position: absolute; top: 0; bottom: 0; width: 0; border-radius: 3px; transition: width .35s cubic-bezier(.22, 1, .36, 1); }
.ai-signals li.up .ai-vote em { background: linear-gradient(90deg, rgba(34, 179, 154, 0.5), var(--c-up)); }
.ai-signals li.down .ai-vote em { background: linear-gradient(270deg, rgba(240, 82, 90, 0.5), var(--c-down)); }
.ai-signals li.flat .ai-vote em { background: #7d8aa3; }
.ai-verdict { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(120, 160, 255, 0.14); animation: aiIn .25s ease-out both; }
.ai-dir { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-weight: 800; font-size: 15px; letter-spacing: 0.04em; color: #fff; }
.ai-dir svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-run.is-up .ai-dir { background: linear-gradient(180deg, #2bb8a9, #1f8f84); box-shadow: 0 6px 18px rgba(38, 166, 154, 0.3); }
.ai-run.is-down .ai-dir { background: linear-gradient(180deg, #f2615e, #d43f3c); box-shadow: 0 6px 18px rgba(239, 83, 80, 0.3); }
.ai-agree { flex: 1; display: grid; grid-template-columns: 1fr auto; row-gap: 5px; font-size: 11.5px; color: var(--c-text-2); }
.ai-agree b { color: var(--c-text); font-size: 13px; }
.ai-agree i { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: rgba(148, 163, 184, 0.14); overflow: hidden; direction: ltr; }
.ai-agree em { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #315fea, #38bdf8); transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.ai-run.placed { border-color: rgba(56, 189, 248, 0.45); }
.ai-run.placed .ai-run-bar i { background: var(--c-cyan); }
.ai-run.placed .ai-run-title b::before { content: '✓'; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-inline-end: 6px; border-radius: 50%; font-size: 10px; background: var(--c-cyan); color: #06223a; vertical-align: 1px; }
.ai-tag { margin-inline-start: 4px; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: #dbe7ff;
  background: linear-gradient(90deg, #315fea, #6b5cff); }

/* the first-time explainer */
.modal-card.ai-intro { position: relative; max-width: 470px; padding: 0 22px 20px; border-color: rgba(109, 147, 247, 0.32); border-radius: 18px;
  background: radial-gradient(120% 60% at 50% 0%, rgba(49, 95, 234, 0.22), transparent 60%), var(--panel); }
.ai-intro-x { position: absolute; top: 10px; right: 10px; }
html[dir="rtl"] .ai-intro-x { right: auto; left: 10px; }
.ai-intro-head { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 26px 8px 4px; }
.ai-intro-head h3 { font-size: 21px; margin: 4px 0 0; }
.ai-intro-head p { margin: 0; color: var(--c-text-2); font-size: 14px; line-height: 1.5; max-width: 360px; }
.ai-intro-head b.up { color: var(--c-up); } .ai-intro-head b.down { color: var(--c-down); }
.ai-steps { list-style: none; margin: 16px 0 14px; padding: 0; display: grid; gap: 10px; }
.ai-steps li { display: flex; gap: 12px; align-items: flex-start; }
.ai-steps li > div { display: grid; gap: 3px; }
.ai-steps b { font-size: 14px; }
.ai-steps small { color: var(--c-text-2); font-size: 12.5px; line-height: 1.45; }
.ai-step-n { flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #cfe0ff; background: rgba(49, 95, 234, 0.2); border: 1px solid rgba(110, 150, 255, 0.35); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ai-chips i { font-style: normal; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; color: #cfe0ff; background: rgba(56, 189, 248, 0.1); border: 1px solid rgba(56, 189, 248, 0.25); }
.ai-example { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; border: 1px dashed rgba(110, 150, 255, 0.45); background: rgba(49, 95, 234, 0.08); }
.ai-dots { flex: none; display: grid; grid-template-columns: repeat(10, 7px); gap: 3px; direction: ltr; }
.ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(148, 163, 184, 0.22); }
.ai-dots i.w { background: var(--c-cyan); box-shadow: 0 0 4px rgba(56, 189, 248, 0.5); }
.ai-example-text { display: grid; gap: 3px; font-size: 12px; line-height: 1.45; color: var(--c-text-2); }
.ai-example-text b { color: var(--c-text); font-size: 16px; }
.ai-example-tag { justify-self: start; padding: 1px 7px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ffd98a; background: rgba(245, 185, 66, 0.14); }
.ai-mine { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.ai-mine > div { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--c-surface-2); }
.ai-mine small { font-size: 11px; color: var(--c-text-2); }
.ai-mine b { font-size: 16px; }
.ai-mine p { grid-column: 1 / -1; margin: 0; font-size: 12.5px; color: var(--c-text-2); text-align: center; }
.ai-intro .modal-foot .btn { flex: 1; justify-content: center; }
.ai-start { display: inline-flex; align-items: center; gap: 7px; background: linear-gradient(90deg, #315fea, #4f6bff 60%, #2f9be8); }
.ai-start svg { width: 16px; height: 16px; fill: #fff; }
@media (max-width: 480px) {
  .ai-example { gap: 12px; align-items: flex-start; }
  .ai-dots { grid-template-columns: repeat(10, 5px); gap: 2px; margin-top: 4px; }
  .ai-dots i { width: 5px; height: 5px; }
  .ai-intro-head { padding-top: 20px; }
  .ai-orb.lg { width: 54px; height: 54px; }
}

@media (max-width: 860px), (max-width: 1024px) and (max-height: 520px) {
  .ai-btn { margin-top: 6px; padding: 6px 10px 6px 7px; gap: 9px; }
  .ai-btn .ai-orb { width: 28px; height: 28px; }
  .ai-btn-text { grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 8px; }
  .ai-btn-go { width: 24px; height: 24px; }
  /* phones: signals are one row of chips with their lean shown by colour, so the chart keeps its height */
  .ai-run { margin-top: 6px; padding: 10px; }
  .ai-run-head { margin-bottom: 8px; }
  .ai-signals { display: flex; flex-wrap: wrap; gap: 5px; }
  .ai-signals li { display: inline-flex; gap: 5px; align-items: center; padding: 3px 9px; border-radius: 999px; background: var(--c-surface-3); font-size: 11.5px; }
  .ai-signals li span, .ai-signals li .ai-vote { display: none; }
  .ai-signals li.pending b { opacity: 0.5; }
  .ai-signals li.up { background: rgba(34, 179, 154, 0.16); box-shadow: inset 0 0 0 1px rgba(34, 179, 154, 0.4); }
  .ai-signals li.down { background: rgba(240, 82, 90, 0.14); box-shadow: inset 0 0 0 1px rgba(240, 82, 90, 0.4); }
  .ai-signals li.up b::after { content: ' ↑'; color: var(--c-up); }
  .ai-signals li.down b::after { content: ' ↓'; color: var(--c-down); }
  .ai-verdict { margin-top: 8px; padding-top: 8px; }
  .ai-dir { padding: 6px 12px; font-size: 14px; }
}
@media (max-width: 374px) { .ai-btn-text small { display: none; } }
/* real account, free AI trade used: locked until the deposit achievement */
.ai-btn.locked { animation: none; background:
    linear-gradient(180deg, rgba(36, 48, 80, 0.55), rgba(16, 24, 44, 0.9)) padding-box,
    linear-gradient(#0c1730, #0c1730) padding-box,
    linear-gradient(90deg, rgba(148, 163, 184, 0.35), rgba(245, 185, 66, 0.55)) border-box; }
.ai-btn.locked .ai-orb { filter: saturate(0.4) brightness(0.8); }
.ai-btn.locked .ai-orb svg { animation: none; }
.ai-btn.locked .ai-btn-go { background: rgba(245, 185, 66, 0.14); }
.ai-btn.locked .ai-btn-go svg { display: none; }
.ai-btn.locked .ai-btn-go::before { content: ''; width: 16px; height: 16px; background: #ffd98a;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / contain no-repeat; }
.ai-btn.locked small { color: #e9c77d; }
.ai-orb-locked { position: relative; }
.ai-lock-badge { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(180deg, #ffd98a, #e2a93b); box-shadow: 0 0 0 3px var(--panel); }
.ai-lock-badge svg { width: 14px; height: 14px; fill: none; stroke: #3a2a05; stroke-width: 2.4; stroke-linecap: round; filter: none; }
.ai-goal { margin: 18px 0 12px; padding: 14px; border-radius: 12px; background: var(--c-surface-2); border: 1px solid rgba(245, 185, 66, 0.3); }
.ai-goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--c-text-2); }
.ai-goal-top b { color: var(--c-text); font-size: 15px; }
.ai-goal-bar { display: block; height: 8px; margin: 10px 0 6px; border-radius: 4px; background: rgba(148, 163, 184, 0.16); overflow: hidden; direction: ltr; }
.ai-goal-bar em { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #e2a93b, #ffd98a); }
.ai-goal small { font-size: 12px; color: #e9c77d; }
.ai-perks { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; color: var(--c-text-2); }
.ai-perks li { display: flex; gap: 8px; align-items: baseline; }
.ai-perks li::before { content: '✓'; color: var(--c-cyan); font-weight: 700; }
a.ai-start { text-decoration: none; justify-content: center; }
@media (prefers-reduced-motion: reduce) {
  .ai-btn, .ai-btn .ai-orb svg, .ai-run-head .ai-orb svg, .ai-orb.lg, .ai-run, .ai-signals li, .ai-verdict, .ai-signals li.pending span { animation: none; }
}

/* the announced first-AI-trade gift (real accounts) */
.ai-btn.gifted .ai-btn-text small { color: #ffe3a3; }
.ai-btn.gifted { background:
    linear-gradient(180deg, rgba(36, 58, 120, 0.55), rgba(16, 28, 62, 0.9)) padding-box,
    linear-gradient(#0c1730, #0c1730) padding-box,
    conic-gradient(from var(--ai-a), #315fea, #38bdf8, #ffd98a, #315fea 60%, #38bdf8, #315fea) border-box; }
.ai-tag.gift { background: linear-gradient(90deg, #315fea, #e2a93b); }
.gift-note { color: #ffd98a; font-weight: 600; }
.ai-gift-ic { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #fff1c9, #ffd98a 45%, #e2a93b); box-shadow: 0 10px 30px rgba(226, 169, 59, 0.35), inset 0 2px 3px rgba(255, 255, 255, 0.6); }
.ai-gift-ic svg { width: 32px; height: 32px; fill: none; stroke: #4a3205; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ai-gift-how { list-style: none; margin: 16px 0 10px; padding: 0; display: grid; gap: 8px; }
.ai-gift-how li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--c-surface-2); border: 1px solid var(--c-border); }
.ai-gift-how b { font-size: 13.5px; }
.ai-gift-how span { font-size: 12.5px; color: var(--c-text-2); }
.ai-gift-terms { margin: 0; font-size: 12px; line-height: 1.5; color: var(--c-text-2); }

/* ---------- Arabic ---------- */
/* IBM Plex Sans Arabic draws Arabic letters; Inter still draws Latin letters and digits, so prices line up the same. */
html.i18n-wait body { opacity: 0; }
html[lang="ar"] body { font-family: Inter, "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
html[lang="ar"] body * { letter-spacing: 0 !important; } /* letter spacing breaks Arabic joining */
html[dir="rtl"] canvas, html[dir="rtl"] code { direction: ltr; }
.lang-switch { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 999px; background: transparent; color: var(--text); font: 600 13px/1 Inter, "IBM Plex Sans Arabic", system-ui, sans-serif; cursor: pointer; white-space: nowrap; }
.lang-switch:empty { display: none; }
.lang-switch[lang="ar"] { font-family: "IBM Plex Sans Arabic", Inter, system-ui, sans-serif; font-size: 14px; }
.pm-item.lang-switch { justify-content: flex-start; min-height: 0; border: 0; border-radius: 8px; padding: 9px 10px; font-weight: 500; }
/* Numbers keep their sign in front (−$10.00, +5.45%): text with no Arabic letters in it is laid out left to right. */
html[dir="rtl"] :is(b, span, small, strong, em, td, .wc-amt) { unicode-bidi: plaintext; }
html[dir="rtl"] .jr-hours { direction: ltr; } /* the hours of the day read left to right, like the chart's time axis */

/* welcome bonus: the part of the real balance that is bonus funds */
.bb-bonus { display: block; font-size: 10.5px; font-weight: 600; color: #f6d58e; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* favourites on phones: the star beside the market button, compact cards, a bigger star column in the picker sheet */
@media (max-width: 860px), (max-width: 1024px) and (max-height: 520px) {
  .fav-btn { order: 6; width: 44px; height: 44px; border-radius: 10px; }
  .market-btn { flex-basis: calc(100% - 100px); }
  .fav-strip { padding: 4px 6px; gap: 4px; }
  .fs-open { grid-template-columns: auto 54px; column-gap: 8px; padding: 5px 24px 5px 8px; }
  .fs-top { font-size: 12px; }
  .fs-chart { width: 54px; height: 30px; }
  .fs-unstar { top: 0; inset-inline-end: 0; width: 26px; height: 26px; }
}
@media (max-width: 600px) {
  .topbar { grid-template-areas: 'brand bal bell help me' 'pick pick pick fav set'; }
  .fav-btn { grid-area: fav; width: 40px; }
  .mm-item { grid-template-columns: 40px minmax(0, 1fr); }
  .mm-star { width: 40px; height: 44px; }
  .mm-cols { padding-left: 52px; }
  .fs-type { display: none; }
}
/* one-row top bars (tablets in portrait, phones held sideways): the star sits right after the market button,
   and only the market button gives up width */
@media (min-width: 601px) and (max-width: 860px), (max-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  .fav-btn { order: 2; width: 40px; height: 40px; }
  .balance-box { flex: none; }
}

/* ---------- payday: a deposit confirmed or a withdrawal sent (showPayday in js/app.js) ---------- */
.pd-modal { z-index: 120; }
.modal-card.pd-card {
  position: relative; max-width: 400px; padding: 30px 24px 18px; overflow: hidden; text-align: center;
  background: radial-gradient(120% 70% at 50% 0%, rgba(245, 196, 81, 0.17), transparent 62%), linear-gradient(180deg, #13223a, #0b1628);
  border: 1px solid rgba(245, 196, 81, 0.45); border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 60px rgba(245, 196, 81, 0.12);
  animation: pdIn .5s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes pdIn { from { opacity: 0; transform: translateY(18px) scale(.94); } }
.pd-glow { position: absolute; left: 50%; top: -130px; width: 380px; height: 270px; transform: translateX(-50%); background: radial-gradient(closest-side, rgba(255, 213, 106, 0.32), transparent); pointer-events: none; }
.pd-ic {
  position: relative; width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  color: #3a2504; background: linear-gradient(145deg, #ffe7a8, #f5c451 55%, #d39431);
  box-shadow: 0 10px 30px rgba(245, 196, 81, 0.35), 0 0 0 6px rgba(245, 196, 81, 0.12);
}
.pd-ic svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pd-out .pd-ic svg { width: 34px; height: 34px; }
.pd-kicker { position: relative; display: block; color: #f5c451; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.pd-amt {
  position: relative; display: block; margin: 6px 0 6px; font-size: 44px; line-height: 1.15; font-weight: 800; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff6d8, #f5c451); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pd-lead { position: relative; max-width: 320px; margin: 0 auto 16px; color: var(--muted); line-height: 1.5; }
.pd-bonus, .pd-total { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; }
.pd-bonus { background: rgba(245, 196, 81, 0.1); border: 1px solid rgba(245, 196, 81, 0.38); color: #f5c451; font-weight: 700; }
.pd-total { margin-top: 6px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.pd-total b { color: var(--text); font-size: 16px; font-variant-numeric: tabular-nums; }
.pd-fine { position: relative; margin: 10px 2px 0; font-size: 11.5px; line-height: 1.45; color: var(--dim); text-align: start; }
.pd-actions { position: relative; display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.btn.pd-go { display: block; text-align: center; text-decoration: none; border-color: transparent; color: #2a1a03; font-weight: 800; background: linear-gradient(180deg, #ffd56a, #f0a91c); box-shadow: 0 8px 24px rgba(240, 169, 28, 0.28); }
@media (hover: hover) { .btn.pd-go:hover { background: linear-gradient(180deg, #ffe08a, #f5b43a); } }
.pd-x { width: 100%; padding: 10px 18px; }
.pd-ref { position: relative; display: block; margin-top: 12px; font-size: 11px; color: var(--dim); }
.bb-value.flash-gold { color: #f5c451; text-shadow: 0 0 18px rgba(245, 196, 81, 0.45); }
.gm-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 200; }
@media (prefers-reduced-motion: reduce) { .modal-card.pd-card { animation: none; } }

