/* Page frame, terminal frame, top bar, keys, fields, status bar, toasts, dialogs (from the mock-up v5; its own bar,
   device frame and leverage dialog left out). */
html { box-sizing: border-box; height: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font-ui); font-stretch: var(--stretch); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--acc-soft); color: var(--text); }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.num { font-family: var(--font-num); font-stretch: var(--num-stretch); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }

.app { height: 100%; }


/* ---- segmented control ---- */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hair); flex: none; }
.seg-b { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 0; border-radius: calc(var(--r) - 2px); background: none; color: var(--mute); font-weight: 600; font-size: 12px; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg-b[aria-pressed="true"], .seg-b[aria-selected="true"] { background: var(--surface-4); color: var(--text); }
.seg-b:disabled { color: var(--dim); opacity: 0.55; cursor: not-allowed; }
.seg-b:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg-flat { background: none; box-shadow: none; padding: 0; }
@media (hover: hover) { .seg-b:not(:disabled):hover { color: var(--text); } }


/* ---- terminal frame ---- */
.term { position: relative; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "tbar" "banners" "main" "sbar"; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-stretch: var(--stretch); overflow: hidden; }
.term :focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.term ::selection { background: var(--acc-soft); }
.term * { scrollbar-width: thin; scrollbar-color: var(--hair-3) transparent; }
.term input { caret-color: var(--acc); }

.tbar { grid-area: tbar; display: flex; align-items: center; gap: 14px; min-height: var(--bar-h); padding: 0 12px; border-bottom: 1px solid var(--hair); background: var(--surface); }
.brandmark { display: flex; align-items: center; gap: 9px; flex: none; }
.logo { width: 24px; height: 24px; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logo-limit { stroke: var(--silver); }
.logo-goal { stroke: var(--acc); }
.logo-path { stroke: var(--text); }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap; }
.mkt-btn { gap: 8px; padding: 0 10px 0 12px; }
.mkt-sym { font-weight: 700; font-size: 14px; }
.mkt-fam { color: var(--dim); font-size: 11px; font-weight: 600; }
.quote { display: flex; align-items: baseline; gap: 10px; flex: none; }
.quote-px { font-size: var(--fs-xl); font-weight: 600; min-width: 8ch; }
.quote-ch { font-size: 12px; }
/* One row tall and wrapping: a stat that no longer fits drops whole to a hidden second row, last in the list first, instead of being cut mid-number. */
.stats { --stat-h: 33px; display: flex; flex-wrap: wrap; gap: 0 20px; height: var(--stat-h); margin: 0; min-width: 0; overflow: hidden; }
.stats div { display: grid; gap: 1px; flex: none; height: var(--stat-h); }
.stats dt { color: var(--dim); font-size: 11px; line-height: 15px; white-space: nowrap; }
.stats dd { margin: 0; font-size: 12px; line-height: 17px; white-space: nowrap; }
.tbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.acct-pill { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--hair-2); color: var(--mute); font-size: 12px; font-weight: 600; white-space: nowrap; }
kbd { font: 600 10px/1 var(--font-num); font-stretch: var(--num-stretch); color: var(--dim); padding: 3px 5px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--hair-2); }

/* ---- keys: the physical buttons ---- */
.key { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--r); color: var(--text); font-weight: 600; font-size: 13px; line-height: 1; white-space: nowrap; background: linear-gradient(var(--key-top), var(--key-bottom)); box-shadow: inset 0 1px 0 var(--key-shine), inset 0 0 0 1px var(--hair-2), 0 1px 0 var(--key-edge), 0 8px 14px -10px rgba(0, 0, 0, 0.55); cursor: pointer; transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); -webkit-tap-highlight-color: transparent; }
.key:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 var(--key-shine), inset 0 0 0 1px var(--hair-2), 0 0 0 var(--key-edge); }
.key:disabled { opacity: 0.5; cursor: not-allowed; }
.key-sm { min-height: 30px; padding: 0 9px; font-size: 12px; gap: 6px; border-radius: var(--r-sm); }
.key-ico { padding: 0; width: 30px; }
.key-buy { background: linear-gradient(var(--buy-hi), var(--buy)); color: var(--key-ink); }
.key-sell { background: linear-gradient(var(--sell-hi), var(--sell)); color: var(--key-ink); }
.key-ghost { background: none; box-shadow: inset 0 0 0 1px var(--hair-2); color: var(--mute); }
.key[data-armed="1"] { box-shadow: inset 0 0 0 1px var(--warn), 0 1px 0 var(--key-edge); color: var(--warn); }
@media (hover: hover) { .key:not(:disabled):hover { filter: brightness(1.1); } .key-ghost:not(:disabled):hover { color: var(--text); } }

/* ---- fields ---- */
.field { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: var(--r); background: var(--bg); box-shadow: inset 0 0 0 1px var(--hair-2); transition: box-shadow var(--t-fast) var(--ease); }
.field:focus-within { box-shadow: inset 0 0 0 1px var(--acc), 0 0 0 3px var(--acc-soft); }
.field input { flex: 1; min-width: 0; height: 34px; border: 0; background: none; outline: none; color: var(--text); }
.field input::placeholder { color: var(--dim); }
.field .i { color: var(--dim); }
.field-u { color: var(--dim); font-size: 11px; font-weight: 600; white-space: nowrap; }
.field[data-bad="1"] { box-shadow: inset 0 0 0 1px var(--warn); }
input[type="search"]::-webkit-search-cancel-button { appearance: none; }

/* ---- status bar ---- */
.sbar { grid-area: sbar; display: flex; align-items: center; gap: 16px; height: 22px; padding: 0 14px; border-top: 1px solid var(--hair); background: var(--surface); color: var(--dim); font-size: 11px; overflow: hidden; }
.sbar > * { flex: none; }
.sbar-live { display: inline-flex; align-items: center; gap: 6px; color: var(--mute); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }

/* ---- toasts ---- */
.toasts { position: absolute; right: 14px; bottom: 38px; z-index: 60; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast { max-width: 340px; padding: 10px 14px; border-radius: var(--r); background: var(--surface-3); box-shadow: var(--shadow-pop); color: var(--text); font-size: 13px; animation: toast-in var(--t) var(--ease); }
.toast { display: flex; gap: 8px; align-items: flex-start; }
.toast .i { margin-top: 1px; color: var(--mute); }
.toast[data-kind="good"] .i { color: var(--acc); }
.toast[data-out="1"] { opacity: 0; transform: translateY(6px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.scrim { position: absolute; inset: 0; z-index: 35; background: var(--scrim); }

/* ---- dialogs: command palette and shortcuts sheet ---- */
.pal { width: min(560px, calc(100vw - 32px)); max-height: min(520px, 76vh); margin-top: 12vh; padding: 0; border: 0; border-radius: 12px; background: #11141a; color: var(--page-ink); box-shadow: 0 0 0 1px var(--page-line), 0 40px 80px -30px rgba(0, 0, 0, 0.9); overflow: hidden; }
.pal[open] { display: flex; flex-direction: column; animation: toast-in var(--t) var(--ease); }
.pal::backdrop { background: rgba(4, 5, 7, 0.6); }
.pal .field { margin: 10px; background: #0a0c10; box-shadow: inset 0 0 0 1px var(--page-line); min-height: 44px; }
.pal .field:focus-within { box-shadow: inset 0 0 0 1px var(--page-blue), 0 0 0 3px rgba(91, 140, 255, 0.15); }
.pal .field input { color: var(--page-ink); height: 42px; font-size: 15px; }
.pal-list { overflow-y: auto; padding: 0 6px 8px; min-height: 0; }
.pal-g { padding: 10px 10px 4px; color: var(--page-ink-3); font-size: 11px; font-weight: 600; }
.pal-i { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--page-ink-2); text-align: left; cursor: pointer; }
.pal-i[aria-selected="true"] { background: #1a2030; color: var(--page-ink); }
.pal-i span:last-child { margin-left: auto; color: var(--page-ink-3); font-size: 12px; }
.pal-empty { padding: 22px 12px; color: var(--page-ink-3); text-align: center; }
.ks-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 18px; }
.ks-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.keysheet .key { background: #1a1f27; color: var(--page-ink-2); box-shadow: inset 0 0 0 1px var(--page-line); }
.ks-list { margin: 0; padding: 4px 18px 18px; display: grid; grid-template-columns: 1fr auto; gap: 10px 20px; overflow-y: auto; }
.ks-list dt { color: var(--page-ink-2); }
.ks-list dd { margin: 0; display: flex; gap: 4px; justify-content: flex-end; }
.ks-list kbd { color: var(--page-ink); box-shadow: inset 0 0 0 1px var(--page-line); font-size: 11px; padding: 4px 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* The leverage chooser (the mock-up's, desk/leverage.js): shown only where the account's trading terms offer the choice. */
.levbox { width: min(400px, calc(100vw - 32px)); max-height: min(640px, 88vh); margin-top: 9vh; }
.levbox .key, .levbox .chip { background: #1a1f27; color: var(--page-ink-2); box-shadow: inset 0 0 0 1px var(--page-line); }
.lv-body { display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 6px 18px 4px; overflow-y: auto; }
.lv-big { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: var(--page-ink); }
.lv-range { width: 100%; height: 28px; margin: 0; accent-color: var(--page-blue); cursor: pointer; }
.lv-range:focus-visible { outline: 2px solid var(--page-blue); outline-offset: 2px; border-radius: 6px; }
.lv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.levbox .chip { min-height: 32px; padding: 0 11px; font-size: 12.5px; }
.levbox .chip[aria-pressed="true"] { background: rgba(91, 140, 255, 0.16); box-shadow: inset 0 0 0 1px var(--page-blue); color: var(--page-ink); }
.lv-facts { display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; margin: 0; padding: 12px 0; border-top: 1px solid var(--page-line); border-bottom: 1px solid var(--page-line); }
.lv-facts dt { color: var(--page-ink-2); }
.lv-facts dd { margin: 0; color: var(--page-ink); text-align: end; }
.lv-warn { margin: 0; padding: 9px 11px; border-radius: 8px; background: rgba(227, 154, 38, 0.13); color: #f0c27a; font-size: 12.5px; line-height: 1.4; }
.lv-note { margin: 0; color: var(--page-ink-3); font-size: 12.5px; line-height: 1.45; }
.lv-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.lv-foot .key { min-width: 112px; }
.levbox .lv-ok { background: var(--page-blue); box-shadow: none; color: #fff; }
.levbox .lv-ok:disabled { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) {
  .levbox .chip:hover { color: var(--page-ink); }
  .levbox .lv-ok:hover:not(:disabled) { background: #6e9aff; }
}
@media (pointer: coarse) {
  .levbox .key, .levbox .chip { min-height: 44px; }
  .levbox .key-ico { width: 44px; }
  .levbox .chip { min-width: 44px; }
  .lv-range { height: 44px; }
  .lv-foot .key { flex: 1 1 0; }
}
@media (max-height: 800px) { .levbox { max-height: 94vh; margin-top: 3vh; } }
