/*
  Hentrad Trade — the trading desk, in the Doji look (see trader/app.css).

  Shares the portal's look. Light by default; dark when the trader
  chooses it (brand/theme.js sets data-theme="dark"). The daily line
  sits at the top of the desk, the price is the one hero figure, and the
  order ticket always shows what a trade risks against what's left of
  today's line before Buy or Sell is pressed. The chart reads its
  colours from --chart-* (trade.js).

  Phone: one column — markets, line, price, chart, ticket, positions,
  with Buy / Sell pinned to the bottom. From 1100px: markets list |
  chart | ticket, positions below.
*/

:root {
  color-scheme: light;
  --navy: #0B1426;
  --navy-2: #111C33;
  --navy-3: #16233F;
  --paper: #F4F5F8;
  --bg: #F0F1F4;
  --surface: #FFFFFF;
  --field: #F6F7FA;
  --track: #E3E6EE;
  --ink: #14182A;
  --muted: #5A6075;
  --line: rgba(20, 24, 42, 0.08);
  --line-strong: rgba(20, 24, 42, 0.14);
  --hover: rgba(20, 24, 42, 0.04);
  --disabled-bg: #E3E6EE;
  --disabled-ink: #8D93A8;
  --blue: #2F5BFF;
  --blue-light: #1B3BCC;     /* blue as text */
  --blue-deep: #1B3BCC;
  --card-2: #F6F7FA;
  --surface-raised: #FFFFFF;
  --green: #3DD674;
  --green-light: #13703A;    /* green as text */
  --red: #E5484D;
  --red-light: #B4232A;      /* red as text */
  --bar-bg: rgba(240, 241, 244, 0.88);
  --glow-1: transparent;
  --glow-2: transparent;
  --panel-shadow: 0 18px 40px -26px rgba(20, 24, 42, 0.28);
  --chart-bg: #FFFFFF;
  --chart-text: #5A6075;
  --chart-grid: rgba(20, 24, 42, 0.06);
  --chart-border: rgba(20, 24, 42, 0.1);
  --display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --body: "Outfit", "Segoe UI", system-ui, sans-serif;
  --wordmark: "Fredoka", "Outfit", system-ui, sans-serif;
  --brand: #2F5BFF;
  --figures: "Outfit", "Segoe UI", system-ui, sans-serif; /* numbers: the body font, every digit the same width */
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0B0E17;
  --bg: #0B0E17;
  --surface: #151B2C;
  --field: #1B2236;
  --track: #232B42;
  --ink: #EEF1F8;
  --muted: rgba(230, 236, 247, 0.70);
  --line: rgba(230, 236, 247, 0.10);
  --line-strong: rgba(230, 236, 247, 0.18);
  --hover: rgba(230, 236, 247, 0.06);
  --disabled-bg: #1F2A44;
  --disabled-ink: rgba(230, 236, 247, 0.6);
  --blue: #5B7FFF;
  --blue-light: #9DB0FF;
  --blue-deep: #9DB0FF;
  --card-2: #1B2236;
  --surface-raised: #1B2236;
  --brand: #3D66FF;
  --green-light: #5EE58F;
  --red-light: #FF8F92;
  --bar-bg: rgba(11, 14, 23, 0.82);
  --glow-1: transparent;
  --glow-2: transparent;
  --panel-shadow: none;
  --chart-bg: #151B2C;
  --chart-text: #9AA7BD;
  --chart-grid: rgba(230, 236, 247, 0.06);
  --chart-border: rgba(230, 236, 247, 0.1);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(900px 520px at 0% -10%, var(--glow-1), transparent 62%), radial-gradient(700px 460px at 105% 0%, var(--glow-2), transparent 60%), var(--bg); background-attachment: fixed; color: var(--ink); font-family: var(--body); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
/* The right wordmark and switch icon for the theme. */
.logo-on-dark, .theme-icon-sun { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
:root[data-theme="dark"] .logo-on-light, :root[data-theme="dark"] .theme-icon-moon { display: none !important; }
:root[data-theme="dark"] .theme-icon-sun { display: inline-flex !important; }
:root[data-theme="dark"] .splash-word img { filter: brightness(0) invert(1); }
.theme-btn { cursor: pointer; color: var(--muted); }
.theme-btn:hover { color: var(--ink); }
h2 { margin: 0; }
p { margin: 0; }
a { color: var(--blue-light); text-decoration: none; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--figures); font-weight: 600; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--green-light); }
.down { color: var(--red-light); }
.label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex-shrink: 0; }
.flip { transform: rotate(180deg); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-blue { background: rgba(47, 91, 255, 0.18); color: var(--blue-light); }
.pill-green { background: rgba(61, 214, 116, 0.16); color: var(--green-light); }
.pill-red { background: rgba(229, 72, 77, 0.18); color: var(--red-light); }
.panel { background: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 60%), var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--panel-shadow); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); color: var(--ink); background: transparent; flex-shrink: 0; }

/* --- Top bar --- */
.desk-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--bar-bg); backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px); border-bottom: 1px solid var(--line); }
.desk-brand { display: flex; align-items: center; gap: 10px; }
.desk-brand img { height: 14px; width: auto; display: block; }
.desk-brand span { font-family: var(--display); font-weight: 600; color: var(--blue-light); }
.desk-bar-gauge { display: none; flex: 1; max-width: 520px; margin-left: 12px; }
.desk-bar-facts { display: none; gap: 22px; margin-left: auto; }
.desk-bar-facts .mono { font-size: 15px; }
#acct-label { margin-left: auto; }

/* The daily line lock: green at the profit line, red at the loss line; a break is neutral. */
.lock-banner { display: flex; gap: 10px; align-items: flex-start; margin: 12px 16px 0; padding: 12px 14px; border-radius: 12px; background: rgba(61, 214, 116, 0.16); border: 1px solid rgba(61, 214, 116, 0.45); color: var(--green-light); font-size: 14px; font-weight: 600; }
.lock-banner.loss { background: rgba(229, 72, 77, 0.16); border-color: rgba(229, 72, 77, 0.5); color: var(--red-light); }
.lock-banner.rest { background: rgba(120, 140, 200, 0.12); border-color: rgba(120, 140, 200, 0.3); color: inherit; font-weight: 500; }
.lock-banner.rest .icon { color: inherit; }
.lock-banner .icon { color: var(--green-light); }
.lock-banner.loss .icon { color: var(--red-light); }

/* --- Layout --- */
.desk { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 32px; max-width: 640px; margin: 0 auto; }
.watchlist { display: none; }
.chart-panel { display: flex; flex-direction: column; gap: 12px; }
.gauge-panel { padding: 14px; }

/* --- The daily line (dark) --- */
.gauge { display: flex; flex-direction: column; gap: 8px; }
.gauge-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.gauge-today { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); }
.gauge-value { font-family: var(--figures); font-size: 18px; font-weight: 600; }
.gauge-line { font-size: 12.5px; color: var(--muted); }
.gauge-track { position: relative; height: 8px; border-radius: 999px; background: var(--track); border: 1px solid var(--line); }
.gauge-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.gauge-zero { position: absolute; top: -4px; bottom: -4px; left: 50%; width: 2px; margin-left: -1px; background: var(--ink); opacity: 0.35; }
.gauge-dot { position: absolute; top: -6px; width: 18px; height: 18px; margin-left: -9px; border-radius: 999px; background: var(--surface); border: 3px solid var(--green); box-shadow: 0 0 14px rgba(61, 214, 116, 0.5); }
.gauge-scale { display: flex; justify-content: space-between; font-family: var(--figures); font-size: 11px; color: var(--muted); }

/* --- Symbol + quote --- */
.symbol-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.symbol-picker { position: relative; display: inline-flex; align-items: center; }
.symbol-picker select {
  appearance: none; -webkit-appearance: none; min-height: 46px; padding: 0 40px 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--field); color: var(--ink);
  font-family: var(--display); font-size: 18px; font-weight: 600; cursor: pointer;
}
.symbol-picker .icon { position: absolute; right: 12px; pointer-events: none; transform: rotate(90deg); color: var(--muted); }
.quote { display: flex; gap: 18px; }
.quote .mono { font-size: 20px; }
.timeframes { display: flex; gap: 2px; overflow-x: auto; }
.timeframes button { min-height: 38px; min-width: 46px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-family: var(--figures); font-size: 13px; font-weight: 600; cursor: pointer; }
.timeframes button.active { background: rgba(47, 91, 255, 0.2); color: var(--blue-light); box-shadow: inset 0 0 0 1px rgba(47, 91, 255, 0.35); }
.chart-box { padding: 6px; overflow: hidden; }
#chart-container { width: 100%; height: 300px; }
.chart-legend { font-size: 12px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }
.lg::before { content: ""; width: 16px; border-top: 2px dashed currentColor; }
.lg-entry { color: var(--blue-light); }
.lg-entry::before { border-top-style: solid; }
.lg-sl { color: var(--red-light); }
.lg-tp { color: var(--green-light); }

/* --- Ticket --- */
.ticket { background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 50%), var(--surface); border: 1px solid var(--line-strong); border-radius: 22px; padding: 10px 16px 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.28); }
.ticket-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--line-strong); align-self: center; }
.ticket-title { font-family: var(--display); font-size: 17px; font-weight: 600; }
#order-form { display: flex; flex-direction: column; gap: 12px; }
.ticket-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.req { color: var(--red-light); font-weight: 600; }
.opt { color: var(--muted); font-weight: 500; }
input {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--field); color: var(--ink); font-family: var(--figures); font-size: 16px; font-weight: 600;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47, 91, 255, 0.18); }
.stepper { display: flex; align-items: center; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--field); padding: 0 4px; }
.stepper input { border: 0; background: transparent; min-height: 44px; text-align: center; padding: 0; outline-offset: -2px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.step-btn:hover { background: var(--hover); }
.quick-stops { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-stops .hint { font-size: 12.5px; color: var(--muted); }
.chip { flex: 1; min-height: 38px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-family: var(--figures); font-size: 12.5px; cursor: pointer; }
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.active { background: rgba(47, 91, 255, 0.2); color: var(--blue-light); border-color: rgba(47, 91, 255, 0.4); }
.risk-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--hover); font-size: 13.5px; color: var(--muted); }
.risk-preview.ok { background: rgba(61, 214, 116, 0.08); }
.risk-preview.warn { background: rgba(229, 72, 77, 0.12); color: var(--red-light); }
.risk-preview strong { color: var(--ink); font-family: var(--figures); }
.buy-sell-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sell-btn, .buy-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; border: 0; border-radius: 16px; font-family: var(--body); font-weight: 700; font-size: 16px; letter-spacing: 0.01em; cursor: pointer; transition: transform 120ms ease, filter 160ms ease, box-shadow 200ms ease; }
.sell-btn:active:not(:disabled), .buy-btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.sell-btn:hover:not(:disabled), .buy-btn:hover:not(:disabled) { filter: brightness(1.07); }
.sell-btn { background: linear-gradient(180deg, #F46A6E, #D9363C); color: #FFFFFF; box-shadow: 0 10px 26px -10px rgba(240, 86, 91, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.buy-btn { background: linear-gradient(180deg, #5EE58F, #2FC264); color: #04140A; box-shadow: 0 10px 26px -10px rgba(61, 214, 116, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.sell-btn small, .buy-btn small { font-family: var(--figures); font-size: 12.5px; font-weight: 500; opacity: 0.85; }
.sell-btn:disabled, .buy-btn:disabled { box-shadow: none; background: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; }
.error { color: var(--red-light); font-size: 13.5px; }
.error:empty { display: none; }

/* --- Positions --- */
.positions-panel { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.positions-panel h2, .closed-title { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.closed-title { margin-top: 14px; }
#positions-list, #history-list { font-size: 14px; color: var(--muted); }
.position-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); }
.position-row:first-child { border-top: 0; }
.position-row .hint { font-size: 12.5px; color: var(--muted); }
.position-right { display: flex; align-items: center; gap: 12px; }
.side { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; margin-left: 6px; }
.side.buy { background: rgba(61, 214, 116, 0.16); color: var(--green-light); }
.side.sell { background: rgba(229, 72, 77, 0.18); color: var(--red-light); }
.close-position-btn { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font-family: var(--body); font-weight: 600; cursor: pointer; }
.close-position-btn:hover:not(:disabled) { background: var(--hover); }
.close-position-btn:disabled { opacity: 0.6; cursor: wait; }

/* --- Watchlist (wide screens) --- */
.watch-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 0 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink); font-family: var(--body); cursor: pointer; text-align: left; }
.watch-row:hover { background: var(--hover); }
.watch-row.active { background: rgba(47, 91, 255, 0.14); border-color: rgba(47, 91, 255, 0.4); }
.watch-row strong { font-size: 14px; }
.watch-row .mono { font-size: 13.5px; }

.offline-banner {
  /* At the top, under the header: Buy, Sell and Close stay reachable below. */
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 72px); z-index: 50; max-width: 600px; margin: 0 auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex; gap: 10px; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; font-size: 13px; text-align: center;
}

/* Phones and tablets: the markets as a row of chips (the symbol menu
   stays for screen readers), and Buy / Sell pinned to the bottom. */
@media (max-width: 1099px) {
  .watchlist { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none; order: -1; }
  .watchlist::-webkit-scrollbar { display: none; }
  .watchlist > .label { display: none; }
  #watchlist { display: flex; gap: 8px; }
  .watch-row { width: auto; min-height: 40px; padding: 0 16px; border-radius: 999px; border-color: var(--line); background: var(--hover); white-space: nowrap; }
  .watch-row .mono { display: none; }
  .watch-row.active { background: rgba(47, 91, 255, 0.18); border-color: rgba(47, 91, 255, 0.5); }
  .symbol-picker { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .quote { width: 100%; justify-content: space-between; }
  .desk { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
  .buy-sell-row {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bar-bg); backdrop-filter: saturate(150%) blur(16px); -webkit-backdrop-filter: saturate(150%) blur(16px);
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 720px) {
  #chart-container { height: 380px; }
  .desk-bar-facts { display: flex; }
  #acct-label { margin-left: 0; }
}

@media (min-width: 1100px) {
  .desk {
    max-width: none; padding: 16px 24px 32px;
    display: grid; grid-template-columns: 220px minmax(0, 1fr) 330px; gap: 16px; align-items: start;
  }
  .desk-bar { padding: 12px 24px; }
  .desk-bar-gauge { display: block; }
  .gauge-panel { display: none; }
  .watchlist { display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; background: var(--surface); box-shadow: var(--panel-shadow); border: 1px solid var(--line); border-radius: 16px; position: sticky; top: 84px; }
  .watchlist .label { padding: 4px 8px 8px; }
  .chart-panel { background: linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0) 40%), var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--panel-shadow); }
  .chart-box { border: 0; padding: 0; }
  #chart-container { height: 460px; }
  .ticket { box-shadow: none; border-radius: 16px; padding: 18px; position: sticky; top: 84px; }
  .ticket-handle { display: none; }
  /* Markets and the ticket run down the sides; your trades sit right under the chart. */
  .watchlist { grid-column: 1; grid-row: 1 / span 2; }
  .chart-panel { grid-column: 2; grid-row: 1; }
  .ticket { grid-column: 3; grid-row: 1 / span 2; }
  .positions-panel { grid-column: 2; grid-row: 2; }
  .desk { grid-template-rows: auto 1fr; }
}

/* Phones zoom the whole page when a field with text under 16px is tapped. */
@media (max-width: 640px) {
  input, select { font-size: 16px; }
}

/* --- Take-profit on an open trade --- */
.tp-btn { min-height: 40px; min-width: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(61, 214, 116, 0.45); background: transparent; color: var(--green-light); font-family: var(--figures); font-size: 13px; font-weight: 700; cursor: pointer; }
.tp-btn:hover, .tp-btn[aria-expanded="true"] { background: rgba(61, 214, 116, 0.12); }
.tp-edit { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 14px; }
.tp-edit label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tp-edit-row { display: flex; gap: 8px; align-items: center; }
.tp-edit-row input { flex: 1; min-width: 0; }
.tp-edit-row button { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font-family: var(--body); font-weight: 600; cursor: pointer; }
.tp-edit-row .tp-save { background: linear-gradient(180deg, #5EE58F, #2FC264); border-color: transparent; color: #04140A; }
.tp-edit-row .tp-remove { color: var(--red-light); }
.tp-edit-row button:disabled { opacity: 0.6; cursor: wait; }
.position-right .mono { white-space: nowrap; }
@media (max-width: 1099px) {
  /* Room for P&L, TP and Close: the buttons drop under the trade on phones. */
  .position-row { flex-wrap: wrap; }
  .position-right { margin-left: auto; }
  .tp-edit { scroll-margin-bottom: 130px; }
}

/* ---- Career mode: the tea break and the line (trade.js) ---- */
.tea-banner { display: flex; gap: 12px; align-items: center; margin: 12px 16px 0; padding: 10px 14px; border-radius: 14px; background: rgba(255, 200, 61, 0.16); border: 1px solid rgba(224, 162, 31, 0.4); font-size: 14px; }
.tea-banner img { width: 38px; height: 48px; object-fit: contain; flex-shrink: 0; }
.tea-banner strong { display: block; font-family: var(--display); }
.moment { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(8, 12, 24, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.moment.open { display: flex; animation: moment-in .35s ease both; }
@keyframes moment-in { from { opacity: 0; } }
.moment-card { width: min(420px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 26px 24px 22px; border-radius: 28px; background: var(--surface); color: var(--ink); text-align: center; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.moment.open .moment-card { animation: moment-pop .45s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes moment-pop { from { transform: translateY(18px) scale(.96); opacity: 0; } }
.moment-art { position: relative; width: 170px; height: 170px; display: grid; place-items: center; }
.moment-art img { width: 120px; height: 156px; object-fit: contain; position: relative; }
.moment-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.moment-ring circle { fill: none; stroke: var(--line-strong); stroke-width: 7; }
.moment-ring .moment-ring-run { stroke: #FFC83D; stroke-linecap: round; stroke-dasharray: 100; }
.moment-time { margin: 0; font-size: 22px; font-weight: 600; color: #9A6B00; }
.moment-card .label { margin: 4px 0 0; }
.moment-card h2 { margin: 0; font-family: var(--display); font-size: 26px; line-height: 1.1; letter-spacing: -0.02em; }
.moment-text { margin: 4px 0 8px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.moment-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.moment-actions .btn { display: flex; align-items: center; justify-content: center; min-height: 50px; border-radius: 14px; font-family: var(--display); font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); }
.moment-actions .btn-primary { background: #0B0D14; color: #fff; border-color: #0B0D14; }
[data-theme="dark"] .moment-actions .btn-primary { background: #fff; color: #0B0D14; border-color: #fff; }
@media (prefers-reduced-motion: reduce) { .moment.open, .moment.open .moment-card { animation: none; } }

/* ---- The Doji look on the desk: the wordmark and calm panels ---- */
.wm { font-family: var(--wordmark); font-weight: 700; letter-spacing: -0.03em; display: inline-block; transform: skewX(-9deg); color: var(--brand); line-height: 1; font-size: 24px; }
:root[data-theme="dark"] .wm { color: #FFFFFF; }
.sell-btn { background: #E5484D; color: #FFFFFF; box-shadow: 0 10px 22px -12px rgba(229, 72, 77, 0.8); }
.buy-btn { background: #2FAE66; color: #FFFFFF; box-shadow: 0 10px 22px -12px rgba(47, 174, 102, 0.8); }
.tp-edit-row .tp-save { background: #2FAE66; color: #FFFFFF; }

/* ---- Learning on the desk (trade.js) ---- */
.market-now { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.market-now strong { color: var(--ink); }
.market-now.m-trending { border-left: 4px solid #2FAE66; }
.market-now.m-ranging { border-left: 4px solid var(--brand); }
.market-now.m-volatile { border-left: 4px solid #E0A21F; }
.practice-note { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.term-btn { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 5px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--card-2); color: var(--muted); font: 700 11px/1 var(--display); cursor: pointer; vertical-align: 1px; text-transform: none; letter-spacing: 0; }
.term-btn:hover { color: var(--ink); border-color: var(--ink); }
.setup-choice { margin: 4px 0 12px; }
.setup-choice .label { margin-bottom: 8px; }
.setup-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.setup-opts button { min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-2); color: var(--ink); font: 600 13.5px var(--display); cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.setup-opts button[aria-checked="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.setup-opts button[data-setup="not-sure"][aria-checked="true"] { background: #FFC83D; border-color: #E0A21F; color: #14182A; }
.tour-btn { font: 700 16px var(--display); color: var(--muted); }
.tour { position: fixed; inset: 0; z-index: 95; }
.tour-hole { position: fixed; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(8, 12, 24, 0.62); transition: left .3s ease, top .3s ease, width .3s ease, height .3s ease; pointer-events: none; }
.tour-card { position: fixed; left: 12px; right: 12px; max-width: 380px; margin: 0 auto; padding: 16px 16px 14px; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6); transition: top .3s ease; }
.tour-head { display: flex; align-items: center; gap: 8px; }
.tour-head img { width: 40px; height: 32px; object-fit: contain; }
.tour-head .label { flex: 1; }
.tour-skip { border: 0; background: none; color: var(--muted); font: 600 14px var(--display); cursor: pointer; }
.tour-card h2 { margin: 8px 0 4px; font-family: var(--display); font-size: 19px; letter-spacing: -0.02em; }
.tour-card p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.tour-actions button { min-height: 42px; padding: 0 18px; border-radius: 12px; font: 600 15px var(--display); cursor: pointer; }
.tour-next { background: #0B0D14; color: #fff; border: 0; }
[data-theme="dark"] .tour-next { background: #fff; color: #0B0D14; }
.tour-back { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
@media (prefers-reduced-motion: reduce) { .tour-hole, .tour-card { transition: none; } }
/* On phones Buy / Sell are pinned to the bottom: anything scrolled into
   view (by the tour, an error, the keyboard) stays clear of them. */
@media (max-width: 1099px) {
  .desk { scroll-padding-bottom: 120px; }
  .ticket *, .positions-panel * { scroll-margin-bottom: 120px; }
}

/* ---- Habits on the desk: the check-in, the tea-break journal ---- */
.checkin { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 4px 0 10px; }
.checkin-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 15px; }
.checkin-scale { display: flex; gap: 6px; }
.checkin-scale button { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--card-2); color: var(--ink); font: 700 15px var(--display); cursor: pointer; }
.checkin-scale button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.moment-journal { width: 100%; padding: 12px; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); margin-bottom: 8px; }
.moment-journal .label { margin: 0 0 8px; }
.moment-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.moment-chips button { min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 13.5px var(--display); cursor: pointer; }
.moment-saved { margin: 0; font-size: 14px; color: var(--green-light); font-weight: 600; }

/* --- Market drills link, today's practice brief --- */
.drills-btn { width: auto; gap: 6px; padding: 0 12px; font-weight: 600; font-size: 14px; }
/* Labelled at every size: a bare target icon means nothing to a newcomer. */
.drills-word { display: inline; }
.drills-btn { width: auto !important; padding: 0 10px !important; gap: 5px; }
/* Phones: the back button says where it goes (the wordmark is hidden there). */
.back-word { display: none; }
.practice-brief { display: flex; gap: 12px; align-items: flex-start; margin: 12px 16px 0; padding: 14px; border-radius: 14px; background: rgba(47, 91, 255, 0.08); border: 1px solid rgba(47, 91, 255, 0.28); font-size: 14px; }
.practice-brief img { width: 54px; height: 54px; flex-shrink: 0; }
.practice-brief .brief-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.practice-brief ol { margin: 4px 0 0; padding-left: 18px; color: var(--muted); display: grid; gap: 3px; }
.practice-brief .btn-link { margin-top: 6px; }
.brief-close { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
@media (min-width: 1100px) { .practice-brief { margin: 16px 24px 0; } }

/* --- Markets by kind --- */
.market-cats { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 4px 6px; }
.market-cats button { min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 12.5px var(--body); cursor: pointer; }
.market-cats button[aria-selected="true"] { background: rgba(47, 91, 255, 0.18); color: var(--blue-light); border-color: rgba(47, 91, 255, 0.45); }
.watch-name { display: flex; flex-direction: column; min-width: 0; }
.watch-name small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
@media (max-width: 1099px) {
  .watchlist { flex-direction: column; gap: 8px; }
  .market-cats { flex-wrap: nowrap; padding: 0; }
  .market-cats button { white-space: nowrap; }
  .watch-name small { display: none; }
}

/* --- Chart tools, legend and full screen --- */
.chart-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-tool { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.chart-tool:hover { background: var(--hover); }
.chart-box { position: relative; }
.chart-ohlc { position: absolute; z-index: 3; top: 6px; left: 8px; max-width: calc(100% - 90px); padding: 2px 6px; border-radius: 6px; background: color-mix(in srgb, var(--chart-bg) 82%, transparent); font-size: 11.5px; font-weight: 500; color: var(--muted); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-ohlc b { color: var(--ink); font-weight: 700; }
.chart-ohlc span { margin-left: 6px; }
.full-head, .full-trade { display: none; }

/* Full screen: top bar, chart, trading bar */
body.chart-full { overflow: hidden; }
body.chart-full .chart-panel {
  position: fixed; inset: 0; z-index: 60; margin: 0; max-width: none; border-radius: 0; border: 0;
  padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  background: var(--chart-bg); display: flex; flex-direction: column; gap: 6px;
}
body.chart-full .chart-panel > :not(.chart-tools):not(.chart-box):not(.full-head):not(.full-trade) { display: none; }
body.chart-full .chart-box { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 0; box-shadow: none; padding: 0; background: transparent; }
body.chart-full #chart-container { flex: 1; height: auto !important; min-height: 0; }
body.chart-full #fullscreen-btn { display: none; }
body.chart-full .buy-sell-row, body.chart-full .desk-bar { visibility: hidden; }

body.chart-full .full-head { display: flex; align-items: center; gap: 14px; min-height: 44px; }
.full-sym select { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); font: 600 15px var(--display); max-width: 46vw; }
.full-quote { font-size: 14px; color: var(--muted); }
.full-pnl { font-size: 15px; }
.full-exit { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 14px var(--body); cursor: pointer; }
.full-exit:hover { background: var(--hover); }

body.chart-full .full-trade { display: flex; align-items: flex-end; gap: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.ft-field { display: flex; flex-direction: column; gap: 4px; }
.ft-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ft-risk { text-transform: none; letter-spacing: 0; margin-left: 4px; color: var(--ink); }
.ft-risk.down { color: var(--red-light); }
.ft-stepper { display: inline-flex; align-items: center; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); overflow: hidden; }
.ft-stepper button { width: 36px; height: 100%; border: 0; background: transparent; color: var(--ink); font-size: 18px; cursor: pointer; }
.ft-stepper span { min-width: 44px; text-align: center; font-size: 14px; }
.ft-chips { display: inline-flex; gap: 4px; }
.ft-chips button { height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 12.5px var(--figures); cursor: pointer; white-space: nowrap; }
.ft-chips button[aria-checked="true"] { background: rgba(47, 91, 255, 0.18); color: var(--blue-light); border-color: rgba(47, 91, 255, 0.45); }
#ft-setup { height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); font: 600 13.5px var(--body); }
.ft-go { margin-left: auto; display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 8px; }
.ft-go .sell-btn, .ft-go .buy-btn { min-height: 48px; border-radius: 12px; font-size: 15px; }
.ft-positions { position: relative; align-self: flex-end; }
.ft-pos-btn { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 600 13.5px var(--body); cursor: pointer; white-space: nowrap; }
.ft-pos-btn .count:not(:empty) { display: inline-block; min-width: 20px; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: rgba(47, 91, 255, 0.18); color: var(--blue-light); font: 600 11.5px var(--figures); }
.ft-pos-list { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 5; width: min(420px, 92vw); max-height: 50vh; overflow-y: auto; padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45); }
.ft-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 6px; border-top: 1px solid var(--line); font-size: 13.5px; }
.ft-row:first-child { border-top: 0; }
.ft-row button { min-height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink); font: 600 13px var(--body); cursor: pointer; }
.ft-empty { padding: 8px; font-size: 13.5px; color: var(--muted); }

/* Phones: the trading bar in two rows, Sell / Buy full width */
@media (max-width: 760px) {
  body.chart-full .full-trade { flex-wrap: wrap; gap: 8px 10px; }
  .ft-go { order: 9; flex-basis: 100%; margin-left: 0; }
  .full-exit span:last-child { display: none; }
  .full-quote { display: none; }
  .ft-chips button { padding: 0 7px; font-size: 11.5px; }
}
/* Short screens (a phone turned sideways): one row, smaller */
@media (max-height: 480px) {
  body.chart-full .full-trade { flex-wrap: nowrap; overflow-x: auto; gap: 8px; }
  .ft-go { order: 0; flex-basis: auto; margin-left: auto; grid-template-columns: repeat(2, 96px); }
  .ft-go .sell-btn, .ft-go .buy-btn { min-height: 40px; font-size: 13px; }
  .ft-label { display: none; }
  body.chart-full .full-head { min-height: 36px; }
}

/* --- Ticket: market, limit, stop --- */
.ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-types { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--hover); border: 1px solid var(--line); }
.order-types button { min-height: 32px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 13px var(--body); cursor: pointer; }
.order-types button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
#order-price-field .field-hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 4px 0 0; }
.hidden { display: none !important; }

/* --- Positions · Orders · History --- */
.positions-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 6px; padding: 0 4px; }
.positions-tabs button { position: relative; min-height: 42px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font: 600 14px var(--body); cursor: pointer; }
.positions-tabs button[aria-selected="true"] { color: var(--ink); }
.positions-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--blue-light); }
.positions-tabs .count:not(:empty) { display: inline-block; min-width: 20px; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: rgba(47, 91, 255, 0.18); color: var(--blue-light); font: 600 11.5px var(--figures); }
#orders-list { font-size: 14px; color: var(--muted); }
.empty-note { font-size: 14px; color: var(--muted); padding: 8px 0; }
.pane-sub { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; }
.position-row.quiet { font-size: 13px; color: var(--muted); padding: 8px 0; }
.history-ranges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.history-ranges button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 13px var(--body); cursor: pointer; }
.history-ranges button[aria-checked="true"] { background: rgba(47, 91, 255, 0.18); color: var(--blue-light); border-color: rgba(47, 91, 255, 0.45); }
.history-summary:not(:empty) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.history-summary > div { padding: 10px 12px; border-radius: 12px; background: var(--hover); display: flex; flex-direction: column; gap: 2px; }
.history-summary .mono { font-size: 17px; }

/* --- Market drills --- */
.drill-pill { margin-left: auto; }
.drills-pick { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.drills-intro { display: flex; gap: 14px; align-items: center; }
.drills-intro img { width: 84px; height: 84px; flex-shrink: 0; }
.drills-intro h1 { font-family: var(--display); font-size: 24px; margin: 0 0 6px; }
.drills-intro p { font-size: 14.5px; line-height: 1.5; }
.drill-cards { display: grid; gap: 10px; }
@media (min-width: 640px) { .drill-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.drill-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; box-shadow: var(--panel-shadow); font-family: var(--body); transition: transform 120ms ease, border-color 160ms ease; }
.drill-card:hover { border-color: rgba(47, 91, 255, 0.5); transform: translateY(-1px); }
.drill-card img { width: 52px; height: 52px; flex-shrink: 0; }
.drill-card-text { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.drill-card-text strong { font-family: var(--display); font-size: 17px; }
.drill-card-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.drill-card.passed { border-color: rgba(61, 214, 116, 0.45); }
.drill-card.passed .drill-card-state { color: var(--green-light); }
.small-note { font-size: 13px; text-align: center; }
.drill-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.drill-hint { font-size: 14px; margin-top: 4px; }
.drill-controls { display: flex; align-items: center; gap: 8px; }
.play-btn { width: 48px; color: var(--blue-light); border-color: rgba(47, 91, 255, 0.45); }
.speeds { display: inline-flex; gap: 2px; }
.speeds button { min-height: 34px; padding: 0 9px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 13px var(--figures); cursor: pointer; }
.speeds button[aria-checked="true"] { background: rgba(47, 91, 255, 0.2); color: var(--blue-light); }
.drill-count { font-size: 12.5px; color: var(--muted); }
.drill-bar { height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; }
.drill-bar span { display: block; height: 100%; width: 0; background: var(--blue-light); transition: width 300ms linear; }
.drill-note { font-size: 13px; }
.stand-btn { min-height: 46px; border-radius: 14px; border: 1px dashed var(--line-strong); background: transparent; color: var(--ink); font: 600 14px var(--body); cursor: pointer; }
.stand-btn:hover { background: var(--hover); }
body.chart-full .drill-head, body.chart-full .drill-bar { display: none; }
/* Small phones: room in the top bar for the Drills button. */
@media (max-width: 480px) {
  .desk-bar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .desk-brand > span { display: none; }
  .desk-bar .icon-btn { width: 40px; height: 40px; }
  .back-btn { width: auto !important; padding: 0 10px 0 4px; gap: 2px; }
  .back-word { display: inline; font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--blue-light); }
  .desk-bar { gap: 6px; }
}
@media (min-width: 1100px) {
  .watchlist { max-height: calc(100vh - 104px); overflow-y: auto; }
  .positions-panel { grid-column: 2 / -1; }
}
.full-kind { font: 600 15px var(--display); }
body.drills-page.chart-full .full-trade { align-items: center; }
.full-pnl { white-space: nowrap; }
@media (max-width: 760px) {
  body.chart-full .full-head { gap: 8px; }
  .full-sym select { max-width: 52vw; font-size: 14px; }
  .full-pnl { font-size: 13px; }
}
body.drills-page #full-play { display: none; }
.full-kind { white-space: nowrap; }

/* The ? menu: the tour, or help */
.help-menu-wrap { position: relative; }
.help-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 230px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45); display: flex; flex-direction: column; }
.help-menu button, .help-menu a { display: block; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: 600 14px var(--body); text-align: left; text-decoration: none; cursor: pointer; }
.help-menu button:hover, .help-menu a:hover { background: var(--hover); }
.news-note { margin: 0; padding: 10px 12px; border-radius: 12px; background: rgba(255, 200, 61, 0.14); border: 1px solid rgba(224, 162, 31, 0.4); font-size: 13.5px; line-height: 1.45; }
.news-note.paused { background: rgba(229, 72, 77, 0.10); border-color: rgba(229, 72, 77, 0.35); }

/* Close all: above the open trades when there are two or more */
.close-all-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 6px; border-radius: 12px; background: var(--field, rgba(127,127,127,.08)); font-size: 13.5px; }
.close-all-btn { min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(229, 72, 77, 0.5); background: transparent; color: var(--red, #E5484D); font: 600 13.5px var(--body); cursor: pointer; }
.close-all-btn:hover:not(:disabled) { background: rgba(229, 72, 77, 0.1); }
.close-all-btn:disabled { opacity: .6; cursor: default; }
.ft-pos-list .close-all-bar { margin: 0 0 4px; }

/* Doji's note for the first days after a comeback */
.comeback-note { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin: 0 0 10px; border-radius: 14px; background: rgba(47, 91, 255, 0.1); border: 1px solid rgba(47, 91, 255, 0.25); font-size: 13.5px; line-height: 1.45; }
.comeback-note img { width: 40px; height: 50px; flex-shrink: 0; object-fit: contain; }
.comeback-note.hidden { display: none; }

/* Prices not live: the numbers fade so they're not mistaken for live ones */
body.prices-stale #quote-bid, body.prices-stale #quote-ask { opacity: 0.45; }

/* The desk couldn't start */
.desk-failed {
  position: fixed; inset: auto 16px 50% 16px; transform: translateY(50%); z-index: 60; max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 16px; padding: 22px 18px;
}
.desk-failed > div { display: flex; flex-direction: column; gap: 4px; }
.desk-failed span { color: var(--muted); font-size: 14px; }

/* ---- Chart tools (charttools.js) ---- */
.chart-tool-group { display: flex; gap: 6px; flex-shrink: 0; }
.chart-tools-btn { width: auto; padding: 0 12px; gap: 6px; font-family: var(--figures); font-size: 13px; font-weight: 600; }
.chart-tools-btn[aria-expanded="true"] { background: rgba(47, 91, 255, 0.2); border-color: rgba(47, 91, 255, 0.45); color: var(--blue-light); }
.chart-box { position: relative; }
body.chart-placing #chart-container { cursor: crosshair; }

.chart-hint {
  pointer-events: none; /* taps go through to the chart; only Cancel catches them */
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); font-size: 13px;
}
.chart-hint button { pointer-events: auto; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--line); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }

.chart-actions {
  position: absolute; z-index: 6; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.chart-actions button { border: 0; border-radius: 8px; padding: 8px 10px; min-height: 36px; background: rgba(47, 91, 255, 0.14); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chart-actions button.danger { background: rgba(229, 72, 77, 0.14); color: #E5484D; }

.chart-menu {
  position: absolute; top: 8px; right: 8px; z-index: 8; width: 360px; max-height: calc(100% - 16px); overflow-y: auto;
  padding: 14px; border-radius: 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}
.chart-menu .cm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.chart-menu .cm-close { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; width: 36px; height: 36px; cursor: pointer; }
.chart-menu .cm-label { margin: 12px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.chart-menu .cm-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chart-menu .cm-tools button, .chart-menu .cm-row button, .chart-menu .cm-seg button {
  min-height: 40px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left;
}
.chart-menu .cm-tools button:hover, .chart-menu .cm-row button:hover:not(:disabled) { border-color: rgba(47, 91, 255, 0.5); }
.chart-menu .cm-inds { display: flex; flex-direction: column; gap: 4px; }
.chart-menu .cm-ind { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 10px; cursor: pointer; }
.chart-menu .cm-ind:hover { background: rgba(47, 91, 255, 0.07); }
.chart-menu .cm-ind input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: #2F5BFF; }
.chart-menu .cm-ind span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.chart-menu .cm-ind small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.chart-menu .cm-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chart-menu .cm-seg button { text-align: center; }
.chart-menu .cm-seg button[aria-pressed="true"] { background: rgba(47, 91, 255, 0.2); border-color: rgba(47, 91, 255, 0.45); color: var(--blue-light); }
.chart-menu .cm-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.chart-menu .cm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }
.chart-menu .cm-row button:disabled { opacity: 0.45; cursor: default; }

/* A level set from the chart flashes in the ticket. */
input.just-set { box-shadow: 0 0 0 3px rgba(47, 91, 255, 0.55); transition: box-shadow 0.3s; }

/* Phones: the tools as a sheet from the bottom, thumb-reachable. */
@media (max-width: 700px) {
  .chart-tools-btn .ct-label { display: none; }
  .chart-tools-btn { width: 40px; padding: 0; }
  .chart-menu { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 78vh; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 80; }
}

/* Chart settings (charttools.js) */
.chart-countdown {
  position: absolute; bottom: 36px; right: 70px; z-index: 4; pointer-events: none; /* above the time axis, clear of the OHLC readout */
  padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
}
.chart-menu .cm-back { border: 0; background: transparent; color: var(--blue-light); font: inherit; font-weight: 600; font-size: 14px; padding: 6px 4px; cursor: pointer; }
.chart-menu .cm-settings {
  display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%; margin-top: 8px; padding: 10px 12px; gap: 2px 8px;
  border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.chart-menu .cm-settings small { grid-column: 1; font-size: 12px; font-weight: 400; color: var(--muted); }
.chart-menu .cm-settings span { grid-row: 1 / span 2; grid-column: 2; font-size: 20px; color: var(--muted); }
.chart-menu .cm-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chart-menu .cm-swatches button {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.chart-menu .cm-swatches button small { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); line-height: 1.3; }
.chart-menu .cm-swatches button[aria-pressed="true"] { border-color: rgba(47, 91, 255, 0.6); box-shadow: inset 0 0 0 1px rgba(47, 91, 255, 0.6); }
.chart-menu .cm-dots { display: inline-flex; gap: 3px; flex-shrink: 0; }
.chart-menu .cm-dots i { display: block; width: 8px; height: 22px; border-radius: 2px; box-sizing: border-box; }
.chart-menu .cm-colors { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; font-size: 13px; }
.chart-menu .cm-colors label { display: inline-flex; align-items: center; gap: 6px; }
.chart-menu .cm-colors input[type="color"] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
.chart-menu .cm-seg-3 { grid-template-columns: 1fr 1fr 1fr; }
.chart-menu .cm-seg-3 button { font-size: 12.5px; }

/* The practice record, in view on the practice desk */
.practice-record { margin: 10px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.practice-record .pr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.practice-record .pr-head .mono { color: var(--muted); font-size: 13px; }
.practice-record .pr-bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.practice-record .pr-bar i { display: block; height: 100%; background: #2F5BFF; border-radius: inherit; transition: width 0.4s; }
.practice-record.passed .pr-bar i { background: #3DD674; }
.practice-record .pr-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.practice-record .pr-kind { padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(47, 91, 255, 0.08); color: var(--muted); }
.practice-record .pr-kind.done { background: rgba(61, 214, 116, 0.14); color: var(--green-light); }
.practice-record .pr-kind.now { background: rgba(245, 184, 61, 0.2); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(245, 184, 61, 0.6); }
.practice-record .pr-line { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.practice-record.needs-now { border-color: rgba(245, 184, 61, 0.6); }
.practice-record.needs-now .pr-line { color: var(--ink); }

/* Phones: all six timeframes fit beside Tools and Full screen. */
@media (max-width: 480px) {
  .timeframes button { min-width: 36px; padding: 0 6px; }
}
.practice-record .pr-tasks { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.practice-record .pr-tasks-head { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.practice-record .pr-task { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.practice-record .pr-task .mono { color: var(--muted); white-space: nowrap; }

/* Phones and tablets: notes sit above the pinned Buy / Sell, never over them. */
@media (max-width: 1099px) { body .hd-toast { bottom: calc(100px + env(safe-area-inset-bottom, 0px)); } }

/* ---- One job per tab (phones and tablets) ----
   Quotes, Chart, Trade, History and Settings, with the order as its own
   screen (body[data-view], trade.js showView), drawn like a mobile trading
   app. Wide screens show the whole desk as before. */
.desk-tabs, .chart-trade, .trade-summary, .desk-settings, .ticket-close, .watch-quote, .watch-head, .watch-sub,
.view-head, .quotes-search, .quotes-note, .chart-market, .ticket-heading .ticket-market,
.ticket-head-gap, .order-kind, .risk-card, .today-card, .pane-title, .pane-note,
.history-ranges [data-range="thisweek"], .history-ranges [data-range="thismonth"] { display: none; }
@media (max-width: 1099px) {
  .desk { padding: 0 16px calc(100px + env(safe-area-inset-bottom)); gap: 0; }
  body:not([data-view="quotes"]) .watchlist,
  body:not([data-view="chart"]) .chart-panel,
  body:not([data-view="order"]) .ticket,
  body:not([data-view="trade"]) .trade-summary,
  body:not([data-view="trade"]):not([data-view="history"]) .positions-panel { display: none; }
  body[data-view="settings"] .desk-settings { display: flex; }
  body[data-view="trade"] .trade-summary { display: flex; }

  /* No top bar: each screen has its title; the way back is in Settings. */
  .desk-bar { display: none; }
  .lock-banner, .tea-banner, .practice-brief { margin: 12px 16px 0; }
  .view-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(20px + env(safe-area-inset-top)) 0 8px; }
  .view-head h1 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
  .head-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: -10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
  .head-btn[aria-checked="true"], .head-btn[aria-expanded="true"] { color: var(--blue-light); background: rgba(47, 91, 255, 0.1); }

  /* The tab bar */
  .desk-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .desk-tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 54px; border: 0; background: transparent; color: var(--muted); font: 500 11px var(--body); cursor: pointer; }
  .desk-tabs button[aria-current="page"] { color: var(--blue-light); font-weight: 600; }
  .desk-tabs .icon { display: flex; }
  body.chart-full .desk-tabs, body[data-view="order"] .desk-tabs { display: none; }

  /* A segmented control: grey track, the chosen one raised. */
  .market-cats, .order-kind, body[data-view="order"] .ticket[data-order-type="limit"] .order-types, body[data-view="order"] .ticket[data-order-type="stop"] .order-types,
  body[data-view="history"] .history-ranges {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; margin: 0;
    border-radius: 12px; border: 0; background: var(--field);
  }
  .market-cats button, .order-kind button, .order-types button, .history-ranges button {
    min-height: 36px; padding: 0 6px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
    font: 500 14px var(--body); white-space: nowrap; box-shadow: none; cursor: pointer;
  }
  .market-cats button[aria-selected="true"], .order-kind button[aria-checked="true"], .order-types button[aria-checked="true"], .history-ranges button[aria-checked="true"] {
    background: var(--surface); color: var(--ink); font-weight: 600; border: 0; box-shadow: 0 1px 2px rgba(20, 24, 42, 0.14);
  }

  /* ---- Quotes ---- */
  .watchlist { display: flex; flex-direction: column; gap: 0; order: 0; margin: 0; padding: 0; overflow: visible; }
  .watchlist > .label { display: none; }
  .quotes-search:not(.hidden) { display: block; margin: 4px 0 8px; }
  .quotes-search input { width: 100%; min-height: 46px; box-sizing: border-box; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--field); color: var(--ink); font: 16px var(--body); }
  .market-cats { margin: 4px 0 6px; }
  #watchlist { display: flex; flex-direction: column; gap: 0; }
  .watch-head { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px; padding: 10px 4px 6px; font-size: 12px; color: var(--muted); text-align: right; }
  .watch-head span:first-child { text-align: left; }
  .watch-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; width: 100%; min-height: 64px; padding: 10px 4px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; white-space: normal; }
  .watch-row.active { background: transparent; border-color: var(--line); }
  .watch-row:hover { background: var(--hover); }
  .watch-row > .mono { display: none; }
  .watch-name { gap: 3px; }
  .watch-row strong { font-size: 16px; }
  .watch-name small:not(.watch-sub) { display: none; }
  .watch-name .watch-sub { display: block; max-width: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
  .watch-row .watch-quote { display: grid; grid-template-columns: repeat(2, 96px); text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
  .watch-quote > span { font-size: 14px; font-weight: 500; white-space: nowrap; }
  .watch-quote b { font-size: 22px; font-weight: 700; }
  .watch-quote sup { font-size: 12px; font-weight: 600; }
  .watch-quote[data-move="up"] { color: var(--green-light); }
  .watch-quote[data-move="down"] { color: var(--red-light); }
  .quotes-note { display: block; margin: 14px 4px 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

  /* ---- Chart ---- */
  .chart-panel { display: flex; flex-direction: column; gap: 10px; }
  .chart-panel, .chart-panel > * { min-width: 0; max-width: 100%; }
  .symbol-bar, .chart-legend { display: none; }
  .chart-tools { order: -3; display: flex; align-items: center; gap: 6px; padding: calc(16px + env(safe-area-inset-top)) 0 0; position: relative; }
  .chart-market { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px 0 0; border: 0; background: transparent; color: var(--ink); font: 700 20px var(--display); cursor: pointer; }
  .chart-market .icon { transform: rotate(90deg); display: flex; }
  .chart-tool-group { margin-left: auto; display: flex; gap: 2px; }
  .chart-tool { width: 44px; height: 44px; border: 0; }
  .chart-tool .ct-label { display: none; }
  .chart-panel > .chart-box { max-width: none; width: calc(100% + 32px); }
  .chart-box { margin: 0 -16px; padding: 0; border: 0; border-radius: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); box-shadow: none; background: var(--chart-bg); }
  #chart-container { height: max(300px, calc(100dvh - 330px)); }
  .chart-trade { display: grid; grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr); gap: 8px; }
  .chart-trade .sell-btn, .chart-trade .buy-btn, .chart-vol { min-height: 58px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
  .chart-trade .sell-btn span, .chart-trade .buy-btn span { font: 600 12px var(--body); letter-spacing: .04em; }
  .chart-trade strong { font-size: 17px; font-variant-numeric: tabular-nums; }
  .chart-vol { border: 0; background: var(--field); color: var(--ink); cursor: pointer; }
  .chart-vol span { font: 500 11px var(--body); color: var(--muted); }

  /* ---- New order ---- */
  .ticket { border: 0; box-shadow: none; padding: calc(12px + env(safe-area-inset-top)) 0 18px; background: transparent; gap: 16px; }
  .ticket-handle { display: none; }
  .ticket-top { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 12px 0; }
  .ticket-close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -8px; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
  .ticket-heading { text-align: center; }
  .ticket-heading .ticket-title { font-size: 17px; }
  .ticket-heading .ticket-market { display: block; font-size: 13px; color: var(--muted); }
  .ticket-head-gap { display: block; }
  .order-kind { grid-column: 1 / -1; }
  .order-types { display: none; grid-column: 1 / -1; }
  .order-types [data-type="market"] { display: none; }
  #order-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
  #order-form > * { grid-column: 1 / -1; margin: 0; }
  #order-form .ticket-grid { display: contents; }
  /* Volume, then stop-loss and take-profit side by side, then the pip chips. */
  #order-form > * { order: 4; }
  #order-form #order-price-field { order: 0; }
  #order-form .field-volume { grid-column: 1 / -1; order: 1; }
  #order-form .field-sl { grid-column: 1; order: 2; }
  #order-form .field-tp { grid-column: 2; order: 2; }
  #order-form .quick-stops { order: 3; }
  #order-form .field label { font-size: 13px; color: var(--muted); }
  #order-form .field-sl .req, #order-form .field-tp .opt { display: none; }
  .stepper { height: 52px; border-radius: 14px; background: var(--field); border: 0; }
  .stepper input { font-size: 22px; font-weight: 700; text-align: center; background: transparent; border: 0; }
  .step-btn { width: 52px; height: 52px; border: 0; background: transparent; }
  #order-stoploss, #order-takeprofit { min-height: 50px; border-radius: 14px; font-size: 18px; }
  #order-stoploss { border: 1.5px solid rgba(229, 72, 77, 0.45); }
  #order-takeprofit { border: 1.5px solid rgba(61, 214, 116, 0.5); }
  .quick-stops { margin-top: -8px !important; }
  .quick-stops .chip { flex: 0 1 auto; min-height: 34px; padding: 0 14px; }
  .risk-preview { display: none !important; }
  .risk-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: var(--field); }
  .rc-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
  .rc-row strong { font-size: 15px; }
  .rc-none { color: var(--muted); }
  .rc-rule { height: 1px; background: var(--line); }
  .rc-verdict, .rc-note { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; line-height: 1.4; }
  .risk-card.ok .rc-verdict { color: var(--green-light); }
  .risk-card.warn .rc-verdict, .risk-card.warn .rc-note { color: var(--red-light); }
  .rc-note { color: var(--muted); }
  .setup-choice .label { margin: 0 0 6px; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--muted); }
  .setup-opts button { min-height: 36px; background: var(--surface); }
  .buy-sell-row .sell-btn, .buy-sell-row .buy-btn { min-height: 64px; border-radius: 16px; font-size: 13px; }
  .buy-sell-row small { font-size: 18px !important; font-weight: 700 !important; opacity: 1 !important; }

  /* ---- Trade ---- */
  .trade-summary { flex-direction: column; gap: 10px; }
  .trade-summary .gauge-panel { display: none; }
  .today-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 18px; background: var(--field); }
  .tc-head { display: flex; align-items: baseline; justify-content: space-between; }
  .tc-head span { font-size: 13px; color: var(--muted); }
  .tc-head strong { font-size: 26px; }
  .tc-track { position: relative; height: 8px; border-radius: 8px; background: var(--track, rgba(127, 127, 127, .2)); }
  .tc-zero { position: absolute; left: 50%; top: -3px; width: 2px; height: 14px; margin-left: -1px; background: var(--muted); }
  .tc-fill { position: absolute; top: 0; height: 8px; border-radius: 8px; background: var(--green); }
  .tc-fill.down { background: var(--red); }
  .tc-scale { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
  .tc-scale span:nth-child(2) { text-align: center; }
  .sum-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .sum-facts div { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
  .sum-facts dt { color: var(--muted); }
  .sum-facts dd { margin: 0; font-weight: 600; }
  .positions-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  body[data-view="trade"] .positions-tabs, body[data-view="history"] .positions-tabs { display: none; }
  body[data-view="trade"] .pane[data-pane="positions"], body[data-view="trade"] .pane[data-pane="orders"] { display: block !important; }
  body[data-view="trade"] .pane[data-pane="history"] { display: none !important; }
  .positions-panel .pane-title { display: block; margin: 18px 0 2px; font: 600 13px var(--body); color: var(--muted); text-transform: none; letter-spacing: 0; }
  .pane-note { display: block; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
  #positions-list .position-row, #orders-list .position-row { cursor: pointer; }
  #positions-list .position-row:not(.manage) .tp-btn, #positions-list .position-row:not(.manage) .close-position-btn { display: none; }
  .position-row .hint { font-variant-numeric: tabular-nums; }
  .position-right > .mono { font-size: 17px; font-weight: 700; }

  /* ---- History ---- */
  .history-head { display: none; }
  body[data-view="history"] .history-head { display: flex; }
  body[data-view="history"] .history-ranges [data-range="today"],
  body[data-view="history"] .history-ranges [data-range="thisweek"],
  body[data-view="history"] .history-ranges [data-range="thismonth"] { display: block; }
  body[data-view="history"] .history-ranges [data-range="week"],
  body[data-view="history"] .history-ranges [data-range="month"],
  body[data-view="history"] .history-ranges [data-range="all"] { display: none; }
  .history-summary:not(:empty) { margin: 14px 0 4px; }
  .history-summary > div { padding: 12px; border-radius: 14px; background: var(--field); gap: 4px; }
  .history-summary .label { font-size: 12px; text-transform: none; letter-spacing: 0; }
  .history-summary .mono { font-size: 19px; font-weight: 700; }
  #history-list .pane-sub { margin: 18px 0 2px; font: 600 13px var(--body); color: var(--muted); text-transform: none; letter-spacing: 0; }

  /* ---- Settings ---- */
  .desk-settings { flex-direction: column; gap: 22px; }
  .desk-settings .view-head { padding-bottom: 0; }
  .profile-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--field); color: var(--ink); text-decoration: none; }
  .profile-avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font: 700 15px var(--display); }
  .profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .profile-text strong { font-size: 16px; }
  .profile-text span { font-size: 13px; color: var(--muted); }
  .profile-card .icon, .set-row .icon { display: flex; color: var(--muted); }
  .set-group { display: flex; flex-direction: column; }
  .set-title { margin: 0 0 2px; font: 600 13px var(--body); color: var(--muted); }
  .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: 400 16px var(--body); text-align: left; text-decoration: none; cursor: pointer; }
  .set-group .set-row:last-child { border-bottom: 0; }
  .set-row > span:first-child { flex: 1; }
  .set-row select { min-height: 40px; max-width: 46%; padding: 0 8px; border: 0; background: transparent; color: var(--muted); font: 16px var(--body); text-align: right; text-align-last: right; cursor: pointer; }
  .set-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brand); }
  .set-value { color: var(--muted); }
  .set-back { color: var(--blue-light); font-weight: 600; }
}

/* ---- Favourite markets (Quotes → Edit) ---- */
.markets-label { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px; }
.markets-label .label { padding: 0; margin: 0; }
.edit-btn { min-height: 32px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--blue-light); font: 600 13.5px var(--body); cursor: pointer; }
.edit-btn[aria-pressed="true"] { background: rgba(47, 91, 255, 0.12); }
.fav-hint { margin: 0 8px 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.fav-star { display: inline-flex; vertical-align: -2px; margin-right: 6px; color: var(--faint, #8D93A8); }
.fav-star.on { color: #E8A317; }
.fav-star.on svg { fill: currentColor; }
.watch-row[aria-pressed] { cursor: pointer; }
.head-actions { display: flex; align-items: center; gap: 2px; }
@media (max-width: 1099px) {
  .markets-label { display: none; }
  .view-head .edit-btn { width: auto; min-height: 44px; padding: 0 10px; margin-right: -10px; font-size: 16px; }
  .fav-hint { margin: 0 4px 8px; }
  .head-actions .head-btn:not(:last-child) { margin-right: 0; }
  .view-head .edit-btn { margin-right: -6px; }
  /* Six groups don't fit as words: Favourites is its star. */
  .fav-cat-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .market-cats [data-cat="fav"] { flex: none; }
  .market-cats:has([data-cat="fav"]) { grid-template-columns: 44px; grid-auto-columns: minmax(0, 1fr); }
  .watch-row[aria-pressed] .watch-quote { opacity: .55; }
}
.fav-cat-star { display: inline-flex; vertical-align: -3px; color: #E8A317; }
.fav-cat-star svg { fill: currentColor; }
@media (min-width: 1100px) { .fav-cat-star { margin-right: 4px; } }

/* ---- Notes from Doji, and the chips under the chart ---- */
.chart-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chart-chips > span, .chip-btn { flex: none; display: inline-flex; align-items: center; min-height: 30px; padding: 0 11px; border-radius: 999px; border: 0; background: var(--field); color: var(--muted); font: 500 12.5px var(--body); white-space: nowrap; }
.chip-btn { cursor: pointer; color: var(--ink); }
.chip-btn:hover { background: var(--hover); }
.chip-btn.m-trending { background: rgba(61, 214, 116, 0.14); color: var(--green-light); }
.chip-btn.m-ranging { background: rgba(47, 91, 255, 0.12); color: var(--blue-light); }
.chip-btn.m-volatile { background: rgba(229, 72, 77, 0.12); color: var(--red-light); }
.chip-practice.passed { background: rgba(61, 214, 116, 0.14); color: var(--green-light); }
.chart-chips .chip-today.up { background: rgba(61, 214, 116, 0.16); color: var(--green-light); font-weight: 600; }
.chart-chips .chip-today.down { background: rgba(229, 72, 77, 0.14); color: var(--red-light); font-weight: 600; }
@media (min-width: 1100px) { .chart-chips .chip-today, .chart-chips .chip-day { display: none; } }
.notes-btn { position: relative; padding: 0; }
.notes-btn img { width: 28px; height: 28px; }
.notes-count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #E5484D; color: #fff; font: 700 10px/16px var(--body); text-align: center; }
.notes-count:empty { display: none; }
.notes-btn:not(.hidden)::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #E5484D; }
.notes-btn:has(.notes-count:not(:empty))::after { display: none; }
.note-list { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 4px 0 8px; text-align: left; }
.note-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 16px; background: var(--card-2, var(--field)); }
.note-item img { width: 40px; height: 48px; object-fit: contain; flex: none; }
.note-item strong { display: block; font-family: var(--display); font-size: 15px; }
.note-item p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.note-steps { margin: 4px 0 8px; padding-left: 20px; text-align: left; display: grid; gap: 4px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.moment-card .practice-record { width: 100%; text-align: left; box-sizing: border-box; margin: 4px 0 8px; }
@media (max-width: 1099px) {
  /* The chart screen: the market and tools, the timeframes right above the
     chart (always in view), the chart, the day's chips, then Sell / Buy. */
  .chart-tools { flex-wrap: wrap; row-gap: 4px; }
  .chart-tools .timeframes { display: flex; order: 5; flex-basis: 100%; position: static; justify-content: space-between; gap: 2px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow-x: auto; }
  .chart-tools .timeframes button { flex: 1; min-width: 0; min-height: 36px; padding: 0 4px; font-size: 13.5px; }
  .chart-box { order: 0; }
  .chart-chips { order: 1; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chart-chips::-webkit-scrollbar { display: none; }
  .chart-trade { order: 2; }
}

/* ---- Buy or sell on the ticket: the stop goes on the right side (trade.js setSide) ---- */
.order-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--field); }
.order-side button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 15px var(--body); cursor: pointer; }
.order-side [data-side="buy"][aria-checked="true"] { background: linear-gradient(180deg, #5EE58F, #2FC264); color: #04140A; }
.order-side [data-side="sell"][aria-checked="true"] { background: linear-gradient(180deg, #F46A6E, #D9363C); color: #FFFFFF; }
/* Only the chosen side's button: the order can't be sent the wrong way round. */
.ticket[data-side="buy"] .buy-sell-row #sell-btn, .ticket[data-side="sell"] .buy-sell-row #buy-btn { display: none; }
.ticket[data-side] .buy-sell-row { grid-template-columns: minmax(0, 1fr); }
