/* Cella007FX app.css — palette tokens, typography, desktop/tablet layout, state classes, UI shell (SPEC 2.1-2.4, App. D).
   Owner: WP-6. Mobile (< 768 px) rules live in mobile.css. Every selector here maps to an id/class in SPEC 2.5 or to a
   class documented in SPEC 2.4 / 4.5 / 7.1 / Appendix D. #overlay gets its z-index (10) inline from chart/overlay.js —
   never set a lower one here; #countdown sits at z-index 20 above it. */

/* ---- 2.1 palette tokens ------------------------------------------------------------------------------------- */
:root {
  --bg-0:#0B0D10; --bg-1:#12151A; --bg-2:#1A1E25; --bg-3:#222731;
  --line:#262B33; --grid:#14171C;
  --text-0:#E8E6E1; --text-1:#9AA0A8; --text-2:#5E646C;
  --gold:#D4AF37; --gold-2:#F2D675; --gold-dim:rgba(212,175,55,.14);
  --up:#2ECC8A; --down:#E5484D; --warn:#F5A524; --info:#4C9AFF; --err:#E5484D; --ok:#2ECC8A;
  --sess-asia:rgba(245,165,36,.07); --sess-london:rgba(76,154,255,.07); --sess-ny:rgba(229,72,77,.07);
  --ema20:#D4AF37; --ema50:#4C9AFF; --ema200:#B8B4AD; --bb:#9C6ADE; --rsi:#B39DDB; --macd:#2962FF; --macd-sig:#FF6D00;
  --atr:#26C6DA; --stoch-k:#4C9AFF; --stoch-d:#F5A524; --vwap:#F2D675;
  --alert:#F5A524; --draw:#D4AF37; --level-day:#FFD54F; --level-pivot:#90A4AE;
  --radius:6px; --hdr-h:48px; --tb-h:36px; --legend-h:22px; --status-h:22px; --panel-w:300px;
  --font-ui:-apple-system,"Segoe UI",Inter,Roboto,Helvetica,Arial,sans-serif;
  --font-mono:"JetBrains Mono","SF Mono",Consolas,"Roboto Mono",monospace;
  /* derived (not in the spec table; used only by this stylesheet) */
  --ok-dim:rgba(46,204,138,.16); --warn-dim:rgba(245,165,36,.16); --err-dim:rgba(229,72,77,.16); --info-dim:rgba(76,154,255,.16);
  --shadow:0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg-0:#FFFFFF; --bg-1:#F4F5F7; --bg-2:#E9EBEF; --bg-3:#DDE0E6; --line:#D5D9E0; --grid:#EEF0F3;
  --text-0:#1B1F26; --text-1:#4E5661; --text-2:#8A919B; --gold:#B8912A; --gold-2:#D4AF37; --gold-dim:rgba(184,145,42,.14);
  --sess-asia:rgba(245,165,36,.10); --sess-london:rgba(76,154,255,.10); --sess-ny:rgba(229,72,77,.10);
  --shadow:0 10px 30px rgba(20,24,32,.18);
  color-scheme: light;
}

/* ---- base / reset ------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-0); color: var(--text-0);
  font: 13px/1.35 var(--font-ui);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--info); }
::selection { background: var(--gold-dim); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--text-1); }
.spread-ok { color: var(--ok); } .spread-warn { color: var(--warn); } .spread-bad { color: var(--err); }
.gold { color: var(--gold); }
.dim { color: var(--text-2); }

/* ---- 2.3 layout grid (desktop >= 1024; tablet 768-1023 overrides below) ------------------------------------ */
#app {
  display: grid;
  grid-template-rows: var(--hdr-h) var(--tb-h) var(--legend-h) minmax(0, 1fr) auto var(--status-h);
  grid-template-areas: "hdr" "tb" "lg" "stage" "banner" "status";
  height: 100vh; height: 100dvh; width: 100%; overflow: hidden;
}
#hdr { grid-area: hdr; } #toolbar { grid-area: tb; } #legend { grid-area: lg; }
#stage { grid-area: stage; } #banner { grid-area: banner; } #statusbar { grid-area: status; }
#stage { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); min-height: 0; min-width: 0; position: relative; }
#stage.panel-closed { grid-template-columns: minmax(0, 1fr); }

/* ---- header --------------------------------------------------------------------------------------------------- */
#hdr {
  display: flex; align-items: center; gap: 16px; padding: 0 12px; min-width: 0;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
}
#brand { font-size: 15px; font-weight: 700; letter-spacing: .12em; white-space: nowrap; color: var(--text-0); }
#brand-sym { margin-left: 12px; font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--text-2); }
#hdr-quote, #hdr-stats { display: flex; align-items: baseline; gap: 12px; min-width: 0; white-space: nowrap; overflow: hidden; font-size: 13px; color: var(--text-1); }
#hdr-quote:empty, #hdr-stats:empty { display: none; }
#hq-bid { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; color: var(--text-0); }
#hq-spread { font-size: 13px; }
/* header MTF ribbon strip (widgets/header.js renders into #hdr-stats) */
.mtf-hdr-bias { font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.mtf-hdr-bias.up { color: var(--up); } .mtf-hdr-bias.down { color: var(--down); } .mtf-hdr-bias.flat { color: var(--text-1); }
.mtf-hdr-score { font-size: 11px; color: var(--text-2); }
.mtf-hdr-tfs { display: inline-flex; align-items: center; gap: 6px; }
.mtf-hdr-tf { font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text-1); white-space: nowrap; }
.mtf-hdr-tf.up { color: var(--up); border-color: rgba(46,204,138,.45); }
.mtf-hdr-tf.down { color: var(--down); border-color: rgba(229,72,77,.45); }
.mtf-hdr-tf.flat { color: var(--text-1); }
.mtf-hdr-tf.pending { color: var(--text-2); opacity: .6; }
.mtf-hdr-tf.active { font-weight: 700; box-shadow: inset 0 0 0 1px var(--gold); }
#hdr-right { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
#clk-main { font-size: 13px; color: var(--text-0); }
#clk-sess { font-size: 11px; color: var(--text-1); }
#btn-panel { font-size: 18px; line-height: 1; padding: 3px 8px; }

/* ---- 2.4 source pill ---------------------------------------------------------------------------------------- */
#srcpill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; white-space: nowrap; cursor: default; user-select: none;
  background: var(--bg-3); color: var(--text-1); border: 1px solid var(--line);
}
#srcpill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
#srcpill.st-init     { color: var(--text-1); }
#srcpill.st-live     { color: var(--ok);   background: var(--ok-dim);   border-color: transparent; }
#srcpill.st-live::before { animation: pulse 1.6s ease-in-out infinite; }
#srcpill.st-delayed  { color: var(--warn); background: var(--warn-dim); border-color: transparent; }
#srcpill.st-paused   { color: var(--warn); background: var(--warn-dim); border-color: transparent; }
#srcpill.st-closed   { color: var(--text-1); background: var(--bg-3); }
#srcpill.st-fallback { color: var(--warn); background: var(--warn-dim); border-color: var(--warn); }
#srcpill.st-quote    { color: var(--err);  background: var(--err-dim);  border-color: transparent; }
#srcpill.st-offline  { color: var(--err);  background: var(--err-dim);  border-color: var(--err); }

/* ---- toolbar -------------------------------------------------------------------------------------------------- */
#toolbar {
  display: flex; align-items: center; gap: 10px; padding: 0 8px; min-width: 0; overflow: hidden;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
}
#toolbar > div { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
#toolbar > div + div { padding-left: 10px; border-left: 1px solid var(--line); }
#tb-right { margin-left: auto; }
#toolbar .btn { padding: 4px 8px; min-height: 26px; font-size: 12px; font-weight: 500; }
#tf-strip .btn { min-width: 34px; padding: 4px 6px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
#tb-tools .btn, #tb-toggles .btn, #tb-right .btn { min-width: 30px; }
#tb-type select { min-height: 26px; padding: 2px 6px; font-size: 12px; font-weight: 500; }
#btn-tool-cancel[hidden] { display: none !important; }

/* ---- buttons -------------------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font: 500 12px/1.2 var(--font-ui); color: var(--text-0); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--text-2); background: var(--bg-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #0B0D10; font-weight: 600; }
.btn.primary:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-1); }
.btn.ghost:hover { color: var(--text-0); background: var(--bg-3); border-color: transparent; }
.btn.danger { color: var(--err); }
button.active, .btn.active, .btn[aria-pressed="true"] { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.btn.sm { padding: 2px 7px; min-height: 22px; font-size: 11px; }
.kbd {
  display: inline-block; min-width: 20px; padding: 1px 6px; text-align: center; font: 11px var(--font-mono);
  color: var(--text-0); background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
}

/* ---- legend --------------------------------------------------------------------------------------------------- */
#legend {
  display: flex; align-items: center; gap: 14px; padding: 0 10px; min-width: 0; font-size: 12px; white-space: nowrap;
  overflow: hidden; color: var(--text-1); background: var(--bg-0); border-bottom: 1px solid var(--line);
}
#legend .lg-tf { color: var(--gold); font-weight: 600; letter-spacing: .04em; }
#legend .lg-ohlc { color: var(--text-1); }
#legend .lg-ind { display: inline-flex; gap: 5px; align-items: baseline; }
#legend .lg-ind .lg-name { color: var(--text-2); }

/* ---- stage / chart ------------------------------------------------------------------------------------------- */
#chart-wrap { position: relative; overflow: hidden; min-width: 0; min-height: 0; background: var(--bg-0); }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
body.tool-active #chart-wrap { cursor: crosshair; }
#countdown {
  position: absolute; right: 0; z-index: 20; pointer-events: none; padding: 1px 6px; font-size: 11px; line-height: 16px;
  color: var(--text-0); background: var(--bg-3); border: 1px solid var(--line); border-right: 0; border-radius: 3px 0 0 3px;
}
#countdown.urgent { color: var(--err); border-color: var(--err); animation: pulse 1s ease-in-out infinite; }
#chart-empty {
  position: absolute; inset: 0; z-index: 15; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: color-mix(in srgb, var(--bg-0) 72%, transparent);
}
#chart-empty .card { width: min(360px, 100%); text-align: center; padding: 20px; box-shadow: var(--shadow); }
#chart-empty-msg { margin: 10px 0 4px; color: var(--text-0); }
#chart-empty .tried { font-size: 11px; color: var(--text-2); margin-bottom: 10px; }
#chart-empty-retry { margin-top: 6px; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto; border-radius: 50%;
  border: 3px solid var(--bg-3); border-top-color: var(--gold); animation: spin .9s linear infinite;
}
#chart-empty.is-offline .spinner { display: none; }

/* ---- panel ---------------------------------------------------------------------------------------------------- */
#panel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  background: var(--bg-1); border-left: 1px solid var(--line);
}
#panel-grip { display: none; }
#panel-tabs {
  display: flex; flex: 0 0 auto; gap: 0; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); background: var(--bg-1);
}
#panel-tabs::-webkit-scrollbar { display: none; }
#panel-tabs .tab {
  flex: 1 0 auto; min-height: 34px; padding: 6px 5px; font: 500 11px var(--font-ui); color: var(--text-1);   /* 6 tabs must fit the 300 px panel */
  background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap;
}
#panel-tabs .tab:hover { color: var(--text-0); }
#panel-tabs .tab[aria-selected="true"], #panel-tabs .tab.active { color: var(--gold); border-bottom-color: var(--gold); background: transparent; }
#panel > section { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px; overscroll-behavior: contain; }
#panel > section > div + div { margin-top: 10px; }
#panel h3, .card-title { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-1); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.card + .card { margin-top: 10px; }
.card table { width: 100%; border-collapse: collapse; font-size: 12px; }
.card td, .card th { padding: 3px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.card tr:last-child td { border-bottom: 0; }
.card td.num, .card th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.note { font-size: 11px; color: var(--text-2); }
.settings-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* tablet 768-1023: the panel is a right drawer over the chart (SPEC 2.3), toggled by #btn-panel */
@media (min-width: 768px) and (max-width: 1023px) {
  #stage { grid-template-columns: minmax(0, 1fr); }
  #panel.drawer {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--panel-w), 85vw); z-index: 30;
    box-shadow: var(--shadow); transform: translateX(100%); transition: transform .22s ease; visibility: hidden;
  }
  #panel.drawer.open { transform: none; visibility: visible; }
}
@media (min-width: 1024px) {
  #stage.panel-closed > #panel { display: none; }
}

/* ---- indicators list / drawings list / alerts list hooks (WP-3 / WP-4 / WP-5 render, WP-6 styles) --------- */
.ind-row, .draw-row, .alert-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.ind-row:last-child, .draw-row:last-child, .alert-row:last-child { border-bottom: 0; }
.ind-swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.ind-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ind-pane, .ind-row .dim { font-size: 10px; color: var(--text-2); }
.ind-row .btn.ghost { padding: 2px 5px; min-height: 22px; }
.ind-empty { padding: 8px 0; color: var(--text-2); font-size: 12px; }
.ind-add-row select { flex: 1 1 auto; min-width: 0; }
.ind-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* ---- WP-5 widget / WP-4 list hooks (rendered by widgets/*.js, tools/alerts.js, tools/draw-ui.js; WP-9 integration) - */
.badge { display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 10px; line-height: 16px; background: var(--bg-3); color: var(--text-1); }
.badge.fired { background: var(--warn-dim); color: var(--warn); }
.alert-row.off { opacity: .55; }
.alert-row .mono { font-variant-numeric: tabular-nums; }
#sess-table tr.open td { color: var(--gold); background: var(--gold-dim); }
#pv-table tr.pp td { color: var(--gold); font-weight: 600; }
.regime { font-weight: 600; letter-spacing: .04em; }
.calc-lots { margin: 6px 0; }
.calc-lots .big { font-size: 22px; font-weight: 600; color: var(--text-0); }
.calc-adv { margin-top: 6px; font-size: 12px; }
.calc-adv > summary { cursor: pointer; font-size: 11px; color: var(--text-1); margin-bottom: 6px; }
.calc-out { margin-top: 8px; }
#w-countdown-val { font-size: 18px; font-weight: 600; color: var(--text-0); }
#q-src.state-live { color: var(--ok); } #q-src.state-delayed, #q-src.state-paused, #q-src.state-fallback { color: var(--warn); }
#q-src.state-quote_only, #q-src.state-offline { color: var(--err); } #q-src.state-closed, #q-src.state-init { color: var(--text-1); }
.draw-head { justify-content: space-between; margin-bottom: 4px; }
.draw-count { font-size: 11px; color: var(--text-1); }
.draw-empty { padding: 8px 0; color: var(--text-2); font-size: 12px; }
.draw-row { cursor: pointer; }
.draw-row.active { background: var(--gold-dim); }
.draw-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.draw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draw-price { font-size: 11px; color: var(--text-2); }
.draw-row .btn.ghost { padding: 2px 5px; min-height: 22px; }

/* ---- forms (2.4 helpers) --------------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; min-width: 0; }
.field label { font-size: 11px; color: var(--text-1); }
.field input, .field select, .field textarea, .ind-add-row select, #tb-type select {
  min-height: 30px; padding: 4px 8px; font-size: 13px; color: var(--text-0); background: var(--bg-0);
  border: 1px solid var(--line); border-radius: 4px; width: 100%; min-width: 0;
}
.field input:focus, .field select:focus { border-color: var(--gold); outline: none; }
.field input[type="checkbox"], .field input[type="radio"] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--gold); }
.field input[type="color"] { padding: 2px; height: 30px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check label { font-size: 13px; color: var(--text-0); }
.field.invalid input, .field.invalid select { border-color: var(--err); }
.field .hint { font-size: 11px; color: var(--text-2); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { opacity: .5; }
select { background-color: var(--bg-0); color: var(--text-0); border: 1px solid var(--line); border-radius: 4px; }

/* ---- banner ---------------------------------------------------------------------------------------------------- */
#banner {
  display: flex; align-items: center; gap: 10px; padding: 4px 12px; min-height: 26px; font-size: 12px;
  border-top: 1px solid var(--line); background: var(--bg-2); color: var(--text-0);
}
#banner .banner-msg { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#banner .banner-details { padding: 1px 7px; min-height: 20px; font-size: 11px; }
#banner.lvl-info { background: var(--info-dim); border-top-color: var(--info); }
#banner.lvl-warn { background: var(--warn-dim); border-top-color: var(--warn); }
#banner.lvl-err  { background: var(--err-dim);  border-top-color: var(--err); }

/* ---- status bar ---------------------------------------------------------------------------------------------- */
#statusbar {
  display: flex; align-items: center; gap: 0; padding: 0 10px; min-width: 0; overflow: hidden; white-space: nowrap;
  font-size: 11px; color: var(--text-1); background: var(--bg-1); border-top: 1px solid var(--line);
}
#statusbar .sb { display: inline-flex; align-items: center; }
#statusbar .sb + .sb::before { content: "·"; margin: 0 7px; color: var(--text-2); }
#statusbar .sb-debug { margin-left: auto; font-family: var(--font-mono); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
#statusbar .ok { color: var(--ok); } #statusbar .bad { color: var(--err); } #statusbar .warn { color: var(--warn); }

/* ---- modal ---------------------------------------------------------------------------------------------------- */
#modal-root {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, .55); overscroll-behavior: contain;
}
body.modal-open { overflow: hidden; }
.modal {
  display: flex; flex-direction: column; width: min(440px, 100%); max-height: min(90vh, 90dvh);
  background: var(--bg-2); color: var(--text-0); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: modalIn .16s ease-out;
}
.modal.wide { width: min(640px, 100%); }
.modal.stacked { display: none; }
.modal-hd { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.modal-hd h2 { margin: 0; flex: 1 1 auto; font-size: 14px; font-weight: 600; }
.modal-x { font-size: 18px; line-height: 1; padding: 2px 7px; }
.modal-bd { padding: 12px; overflow: auto; min-height: 0; }
.modal-bd p { margin: 0 0 8px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }

/* ---- toasts --------------------------------------------------------------------------------------------------- */
#toast-root {
  position: fixed; right: 12px; bottom: calc(var(--status-h) + 12px); z-index: 110; display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; font-size: 12px; line-height: 1.35;
  background: var(--bg-2); color: var(--text-0); border: 1px solid var(--line); border-left: 3px solid var(--info);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; animation: toastIn .18s ease-out; word-break: break-word;
}
.toast.info { border-left-color: var(--info); } .toast.success { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); } .toast.error { border-left-color: var(--err); }
.toast .toast-msg { flex: 1 1 auto; min-width: 0; }
.toast .toast-n { font-size: 10px; color: var(--text-2); font-family: var(--font-mono); }
.toast.leaving { opacity: 0; transform: translateX(12px); transition: opacity .18s, transform .18s; }

/* ---- help overlay (#help, ui/shortcuts.js) --------------------------------------------------------------------- */
#help { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .5); }
.help-card { width: min(720px, 100%); max-height: min(90vh, 90dvh); overflow: auto; padding: 14px 16px; box-shadow: var(--shadow); background: var(--bg-2); }
.help-card h2 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.help-card h2 .btn { margin-left: auto; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 18px; }
.help-grid h4 { grid-column: 1 / -1; margin: 8px 0 2px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-1); }
.help-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 12px; }
.help-row .keys { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.help-row .desc { color: var(--text-1); }

/* ---- animations / motion --------------------------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes flashUp { 0% { color: var(--up); background: rgba(46,204,138,.25); } 100% { background: transparent; } }
@keyframes flashDown { 0% { color: var(--down); background: rgba(229,72,77,.25); } 100% { background: transparent; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.flash-up { animation: flashUp .3s ease-out; }
.flash-down { animation: flashDown .3s ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .flash-up, .flash-down { animation: none; }
}

/* ---- scrollbars (dark, thin) ------------------------------------------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- lib failure notice (main.js shows it when LWC is missing) --------------------------------------------------- */
#liberr { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: var(--bg-0); color: var(--text-0); font-size: 14px; }
/* ---- Trade setup infographic (widgets/setup.js) ---- */
#w-setup { margin-bottom: 10px; }
.setup-head { display: flex; align-items: center; gap: 8px; }
.setup-head h3 { margin: 0; flex: 1 1 auto; }
.setup-side { font-weight: 700; letter-spacing: .06em; padding: 1px 8px; }
.setup-side.up { background: rgba(46,204,138,.15); color: var(--up); border: 1px solid var(--up); }
.setup-side.down { background: rgba(229,72,77,.15); color: var(--down); border: 1px solid var(--down); }
.setup-since { display: block; font-size: 10px; letter-spacing: .04em; margin-top: 4px; }
.setup-headline { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--text-0); margin: 6px 0 8px; }
.setup-info { display: flex; gap: 6px; align-items: center; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 4px; }
.setup-ladder { flex: 1 1 auto; min-width: 0; color: var(--text-1); }
.setup-ladder-svg { display: block; }
.sl-name { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sl-price { font-family: var(--font-mono); font-size: 12px; font-weight: 700; }
.sl-sub { font-family: var(--font-mono); font-size: 9px; fill: var(--text-2); }
.setup-gauge { flex: 0 0 76px; display: flex; flex-direction: column; align-items: center; color: var(--text-1); border-left: 1px solid var(--line); padding-left: 4px; }
.sg-letter { font-size: 22px; font-weight: 800; }
.sg-score { font-size: 8px; fill: var(--text-2); font-family: var(--font-mono); }
.setup-label { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.setup-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.setup-tile { background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px; border-left-width: 3px; min-width: 0; }
.setup-tile.entry { border-left-color: #7C83FF; } .setup-tile.stop { border-left-color: var(--down); } .setup-tile.target { border-left-color: var(--up); } .setup-tile.rr { border-left-color: var(--gold); }
.setup-tile-v { display: block; font-size: 15px; font-weight: 700; color: var(--text-0); white-space: nowrap; }
.setup-tile.stop .setup-tile-v { color: var(--down); } .setup-tile.target .setup-tile-v { color: var(--up); }
.setup-tile-sub { display: block; font-size: 10px; color: var(--text-2); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setup-bars { margin-top: 8px; display: grid; gap: 3px; }
.setup-bar { display: grid; grid-template-columns: 62px 1fr 38px; grid-template-areas: "l t v" "l x x"; align-items: center; column-gap: 6px; font-size: 10px; }
.setup-bar-label { grid-area: l; color: var(--text-1); }
.setup-bar-track { grid-area: t; height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.setup-bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--gold); }
.setup-bar.ok .setup-bar-fill { background: var(--up); } .setup-bar.weak .setup-bar-fill { background: var(--down); opacity: .8; }
.setup-bar-val { grid-area: v; text-align: right; color: var(--text-2); font-size: 10px; }
.setup-bar-text { grid-area: x; color: var(--text-2); font-size: 9px; line-height: 1.2; }
.setup-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { font-size: 10px; line-height: 16px; padding: 1px 7px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text-1); }
.chip-ok { border-color: rgba(46,204,138,.5); color: var(--up); } .chip-weak { border-color: rgba(229,72,77,.4); color: var(--text-1); } .chip-info { color: var(--text-2); }
.setup-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; }
.setup-foot select { font: inherit; font-size: 11px; background: var(--bg-3); color: var(--text-0); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.setup-lots { display: block; margin-top: 6px; font-size: 11px; color: var(--text-1); }
.setup-disclaimer { margin: 6px 0 0; font-size: 10px; }

/* ---- Multi-timeframe trend panel (widgets/mtf.js) ---- */
#w-mtf { margin-bottom: 10px; }
.mtf-head { display: flex; align-items: baseline; gap: 8px; }
.mtf-head h3 { margin: 0; flex: 1 1 auto; }
.mtf-ribbon { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.mtf-grid { display: grid; gap: 3px; margin: 8px 0; }
.mtf-kv { display: grid; grid-template-columns: 54px 1fr 40px auto; align-items: center; gap: 6px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; }
.mtf-k { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.mtf-k2 { text-align: right; }
.mtf-v { font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.mtf-v2 { font-size: 11px; text-align: right; white-space: nowrap; }
.mtf-v.up, .mtf-v2.up, .mtf-trend.up, .mtf-spread.up { color: var(--up); }
.mtf-v.down, .mtf-v2.down, .mtf-trend.down, .mtf-spread.down { color: var(--down); }
.mtf-v.flat, .mtf-trend.flat, .mtf-spread.flat { color: var(--text-1); }
.mtf-v.warn { color: var(--warn, #F5A524); }
.mtf-meter-wrap { display: flex; align-items: center; gap: 6px; }
.mtf-meter { display: inline-block; width: 72px; height: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.mtf-meter-fill { display: block; height: 100%; background: var(--text-2); }
.mtf-meter-fill.hot { background: var(--down); }
.mtf-table-head, .mtf-row { display: grid; grid-template-columns: 52px 1fr 54px 62px; align-items: center; gap: 4px; padding: 3px 8px; }
.mtf-table-head { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); border-bottom: 1px solid var(--line); }
.mtf-table-head span:nth-child(3), .mtf-table-head span:nth-child(4), .mtf-spread, .mtf-grade { text-align: right; }
.mtf-row { font-size: 11px; border-bottom: 1px solid var(--line); }
.mtf-row:last-child { border-bottom: 0; }
.mtf-row.active { background: var(--bg-3); }
.mtf-tf { font-weight: 700; color: var(--text-1); }
.mtf-row.active .mtf-tf { color: var(--gold); }
.mtf-trend { font-weight: 600; }
.mtf-grade { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.mtf-grade.g-strong { color: var(--up); } .mtf-grade.g-moderate { color: var(--gold); } .mtf-grade.g-weak { color: var(--down); } .mtf-grade.g-none { color: var(--text-2); }
.mtf-bias { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 8px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---- Trade setup score alert row ---- */
.setup-alertrow { margin-top: 4px; }
.setup-alertrow select { font: inherit; font-size: 11px; background: var(--bg-3); color: var(--text-0); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.setup-alertstate { flex: 1 1 100%; font-size: 10px; }
