*,*::before,*::after{margin:0;padding:0;box-sizing:border-box;}

/* Focus and number fields (owner, 2026-10-02). Keyboard focus is a crisp 1px
   ring sitting on the element's own edge: no glow, no blur, no ring floating
   away from the box. Component rules may restate it in their own colour, but
   only in this shape. Number fields never show the native up/down spinner
   arrows, in any browser. */
:focus-visible{outline:1px solid var(--accent);outline-offset:-1px;}
input[type="number"]{-moz-appearance:textfield;appearance:textfield;}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}

@keyframes alertSlideDown{from{transform:translateY(-100%);opacity:0;}to{transform:translateY(0);opacity:1;}}
@keyframes alertFadeOut{from{opacity:1;transform:translateY(0);}to{opacity:0;transform:translateY(-100%);}}
.alert-banner{animation:alertSlideDown .35s ease-out forwards;}
.alert-banner.dismissing{animation:alertFadeOut .4s ease-in forwards;}

/* Theme flip (theme.js MP.setTheme, 2026-10-08): no colour transition may
   run across the flip, or eased controls show the old theme for ~90ms (dark
   chips on a light page). Held for two frames only; keyframe animations
   are untouched. */
:root.theme-flip *,:root.theme-flip *::before,:root.theme-flip *::after{transition:none!important;}

:root{
  /* ── COLOR TOKENS MOVED ──
     Every color token now lives in tokens.css (the single source of truth,
     loaded before this file) so both themes flip from one place. Do NOT
     re-add color vars here — app.css loads AFTER tokens.css and would
     shadow the theme-tracking color-mix() derivations. Non-color design
     tokens (type, geometry, layout, motion) stay below. */

  /* ── Typography ── */
  /* Text families FIRST, emoji families LAST (fixed 2026-09-29). Chrome picks
     a font per character, walking the list: an emoji font listed ahead of the
     text fonts carries the space and 0 to 9 (Noto Color Emoji on Linux,
     Segoe UI Emoji on Windows) and wins for those glyphs whenever the named
     text font is not present. That drew a 19px space in 17px text app wide
     ("Economic   Calendar", "2 9"). Inter was listed first but is NOT
     vendored in static/fonts/fonts.css, so it was dropped: body text is the
     platform UI font. CJK families come after the Latin ones (tweets and
     headlines carry Japanese / Chinese text); emoji still render, from the
     trailing emoji families. tests/core/test_font_stacks.py guards this. */
  --font-display:  'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', 'DejaVu Sans', Arial, 'Noto Sans JP', 'Noto Sans SC', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  --font-sans:     system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', 'DejaVu Sans', Arial, 'Noto Sans JP', 'Noto Sans SC', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  --font-mono:     'MP Minus', 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'DejaVu Sans Mono', 'Noto Sans Mono CJK JP', monospace, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';

  /* ── Minimum-size floors ──────────────────────────────────────────────────
     The root font is fluid (see the `html` rule at the bottom of this file) and
     is tuned for the ~3072px CSS 27" reference, where it sits at its 22px cap.
     It quietly under-floors the machine most people actually use: at 1440 the
     root resolves to 14.08px, so a 0.5625rem micro-label lands at 7.9px and a
     1.375rem control at 19.4px — smaller than the smallest type in any shipping
     terminal product, and under the 24x24 CSS px pointer target.

     CSS has no `min-font-size`, so the floor has to be applied per declaration
     with max(). These two constants are THE ONE PLACE the numbers live, so the
     whole product retunes by editing these two lines:
       --fs-floor   smallest legible text.
       --ctl-floor  smallest pointer target (WCAG 2.2 SC 2.5.8 = 24x24 CSS px).

     Both sit BELOW what the rem produces at 2560 (root 20.12px) and at 3072
     (root 22px), so they engage only on narrower screens and the 27" reference
     renders byte-identically. TRAP: never floor a declaration whose rem already
     resolves below the floor at 3072 (font-size < 0.4545rem, height < 1.0909rem)
     — that would move the reference. */
  --fs-floor:      10px;
  --ctl-floor:     24px;

  /* ── Data page scale (owner, 2026-10-05: Option A "dense") ──────────────
     The Economic Calendar, Analyst Targets and Screener grids use exactly
     two sizes and one row height: values and names --fs-data, labels and
     column heads --fs-label, rows --row-data. Each is the px floor or the
     rem that equals it at 1440 (root 14.076px), whichever is larger, so the
     text never shrinks below 12 / 11 px on narrow windows (the fluid root
     drops to 12px at 1024) and still grows with the rest of the app on big
     monitors. eva/app/web/screener.css carries the same three values. */
  --fs-data:       max(12px, 0.8525rem);
  --fs-label:      max(11px, 0.7814rem);
  --row-data:      max(24px, 1.705rem);

  /* ── Sub-reference variants ───────────────────────────────────────────────
     The two constants above can only be used where the TRAP above is satisfied
     — where the declaration's own rem already resolves at or above the floor at
     3072, so max()/min-height is provably inert on the reference monitor.

     A lot of what the JS-rendered UI actually puts on screen fails that test,
     because its box is CONTENT sized rather than rem sized: an icon plus
     padding (.si-lock is 15px at 1440 and 23.4px at 3072), a two-character
     ticker chip, a bare input's line box. There is no rem to floor, and a plain
     min-height would grow them at 3072 too.

     These two are the same numbers, switched OFF once the root font stops
     scaling. `min-*: 0` is the CSS initial value and `max(x, 0px)` is x, so
     above the breakpoint every rule written against them is literally inert —
     the reference cannot move, by construction, without anybody having to redo
     the arithmetic per declaration.

     The breakpoint is where `html{font-size:clamp(12px, 6.3px + 0.54vw, 22px)}`
     reaches its 22px cap: 6.3 + 0.54vw >= 22 ⇒ width >= 2907.4px. Switching
     there rather than at 3072 keeps the whole capped regime (2908px upwards)
     consistent with the reference instead of leaving a 165px band that renders
     differently from both sides. */
  --ctl-floor-sub: var(--ctl-floor);
  --fs-floor-sub:  var(--fs-floor);

  /* ── Letter-spacing scale ── */
  --tr-display:    -0.03em;
  --tr-heading:    -0.02em;
  --tr-body:       -0.01em;
  --tr-caps:        0.08em;
  --tr-mono:        0.01em;

  /* ── Geometry ── */
  --radius:        0.25rem;
  --radius-sm:     0.1875rem;
  --radius-lg:     0.375rem;

  /* ── Layout ── */
  /* rem so they scale with the fluid root font on large screens */
  --sidebar-w:     clamp(11.25rem, 14.5vw, 13.75rem);
  --rail-w:        4rem;   /* resting width of the hover-rail sidebar */
  /* Drawing-tools column between sidebar and charts. 2.875rem (was 2.5rem):
     at 2.5rem the tool button filled the column edge to edge, leaving the
     variant chevron no room — it overlapped the glyph and sat on the active
     ring. The extra 0.375rem is the chevron's own lane (see 13-widgets.css). */
  --chart-rail-w:  2.875rem;
  --ss-w:          20rem;  /* sentiment-settings panel width */
  --ksd-w:         18.75rem;  /* Key Stats side dock width (300px) */
  --trade-rail-w:  2.25rem;   /* right-edge Order rail strip */
  --header-h:      2.25rem; /* was 2.5rem — thinner header strip (2026-07-10) */
  --intel-h:       1.875rem;

  /* ── Motion ── */
  --ease-out:      cubic-bezier(0.22, 0.8, 0.18, 1);
  --ease-in-out:   cubic-bezier(0.4, 0, 0.2, 1);
  /* long-travel panel slides (sidebar fly-out, trade drawer):
     fast launch, long soft landing */
  --ease-glide:    cubic-bezier(0.33, 0.66, 0.08, 1);
  --dur-fast:      140ms;
  --dur:           220ms;
  --dur-slow:      420ms;
  --dur-reveal:    560ms;
}

/* ─── Global typography rules ─── */
h1,h2,h3,h4,h5,h6{font-family:var(--font-display);letter-spacing:var(--tr-heading);}
h1{letter-spacing:var(--tr-display);}
.font-mono,code,pre{font-variant-numeric:tabular-nums;}

/* ─────────────── Mask-reveal utilities ─────────────── */
@keyframes mask-in-up{
  from{clip-path:inset(100% 0 0 0);transform:translateY(6px);opacity:0;}
  to  {clip-path:inset(0 0 0 0);   transform:translateY(0);   opacity:1;}
}
@keyframes mask-in-x{
  from{clip-path:inset(0 100% 0 0);opacity:0;}
  to  {clip-path:inset(0 0 0 0);   opacity:1;}
}
.reveal{animation:mask-in-up var(--dur-reveal) var(--ease-out) both;}

/* ── Directional chevron ──────────────────────────────────────────────────
   One crisp SVG chevron, used for EVERY up/down indicator and caret across the
   app (board rows, movers/heatmap tiles, market breadth, chart-panel toggles).
   Drawn as a mask so it inherits currentColor — each caller's green/red/muted
   color carries straight through — and sized in `em` so it tracks the caller's
   font-size. Geometry (stroked polyline, round joins) matches the sidebar and
   menu carets so every arrow on the page reads as one family.
   Up by default; add `.dn`/`.down` to point down, `.flat` for the no-change dash. */
.mp-arrow{
  display:inline-block;
  width:0.82em;height:0.82em;
  vertical-align:-0.08em;
  flex:none;
  background-color:currentColor;
  --mp-arrow-svg:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4,10 8,6 12,10'/%3E%3C/svg%3E");
  -webkit-mask:var(--mp-arrow-svg) center / contain no-repeat;
          mask:var(--mp-arrow-svg) center / contain no-repeat;
  transition:transform .2s var(--ease-out, ease);
}
.mp-arrow.dn,.mp-arrow.down{transform:rotate(180deg);}
.mp-arrow.flat{
  --mp-arrow-svg:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Cline x1='4' y1='8' x2='12' y2='8'/%3E%3C/svg%3E");
}

html,body{height:100%;overflow:hidden;}
/* Root font-size drives the whole rem-based UI, so this ONE clamp scales every
   component together. Tuned so a 27" desktop (~2560px) stays ~20px — the size
   that reads well there — while narrower screens shrink proportionally instead
   of flooring at one big size: ~14px on a 1440 laptop, ~13px at 1280, down to a
   12px floor. Widen the slope or lower the floor to shrink small screens more. */
html{font-size:clamp(12px, calc(6.3px + 0.54vw), 22px);}
/* The root font is capped from here up, so this is the reference regime: every
   sub-reference floor switches itself off and the 27" rendering is exactly what
   it was before the floors pass. See the block at the top of this file. */
@media (min-width:2908px){
  :root{--ctl-floor-sub:0px;--fs-floor-sub:0px;}
}
body{
  font-family:var(--font-sans);
  letter-spacing:var(--tr-body);
  background:var(--bg-primary);
  color:var(--text-primary);
  display:flex;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}


/* ── MPToast: the ONE success cue (T9 feel round 1, 2026-10-23) ──────────
   static/js/lib/toast.js builds #mp-toast on first use. Same spot as the
   order toast always used (bottom centre), tokens.css green, no glow, 120 ms
   opacity + translate in, nothing animated under reduced motion. The pressed
   button check (.mtst-pressed) only swaps the label; it never resizes. */
.mp-toast{
  /* 3rem: clear of the chart's time axis labels at the window bottom (T9 feel round 2). */
  position:fixed;left:50%;bottom:3rem;z-index:10056;
  display:inline-flex;align-items:center;gap:0.5rem;
  max-width:min(36rem, calc(100vw - 2rem));
  padding:0.5rem 0.875rem;border-radius:var(--radius, 6px);
  background:var(--green);color:var(--on-accent);
  font-family:var(--font-sans);font-size:0.8125rem;font-weight:500;line-height:1.35;letter-spacing:var(--tr-body);
  box-shadow:var(--shadow-hairline);
  opacity:0;transform:translate(-50%, 8px);pointer-events:none;
  transition:opacity .12s ease-out, transform .12s ease-out;
}
.mp-toast.show{opacity:1;transform:translate(-50%, 0);pointer-events:auto;}
.mp-toast.err{background:var(--red);}
.mp-toast.err .mtst-icw{display:none;}
.mp-toast .mtst-icw{display:inline-flex;flex:0 0 auto;}
.mp-toast .mtst-txt{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
.mp-toast .mtst-undo{
  flex:0 0 auto;margin-left:0.25rem;padding:0.125rem 0.5rem;
  border:0;border-radius:var(--radius-sm, 4px);cursor:pointer;
  background:color-mix(in srgb, var(--on-accent-bright) 18%, transparent);
  color:inherit;font:inherit;font-weight:700;
}
.mp-toast .mtst-undo:hover{background:color-mix(in srgb, var(--on-accent-bright) 28%, transparent);}
.mp-toast .mtst-undo[hidden]{display:none;}
.mtst-pressed{display:inline-flex;align-items:center;justify-content:center;gap:0.375rem;}
.mtst-pressed .mtst-ic{flex:0 0 auto;}
@media (prefers-reduced-motion: reduce){
  .mp-toast{transition:none;transform:translate(-50%, 0);}
}
