/* =====================================================================
   Calc.Trading design system v2
   Tokens → base → layout → components → calculator → content → utilities
   No framework, no build step. Respects prefers-reduced-motion & color-scheme.
   ===================================================================== */

@font-face { font-family: "Inter"; src: url("/fonts/inter-variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-variable.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; }

/* ---------- 1. Tokens ---------- */
:root {
  --ink-950: #060b18; --ink-900: #0b1326; --ink-800: #121c33; --ink-700: #1e2a45; --ink-600: #334262;
  --slate-500: #5b6b86; --slate-400: #8593ab; --slate-300: #b9c3d4; --slate-200: #dde3ec; --slate-100: #eef2f7; --slate-50: #f6f8fb;
  --blue-700: #1d4ed8; --blue-600: #2563eb; --blue-500: #3b82f6; --blue-100: #dbe7ff; --blue-50: #eef4ff;
  --emerald-600: #059669; --emerald-500: #10b981; --emerald-50: #e8f8f1;
  --rose-600: #e11d48; --rose-50: #fff0f3;
  --amber-600: #d97706; --amber-50: #fff7e6;
  --violet-600: #7c3aed;

  --bg: #f6f8fb; --bg-elev: #ffffff; --bg-sunken: #eef2f7; --bg-hero: #0b1326;
  --text: #0b1326; --text-2: #334262; --text-3: #5b6b86; --text-inv: #ffffff;
  --border: #dde3ec; --border-strong: #b9c3d4;
  --primary: var(--blue-600); --primary-hover: var(--blue-700); --primary-soft: var(--blue-50); --primary-ring: rgba(37, 99, 235, .28);
  --pos: var(--emerald-600); --pos-soft: var(--emerald-50); --neg: var(--rose-600); --neg-soft: var(--rose-50); --warn: var(--amber-600); --warn-soft: var(--amber-50);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* type scale (fluid) */
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-base: 1rem; --fs-md: 1.0625rem; --fs-lg: 1.25rem;
  --fs-xl: clamp(1.35rem, 1.1rem + .8vw, 1.6rem);
  --fs-2xl: clamp(1.6rem, 1.25rem + 1.2vw, 2.1rem);
  --fs-3xl: clamp(2rem, 1.4rem + 2.2vw, 3.1rem);

  /* spacing scale */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.25rem; --s-6: 1.5rem; --s-8: 2rem; --s-10: 2.5rem; --s-12: 3rem; --s-16: 4rem; --s-20: 5rem;

  --radius-sm: 8px; --radius: 12px; --radius-lg: 18px; --radius-xl: 24px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(11, 19, 38, .06);
  --shadow: 0 1px 2px rgba(11, 19, 38, .05), 0 6px 20px -8px rgba(11, 19, 38, .12);
  --shadow-lg: 0 2px 6px rgba(11, 19, 38, .06), 0 24px 48px -16px rgba(11, 19, 38, .22);
  --ease: cubic-bezier(.2, .7, .2, 1); --dur: .22s;
  --container: 1200px; --header-h: 64px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #070c19; --bg-elev: #0f1729; --bg-sunken: #0b1222; --bg-hero: #050914;
  --text: #e8edf6; --text-2: #b9c3d4; --text-3: #8593ab; --border: #1e2a45; --border-strong: #334262;
  --primary: #4f8bff; --primary-hover: #6c9fff; --primary-soft: rgba(79, 139, 255, .12); --primary-ring: rgba(79, 139, 255, .35);
  --pos: #34d399; --pos-soft: rgba(52, 211, 153, .12); --neg: #fb7185; --neg-soft: rgba(251, 113, 133, .12); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .6); --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; font-family: var(--font-sans); font-size: var(--fs-base); line-height: 1.65; color: var(--text); background: var(--bg); text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.02em; margin: 0 0 var(--s-3); color: var(--text); font-weight: 700; }
h1 { font-size: var(--fs-3xl); letter-spacing: -.03em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); letter-spacing: -.01em; }
h4 { font-size: var(--fs-base); }
p { margin: 0 0 var(--s-4); }
ul, ol { padding-left: 1.25rem; margin: 0 0 var(--s-4); }
li + li { margin-top: .35rem; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--blue-100); color: var(--ink-900); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-8) 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 3. Layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s-5); }
.section { padding: var(--s-16) 0; }
.section-sm { padding: var(--s-10) 0; }
.section-head { max-width: 720px; margin-bottom: var(--s-8); }
.section-head p { color: var(--text-2); font-size: var(--fs-md); }
.eyebrow { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--fs-xs); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: var(--s-3); }
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stack > * + * { margin-top: var(--s-4); }
.muted { color: var(--text-3); }
.small { font-size: var(--fs-sm); }

/* ---------- 4. Header / navigation ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg-elev) 86%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: var(--s-4); height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 750; font-size: 1.08rem; letter-spacing: -.02em; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand span b { color: var(--primary); font-weight: 750; }
.nav { display: flex; align-items: center; gap: .25rem; margin-left: var(--s-4); }
.nav > a, .nav-trigger { position: relative; display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .75rem; border-radius: 10px; font-size: var(--fs-sm); font-weight: 560; color: var(--text-2); text-decoration: none; background: none; border: 0; cursor: pointer; font-family: inherit; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.nav > a:hover, .nav-trigger:hover, .nav-trigger[aria-expanded="true"], .nav > a[aria-current="page"] { background: var(--bg-sunken); color: var(--text); }
.nav-trigger svg { transition: transform var(--dur) var(--ease); }
.nav-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav-item { position: relative; }
.mega { position: absolute; top: calc(100% + 10px); left: 50%; width: min(880px, 92vw); transform: translate(-40%, 6px); opacity: 0; visibility: hidden; pointer-events: none; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--s-5); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); transition: opacity .18s var(--ease), transform .18s var(--ease), visibility 0s .18s; }
.mega.small-menu { width: 300px; grid-template-columns: 1fr; transform: translate(-30%, 6px); }
.nav-item.open .mega { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-40%, 0); transition: opacity .18s var(--ease), transform .18s var(--ease); }
.nav-item.open .mega.small-menu { transform: translate(-30%, 0); }
.mega h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0 0 var(--s-2); }
.mega h3 a { color: inherit; text-decoration: none; }
.mega ul { list-style: none; padding: 0; margin: 0 0 var(--s-4); }
.mega li { margin: 0; }
.mega li a { display: block; padding: .32rem .5rem; margin: 0 -.5rem; border-radius: 8px; font-size: var(--fs-sm); color: var(--text-2); text-decoration: none; }
.mega li a:hover { background: var(--primary-soft); color: var(--primary); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2); cursor: pointer; transition: border-color var(--dur), color var(--dur), background var(--dur); }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.search-btn { display: inline-flex; align-items: center; gap: .5rem; height: 40px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-sunken); color: var(--text-3); font: inherit; font-size: var(--fs-sm); cursor: pointer; min-width: 210px; }
.search-btn kbd { margin-left: auto; font-size: .7rem; border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--bg-elev); }
.menu-btn { display: none; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; } [data-theme="dark"] .theme-icon-light { display: none; }

@media (max-width: 960px) {
  .nav, .search-btn span, .search-btn kbd { display: none; }
  .search-btn { min-width: 0; width: 40px; padding: 0; justify-content: center; background: var(--bg-elev); }
  .menu-btn { display: inline-grid; }
}
.drawer { position: fixed; inset: 0; z-index: 70; display: none; }
.drawer.open { display: block; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(6, 11, 24, .45); animation: fade .2s var(--ease); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 88vw); background: var(--bg-elev); padding: var(--s-5); overflow-y: auto; box-shadow: var(--shadow-lg); animation: slide-in .25s var(--ease); }
.drawer-panel details { border-bottom: 1px solid var(--border); padding: .4rem 0; }
.drawer-panel summary { cursor: pointer; font-weight: 600; padding: .5rem 0; list-style: none; display: flex; justify-content: space-between; }
.drawer-panel summary::-webkit-details-marker { display: none; }
.drawer-panel ul { list-style: none; padding: 0 0 .5rem; margin: 0; }
.drawer-panel li a, .drawer-panel > nav > a { display: block; padding: .45rem 0; color: var(--text-2); text-decoration: none; font-size: var(--fs-sm); }
.drawer-panel > nav > a { font-weight: 600; color: var(--text); font-size: var(--fs-base); border-bottom: 1px solid var(--border); padding: .8rem 0; }

/* ---------- 5. Buttons, badges, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .65rem 1.15rem; border-radius: 11px; font: inherit; font-size: var(--fs-sm); font-weight: 620; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: transform .12s var(--ease), background var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur), color var(--dur); white-space: nowrap; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .55); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-sm { min-height: 34px; padding: .4rem .75rem; font-size: var(--fs-xs); border-radius: 9px; }
.btn-light { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .22); }
.btn-light:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 620; background: var(--bg-sunken); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.badge.neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2); font-size: var(--fs-sm); text-decoration: none; transition: all var(--dur) var(--ease); }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 6. Cards ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s-6); box-shadow: var(--shadow-sm); }
.calc-card { position: relative; display: flex; flex-direction: column; gap: .5rem; padding: var(--s-5); border-radius: var(--radius-lg); background: var(--bg-elev); border: 1px solid var(--border); text-decoration: none; color: var(--text); transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease); overflow: hidden; }
.calc-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), var(--primary-soft), transparent 45%); opacity: 0; transition: opacity .3s var(--ease); pointer-events: none; }
.calc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); color: var(--text); }
.calc-card:hover::after { opacity: 1; }
.calc-card h3 { font-size: 1.02rem; margin: 0; }
.calc-card p { color: var(--text-3); font-size: var(--fs-sm); margin: 0; line-height: 1.5; }
.calc-card .go { margin-top: auto; padding-top: .4rem; font-size: var(--fs-xs); font-weight: 650; color: var(--primary); display: inline-flex; align-items: center; gap: .3rem; }
.calc-card .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.cat-india .ico { background: #fff1e6; color: #c2410c; } .cat-us .ico { background: var(--blue-50); color: var(--blue-700); }
.cat-crypto .ico { background: #fff7e0; color: #b45309; } .cat-risk .ico { background: var(--emerald-50); color: var(--emerald-600); } .cat-invest .ico { background: #f3edff; color: var(--violet-600); }
[data-theme="dark"] .calc-card .ico { background: var(--primary-soft); color: var(--primary); }

/* ---------- 7. Hero ---------- */
.hero { position: relative; overflow: hidden; background: var(--bg-hero); color: #fff; padding: var(--s-20) 0 var(--s-16); isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: -40% -10% auto; height: 140%; background: radial-gradient(600px 300px at 15% 20%, rgba(37, 99, 235, .45), transparent 60%), radial-gradient(500px 280px at 85% 10%, rgba(16, 185, 129, .25), transparent 60%), radial-gradient(500px 300px at 60% 90%, rgba(124, 58, 237, .25), transparent 60%); z-index: -1; }
.hero::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 75%); z-index: -1; }
.hero h1 { color: #fff; max-width: 900px; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, #8fb4ff, #6ee7b7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { font-size: var(--fs-lg); color: #c6d2ea; max-width: 720px; margin-bottom: var(--s-8); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero-markets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); margin-top: var(--s-12); }
.market-tile { display: block; padding: var(--s-5); border-radius: var(--radius-lg); background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); color: #fff; text-decoration: none; transition: background .25s var(--ease), transform .25s var(--ease), border-color .25s; }
.market-tile:hover { background: rgba(255, 255, 255, .09); transform: translateY(-3px); color: #fff; border-color: rgba(255, 255, 255, .25); }
.market-tile strong { display: block; font-size: 1.05rem; margin-bottom: .2rem; }
.market-tile span { color: #aebbd6; font-size: var(--fs-sm); }
.page-hero { background: linear-gradient(180deg, var(--bg-elev), var(--bg)); border-bottom: 1px solid var(--border); padding: var(--s-8) 0 var(--s-8); }
.page-hero .lede { font-size: var(--fs-md); color: var(--text-2); max-width: 760px; margin: 0; }
.page-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--text-3); align-items: center; }
.page-meta span { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- 8. Breadcrumbs ---------- */
.breadcrumbs ol { list-style: none; padding: 0; margin: 0 0 var(--s-4); display: flex; flex-wrap: wrap; gap: .35rem; font-size: var(--fs-sm); color: var(--text-3); }
.breadcrumbs li { margin: 0; display: inline-flex; align-items: center; gap: .35rem; }
.breadcrumbs li + li::before { content: "/"; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-3); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }

/* ---------- 9. Calculator tool ---------- */
.tool { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: var(--s-6); align-items: start; margin-top: var(--s-6); }
@media (max-width: 900px) { .tool { grid-template-columns: 1fr; } }
.tool-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: var(--s-6); box-shadow: var(--shadow); }
.tool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: var(--s-5); }
.tool-head h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; }
.tabs { display: inline-flex; padding: 4px; gap: 4px; background: var(--bg-sunken); border-radius: 12px; border: 1px solid var(--border); flex-wrap: wrap; }
.tabs button, .tabs a { border: 0; background: none; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); padding: .4rem .8rem; border-radius: 9px; cursor: pointer; text-decoration: none; transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.tabs [aria-selected="true"], .tabs [aria-pressed="true"] { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-4); }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: .35rem; }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }
.input-wrap { position: relative; display: flex; align-items: center; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 11px; transition: border-color var(--dur), box-shadow var(--dur); }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input-wrap input, .input-wrap select { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--font-mono); font-size: 1rem; font-variant-numeric: tabular-nums; padding: .7rem .8rem; color: var(--text); border-radius: 11px; outline: none; }
.input-wrap select { font-family: var(--font-sans); font-size: var(--fs-sm); appearance: none; padding-right: 2rem; cursor: pointer; }
.input-wrap.select::after { content: ""; position: absolute; right: .9rem; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg) translateY(-2px); pointer-events: none; }
.input-wrap .affix { padding: 0 .75rem; font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; white-space: nowrap; }
.input-wrap .affix.pre { padding-right: 0; }
.field.invalid .input-wrap { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.field .err { min-height: 0; font-size: var(--fs-xs); color: var(--neg); font-weight: 560; }
.seg { display: flex; padding: 4px; gap: 4px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 12px; }
.seg label { flex: 1; position: relative; text-align: center; cursor: pointer; margin: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: .5rem .4rem; border-radius: 9px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.seg input:checked + span { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 3px solid var(--primary-ring); }
.seg.side input[value="LONG"]:checked + span, .seg.side input[value="BUY"]:checked + span { color: var(--pos); }
.seg.side input[value="SHORT"]:checked + span, .seg.side input[value="SELL"]:checked + span { color: var(--neg); }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px dashed var(--border); }
.form-error { color: var(--neg); font-size: var(--fs-sm); margin-top: var(--s-3); }

.result { position: sticky; top: calc(var(--header-h) + 16px); background: linear-gradient(160deg, var(--ink-900), var(--ink-800)); color: #e8edf6; border-radius: var(--radius-xl); padding: var(--s-6); box-shadow: var(--shadow-lg); overflow: hidden; isolation: isolate; }
.result::before { content: ""; position: absolute; inset: -30% -20% auto auto; width: 70%; height: 80%; background: radial-gradient(closest-side, rgba(59, 130, 246, .35), transparent); z-index: -1; }
@media (max-width: 900px) { .result { position: relative; top: 0; } }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.result-label { font-size: var(--fs-sm); color: #aebbd6; font-weight: 560; }
.result .badge { background: rgba(255, 255, 255, .08); color: #dbe5ff; border-color: rgba(255, 255, 255, .14); }
.result .badge.pos { background: rgba(52, 211, 153, .15); color: #6ee7b7; } .result .badge.neg { background: rgba(251, 113, 133, .16); color: #fda4af; } .result .badge.warn { background: rgba(251, 191, 36, .16); color: #fcd34d; } .result .badge.info { background: rgba(96, 165, 250, .16); color: #bfdbfe; }
.result-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: clamp(2rem, 1.4rem + 2.2vw, 2.75rem); font-weight: 650; letter-spacing: -.03em; line-height: 1.1; margin: .6rem 0 .35rem; color: #fff; word-break: break-word; }
.result-value.pos { color: #6ee7b7; } .result-value.neg { color: #fda4af; } .result-value.warn { color: #fcd34d; }
.result-sub { color: #c6d2ea; font-size: var(--fs-sm); margin-bottom: var(--s-5); }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: rgba(255, 255, 255, .08); border-radius: 14px; overflow: hidden; margin: 0; }
.metrics div { background: rgba(11, 19, 38, .55); padding: .75rem .9rem; }
.metrics dt { font-size: var(--fs-xs); color: #93a3c3; margin-bottom: .15rem; }
.metrics dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .95rem; color: #fff; font-weight: 560; word-break: break-word; }
.warnings { margin-top: var(--s-4); display: grid; gap: .5rem; }
.warnings p { margin: 0; padding: .6rem .8rem; border-radius: 10px; background: rgba(251, 191, 36, .12); color: #fde68a; font-size: var(--fs-sm); border: 1px solid rgba(251, 191, 36, .25); }
.result-note { margin: var(--s-4) 0 0; font-size: var(--fs-xs); color: #93a3c3; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--s-5); }
.result-actions .btn { min-height: 36px; }
.chart { margin-top: var(--s-5); background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: .75rem; }
.chart figcaption { font-size: var(--fs-xs); color: #93a3c3; margin-bottom: .4rem; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { stroke: rgba(255, 255, 255, .18); stroke-width: 1; }
.chart .grid-l { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.chart text { fill: #93a3c3; font-size: 10px; font-family: var(--font-mono); }
.chart .line { fill: none; stroke: #60a5fa; stroke-width: 2; }
.chart .line2 { fill: none; stroke: #a5b4fc; stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .band { fill: rgba(96, 165, 250, .18); }
.chart .zero { stroke: rgba(255, 255, 255, .35); stroke-dasharray: 3 3; }
.chart .pos-area { fill: rgba(52, 211, 153, .18); } .chart .neg-area { fill: rgba(251, 113, 133, .16); }
.chart .marker { stroke: #fcd34d; stroke-dasharray: 2 3; }
.chart .dot { fill: #fcd34d; }
.is-updating .result-value { animation: pop .35s var(--ease); }
.mobile-result-bar { display: none; }
@media (max-width: 900px) {
  .mobile-result-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem 1rem; background: var(--ink-900); color: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); transform: translateY(140%); transition: transform .3s var(--ease); text-decoration: none; }
  .mobile-result-bar.show { transform: none; }
  .mobile-result-bar span { font-size: var(--fs-xs); color: #aebbd6; } .mobile-result-bar strong { font-family: var(--font-mono); font-size: 1.05rem; color: #fff; }
}
noscript .noscript-note, .noscript-note { display: block; margin-top: var(--s-3); font-size: var(--fs-xs); color: #fcd34d; }

/* ---------- 10. Article / documentation ---------- */
.doc-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s-10); align-items: start; }
@media (max-width: 1000px) { .doc-layout { grid-template-columns: 1fr; } .toc { display: none; } }
.toc { position: sticky; top: calc(var(--header-h) + 24px); font-size: var(--fs-sm); max-height: calc(100vh - var(--header-h) - 48px); overflow: auto; }
.toc strong { display: block; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: .5rem; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.toc li { margin: 0; }
.toc a { display: block; padding: .3rem 0 .3rem .9rem; margin-left: -2px; border-left: 2px solid transparent; color: var(--text-3); text-decoration: none; line-height: 1.4; transition: color var(--dur), border-color var(--dur); }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.prose { max-width: 760px; font-size: var(--fs-md); color: var(--text-2); }
.prose > section { padding-top: var(--s-8); }
.prose > section + section { border-top: 1px solid var(--border); margin-top: var(--s-8); }
.prose h2 { font-size: var(--fs-xl); margin-bottom: var(--s-4); }
.prose h3 { font-size: 1.1rem; margin-top: var(--s-6); }
.prose strong { color: var(--text); }
.prose ul li::marker { color: var(--primary); }
.prose ol li::marker { color: var(--text-3); font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 0 0 var(--s-5); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.prose table, table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.prose th, .prose td, table.data th, table.data td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th, table.data th { background: var(--bg-sunken); color: var(--text); font-weight: 650; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; }
.prose tr:last-child td, table.data tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; }
.formula { margin: var(--s-4) 0 var(--s-5); padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--bg-sunken); border: 1px solid var(--border); border-left: 4px solid var(--primary); overflow-x: auto; }
.formula code { font-family: var(--font-mono); font-size: .98rem; color: var(--text); white-space: pre; line-height: 1.7; }
.prose pre { background: var(--ink-900); color: #e8edf6; padding: var(--s-4); border-radius: var(--radius); overflow-x: auto; font-size: var(--fs-sm); }
.prose :not(pre) > code { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 6px; padding: .05rem .35rem; color: var(--text); }
.callout, .prose blockquote { margin: var(--s-5) 0; padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent); color: var(--text-2); }
.callout p:last-child, .prose blockquote p:last-child { margin-bottom: 0; }
.callout-warning, .callout-important { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout-example { background: var(--pos-soft); border-color: color-mix(in srgb, var(--pos) 25%, transparent); }
.faq { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); margin-bottom: .6rem; overflow: hidden; }
.faq summary { cursor: pointer; list-style: none; padding: 1rem 1.2rem; font-weight: 620; color: var(--text); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; font-weight: 400; color: var(--text-3); transition: transform var(--dur) var(--ease); flex-shrink: 0; }
.faq[open] summary::after { transform: rotate(45deg); }
.faq .faq-a { padding: 0 1.2rem 1rem; color: var(--text-2); }
.faq .faq-a p:last-child { margin-bottom: 0; }
.refs { list-style: none; padding: 0; counter-reset: ref; }
.refs li { counter-increment: ref; padding-left: 2rem; position: relative; margin-bottom: .6rem; font-size: var(--fs-sm); }
.refs li::before { content: counter(ref); position: absolute; left: 0; top: .1rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--bg-sunken); border: 1px solid var(--border); display: grid; place-items: center; font-size: .7rem; font-weight: 650; color: var(--text-3); }
.refs .pub { color: var(--text-3); }
.disclaimer-box { margin-top: var(--s-8); padding: var(--s-5); border-radius: var(--radius); border: 1px dashed var(--border-strong); font-size: var(--fs-sm); color: var(--text-3); background: var(--bg-elev); }
.author-box { display: flex; gap: var(--s-4); align-items: flex-start; padding: var(--s-5); border-radius: var(--radius-lg); background: var(--bg-elev); border: 1px solid var(--border); margin-top: var(--s-8); font-size: var(--fs-sm); }
.author-box .avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }

/* ---------- 11. Ads ---------- */
.ad-slot { margin: var(--s-8) 0; text-align: center; min-height: 100px; }
.ad-slot .ad-label { display: block; font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin-bottom: .35rem; }

/* ---------- 12. Footer ---------- */
.site-footer { margin-top: var(--s-16); background: var(--bg-hero); color: #aebbd6; padding: var(--s-16) 0 var(--s-8); font-size: var(--fs-sm); }
.site-footer a { color: #c6d2ea; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: var(--s-8); }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-grid h2 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: #fff; margin-bottom: var(--s-3); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: 0 0 .45rem; }
.footer-bottom { margin-top: var(--s-10); padding-top: var(--s-6); border-top: 1px solid rgba(255, 255, 255, .1); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; font-size: var(--fs-xs); color: #8593ab; }
.footer-risk { margin-top: var(--s-6); font-size: var(--fs-xs); color: #8593ab; max-width: 900px; }

/* ---------- 13. Search dialog / toast / tooltip ---------- */
dialog.search { width: min(640px, 94vw); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-lg); margin-top: 10vh; }
dialog.search::backdrop { background: rgba(6, 11, 24, .5); backdrop-filter: blur(3px); }
dialog.search[open] { animation: rise .22s var(--ease); }
.search-input { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.search-input input { flex: 1; border: 0; background: none; font: inherit; font-size: 1.05rem; color: var(--text); outline: none; }
.search-results { list-style: none; margin: 0; padding: .5rem; max-height: 55vh; overflow-y: auto; }
.search-results li { margin: 0; }
.search-results a { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .8rem; border-radius: 10px; color: var(--text); text-decoration: none; font-size: var(--fs-sm); }
.search-results a small { color: var(--text-3); }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--primary-soft); color: var(--primary); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink-900); color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: var(--fs-sm); box-shadow: var(--shadow-lg); z-index: 90; transition: all .25s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.tip { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 11px; color: var(--text-3); cursor: help; background: var(--bg-elev); font-weight: 700; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 240px; padding: .5rem .65rem; border-radius: 8px; background: var(--ink-900); color: #fff; font-size: var(--fs-xs); font-weight: 500; line-height: 1.4; z-index: 10; white-space: normal; box-shadow: var(--shadow); }

/* ---------- 14. Forms (contact) & alerts ---------- */
.form-grid { display: grid; gap: var(--s-4); }
.form-grid input, .form-grid textarea, .form-grid select { width: 100%; font: inherit; padding: .7rem .85rem; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); }
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.form-grid label { font-weight: 600; font-size: var(--fs-sm); display: block; margin-bottom: .3rem; }
.alert { padding: var(--s-4) var(--s-5); border-radius: var(--radius); margin-bottom: var(--s-5); font-size: var(--fs-sm); border: 1px solid var(--border); }
.alert-success { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.alert-error { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- 15. Misc components ---------- */
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-5); }
.feature { padding: var(--s-5); border-radius: var(--radius-lg); background: var(--bg-elev); border: 1px solid var(--border); }
.feature h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.feature p { font-size: var(--fs-sm); color: var(--text-3); margin: 0; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-4); }
.stat { padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--border); }
.stat b { display: block; font-family: var(--font-mono); font-size: 1.5rem; color: var(--text); }
.stat span { font-size: var(--fs-sm); color: var(--text-3); }
.glossary-list dt { font-weight: 700; color: var(--text); margin-top: var(--s-5); }
.glossary-list dd { margin: .3rem 0 0; color: var(--text-2); }
.letter-nav { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: var(--s-6); }
.letter-nav a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-elev); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.cta-band { margin-top: var(--s-12); padding: var(--s-10); border-radius: var(--radius-xl); background: linear-gradient(135deg, var(--ink-900), #16306b); color: #fff; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-5); }
.cta-band h2 { color: #fff; margin: 0 0 .3rem; font-size: var(--fs-xl); }
.cta-band p { color: #c6d2ea; margin: 0; }

/* ---------- 16. Motion ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.985); opacity: .65; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); transition-delay: var(--d, 0s); }
  .js .reveal.in { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- 17. Print ---------- */
@media print {
  .site-header, .site-footer, .toc, .ad-slot, .result-actions, .form-actions, .mobile-result-bar, .tabs { display: none !important; }
  .result { position: static; background: #fff; color: #000; box-shadow: none; border: 1px solid #ccc; }
  .result * { color: #000 !important; }
  body { background: #fff; }
}

/* Referral / affiliate links (calculator pages). Deliberately styled as site content, not as an ad unit. */
.referrals { margin-top: var(--s-10, 2.5rem); padding-top: var(--s-6, 1.5rem); border-top: 1px solid var(--border); }
.referrals h2 { margin-bottom: .35rem; }
.referrals-note { font-size: var(--fs-sm); color: var(--text-2); margin: 0 0 var(--s-4, 1rem); }
.referral-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }
.referral-card { display: flex; flex-direction: column; gap: .3rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.prose .referral-card { margin: 0; }
.referral-name { font-size: 1rem; color: var(--text); }
.referral-tagline { font-size: var(--fs-sm); color: var(--text-2); }
.referral-offer { font-size: var(--fs-sm); color: var(--text); font-weight: 600; }
.referral-cta { margin-top: auto; align-self: flex-start; }
.prose .referral-cta { text-decoration: none; }
@media print { .referrals { display: none !important; } }
