/* ============================================================
   Inter — bundled locally for offline reliability.
   Was: <link href="https://fonts.googleapis.com/css2?...">
   The WOFF2 files live in static/fonts/. CSS url() is
   relative to this stylesheet (also static/), so the path
   is fonts/inter-<weight>-<subset>.woff2.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===========================================================================
   Trading Tracker — premium UI styles
   Tailwind handles 95% of layout; this file adds polish, custom components,
   and the design tokens that make the app feel like a serious product.
   =========================================================================== */

:root {
  /* ============================================================
     Robinhood-inspired theme palette
     ------------------------------------------------------------
     Brand color IS the up color — the signature neon green is
     used both for primary CTAs and for positive P&L, which
     is the trick that makes RH feel cohesive: gains, brand,
     and "go" are all the same hue.
     Down = RH's red-orange (#FF5000), not a generic red — the
     warmer hue is part of why losses don't feel as "alarm"-y.

     THEMING:
     The :root block holds the DEFAULT (= dark) palette so the
     app still works if data-theme is missing. [data-theme="dark"]
     and [data-theme="light"] blocks below override the same
     tokens. Toggle on <html> by setting data-theme. The pre-paint
     bootstrap script in index.html prevents FOUC by reading
     localStorage before stylesheets evaluate.
     ============================================================ */

  /* Brand — Robinhood neon green (same in both themes) */
  --brand-50:  #e6fff0;
  --brand-100: #c7ffd9;
  --brand-300: #33d65c;
  --brand-500: #00c805;   /* the iconic Robinhood green */
  --brand-600: #00b104;
  --brand-700: #009003;

  /* Surfaces — DARK is the default. */
  --bg:         #000000;
  --bg-elev-1: #0e0e10;
  --bg-elev-2: #1a1a1c;
  --bg-elev-3: #26262a;
  --border:        #1e1e22;
  --border-strong: #2c2c32;

  /* Text — high-contrast white on black, with cool muted grays */
  --text:       #ffffff;
  --text-muted: #9094a3;
  --text-dim:   #6b6e78;

  /* Status — RH up is the brand green; down is RH's warm red-orange */
  --up:        #00c805;
  --up-soft:   rgba(0, 200, 5, 0.13);
  --down:      #ff5000;
  --down-soft: rgba(255, 80, 0, 0.13);
  --warn:      #ffb020;
  --info:      #33d65c;

  /* Layout */
  --sidebar-w: 250px;
  --topbar-h: 56px;

  /* ---- Design system tokens (added 2026-04-30) ---- */
  /* Type scale — 7 steps, all in px so older browsers + email clients render correctly */
  --text-2xs:  10.5px;
  --text-xs:   11.5px;
  --text-sm:   12.5px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  28px;

  /* Spacing scale — multiples of 4 */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-7:  32px;
  --space-8:  40px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Shadows — RH-style: deeper black, no colored glows.
     The brand glow is a translucent green halo for the primary CTA. */
  --sh-sm: 0 1px 2px rgba(0,0,0,0.40);
  --sh-md: 0 4px 14px rgba(0,0,0,0.55);
  --sh-lg: 0 10px 30px rgba(0,0,0,0.70);
  --sh-glow-brand: 0 6px 22px rgba(0,200,5,0.28);

  /* Semantic accent variants — re-tuned for RH's warmer palette
     (success = brand green; warning = amber; danger = red-orange;
     info collapses to the brand green so the whole UI sings one note). */
  --acc-success-fg: #33d65c;
  --acc-success-bg: rgba(0,200,5,0.12);
  --acc-success-border: rgba(0,200,5,0.28);
  --acc-warning-fg: #ffd166;
  --acc-warning-bg: rgba(255,176,32,0.10);
  --acc-warning-border: rgba(255,176,32,0.28);
  --acc-danger-fg:  #ff7849;
  --acc-danger-bg:  rgba(255,80,0,0.10);
  --acc-danger-border: rgba(255,80,0,0.28);
  --acc-info-fg:    #33d65c;
  --acc-info-bg:    rgba(0,200,5,0.10);
  --acc-info-border: rgba(0,200,5,0.25);
  --acc-neutral-fg: var(--text-muted);
  --acc-neutral-bg: rgba(255,255,255,0.04);
  --acc-neutral-border: var(--border);

  /* Surface levels — alternative names that read more semantically in markup */
  --surface:    var(--bg-elev-1);
  --surface-2:  var(--bg-elev-2);
  --surface-3:  var(--bg-elev-3);
  --border-subtle: rgba(255,255,255,0.05);
  --accent: var(--brand-300);   /* generic brand accent for prose links/badges */

  /* Editable-yellow defaults (dark-mode values — overridden in
     [data-theme="light"]). Used by .editable inputs in P&L tracker. */
  --editable-text: #fde68a;
  --editable-bg:   rgba(253, 224, 71, 0.06);
  --editable-border:       rgba(253, 224, 71, 0.20);
  --editable-border-focus: rgba(253, 224, 71, 0.70);
  --editable-bg-focus:     rgba(253, 224, 71, 0.12);

  /* Topbar surface + breadcrumb non-current text (dark-theme defaults). */
  --topbar-bg:   rgba(0, 0, 0, 0.72);
  --crumb-color: #c8ccd2;
  --focus-ring: rgba(0, 200, 5, 0.22);

  /* Fullscreen overlay backdrop used by modals, prewarm progress, the
     language picker, and the zoom modal. Dark with high opacity dims
     whatever's underneath in either theme. The dark theme uses a
     slightly blue-tinted black; the light theme override below uses
     a softer translucent dark so the underlying white isn't fully
     obscured (still readable that the modal is over your content). */
  --modal-bg: rgba(8, 12, 24, 0.92);
}

/* ============================================================
   Dark theme — explicit override of :root for [data-theme="dark"].
   Identical to :root because dark IS the default; defining it
   explicitly lets the toggle reset cleanly without relying on
   "remove the attribute" semantics.
   ============================================================ */
[data-theme="dark"] {
  --bg:         #000000;
  --bg-elev-1: #0e0e10;
  --bg-elev-2: #1a1a1c;
  --bg-elev-3: #26262a;
  --border:        #1e1e22;
  --border-strong: #2c2c32;

  --text:       #ffffff;
  --text-muted: #9094a3;
  --text-dim:   #6b6e78;

  /* Accent for prose links, badges, and small-text emphasis. The pale
     green works on near-black surfaces. */
  --accent: #33d65c;

  /* `--brand-300` is the lighter brand green — used as link / inline
     accent color throughout. Pale green on near-black: perfect. */
  --brand-300: #33d65c;

  /* Editable-yellow affordance for in-place inputs (P&L tracker cells).
     Soft yellow text on a faint yellow background reads on dark surfaces. */
  --editable-text: #fde68a;
  --editable-bg:   rgba(253, 224, 71, 0.06);
  --editable-border:       rgba(253, 224, 71, 0.20);
  --editable-border-focus: rgba(253, 224, 71, 0.70);
  --editable-bg-focus:     rgba(253, 224, 71, 0.12);

  --acc-neutral-bg: rgba(255,255,255,0.04);
  --border-subtle:  rgba(255,255,255,0.05);

  --sh-sm: 0 1px 2px rgba(0,0,0,0.40);
  --sh-md: 0 4px 14px rgba(0,0,0,0.55);
  --sh-lg: 0 10px 30px rgba(0,0,0,0.70);

  /* Topbar surface + breadcrumb non-current text.
     The previous translucent-black with backdrop-blur looked premium
     but the muted breadcrumb text disappeared into the surface
     ("P&L Tracker / Invid Johannes" — the "P&L Tracker" was illegible).
     Now: same dark surface but the crumb gets its own brighter slate
     so the breadcrumb hierarchy still reads. */
  --topbar-bg:   rgba(0, 0, 0, 0.72);
  --crumb-color: #c8ccd2;
}

/* ============================================================
   Light theme — Robinhood's web app in light mode.
   Surface palette: pure white canvas, light-gray secondary
   surfaces, very subtle borders. Text is near-black on white
   with muted gray for secondary, exactly like RH light mode.
   ============================================================ */
[data-theme="light"] {
  /* Surfaces — pure white canvas; cards = same white but bordered;
     elev-2 = a faint warm-gray for hover/secondary fills. RH light
     mode is famously stark — it doesn't tint cards, it just bounds
     them with hairlines. */
  --bg:         #ffffff;
  --bg-elev-1: #ffffff;
  --bg-elev-2: #f5f6f8;
  --bg-elev-3: #ebedf0;
  --border:        #e4e6ea;
  --border-strong: #c8ccd2;

  /* Text — near-black headlines, slate-cool muted, dim hints */
  --text:       #14181f;
  --text-muted: #5b616b;
  --text-dim:   #8a8f99;

  /* Status — same brand greens/reds (the up green is iconic and
     doesn't get diluted in light mode), but the soft tints get
     stronger alpha so they read against white. */
  --up:        #00c805;
  --up-soft:   rgba(0, 200, 5, 0.12);
  --down:      #ff5000;
  --down-soft: rgba(255, 80, 0, 0.10);
  --warn:      #c87800;     /* deeper amber for legibility on white */
  --info:      #00b104;

  /* Accent variants re-tuned for light surfaces — softer foregrounds
     and slightly stronger borders so callouts stay visible without
     screaming. */
  --acc-success-fg: #008a04;
  --acc-success-bg: rgba(0,200,5,0.10);
  --acc-success-border: rgba(0,200,5,0.32);
  --acc-warning-fg: #a8620a;
  --acc-warning-bg: rgba(255,176,32,0.14);
  --acc-warning-border: rgba(255,176,32,0.40);
  --acc-danger-fg:  #c43a00;
  --acc-danger-bg:  rgba(255,80,0,0.10);
  --acc-danger-border: rgba(255,80,0,0.32);
  --acc-info-fg:    #008a04;
  --acc-info-bg:    rgba(0,200,5,0.09);
  --acc-info-border: rgba(0,200,5,0.30);
  --acc-neutral-fg: var(--text-muted);
  --acc-neutral-bg: rgba(0,0,0,0.04);
  --acc-neutral-border: var(--border);

  --border-subtle: rgba(0,0,0,0.06);

  /* Shadows are softer + cooler on light surfaces; pure-black drops
     would look harsh. RH uses warm grays that read like elevation. */
  --sh-sm: 0 1px 2px rgba(20,24,31,0.06);
  --sh-md: 0 4px 14px rgba(20,24,31,0.08);
  --sh-lg: 0 10px 30px rgba(20,24,31,0.12);
  --sh-glow-brand: 0 6px 20px rgba(0,200,5,0.22);

  /* Accent for prose links, badges, and small-text emphasis. The pale
     dark-mode green (#33d65c) is ILLEGIBLE on white — we use a fully
     saturated dark green (#008a04) on light surfaces so links and
     accents have the contrast a sighted user can actually read. */
  --accent: #008a04;

  /* `--brand-300` everywhere else (links inside table rows, "log trades"
     CTAs, etc.). Same logic as --accent: the dark-theme pale green
     fails contrast on white, so we override to the same deep green
     used for accent. ~5.6:1 against white = WCAG AA. */
  --brand-300: #008a04;

  /* Editable-yellow affordance — yellow text on near-white is unreadable.
     In light mode we keep the warm-yellow background tint (still feels
     "this is editable"), but switch the text/border to a deep amber
     that has enough contrast to read. */
  --editable-text: #6b4400;
  --editable-bg:   rgba(253, 224, 71, 0.18);
  --editable-border:       rgba(176, 130, 0, 0.40);
  --editable-border-focus: rgba(176, 130, 0, 0.85);
  --editable-bg-focus:     rgba(253, 224, 71, 0.30);

  /* `--text-dim` was #8a8f99 — a pale slate that fails WCAG (~2.7:1
     against white) and made the OBJETIVO $ column unreadable in
     the P&L tracker. Bumping to #4a4f57 gets it to ~6:1 contrast
     while staying clearly less prominent than --text-muted (#5b616b
     ≈ 5.4:1) and the primary --text (#14181f ≈ 15:1). */
  --text-dim:   #4a4f57;

  /* Topbar in light mode is near-white with a subtle blur — it should
     blend with the canvas, not feel like a separate dark slab. The
     breadcrumb non-current text uses the standard --text-muted because
     it's now sitting on a light surface where slate-gray reads. */
  --topbar-bg:   rgba(255, 255, 255, 0.85);
  --crumb-color: var(--text-muted);
  --focus-ring: rgba(0, 138, 4, 0.18);

  /* Modal backdrop — on a white canvas, a near-opaque navy would feel
     like a hard slab dropping in. Use a softer, slightly translucent
     dark so the underlying page is still faintly visible (the user
     keeps spatial context that the modal is over their content) while
     the modal itself sits on a clearly elevated surface. */
  --modal-bg: rgba(20, 24, 31, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  /* Robinhood's web app uses a custom face called "Capsule Sans Text"
     that we can't ship without a license. The closest free stand-ins,
     in order: SF Pro Text (macOS native — matches the RH iOS app
     exactly), then Inter (which we bundle locally), then system-ui.
     This keeps the typography feeling native on macOS where the app
     is run, with Inter as the cross-platform safety net. */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  /* Tabular nums + ss01 (default) + cv11 (single-story 'a' for a more
     RH-feeling sans). RH numbers are tabular everywhere. */
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;   /* slight tightening — RH default */
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
::selection {
  background: rgba(0, 200, 5, 0.28);
  color: var(--text);
}
:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ===========================================================================
   Auth
   =========================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
  z-index: 1;
}
.auth-grid {
  width: 100%;
  max-width: 1060px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 28px;
  align-items: center;
}
.auth-guide {
  min-height: 540px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background:
    linear-gradient(135deg, rgba(0,200,5,0.08), rgba(0,0,0,0) 55%),
    var(--bg-elev-1);
  padding: 32px;
}
.auth-brand-row,
.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-page .brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Shield SVG provides its own fill + silhouette. Drop-shadow follows
     the shield outline (not a rounded-square outline) for a clean glow. */
  filter: drop-shadow(0 6px 18px rgba(0, 200, 5, 0.34));
}
.auth-page .brand-mark svg { width: 100%; height: 100%; display: block; }
.auth-brand-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0;
}
.auth-guide h1 {
  font-size: 44px;
  line-height: 1.05;
  margin: 42px 0 14px;
  letter-spacing: 0;
}
.auth-guide p {
  max-width: 560px;
  color: var(--text-muted);
  line-height: 1.65;
  font-size: var(--text-md);
  margin: 0;
}
.auth-steps {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}
.auth-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
}
[data-theme="light"] .auth-step { background: rgba(0,0,0,0.025); }
.auth-step-num {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-500);
  color: #001a01;
  font-weight: 800;
  font-size: var(--text-sm);
}
.auth-step strong {
  display: block;
  color: var(--text);
  font-size: var(--text-base);
  margin-bottom: 4px;
}
.auth-step span:last-child {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.auth-trust {
  color: var(--text-dim);
  font-size: var(--text-xs);
  margin-top: 28px;
}
.auth-card {
  padding: 30px;
}
.auth-card-head {
  margin-bottom: 22px;
}
.auth-mobile-brand {
  display: none;
  margin-bottom: 22px;
}
.auth-card h2 {
  margin: 0;
  font-size: var(--text-2xl);
  line-height: 1.2;
  letter-spacing: 0;
}
.auth-card-head p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}

/* Robinhood is a flat-black canvas — no radial backdrop. The previous
   blue/green sheen fought the brand-green-as-up-color signal. We
   keep the ::before pseudo for future use (e.g. a subtle vignette
   on tall pages) but currently render it transparent. */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: transparent;
}

/* ===========================================================================
   App shell — sidebar + main
   =========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  border-right: 1px solid var(--border);
  /* Flat black to match the RH dark canvas — no gradient. */
  background: var(--bg);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar,
.hscroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.sidebar::-webkit-scrollbar-thumb,
.hscroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-mark {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  /* Tradorian shield SVG: the silhouette and color live in the inline
     <svg> child, not on this container. drop-shadow follows the actual
     shield outline so the green glow doesn't extend past the silhouette. */
  filter: drop-shadow(0 6px 16px rgba(0, 200, 5, 0.35));
}
.sidebar-brand .brand-mark svg { width: 100%; height: 100%; display: block; }
.sidebar-brand .brand-text {
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.sidebar-brand .brand-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 1px;
}

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group .nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 6px 10px 4px;
}

/* Sidebar section grouping (Learn / Master / Trade / Tools) */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}
.nav-section:last-child { border-bottom: 0; margin-bottom: 0; }
.nav-section .nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 700;
  color: var(--text-dim);
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-muted);
  cursor: pointer;
  min-height: 36px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  position: relative;
}
.nav-item .nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.nav-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
/* RH-style active state — subtle charcoal tile with white text and a
   3px green accent stripe on the leading edge. The previous saturated
   brand-fill made the sidebar look aggressive against pure black; this
   reads as confident but quiet, the way the RH nav does. */
.nav-item.active {
  background: var(--bg-elev-2);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: inset 3px 0 0 var(--brand-500);
}
.nav-item.active .nav-icon { color: var(--brand-500); }

.sidebar-user {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  /* Charcoal disc with green text — keeps the sidebar palette tight to
     two colors (white + green) instead of introducing a violet accent. */
  background: var(--bg-elev-3);
  border: 1px solid var(--border-strong);
  color: var(--brand-300);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .user-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .logout-btn {
  background: none; border: 0; color: var(--text-muted); cursor: pointer;
  font-size: 12px; padding: 4px 6px; border-radius: 4px;
}
.sidebar-user .logout-btn:hover { color: var(--down); background: var(--bg-elev-2); }

/* Topbar inside main — themed surface (was hardcoded black, which made
   the breadcrumb non-current items disappear into the bg in dark mode
   AND looked wrong in light mode where the rest of the app is white).
   Now the topbar adopts the page surface and the crumbs use a brighter
   slate that has real contrast on both backdrops. */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.topbar > .row {
  min-width: 0;
}
/* Breadcrumb non-current crumbs use the dedicated --crumb-color so they
   stay readable against the topbar regardless of theme. The current
   page (the <strong>) stays at full --text contrast. */
.topbar .crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--crumb-color);
  min-width: 0;
  overflow: hidden;
}
.topbar .crumbs span,
.topbar .crumbs strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .crumbs strong { color: var(--text); font-weight: 600; }
.topbar .topbar-actions { display: flex; align-items: center; gap: 10px; }

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}

.main {
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}
.view {
  padding: 28px 32px 80px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* ===========================================================================
   Cards
   =========================================================================== */
.card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  position: relative;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.card.elev { box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
.card.hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}
.card-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Stat card variant — older sibling of .kpi, same RH-styled hierarchy */
.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.stat-card .stat-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.stat-card .stat-delta {
  font-size: 13px;
  margin-top: 4px;
  font-weight: 600;
  font-feature-settings: "tnum";
}
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Color tones */
.tone-up { color: var(--up); }
.tone-down { color: var(--down); }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

/* Pill / chip */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-elev-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.pill.up { background: var(--up-soft); color: var(--up); border-color: rgba(16,185,129,0.25); }
.pill.down { background: var(--down-soft); color: var(--down); border-color: rgba(255,80,0,0.25); }
.pill.brand { background: rgba(0,200,5,0.13); color: var(--brand-300); border-color: rgba(0,200,5,0.30); }
.pill.warn { background: rgba(255,176,32,0.13); color: var(--warn); border-color: rgba(255,176,32,0.30); }

/* Section heading */
.section-h {
  display: flex; align-items: end; justify-content: space-between;
  margin: 32px 0 14px;
}
.section-h h2 {
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0;
}
.section-h .section-sub {
  font-size: 13px; color: var(--text-muted); margin-top: 2px;
}

/* ===========================================================================
   Design-system components (2026-04-30)
   These classes are the standard vocabulary for the "learning" views:
   review, recap, calibration, skill tree, teach-back, journal grade.
   Goal: replace inline-style soup with consistent, themeable patterns.
   =========================================================================== */

/* ---- Typography helpers — explicit class for size + weight intent ---- */
.h1 { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
.h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; margin: 0; }
.h3 { font-size: var(--text-lg); font-weight: 700; line-height: 1.3; margin: 0; }
.t-body  { font-size: var(--text-base); line-height: 1.55; color: var(--text); }
.t-small { font-size: var(--text-sm); line-height: 1.5; color: var(--text-muted); }
.t-tiny  { font-size: var(--text-xs); line-height: 1.4; color: var(--text-muted); }
.t-caps {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-muted);
}
.t-num { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }

/* ---- Page header (title + subtitle pattern, used at the top of every view) ---- */
.page-header { margin-bottom: var(--space-5); }
.page-header > .h1 { margin-bottom: var(--space-1); }
.page-header > .page-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 720px;
  line-height: 1.55;
}
.page-title {
  font-size: var(--text-3xl);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  max-width: 760px;
  margin: var(--space-1) 0 0;
}

/* ---- Card variants ---- */
/* Base .card already defined above; these are the additional flavors. */
.card-soft { background: var(--surface-2); }
.card-tight { padding: var(--space-3) var(--space-4); }
.card-compact { padding: var(--space-2) var(--space-3); }

/* Accent-bordered card — left rule shows tone */
.card-accent { border-left: 4px solid var(--acc-neutral-fg); }
.card-accent--success { border-left-color: var(--acc-success-fg); }
.card-accent--warning { border-left-color: var(--acc-warning-fg); }
.card-accent--danger  { border-left-color: var(--acc-danger-fg); }
.card-accent--info    { border-left-color: var(--acc-info-fg); }

/* Soft-tinted callout card — uses the matching tone's bg + left border */
.callout {
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--acc-neutral-fg);
  background: var(--acc-neutral-bg);
}
.callout--success { border-left-color: var(--acc-success-fg); background: var(--acc-success-bg); }
.callout--warning { border-left-color: var(--acc-warning-fg); background: var(--acc-warning-bg); }
.callout--danger  { border-left-color: var(--acc-danger-fg);  background: var(--acc-danger-bg); }
.callout--info    { border-left-color: var(--acc-info-fg);    background: var(--acc-info-bg); }
.callout--brand   { border-left-color: var(--brand-300);      background: rgba(0,200,5,0.08); }
.callout > .callout-label {
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--acc-neutral-fg);
  margin-bottom: var(--space-1);
}
.callout--success > .callout-label { color: var(--acc-success-fg); }
.callout--warning > .callout-label { color: var(--acc-warning-fg); }
.callout--danger  > .callout-label { color: var(--acc-danger-fg); }
.callout--info    > .callout-label { color: var(--acc-info-fg); }
.callout--brand   > .callout-label { color: var(--brand-300); }
.callout > .callout-body {
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
}

/* ---- Severity badge — replaces the ad-hoc inline pills ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--acc-neutral-bg);
  color: var(--acc-neutral-fg);
  border: 1px solid var(--acc-neutral-border);
  white-space: nowrap;
}
.badge--success { background: var(--acc-success-bg); color: var(--acc-success-fg); border-color: var(--acc-success-border); }
.badge--warning { background: var(--acc-warning-bg); color: var(--acc-warning-fg); border-color: var(--acc-warning-border); }
.badge--danger  { background: var(--acc-danger-bg);  color: var(--acc-danger-fg);  border-color: var(--acc-danger-border); }
.badge--info    { background: var(--acc-info-bg);    color: var(--acc-info-fg);    border-color: var(--acc-info-border); }
.badge--brand   { background: rgba(0,200,5,0.13);  color: var(--brand-300);      border-color: rgba(0,200,5,0.30); }
.badge--solid-danger { background: var(--down); color: white; border-color: transparent; }

/* ---- KPI block (big number + small label) ---- */
/* RH gives big P&L numbers serious weight + tight tracking + tabular
   numerals so digits don't dance when the value updates. The label
   above sits in lowercase muted gray, NOT uppercase letterspaced —
   that reads more polished against the heavy number underneath. */
.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.kpi > .kpi-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.kpi > .kpi-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: var(--text);
}
.kpi > .kpi-sub {
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-feature-settings: "tnum";
}
.kpi--lg > .kpi-value { font-size: 40px; letter-spacing: -0.025em; }
.kpi--success > .kpi-value { color: var(--acc-success-fg); }
.kpi--warning > .kpi-value { color: var(--acc-warning-fg); }
.kpi--danger  > .kpi-value { color: var(--acc-danger-fg); }
.kpi--info    > .kpi-value { color: var(--acc-info-fg); }
.kpi--brand   > .kpi-value { color: var(--brand-300); }

/* ---- Stat strip (row of KPI blocks at the top of a view) ---- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.stat-strip > .kpi { padding: 0; }

/* ---- Grade row — the per-dimension bar pattern shared by journal grading,
       teach-back grading, and any future scoring panel. ---- */
.grade-row {
  display: grid;
  grid-template-columns: 170px 1fr 36px;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.grade-row:last-child { border-bottom: 0; }
.grade-row .grade-label { font-weight: 600; font-size: var(--text-base); }
.grade-row .grade-comment {
  font-size: var(--text-sm);
  font-weight: 400;
  margin-top: 3px;
  line-height: 1.4;
  color: var(--text-muted);
}
.grade-row .grade-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.grade-row .grade-bar > .grade-fill {
  height: 100%;
  transition: width 0.5s ease-out;
}
.grade-row .grade-score {
  text-align: right;
  font-weight: 700;
  font-size: var(--text-md);
  font-feature-settings: "tnum";
}

/* Small "weakest" pill that decorates a label */
.gap-pill {
  display: inline-block;
  background: var(--down);
  color: white;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: var(--text-2xs);
  margin-left: var(--space-2);
  letter-spacing: 0.04em;
  font-weight: 700;
}

/* ---- Empty state ---- */
.empty-state {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  max-width: 520px;
  margin: var(--space-6) auto;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.empty-state > .empty-icon {
  font-size: 42px;
  margin-bottom: var(--space-2);
  display: block;
}
.empty-state > .h3 { margin-bottom: var(--space-2); }
.empty-state > p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  margin: 0 0 var(--space-4);
}

/* ---- List row — clean rows used in concept lists, teach-back history, etc. ---- */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
}
.list-row:last-child { border-bottom: 0; }
.list-row .list-row-meta { color: var(--text-muted); font-size: var(--text-xs); margin-top: 2px; }

/* ---- Hero CTA (the big "next thing to do" card on Today) ----
   RH-styled: subtle green-tinted dark surface with a thin green border
   that brightens on hover, and a pill-shaped solid-green call-to-action
   on the right. The gradient is much darker than the prior blue version
   so it reads as "premium dark surface" rather than "bright tile". */
.hero-cta {
  display: block;
  padding: var(--space-6) var(--space-6);
  border-radius: var(--r-lg);
  text-decoration: none;
  border: 1px solid rgba(0,200,5,0.22);
  background:
    linear-gradient(135deg, rgba(0,200,5,0.07), rgba(0,200,5,0.01) 70%),
    var(--bg-elev-1);
  margin-bottom: var(--space-4);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.hero-cta:hover {
  transform: translateY(-1px);
  border-color: rgba(0,200,5,0.45);
  box-shadow: var(--sh-glow-brand);
}
.hero-cta--warning {
  background:
    linear-gradient(135deg, rgba(255,176,32,0.08), rgba(255,176,32,0.01) 70%),
    var(--bg-elev-1);
  border-color: rgba(255,176,32,0.28);
}
.hero-cta--warning:hover {
  border-color: rgba(255,176,32,0.50);
  box-shadow: 0 6px 22px rgba(255,176,32,0.22);
}
.hero-cta .hero-cta-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-4); flex-wrap: wrap;
}
.hero-cta .hero-cta-eyebrow {
  font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700;
  color: var(--brand-300);
}
.hero-cta--warning .hero-cta-eyebrow { color: var(--acc-warning-fg); }
.hero-cta .hero-cta-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0;
  color: var(--text);
  line-height: 1.2;
}
.hero-cta .hero-cta-sub {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.hero-cta .hero-cta-pill {
  font-size: var(--text-base);
  font-weight: 700;
  color: #001a01;
  background: var(--brand-500);
  padding: 12px 22px;
  border-radius: 999px;   /* RH pill shape */
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--sh-glow-brand);
}
.hero-cta--warning .hero-cta-pill {
  background: var(--warn);
  color: #1a0e00;
  box-shadow: 0 4px 16px rgba(255,176,32,0.32);
}

/* ---- Today page — calmer, action-first dashboard ---- */
.today-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.today-level-pill {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}
.today-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: var(--space-4);
  align-items: start;
}
.today-primary,
.today-side {
  min-width: 0;
}
.today-side {
  display: grid;
  gap: var(--space-3);
}
.today-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.today-metric {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.today-metric span,
.today-metric small {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.35;
}
.today-metric strong {
  display: block;
  color: var(--text);
  font-size: var(--text-xl);
  line-height: 1.15;
  margin: 4px 0 2px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.today-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--space-4);
}
.today-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.today-panel-head span:last-child:not(:first-child) {
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
.today-routine-list,
.today-focus-list,
.today-weak-list,
.today-shortcuts {
  display: grid;
  gap: var(--space-2);
}
.today-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: var(--space-2);
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--tint-hover);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.today-step:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
  transform: translateY(-1px);
}
.today-step-index {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--acc-success-bg);
  border: 1px solid var(--acc-success-border);
  color: var(--acc-success-fg);
  font-size: var(--text-xs);
  font-weight: 800;
}
.today-step strong,
.today-step small {
  display: block;
}
.today-step strong {
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.3;
}
.today-step small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  margin-top: 2px;
}
.today-focus-card--compact {
  display: grid;
  gap: 6px;
  padding: var(--space-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--acc-info-border);
  background: var(--acc-info-bg);
  text-decoration: none;
}
.today-focus-card--compact.focus-card--danger {
  border-color: var(--acc-danger-border);
  background: var(--acc-danger-bg);
}
.today-focus-card--compact.focus-card--warning {
  border-color: var(--acc-warning-border);
  background: var(--acc-warning-bg);
}
.today-focus-card--compact strong {
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.35;
}
.today-focus-card--compact > span:last-child {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}
.first-run-guide {
  border: 1px solid rgba(0,200,5,0.28);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(0,200,5,0.08), rgba(0,200,5,0.02));
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.first-run-guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.first-run-guide-head strong {
  display: block;
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.35;
  margin-top: 4px;
}
.first-run-guide-head > span {
  flex: 0 0 auto;
  color: var(--acc-success-fg);
  border: 1px solid var(--acc-success-border);
  background: var(--acc-success-bg);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: 800;
  font-feature-settings: "tnum";
}
.first-run-steps {
  display: grid;
  gap: var(--space-2);
}
.first-run-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.first-run-step:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
  transform: translateY(-1px);
}
.first-run-step.is-current {
  border-color: rgba(0,200,5,0.45);
  background: rgba(0,200,5,0.08);
}
.first-run-step.is-done {
  opacity: 0.82;
}
.first-run-step-marker {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--tint-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 900;
  font-feature-settings: "tnum";
}
.first-run-step.is-current .first-run-step-marker,
.first-run-step.is-done .first-run-step-marker {
  color: var(--acc-success-fg);
  background: var(--acc-success-bg);
  border-color: var(--acc-success-border);
}
.first-run-step-copy {
  min-width: 0;
}
.first-run-step-copy strong,
.first-run-step-copy small {
  display: block;
}
.first-run-step-copy strong {
  color: var(--text);
  font-size: var(--text-sm);
  line-height: 1.3;
}
.first-run-step-copy small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  margin-top: 2px;
}
.first-run-step-cta {
  color: var(--acc-success-fg);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}
.today-weak-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.today-weak-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.today-weak-row span {
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 650;
  min-width: 0;
}
.today-weak-row strong {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.today-shortcuts {
  grid-template-columns: 1fr;
}
.today-shortcuts a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
  background: var(--tint-hover);
}
.today-shortcuts a:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}
@media (max-width: 680px) {
  .first-run-step {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .first-run-step-cta {
    grid-column: 2;
  }
}

/* ---- Slim stat-line (a one-row inline summary, replaces the 4-up KPI strip) ---- */
.stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--space-4);
  font-size: var(--text-base);
}
.stat-line > .stat-line-item {
  display: flex; align-items: center; gap: var(--space-1);
  font-feature-settings: "tnum";
}
.stat-line > .stat-line-item .stat-line-label {
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.stat-line > .stat-line-item .stat-line-value {
  color: var(--text);
  font-weight: 700;
}
.stat-line > .stat-line-divider {
  width: 1px; height: 18px;
  background: var(--border-strong);
  flex-shrink: 0;
}

/* ---- Today focus card (the row of 1-3 prioritized "do this" cards) ---- */
.focus-card {
  display: block;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--r-md);
  text-decoration: none;
  border: 1px solid var(--acc-info-border);
  background: var(--acc-info-bg);
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
}
.focus-card:hover { transform: translateY(-1px); }
.focus-card--critical {
  background: var(--acc-danger-bg);
  border-color: var(--acc-danger-border);
}
.focus-card--warning {
  background: var(--acc-warning-bg);
  border-color: var(--acc-warning-border);
}
.focus-card--info {
  background: var(--acc-info-bg);
  border-color: var(--acc-info-border);
}
.focus-card .focus-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.focus-card .focus-content { flex: 1; min-width: 0; }
.focus-card .focus-head {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  margin-bottom: var(--space-1);
}
.focus-card .focus-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.focus-card .focus-detail {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.5;
}
.focus-card .focus-action {
  font-size: var(--text-base);
  margin-top: var(--space-2);
  font-weight: 600;
  color: var(--acc-info-fg);
}
.focus-card--critical .focus-action { color: var(--acc-danger-fg); }
.focus-card--warning .focus-action { color: var(--acc-warning-fg); }

/* ---- Daily routine strip ---- */
.routine-strip {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.routine-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: var(--space-3);
}
.routine-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.routine-item {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elev-1);
  transition: border-color 0.15s, transform 0.15s;
}
.routine-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.routine-num {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--acc-success-bg);
  border: 1px solid var(--acc-success-border);
  color: var(--acc-success-fg);
  font-weight: 800;
  font-size: var(--text-sm);
}
.routine-copy strong {
  display: block;
  font-size: var(--text-base);
  color: var(--text);
  margin-bottom: 3px;
}
.routine-copy span {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* ---- Paper trade logger ---- */
.paper-form-intro {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
  border: 1px solid var(--acc-info-border);
  background: var(--acc-info-bg);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}
.paper-form-intro strong {
  display: block;
  color: var(--text);
  font-size: var(--text-base);
  margin-bottom: 2px;
}
.paper-form-intro span {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.paper-trade-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

/* ---- Confirm/alert dialog (replaces native browser confirm()) ---- */
.ui-dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  z-index: 9500;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ui-dialog-backdrop.show { opacity: 1; }
.ui-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--sh-lg);
  transform: translateY(8px) scale(0.985);
  transition: transform 0.18s ease;
}
.ui-dialog-backdrop.show .ui-dialog { transform: translateY(0) scale(1); }
.ui-dialog .ui-dialog-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-2);
  color: var(--text);
}
.ui-dialog .ui-dialog-body {
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}
.ui-dialog .ui-dialog-actions {
  display: flex; gap: var(--space-2); justify-content: flex-end;
}

/* ---- Toast notifications ---- */
.toast-host {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 9000;
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
  max-width: calc(100vw - var(--space-7));
}
.toast {
  pointer-events: auto;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--acc-info-fg);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 240px; max-width: 380px;
  box-shadow: var(--sh-md);
  font-size: var(--text-base);
  color: var(--text);
  transform: translateX(110%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast--success { border-left-color: var(--acc-success-fg); }
.toast--warning { border-left-color: var(--acc-warning-fg); }
.toast--danger  { border-left-color: var(--acc-danger-fg); }
.toast .toast-msg { flex: 1; line-height: 1.5; }
.toast .toast-action {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  white-space: nowrap;
}
.toast .toast-action:hover { background: var(--surface-2); }
.toast .toast-close {
  background: transparent; border: 0; color: var(--text-dim);
  font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.toast .toast-close:hover { color: var(--text); }

@media (max-width: 600px) {
  .toast-host {
    bottom: var(--space-3);
    right: var(--space-3);
    left: var(--space-3);
  }
  .toast { max-width: none; }
}

/* ---- Skeleton loader ----
   The sweep uses a CSS variable for the highlight color so the
   shimmer stays visible against both dark and light surfaces.
   Dark theme: subtle white shimmer on near-black. Light theme:
   subtle gray shimmer on white. */
.skeleton {
  background: linear-gradient(90deg,
    var(--skeleton-base) 0%,
    var(--skeleton-hi)   50%,
    var(--skeleton-base) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
[data-theme="dark"]  {
  --skeleton-base: rgba(255,255,255,0.04);
  --skeleton-hi:   rgba(255,255,255,0.10);
  /* Tint helpers — used wherever the original dark-only theme used
     a tiny white-alpha for hover states or quiet backgrounds. */
  --tint-hover:    rgba(255,255,255,0.02);
  --tint-quiet:    rgba(255,255,255,0.04);
}
[data-theme="light"] {
  --skeleton-base: rgba(20,24,31,0.05);
  --skeleton-hi:   rgba(20,24,31,0.10);
  --tint-hover:    rgba(20,24,31,0.03);
  --tint-quiet:    rgba(20,24,31,0.04);
}
:root {
  --skeleton-base: rgba(255,255,255,0.04);
  --skeleton-hi:   rgba(255,255,255,0.10);
  --tint-hover:    rgba(255,255,255,0.02);
  --tint-quiet:    rgba(255,255,255,0.04);
}
@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; margin: 8px 0; }
.skeleton-line.skeleton-line--short { width: 40%; }
.skeleton-line.skeleton-line--mid   { width: 70%; }
.skeleton-block { height: 90px; margin: 12px 0; }

/* ===========================================================================
   Buttons
   =========================================================================== */
/* Buttons — RH-style chunky pills with tabular weight.
   Primary is solid green, sized generously (RH leans into "tap-friendly"
   even on web), and gets a subtle green halo. Black text on green
   improves contrast on the bright #00C805 surface vs. white. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-weight: 700; line-height: 1;
  border: 1px solid transparent;
  min-height: 36px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, transform 0.05s, box-shadow 0.15s;
  user-select: none;
  letter-spacing: -0.005em;
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-primary {
  background: var(--brand-500);
  color: #001a01;
  border-color: transparent;
  box-shadow: var(--sh-glow-brand);
}
.btn-primary:hover {
  background: var(--brand-300);
  box-shadow: 0 8px 26px rgba(0,200,5,0.40);
}
.btn-ghost {
  background: var(--bg-elev-2); color: var(--text); border-color: var(--border);
  border-radius: 999px;
}
.btn-ghost:hover { background: var(--bg-elev-3); border-color: var(--border-strong); }
.btn-danger {
  background: var(--down); color: white; border-color: transparent;
  box-shadow: 0 4px 14px rgba(255,80,0,0.35);
}
.btn-danger:hover { background: #ff7849; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 30px; }

/* ===========================================================================
   Tables
   =========================================================================== */
.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.tbl thead th {
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.tbl tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-feature-settings: "tnum";
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--tint-hover); }
.tbl tbody tr.today { background: rgba(0,200,5,0.06); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .total-row { background: var(--bg-elev-2); font-weight: 700; }

.hscroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ===========================================================================
   Inputs
   =========================================================================== */
.field {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  width: 100%;
  min-height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
/* Focus ring is the brand green, kept subtle so dense forms don't strobe */
.field:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(0,200,5,0.12);
}
.field::placeholder { color: var(--text-dim); }
textarea.field {
  resize: vertical;
  line-height: 1.55;
}
select.field {
  cursor: pointer;
}
.field:disabled,
.editable:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* "Yellow editable" inline inputs (P&L tracker cells, etc.) — the colors
   come from theme tokens so the affordance reads on both surfaces:
   light yellow on near-black for dark mode; deep amber on warm-yellow
   tint for light mode. */
.editable {
  background: var(--editable-bg);
  color: var(--editable-text);
  border: 1px solid var(--editable-border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  font-feature-settings: "tnum";
  text-align: right;
  width: 80px;
  transition: background 0.15s, border-color 0.15s;
}
.editable:focus {
  outline: none;
  border-color: var(--editable-border-focus);
  background: var(--editable-bg-focus);
}

/* ===========================================================================
   Calendar tiles (preserved from earlier)
   =========================================================================== */
.cal-day {
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 4px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.12s;
}
.cal-day:hover { filter: brightness(1.15); }
.cal-tile-empty { background: var(--bg-elev-3); border: 1px solid var(--border); color: var(--text-muted); }
.cal-tile-win   { background: var(--up); color: white; }
.cal-tile-loss  { background: var(--down); color: white; }
.cal-tile-flat  { background: var(--bg-elev-3); color: var(--text); border: 1px solid var(--border-strong); }

/* ===========================================================================
   Lessons UI
   =========================================================================== */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.lesson-card {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}
.lesson-card::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  /* Subtle green wash on lesson tiles — same idea as the prior blue wash,
     but tonally consistent with the rest of the RH theme. */
  background: linear-gradient(135deg, rgba(0,200,5,0.05) 0%, transparent 60%);
}
.lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-500);
  background: var(--bg-elev-2);
}
.lesson-num {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand-300);
  font-weight: 700;
}
.lesson-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}
.lesson-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}
.lesson-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.lesson-card.completed { border-color: rgba(0,200,5,0.40); }
.lesson-card.completed::after {
  content: "✓ Done";
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 700;
  background: var(--up-soft); color: var(--up);
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid rgba(0,200,5,0.30);
}

/* Reading view */
.lesson-reader {
  max-width: 1080px;
  margin: 0 auto;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 38px 44px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.lesson-reader h1 {
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.lesson-reader h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em;
  margin: 32px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.lesson-reader h3 {
  font-size: 16px; font-weight: 700;
  margin: 22px 0 6px;
  color: var(--brand-300);
}
.lesson-reader p { margin: 12px 0; color: var(--text-muted); }
.lesson-reader strong { color: var(--text); }
.lesson-reader em { color: var(--text-muted); }
.lesson-reader blockquote {
  margin: 16px 0; padding: 14px 18px;
  background: rgba(255, 176, 32, 0.08);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  color: #ffd166;
}
.lesson-reader blockquote p:first-child { margin-top: 0; }
.lesson-reader blockquote p:last-child { margin-bottom: 0; }
.lesson-reader ul, .lesson-reader ol { padding-left: 22px; margin: 12px 0; }
.lesson-reader li { margin: 6px 0; color: var(--text-muted); }
.lesson-reader code {
  background: var(--bg-elev-3); padding: 1px 6px; border-radius: 4px;
  font-family: "SF Mono", Menlo, monospace; font-size: 13px;
  color: #fde68a;
}
.lesson-reader pre {
  background: var(--bg-elev-3); padding: 12px 16px; border-radius: 8px;
  overflow-x: auto; margin: 14px 0;
}
.lesson-reader table {
  width: 100%; border-collapse: collapse; margin: 16px 0;
  font-size: 13.5px;
}
.lesson-reader table th {
  text-align: left; padding: 8px 12px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}
.lesson-reader table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.lesson-reader hr {
  border: 0; border-top: 1px solid var(--border); margin: 28px 0;
}

/* ---------------------------------------------------------------------------
   Interactive pattern cards (Module 6, 13–18, etc.)
   - Cursor + hover lift on the whole card
   - Trendlines / level lines glow on hover
   - "draw" class triggers an animated stroke-dasharray pen-stroke
   - SVGs scaled up significantly so patterns are clearly readable
   --------------------------------------------------------------------------- */

/* --- Uniform SVG diagrams in pattern cards ----------------------------- */
/* Every chart-style pattern SVG renders at the same 360px width across all
   reference lessons (Modules 6, 13–20), regardless of its original inline
   size. The only exceptions are single-candle and 2-candle SVGs whose
   viewBoxes are inherently tall/narrow — those use proportionally smaller
   widths so they don't render absurdly tall. */
.pattern-card > svg { height: auto !important; max-width: 100% !important; }

/* Tall, narrow single-candle SVGs (Module 13 Essential / Rest) */
.pattern-card > svg[style*="width:48px"]   { width: 130px !important; }
.pattern-card > svg[style*="width:60px"]   { width: 180px !important; }

/* Two-candle pattern SVGs (Engulfing, Tweezer, Harami, etc.) */
.pattern-card > svg[style*="width:130px"]  { width: 280px !important; }

/* All chart-style pattern SVGs — UNIFORM 360px wide on every page */
.pattern-card > svg[style*="width:80px"]   { width: 360px !important; }
.pattern-card > svg[style*="width:100px"]  { width: 360px !important; }
.pattern-card > svg[style*="width:104px"]  { width: 360px !important; }
.pattern-card > svg[style*="width:160px"]  { width: 360px !important; }
.pattern-card > svg[style*="width:200px"]  { width: 360px !important; }
.pattern-card > svg[style*="width:240px"]  { width: 360px !important; }

@media (max-width: 600px) {
  /* On phones, cap so the SVG never exceeds the card width */
  .pattern-card > svg { max-width: 100% !important; }
}

.pattern-card {
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.pattern-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-500) !important;
  box-shadow: 0 6px 24px rgba(0,200,5,0.20);
}
/* Highlight dashed reference lines (trendlines, S/R, neckline) on hover */
.pattern-card:hover svg line[stroke-dasharray],
.pattern-card:hover svg path[stroke-dasharray] {
  filter: drop-shadow(0 0 4px currentColor);
}
.pattern-card:hover svg circle {
  filter: drop-shadow(0 0 6px currentColor);
}
/* Replay button — small label that becomes visible on hover */
.pattern-card .replay-hint {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 10.5px; color: var(--brand-300);
  background: rgba(0,200,5,0.12);
  padding: 2px 8px; border-radius: 999px;
  opacity: 0; transition: opacity .15s ease;
  pointer-events: none;
  border: 1px solid rgba(0,200,5,0.30);
  font-weight: 600;
}
.pattern-card { position: relative; }
.pattern-card:hover .replay-hint { opacity: 1; }

/* Path-drawing animation — applied transiently via JS */
.pattern-card svg path.pattern-anim {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: pattern-draw 1.6s ease-out forwards;
}
.pattern-card svg circle.pattern-anim,
.pattern-card svg rect.pattern-anim {
  opacity: 0;
  animation: pattern-fade 0.6s ease-out 1.4s forwards;
}
@keyframes pattern-draw {
  from { stroke-dashoffset: 1000; }
  to   { stroke-dashoffset: 0; }
}
@keyframes pattern-fade {
  from { opacity: 0; transform: scale(0.6); transform-origin: center; }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------------------------------------------------------------------------
   Pattern cards (Modules 13 & 14) — readable spacing between
   What / Means / Trade / Watch out blocks. The card markup uses
   <strong>label:</strong> text<br> repeated; this CSS makes each <br>
   produce a real visual gap so the labels don't run together.
   --------------------------------------------------------------------------- */
.lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > div br {
  display: block;
  content: "";
  margin-top: 10px;
}
/* First strong in each card needs no top spacing */
.lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > div > strong:first-child {
  display: inline-block;
  margin-top: 0;
}
/* Make the labels (What:, Means:, etc.) a touch heavier for scanning */
.lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > div > strong {
  font-weight: 700;
  color: var(--text);
}
/* Ensure pattern-card SVGs don't cause horizontal scrolling */
.lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > svg {
  max-width: 100%;
  height: auto;
}
/* (Earlier we bumped tiny SVG text via attribute selector, but that broke
   the Time & Sales / Bid-Ask / Volume Profile diagrams whose tiny font sizes
   were intentional and sized to fit their small viewBoxes. Removed.) */

.lesson-reader-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1080px; margin: 0 auto 18px;
}

/* ===========================================================================
   Modal
   =========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 460px;
  max-height: min(88vh, 820px);
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.modal h2 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 14px;
}

.account-card,
.practice-module-card,
.glossary-term {
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.account-card:hover,
.practice-module-card:hover,
.glossary-term:hover {
  border-color: var(--border-strong) !important;
  box-shadow: var(--sh-sm);
}
.practice-module-card,
.drill-option {
  font-family: inherit;
}
.theme-toggle svg {
  width: 15px;
  height: 15px;
}

/* ===========================================================================
   Responsive
   ===========================================================================
   Three breakpoints:
     ≤ 880px  — tablet & below (sidebar becomes a drawer)
     ≤ 600px  — phone portrait (compact typography, stacked widgets)
     ≤ 400px  — small phones (further compaction)
   =========================================================================== */

/* ---- Tablet & below (≤ 880px) ---- */
@media (max-width: 880px) {
  .auth-page { padding: 18px; align-items: flex-start; }
  .auth-grid { grid-template-columns: 1fr; max-width: 560px; }
  .auth-guide { display: none; }
  .auth-mobile-brand { display: flex; }

  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: 280px;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .view { padding: 18px 16px 80px; }
  .today-layout { grid-template-columns: 1fr; }
  .today-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-side > .callout { grid-column: 1 / -1; }
  .lesson-reader { padding: 24px 22px; border-radius: 10px; font-size: 14.5px; }
  .topbar { padding: 0 16px; }

  /* Force the candle builder's two-column layout to stack on tablets too */
  [data-interactive="candle-builder"] > div:not(:first-child):not([data-cb-narrative]) {
    grid-template-columns: 1fr !important;
  }
}

/* ---- Phone portrait (≤ 600px) ---- */
@media (max-width: 600px) {
  .auth-page { padding: 12px; }
  .auth-card { padding: 22px; }
  .auth-card h2 { font-size: var(--text-xl); }
  .routine-grid { grid-template-columns: 1fr; }
  .hero-cta { padding: var(--space-5); }
  .hero-cta .hero-cta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-cta .hero-cta-title { font-size: var(--text-xl); }
  .hero-cta .hero-cta-pill {
    width: 100%;
    text-align: center;
    padding: 11px 18px;
  }
  .paper-form-intro { align-items: stretch; flex-direction: column; }
  .paper-form-intro .btn { width: 100%; justify-content: center; }
  .paper-trade-form { grid-template-columns: 1fr; }
  .today-header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: var(--space-4);
  }
  .today-level-pill { white-space: normal; }
  .today-side,
  .today-metrics {
    grid-template-columns: 1fr;
  }
  .today-metric {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 var(--space-3);
    align-items: center;
  }
  .today-metric strong {
    grid-row: 1 / span 2;
    grid-column: 2;
    margin: 0;
    text-align: right;
  }
  .today-panel { padding: var(--space-3); }

  /* Tighten top-level layout */
  .view { padding: 14px 12px 80px; }
  .topbar { height: 52px; padding: 0 12px; }
  .topbar .crumbs { font-size: 12px; gap: 6px; }
  .topbar .crumbs span { display: none; }       /* hide breadcrumb separators */
  .topbar .crumbs strong { display: inline; }   /* keep current page name */
  .topbar .topbar-actions { gap: 6px; min-width: 0; }
  .topbar-actions .btn { font-size: 12px; padding: 6px 8px; }

  /* Stat cards more compact */
  .card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }
  .stat-card .stat-sub { font-size: 10.5px; }
  .section-h { margin: 22px 0 10px; }
  .section-h h2 { font-size: 16px; }
  .section-h .section-sub { font-size: 12px; }

  /* Lesson reader: smaller padding + tighter type */
  .lesson-reader {
    padding: 18px 16px;
    font-size: 14.5px;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .lesson-reader h1 { font-size: 22px; line-height: 1.2; }
  .lesson-reader h2 { font-size: 17px; margin: 24px 0 8px; padding-top: 10px; }
  .lesson-reader h3 { font-size: 15px; margin: 18px 0 6px; }
  .lesson-reader p { margin: 10px 0; }
  .lesson-reader blockquote { padding: 12px 14px; }
  .lesson-reader table { font-size: 13px; }
  .lesson-reader table th, .lesson-reader table td { padding: 6px 8px; }

  /* Lesson cards in the catalog */
  .lesson-card { padding: 14px; min-height: auto; }
  .lesson-grid { grid-template-columns: 1fr; gap: 12px; }
  .lesson-title { font-size: 15px; }

  /* Lesson reader toolbar — wrap the pills onto a second line */
  .lesson-reader-toolbar { flex-wrap: wrap; gap: 8px; }
  .lesson-reader-toolbar > .row { gap: 6px; }

  /* Buttons */
  .btn { padding: 7px 12px; font-size: 13px; }
  .btn-sm { padding: 5px 9px; font-size: 11.5px; }

  /* Tables: still horizontally scrollable, but tighter */
  .tbl { font-size: 12px; }
  .tbl thead th { padding: 8px 8px; font-size: 10px; }
  .tbl tbody td { padding: 8px 8px; }

  /* Modals: full-width, bottom-sheet feel */
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 18px;
    border-radius: 14px 14px 10px 10px;
  }
  .modal form.grid,
  #plan-form .grid {
    grid-template-columns: 1fr !important;
  }

  /* Calendar tiles — smaller on phones */
  .cal-day { height: 38px; font-size: 9px; padding: 2px; }

  /* Account card grid — already responsive via Tailwind, but ensure single column */
  .account-card { padding: 14px; }

  /* Volume scenario builder controls — let them scroll horizontally */
  [data-interactive="volume-scenario"] [data-vs-controls] {
    overflow-x: auto;
    grid-template-columns: repeat(5, 92px) !important;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  /* Pattern cards in lesson 13 / 14 — full-width stacking on mobile */
  .lesson-reader [style*="display:flex"][style*="flex-wrap:wrap"] {
    gap: 12px !important;
  }
  /* Pattern-card SVGs: shrink-to-fit, never wider than the card */
  .lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > svg {
    max-width: 100% !important;
    height: auto !important;
    flex-shrink: 1 !important;
  }
  /* Pattern-card text: kill the inline min-width:280px so text wraps inside
     the card on narrow screens (this was causing horizontal overflow on phones) */
  .lesson-reader [style*="background:rgba(255,255,255,0.02)"][style*="display:flex"] > div {
    min-width: 0 !important;
    flex-basis: 100% !important;
    width: 100% !important;
  }
  /* Anatomy SVG (full-width inside lesson) — already responsive, just ensure it can't push the card wider */
  .lesson-reader figure svg {
    max-width: 100% !important;
    height: auto !important;
  }
  /* Belt-and-suspenders: prevent any element from forcing horizontal overflow */
  .lesson-reader { overflow-x: hidden; }
  .lesson-reader * { max-width: 100%; }

  /* Sidebar inside drawer */
  .sidebar { width: 260px; padding: 14px 12px; }

  /* Larger touch targets for inputs */
  .field { padding: 10px 12px; font-size: 14.5px; }
  input[type="number"].editable { padding: 6px 8px; }
  input[type="range"] { height: 28px; }
}

/* ---- New learning views (review queue, recap, calibration, teach-back) ----
   These views were authored with desktop-first inline styles. On phones the
   multi-column grids get cramped or overflow; the rules below collapse them
   into stacked layouts without touching the JS. */
@media (max-width: 600px) {
  /* Review queue header card — switch from 4-col to 2x2 grid */
  .sr-summary-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .sr-summary-grid > button { grid-column: 1 / -1; width: 100%; }

  /* Review queue rows — 4 columns is too cramped, drop the date column */
  .sr-row { grid-template-columns: 1fr 80px 56px !important; }
  .sr-row .sr-row-date { display: none; }

  /* Calibration per-concept table — drop the "claimed" col on phones,
     keep only Concept / Attempts / Actual / Gap */
  .cal-pc-row, .cal-pc-header {
    grid-template-columns: 1fr 56px 64px 64px !important;
  }
  .cal-pc-row .cal-pc-claimed, .cal-pc-header .cal-pc-claimed { display: none; }

  /* Calibration trend SVG — let it shrink */
  .cal-trend-svg { width: 100%; height: auto; }

  /* Recap stat strip — already auto-fit, but force 2-col on tight screens */
  .recap-stats { grid-template-columns: repeat(2, 1fr) !important; }
  .recap-cards { grid-template-columns: 1fr !important; }

  /* Teach-back + journal grade panels — collapse the 3-col rows to stacked */
  .grade-row {
    grid-template-columns: 1fr 36px !important;
    grid-template-areas: "label score" "bar bar" !important;
    row-gap: 6px !important;
  }
  .grade-row > div:nth-child(1) { grid-area: label; }
  .grade-row > div:nth-child(2) { grid-area: bar; }
  .grade-row > div:nth-child(3) { grid-area: score; }

  /* Skill-tree module header — stack the title and stats on phones */
  .skill-mod-header { flex-direction: column; align-items: flex-start !important; gap: 6px; }
  .skill-mod-header > div:last-child { text-align: left !important; }

  /* Today focus cards — already block-level <a> tags; just ensure their
     internal action row wraps cleanly */
  .today-focus-card > div { flex-wrap: wrap; }
}

/* ---- Small phones (≤ 400px) ---- */
@media (max-width: 400px) {
  .view { padding: 12px 10px 80px; }
  .lesson-reader { padding: 16px 14px; font-size: 14px; }
  .lesson-reader h1 { font-size: 20px; }
  .lesson-reader h2 { font-size: 16px; }
  .lesson-reader h3 { font-size: 14.5px; }
  .stat-card .stat-value { font-size: 18px; }
  .cal-day { height: 32px; }
  .topbar-actions .btn span { display: none; }   /* show icon only */
}

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

/* Backdrop when sidebar is open on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 25;
}
.sidebar-backdrop.open { display: block; }

/* Smooth reveal */
.fade-in { animation: fadeIn 0.18s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Small utilities */
.tabular { font-feature-settings: "tnum"; }
.row { display: flex; align-items: center; gap: 10px; }
.gap-3 { gap: 12px; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.text-tiny { font-size: 11px; }

/* ========================================================================
   Print mode for lesson cheat sheets
   When the user prints from a lesson, hide the chrome and present the
   lesson content cleanly on white paper.
   ======================================================================== */
@media print {
  /* Hide app chrome */
  .sidebar, .topbar, .breadcrumbs, .lesson-reader-toolbar,
  .no-print, #mark-complete,
  .sidebar-backdrop, #modal-root,
  .lesson-reader > hr,
  .lesson-reader > .row:last-child {
    display: none !important;
  }
  /* Reset body for print */
  body, .app-shell, .main, #view-root {
    background: white !important;
    color: black !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  /* Strip dark theme from the lesson content */
  .lesson-reader, .lesson-reader * {
    background: transparent !important;
    color: black !important;
    border-color: #999 !important;
  }
  .lesson-reader strong, .lesson-reader b { color: black !important; }
  .lesson-reader code, .lesson-reader pre {
    background: #f5f5f5 !important;
    color: black !important;
    border: 1px solid #ddd !important;
  }
  /* Tables */
  .lesson-reader table {
    page-break-inside: avoid;
    border-collapse: collapse;
  }
  .lesson-reader th, .lesson-reader td {
    border: 1px solid #999 !important;
    padding: 6px 10px !important;
  }
  /* Headings */
  .lesson-reader h1 { font-size: 22pt; margin-top: 0; }
  .lesson-reader h2 {
    font-size: 16pt;
    margin-top: 18pt;
    page-break-after: avoid;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4pt;
  }
  .lesson-reader h3 { font-size: 13pt; page-break-after: avoid; }
  /* Hide interactive widgets — they don't print meaningfully */
  [data-interactive] {
    display: none !important;
  }
  /* Pattern card SVGs — keep them if they're static reference diagrams */
  .lesson-reader svg {
    max-width: 100% !important;
    height: auto !important;
  }
  /* Page break controls */
  .lesson-reader p, .lesson-reader li, .lesson-reader blockquote {
    page-break-inside: avoid;
  }
  /* Add a header to printed pages */
  .lesson-reader::before {
    content: "Day Trading 101 — Cheat Sheet";
    display: block;
    font-size: 9pt;
    color: #666;
    margin-bottom: 8pt;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4pt;
  }
  /* Better link printing */
  a { color: black !important; text-decoration: none !important; }
}

/* Paper-trading chart live indicator and tape animations */
@keyframes paper-live-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.15); }
}
@keyframes paper-tape-slide {
  from { opacity: 0; transform: translateY(-6px); background-color: rgba(0, 200, 5, 0.18); }
  to   { opacity: 1; transform: translateY(0);     background-color: transparent; }
}
.paper-tape-row-new {
  animation: paper-tape-slide 0.4s ease-out;
}

/* Highlight pulse on the "Open position" button after a ladder click */
@keyframes paper-at-open-pulse-kf {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 200, 5, 0.0); transform: scale(1); }
  20%      { box-shadow: 0 0 0 12px rgba(0, 200, 5, 0.45); transform: scale(1.06); }
  60%      { box-shadow: 0 0 0 24px rgba(0, 200, 5, 0.0);  transform: scale(1.02); }
}
.paper-at-open-pulse {
  animation: paper-at-open-pulse-kf 1.0s ease-out 2;
}

/* Pop-out window mode (#/chart-popout): full bleed — chart fills the
   entire window, NO app shell, NO breadcrumbs, NO surrounding chrome.
   The body gets .chart-popout-mode set by the router. We use
   position:fixed inset:0 on the chart card so it doesn't depend on the
   parent layout/flex, and we strip page padding/margin from every
   ancestor up to <body> so there's no leftover padding showing. */
body.chart-popout-mode {
  background: var(--bg-elev-1) !important;
  overflow: hidden;
}
body.chart-popout-mode .sidebar,
body.chart-popout-mode .sidebar-backdrop,
body.chart-popout-mode .app-sidebar,
body.chart-popout-mode .topbar,
body.chart-popout-mode .top-bar,
body.chart-popout-mode .page-header,
body.chart-popout-mode .breadcrumbs,
body.chart-popout-mode #paper-active-trader,
body.chart-popout-mode #paper-buy-form,
body.chart-popout-mode #paper-stats,
body.chart-popout-mode #paper-strategies,
body.chart-popout-mode #paper-open-list,
body.chart-popout-mode #paper-closed-list,
body.chart-popout-mode #paper-strategy-list,
body.chart-popout-mode #paper-strategy-closed-list,
body.chart-popout-mode #paper-copilot,
body.chart-popout-mode #paper-reset,
body.chart-popout-mode .footer,
body.chart-popout-mode footer {
  display: none !important;
}
/* Strip layout from every ancestor of the chart card so position:fixed
   doesn't get clipped by overflow:hidden on a parent, and the card sits
   flush with the window edges. */
body.chart-popout-mode .app-shell,
body.chart-popout-mode .app-main,
body.chart-popout-mode #view-root {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  width: 100% !important;
  height: auto !important;
  overflow: visible !important;
}
/* The chart card itself: pin to all four window edges, scroll the
   internal content if it overflows (chart body + drawing tools). */
body.chart-popout-mode #paper-chart-card {
  position: fixed !important;
  inset: 0 !important;
  margin: 0 !important;
  padding: 10px !important;
  max-width: none !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  overflow: auto !important;
  z-index: 100 !important;
}
/* In popout, the chart workspace should fill the available height so
   you actually USE the window space instead of getting a tall card with
   empty space below it. */
body.chart-popout-mode #paper-chart-card .paper-chart-workspace {
  min-height: calc(100vh - 280px);
}
body.chart-popout-mode #paper-chart-body {
  min-height: calc(100vh - 320px) !important;
}

/* ========================================================================
 * Mobile responsive rules for the paper-trade chart card and related UIs.
 * Designed around three breakpoints:
 *   ≤ 900px — tablet / large-phone landscape: stack chart features
 *             vertically, drawing toolbar goes horizontal
 *   ≤ 640px — phone portrait: collapse Active Trader's T&S, tighten
 *             padding, larger tap targets (Apple HIG min 44px)
 *   ≤ 400px — small phones: aggressive tightening
 *
 * iOS safe-area: padding inserts handle the notch / home-indicator on
 * iPhones in standalone PWA mode.
 * ====================================================================== */

/* iPhone notch / home indicator support for installed PWAs */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  /* Sticky / fixed elements still get the bottom inset */
  .topbar, .top-bar {
    padding-top: max(8px, env(safe-area-inset-top));
  }
}

@media (max-width: 900px) {
  /* Chart workspace: stack drawing toolbar above the chart body and let
     the toolbar buttons wrap horizontally (the toolbar's own children
     are flex-direction:column inline; we override). */
  .paper-chart-workspace {
    flex-direction: column !important;
  }
  .paper-chart-drawtools {
    flex-direction: row !important;
    width: 100% !important;
    flex-wrap: wrap;
    align-self: stretch !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Drawing toolbar buttons get a slightly larger tap area on mobile */
  .paper-chart-drawtools button {
    min-width: 36px;
    min-height: 36px;
  }
  /* Options chain page: the calls/puts/strike table is 11 columns wide;
     wrap it in horizontal scroll so the user can swipe across instead of
     blowing out the viewport. */
  #opt-canvas table {
    font-size: 10px !important;
  }
  #opt-canvas .card {
    padding: 0;
  }
  /* Replay toolbar already wraps via flex-wrap; tighten gap on mobile. */
  #paper-replay-controls {
    gap: 6px !important;
    padding: 6px 8px !important;
  }
  #paper-replay-controls input,
  #paper-replay-controls select {
    min-height: 38px;  /* easier to tap */
  }
}

@media (max-width: 640px) {
  /* Active Trader: stack ladder above T&S, or hide T&S entirely on
     phone-portrait widths so the ladder gets full attention. */
  .paper-at-grid {
    grid-template-columns: 1fr !important;
  }
  .paper-at-grid > #paper-at-tape {
    display: none !important;
  }
  /* Position summary strip — 5 columns is too much on phones. Stack to
     two rows of ~2-3 each. */
  #paper-active-trader > div[style*="grid-template-columns:repeat(5"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  /* Quantity preset buttons get bigger tap targets */
  #paper-at-qty-presets button {
    min-height: 36px;
    padding: 8px 12px !important;
  }
  /* BUY/SELL/REVERSE/FLATTEN buttons: full-width row on phone */
  .paper-at-action-btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    padding: 10px 12px !important;
    font-size: 14px !important;
  }
  /* Live price chip: shrink the giant price font so it doesn't blow out */
  #paper-chart-live-price {
    font-size: 18px !important;
  }
  /* Card padding is generous on desktop — tighten on phone */
  #paper-chart-card {
    padding: 10px !important;
  }
  /* Replay controls: stack the date/time/speed on a phone */
  #paper-replay-controls {
    font-size: 11px !important;
  }
  #paper-replay-controls input[type="date"] { width: 100% !important; }
  #paper-replay-controls input[type="time"] { width: 100% !important; }
  /* Options chain copy-bar buttons: stack at narrow widths */
  #opt-copy-bar > div {
    gap: 6px !important;
  }
}

@media (max-width: 400px) {
  /* Aggressive tightening for small Android / iPhone SE-class screens */
  .paper-chart-drawtools button {
    min-width: 32px;
    min-height: 32px;
    font-size: 11px;
  }
  /* Ladder rows — make them a touch shorter so more fit on screen */
  #paper-at-ladder > div {
    height: 18px !important;
    font-size: 10px !important;
  }
}

/* Tap targets: every interactive element on mobile should be ≥40px tall
   so it's easy to hit. This is broad — only applies via :is() to known
   button/link selectors so we don't bloat tiny icon controls. */
@media (max-width: 640px) {
  .btn-sm, .btn-ghost.btn-sm, .btn-primary.btn-sm,
  button[class*="btn-sm"] {
    min-height: 38px;
  }
}

/* ---------------------------------------------------------------------------
   Trial-countdown banner — sits between the topbar and the view, full width.
   Three urgency states color-coded:
     - info  (6-7d left)  → soft brand blue
     - warn  (3-5d left)  → amber
     - urgent (≤2d, expired, past_due, canceled) → red, prompts immediate action
   The CTA button uses --btn-sm to match topbar density.
   --------------------------------------------------------------------------- */
.trial-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.trial-banner__text { line-height: 1.3; flex: 1; }

/* ===========================================================================
 * Welcome-confetti — Day-1 level-up moment.
 * Pure CSS, no library. Twenty-four small squares fall from above the
 * card, fade out, and stop ~1.6s later. Pointer-events:none so the
 * confetti doesn't intercept clicks on the buttons underneath.
 * =========================================================================== */
.welcome-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.welcome-confetti > span {
  position: absolute;
  top: -10%;
  width: 8px;
  height: 8px;
  opacity: 0;
  transform: rotate(0deg);
  animation: welcome-confetti-fall 1.6s ease-out forwards;
  border-radius: 1.5px;
}
@keyframes welcome-confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg);    opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(420px) rotate(720deg);  opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* No animation for users who've opted out of motion. */
  .welcome-confetti > span { display: none; }
}
/* Pricing chip — sits between the days-left label and the CTA so users
   know what the post-trial ask is. Subtle but always present. */
.trial-banner__price {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
}
@media (max-width: 640px) {
  /* On phones the banner stacks: label on row 1, price+CTA on row 2.
     Keeps the urgency message above the fold. */
  .trial-banner { flex-wrap: wrap; row-gap: 6px; }
  .trial-banner__text { flex: 1 0 100%; }
  .trial-banner__price { font-size: 11.5px; padding: 2px 8px; }
}
.trial-banner--info {
  background: color-mix(in srgb, #60a5fa 12%, transparent);
  color: var(--text);
}
.trial-banner--warn {
  background: color-mix(in srgb, #fbbf24 18%, transparent);
  color: var(--text);
}
.trial-banner--urgent {
  background: color-mix(in srgb, #ef4444 18%, transparent);
  color: var(--text);
}
.trial-banner--urgent .trial-banner__text {
  font-weight: 600;
}
@media (max-width: 640px) {
  .trial-banner {
    padding: 8px 12px;
    font-size: 12.5px;
  }
}

/* ===========================================================================
 * Paper-trading chart + Active Trader side-by-side layout
 *
 * Chart on the left, Active Trader docked to the right. Wraps to two
 * stacked rows on narrow viewports (<1100px) so mobile/tablet keeps
 * the chart full-width and the ladder underneath — same effective
 * behavior as the old layout pre-redesign.
 * =========================================================================== */
.paper-chart-at-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex-wrap: wrap;
}
.paper-chart-at-row > .paper-chart-pane {
  flex: 1 1 600px;
  min-width: 0;
}
.paper-chart-at-row > .paper-active-trader-pane {
  flex: 0 0 360px;
  min-width: 320px;
  max-width: 420px;
  align-self: stretch;
}
@media (max-width: 1100px) {
  .paper-chart-at-row > .paper-active-trader-pane {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }
}
/* Mobile pass on the Trade Desk pane.
   The desktop layout has min-width:480px on the ladder, which on a 380px
   phone results in horizontal scroll, tiny touch targets, and an
   unusable buy/sell area. These rules:
     - Drop the min-width so the pane truly fills the viewport
     - Bump font sizes in the ladder so prices are readable at arm's length
     - Force buttons to ≥44px tap targets (Apple HIG / WCAG 2.5.5)
     - Reflow the toolbar row to wrap cleanly
   Desktop behavior is untouched — these rules only fire below 768px. */
@media (max-width: 768px) {
  .paper-chart-at-row { gap: 12px; }
  .paper-chart-at-row > .paper-active-trader-pane,
  .paper-active-trader-pane {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  /* Top action row (Buy MKT / Sell MKT / Flatten / Reverse / Cancel all) —
     wrap and grow on phones so each button hits ≥44px tall and stops
     overflowing off-screen. The inline-style padding declares 8px 16px
     which is fine; we override with min-height for the touch target. */
  .paper-active-trader-pane .paper-at-action-btn,
  .paper-active-trader-pane button {
    min-height: 40px;
  }
  .paper-at-buy, .paper-at-sell {
    flex: 1 1 calc(50% - 4px);
    min-height: 48px;
    font-size: 14px !important;
  }
  /* Ladder rows — bump price + size font and row height for fat fingers. */
  #paper-at-ladder .ladder-row {
    min-height: 32px;
    font-size: 13px;
  }
  /* Working-orders panel below the ladder — give cancel buttons a real
     tap target on phones. The desktop × was 10px font with 2-8px
     padding; on phones we need at least 32×32px. */
  #paper-at-orders-list button[data-cancel-order] {
    min-width: 32px;
    min-height: 32px;
    font-size: 14px !important;
    padding: 4px 10px !important;
  }
}

/* ===========================================================================
 * Market-state badge
 *
 * One pill next to the chart status that tells the user at a glance
 * whether they're looking at live data, delayed data, demo synthetic
 * bars, a market-closed snapshot, or a scrubbed-back replay.
 * The color carries the meaning; the label confirms it.
 * =========================================================================== */
.market-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  border: 1px solid transparent;
  white-space: nowrap;
}
.market-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.market-badge--live    { color: #22c55e; background: rgba(34,197,94,0.10);  border-color: rgba(34,197,94,0.30); }
.market-badge--delayed { color: #eab308; background: rgba(234,179,8,0.10);  border-color: rgba(234,179,8,0.32); }
.market-badge--session { color: #38bdf8; background: rgba(56,189,248,0.10); border-color: rgba(56,189,248,0.32); }
.market-badge--closed  { color: #94a3b8; background: rgba(148,163,184,0.12); border-color: rgba(148,163,184,0.32); }
.market-badge--replay  { color: #a78bfa; background: rgba(167,139,250,0.10); border-color: rgba(167,139,250,0.32); }
.market-badge--demo    { color: #ef4444; background: rgba(239,68,68,0.10);  border-color: rgba(239,68,68,0.34); }
.market-badge--unknown { color: var(--text-muted); background: var(--bg-elev-1); border-color: var(--border); }

/* ===========================================================================
 * Tailwind utility shim
 *
 * Replaces the runtime Tailwind play CDN script (cdn.tailwindcss.com), which
 * Tailwind itself logs a console warning about in production. We only ever
 * used a tiny subset of Tailwind classes (grid layout + a couple of spacing
 * helpers + responsive prefixes), so hand-rolling them as plain CSS removes
 * the runtime dependency entirely. Keep this list strictly aligned with the
 * actual classes referenced in app.js / templates — anything else stays
 * unstyled, which is the cleanest signal that we shouldn't be using it.
 * =========================================================================== */
.text-center { text-align: center; }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
