/* ============================================================
   NEPSE DECODE · D2 design system (production)
   Dark-first. Approved from the D2 sample round (S1/S2/S6/S7/S9).
   Pages opt in with <body class="d2"> and load ONLY this stylesheet
   (plus page-specific CSS). Light mode via [data-theme="light"].
   ============================================================ */

/* Skip link (a11y): visible on keyboard focus only */
.skip-link {
  position: absolute; left: 16px; top: 12px; z-index: 5000;
  background: var(--d2-volt); color: #0a0d12;
  font-size: 14px; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; text-decoration: none;
  transform: translateY(-70px);
  transition: transform .25s ease;
}
.skip-link:focus { transform: none; }
/* d2 pages: `body.d2 a` (0,1,2) otherwise wins over the pill rule for link
   color; light-scoped so dark keeps its own pill untouched. */
[data-nd-ed="light"] body.d2 .skip-link, [data-theme="light"] body.d2 .skip-link { color: var(--nd-on-lime, #0A0C10); }
@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

:root {
  --d2-bg: var(--nd-bg);            /* G1: aliased to nd-tokens */
  --d2-surface: var(--nd-panel);
  --d2-surface2: var(--nd-panel-2);
  --d2-surface3: #1a2230;
  --d2-line: var(--nd-border);
  --d2-line-soft: #1b2330;
  --d2-ink: var(--nd-text);
  --d2-ink-soft: var(--nd-muted);
  --d2-muted: var(--nd-dim);
  --d2-faint: #7e8798;
  --d2-volt: var(--nd-lime);          /* brand lime — one lime site-wide (Wave A) */
  --d2-volt-dim: #9CC327;
  --d2-volt-ink: #1a2005;
  --d2-hairline: var(--d2-line-soft);  /* alias: was referenced but undefined */
  --d2-card: var(--d2-surface);       /* alias: was referenced but undefined */
  --d2-gain: var(--nd-up);
  --d2-gain-deep: #0f5132;
  --d2-gain-bg: rgba(61, 220, 132, .1);
  --d2-loss: var(--nd-down);
  --d2-loss-deep: #5c1a1a;
  --d2-loss-bg: rgba(255, 93, 93, .1);
  --d2-gold: #c9a86f;
  --d2-brand: #1e4b38;
  --d2-r-sm: 6px;
  --d2-r-md: 10px;
  --d2-r-lg: 16px;
  --d2-r-pill: 999px;
  --d2-font: var(--nd-font-sans);
  --d2-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

[data-theme="light"] {
  --d2-bg: #f4f2ec;
  --d2-surface: #ffffff;
  --d2-surface2: #faf8f2;
  --d2-surface3: #f0ece1;
  --d2-line: #e2ddd0;
  --d2-line-soft: #ede9dc;
  --d2-ink: #1b1a17;
  --d2-ink-soft: #4a463c;
  --d2-muted: #7a7466;
  --d2-faint: #a8a294;
  --d2-volt: var(--nd-lime);          /* matches --nd-lime light value (Wave A) */
  --d2-volt-dim: #42660B;
  --d2-volt-ink: #ffffff;
  --d2-gain: var(--nd-up);
  --d2-gain-bg: rgba(23, 114, 69, .1);
  --d2-loss: var(--nd-down);
  --d2-loss-bg: rgba(179, 55, 42, .08);
  --d2-gold: #8a6d3b;
  --d2-shadow: 0 12px 32px rgba(60, 50, 30, .1);
}

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

body.d2 {
  margin: 0;
  background: var(--d2-bg);
  color: var(--d2-ink);
  font-family: var(--d2-font);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

body.d2 ::selection { background: var(--d2-volt); color: var(--d2-volt-ink); }
body.d2 a { color: var(--d2-ink); text-decoration: none; }
body.d2 a:hover { color: var(--d2-volt); text-decoration: underline; }
body.d2 :focus-visible { outline: 2px solid var(--d2-volt); outline-offset: 2px; border-radius: 4px; }
body.d2 .d2-num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.d2-shell { display: flex; min-height: 100vh; }
.d2-side {
  width: 232px; flex: none;
  position: sticky; top: 0; height: 100vh;
  background: var(--d2-surface);
  border-right: 1px solid var(--d2-line-soft);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}
.d2-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; letter-spacing: -.01em;
  color: var(--d2-ink); padding: 6px 10px 16px;
}
.d2-brand img { width: 28px; height: 28px; }
.d2-brand:hover { text-decoration: none; }
.d2-nav-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--d2-faint); font-weight: 700; padding: 12px 10px 6px;
}
.d2-side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--d2-r-md);
  color: var(--d2-ink-soft); font-weight: 600; font-size: 14px;
}
.d2-side nav a:hover { background: var(--d2-surface2); text-decoration: none; color: var(--d2-ink); }
.d2-side nav a.on { background: var(--d2-surface3); color: var(--d2-volt); }
.d2-side .d2-side-foot { margin-top: auto; padding: 14px 10px 4px; font-size: 12px; color: var(--d2-faint); }

.d2-topbar {
  display: none;
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--d2-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--d2-line-soft);
  padding: 10px 16px;
  align-items: center; gap: 12px;
}
.d2-topbar .d2-brand { padding: 0; font-size: 16px; }
.d2-mobilenav {
  display: none;
  gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px;
  border-bottom: 1px solid var(--d2-line-soft);
  background: var(--d2-surface);
  position: sticky; top: 53px; z-index: 55;
}
.d2-mobilenav::-webkit-scrollbar { display: none; }
.d2-mobilenav a {
  flex: none; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: var(--d2-r-pill);
  border: 1px solid var(--d2-line); color: var(--d2-ink-soft);
}
.d2-mobilenav a.on { background: var(--d2-volt); border-color: var(--d2-volt); color: var(--d2-volt-ink); }
.d2-mobilenav a:hover { text-decoration: none; }

.d2-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.d2-wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- type ---------- */
.d2-kicker {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--d2-volt); font-weight: 700; margin: 0 0 10px;
}
.d2-h1 {
  font-size: clamp(30px, 4vw, 44px); line-height: 1.08;
  letter-spacing: -.02em; margin: 0 0 10px; font-weight: 800;
}
.d2-lede { color: var(--d2-ink-soft); max-width: 62ch; margin: 0 0 26px; font-size: 15px; }
.d2-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 40px 0 16px;
}
.d2-section-head h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; font-weight: 750; }
.d2-section-link { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- cards & buttons ---------- */
.d2-card {
  background: var(--d2-surface);
  border: 1px solid var(--d2-line-soft);
  border-radius: var(--d2-r-lg);
  padding: 22px;
}
.d2-card + .d2-card { margin-top: 18px; }
.d2-card-sub { font-size: 12.5px; color: var(--d2-faint); margin: 4px 0 0; font-weight: 500; }
.d2-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--d2-volt); color: var(--d2-volt-ink);
  font-weight: 700; font-size: 14px;
  border: 0; border-radius: var(--d2-r-md);
  padding: 10px 18px; cursor: pointer;
}
.d2-btn:hover { filter: brightness(1.06); text-decoration: none; }
.d2-btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; color: var(--d2-ink);
  border: 1px solid var(--d2-line); border-radius: var(--d2-r-md);
  font-weight: 600; font-size: 14px; padding: 9px 16px; cursor: pointer;
}
.d2-btn-ghost:hover { border-color: var(--d2-volt); color: var(--d2-volt); text-decoration: none; }
.d2-pill-btn {
  background: var(--d2-surface2); color: var(--d2-ink-soft);
  border: 1px solid var(--d2-line); border-radius: var(--d2-r-pill);
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; cursor: pointer;
  font-family: var(--d2-font);
}
.d2-pill-btn[aria-pressed="true"] { background: var(--d2-volt); border-color: var(--d2-volt); color: var(--d2-volt-ink); }
.d2-seg { display: inline-flex; background: var(--d2-surface2); border: 1px solid var(--d2-line-soft); border-radius: var(--d2-r-pill); padding: 3px; gap: 2px; }
.d2-seg button {
  border: 0; background: transparent; color: var(--d2-muted);
  font: 600 13px var(--d2-font); padding: 7px 14px; border-radius: var(--d2-r-pill); cursor: pointer;
}
.d2-seg button[aria-pressed="true"] { background: var(--d2-surface3); color: var(--d2-ink); }
.d2-seg button:hover { color: var(--d2-ink); }

/* ---------- chips, badges, state ---------- */
.d2-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 11px; border-radius: var(--d2-r-pill);
  border: 1px solid var(--d2-line); color: var(--d2-ink-soft);
  background: var(--d2-surface2); white-space: nowrap;
}
.d2-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--d2-faint); flex: none; }
.d2-dot.live { background: var(--d2-gain); box-shadow: 0 0 0 0 rgba(61, 220, 132, .5); animation: d2-ping 1.6s infinite; }
.d2-dot.delayed { background: var(--d2-gold); }
.d2-dot.preopen { background: var(--d2-volt); }
.d2-dot.closed { background: var(--d2-faint); }
@keyframes d2-ping {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, .45); }
  70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}
/* nlv-badge comes from js/nepse-live.js — themed for D2 */
.nlv-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 11px; border-radius: var(--d2-r-pill);
  border: 1px solid var(--d2-line); color: var(--d2-ink-soft);
  background: var(--d2-surface2); white-space: nowrap;
}
.nlv-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--d2-faint); }
.nlv-badge.live { color: var(--d2-gain); border-color: var(--d2-gain-deep); }
.nlv-badge.live .dot { background: var(--d2-gain); animation: d2-ping 1.6s infinite; }
.nlv-badge.delayed { color: var(--d2-gold); }
.nlv-badge.delayed .dot { background: var(--d2-gold); }
.nlv-badge.preopen { color: var(--d2-volt); }
.nlv-badge.preopen .dot { background: var(--d2-volt); }
.nlv-sub { font-size: 12.5px; color: var(--d2-muted); }

/* ---------- ticker tape ---------- */
.d2-ticker {
  overflow: hidden; white-space: nowrap;
  border-bottom: 1px solid var(--d2-line-soft);
  background: var(--d2-surface);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.d2-ticker-track { display: inline-flex; gap: 26px; padding: 9px 0; animation: d2-tick 60s linear infinite; }
.d2-ticker:hover .d2-ticker-track { animation-play-state: paused; }
@keyframes d2-tick { to { transform: translateX(-50%); } }
.d2-tick-item { display: inline-flex; gap: 8px; align-items: baseline; font-size: 13px; }
.d2-tick-item .tk-sym { font-weight: 700; color: var(--d2-ink); }
.d2-tick-item .tk-px { color: var(--d2-ink-soft); }
.d2-tick-item .tk-chg.up { color: var(--d2-gain); }
.d2-tick-item .tk-chg.dn { color: var(--d2-loss); }

/* ---------- hero (S1 market command) ---------- */
.d2-hero-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 28px; }
.d2-hero-grid > * { min-width: 0; } /* grid blowout guard: chart canvas must not widen the document on mobile */
.d2-movers-row > * { min-width: 0; } /* same guard for the movers/index cards */
.d2-tscroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.d2-hero-label { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--d2-muted); font-weight: 700; margin-bottom: 6px; }
.d2-hero-price { font-size: clamp(44px, 5.5vw, 68px); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.d2-hero-badge {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-size: 17px; font-weight: 750; margin-top: 10px;
  padding: 6px 14px; border-radius: var(--d2-r-pill);
}
.d2-hero-badge.up { color: var(--d2-gain); background: var(--d2-gain-bg); }
.d2-hero-badge.dn { color: var(--d2-loss); background: var(--d2-loss-bg); }
.d2-hero-badge small { font-size: 13px; font-weight: 600; opacity: .85; }
.d2-hero-chart { margin-top: 18px; height: 150px; }
.d2-hero-chart canvas { width: 100%; height: 100%; display: block; }
.d2-range-block { margin-bottom: 20px; }
.d2-range-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--d2-muted); margin-bottom: 8px; }
.d2-range-label strong { color: var(--d2-ink-soft); font-weight: 700; }
.d2-range { position: relative; height: 8px; border-radius: var(--d2-r-pill); background: var(--d2-surface3); }
.d2-range .fill { position: absolute; top: 0; bottom: 0; border-radius: var(--d2-r-pill); background: linear-gradient(90deg, var(--d2-loss), var(--d2-gain)); opacity: .55; }
.d2-range .marker { position: absolute; top: -4px; width: 3px; height: 16px; background: var(--d2-ink); border-radius: 2px; transform: translateX(-50%); }
.d2-range-vals { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--d2-muted); margin-top: 6px; }
.d2-range-vals b { color: var(--d2-ink-soft); font-weight: 700; }
.d2-breadth-bar { display: flex; height: 10px; border-radius: var(--d2-r-pill); overflow: hidden; background: var(--d2-surface3); }
.d2-breadth-bar .b-up { background: var(--d2-gain); }
.d2-breadth-bar .b-fl { background: var(--d2-faint); }
.d2-breadth-bar .b-dn { background: var(--d2-loss); }
.d2-breadth-legend { display: flex; gap: 18px; font-size: 13px; color: var(--d2-muted); margin-top: 8px; flex-wrap: wrap; }
.d2-breadth-legend b { font-weight: 750; }
.d2-breadth-legend .up { color: var(--d2-gain); }
.d2-breadth-legend .down { color: var(--d2-loss); }
.d2-breadth-legend .flat { color: var(--d2-ink-soft); }

/* ---------- tables ---------- */
.d2-table-wrap { overflow-x: auto; border: 1px solid var(--d2-line-soft); border-radius: var(--d2-r-md); }
.d2-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.d2-table th {
  text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--d2-muted); font-weight: 700; padding: 10px 14px;
  border-bottom: 1px solid var(--d2-line); background: var(--d2-surface2);
  white-space: nowrap;
}
.d2-table td { padding: 10px 14px; border-bottom: 1px solid var(--d2-line-soft); color: var(--d2-ink-soft); }
.d2-table tr:last-child td { border-bottom: 0; }
.d2-table tbody tr:hover td { background: var(--d2-surface2); }
.d2-table .up { color: var(--d2-gain); font-weight: 700; }
.d2-table .dn { color: var(--d2-loss); font-weight: 700; }
.d2-table th.sortable { cursor: pointer; }
.d2-table th.sortable:hover { color: var(--d2-ink); }

/* ---------- pulse (S9 event tape) ---------- */
.d2-pulse-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.d2-pulse-state { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.d2-pulse-updated { font-size: 13px; color: var(--d2-muted); }
.d2-pulse-flash { font-size: 12.5px; color: var(--d2-gain); opacity: 0; transition: opacity .4s; font-weight: 600; }
.d2-pulse-flash.show { opacity: 1; }
.d2-pulse-refresh { display: flex; align-items: center; gap: 10px; }
.d2-pulse-count { font-size: 13px; color: var(--d2-muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.d2-pulse-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.d2-fbtn {
  background: var(--d2-surface2); color: var(--d2-ink-soft);
  border: 1px solid var(--d2-line); border-radius: var(--d2-r-pill);
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; cursor: pointer;
  font-family: var(--d2-font);
}
.d2-fbtn:hover { border-color: var(--d2-volt); color: var(--d2-ink); }
.d2-fbtn.on { background: var(--d2-volt); border-color: var(--d2-volt); color: var(--d2-volt-ink); }
.d2-pulse-tape { display: flex; flex-direction: column; }
.d2-pulse-row {
  display: grid; grid-template-columns: 112px auto auto minmax(0,1fr);
  gap: 6px 14px; align-items: baseline; padding: 13px 4px;
  border-bottom: 1px solid var(--d2-line-soft);
  animation: d2-rowin .35s ease;
}
@keyframes d2-rowin { from { opacity: 0; transform: translateY(-6px); } }
.d2-pulse-row:last-child { border-bottom: 0; }
.d2-pulse-time { font-size: 12.5px; color: var(--d2-muted); line-height: 1.4; }
.d2-pulse-time span { display: block; color: var(--d2-faint); font-size: 11.5px; }
.d2-pulse-kind {
  font-size: 10.5px; font-weight: 800; letter-spacing: .09em;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.4;
  border: 1px solid transparent;
}
.pk-news { color: #9ecbff; background: rgba(90,169,255,.13); border-color: rgba(90,169,255,.35); }
.pk-corp { color: var(--d2-volt); background: rgba(184,230,46,.09); border-color: rgba(184,230,46,.32); }
.pk-ms { color: var(--d2-ink); background: var(--d2-surface3); border-color: var(--d2-line); }
.d2-pulse-sym {
  font-weight: 800; font-size: 13px; color: var(--d2-ink);
  font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: .02em;
}
.d2-pulse-title { font-size: 14px; color: var(--d2-ink); font-weight: 600; line-height: 1.5; min-width: 0; overflow-wrap: break-word; }
.d2-pulse-title a { color: var(--d2-ink); font-weight: 700; }
.d2-pulse-title a:hover { color: var(--d2-volt); text-decoration: underline; }
/* 2026-10-02: paged tape — rows-per-page + Showing X–Y + Prev/Next;
   steady min-height so the card doesn't jump between pages */
.d2-pulse-tape { min-height: 420px; }
.d2-pulse-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--d2-hairline); }
.d2-pulse-pages[hidden] { display: none; }
.d2-pulse-rpp { font-size: 13px; color: var(--d2-muted); display: flex; align-items: center; gap: 8px; }
.d2-pulse-rpp select { padding: 6px 10px; border: 1px solid var(--d2-hairline); border-radius: 8px; background: var(--d2-card); color: var(--d2-ink); font-size: 13px; }
.d2-pulse-pageinfo { font-size: 13px; color: var(--d2-muted); font-variant-numeric: tabular-nums; }
.d2-pulse-nav { display: flex; gap: 8px; margin-left: auto; }
.d2-pulse-nav .d2-pill-btn:disabled { opacity: .45; cursor: default; }
.d2-pulse-meta { font-size: 12.5px; color: var(--d2-muted); margin-top: 3px; }
.d2-pulse-meta .d2-sym { color: var(--d2-ink); font-weight: 700; }

/* ---------- market map (S2 treemap) ---------- */
.d2-map-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.d2-map-legend { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--d2-muted); flex-wrap: wrap; }
.d2-map-legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.d2-treemap { width: 100%; height: 460px; display: block; border-radius: var(--d2-r-md); cursor: pointer; }

/* ---------- watchlist deck (S7) ---------- */
.d2-wl-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.d2-wl-tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--d2-line); background: var(--d2-surface2);
  color: var(--d2-ink-soft); border-radius: var(--d2-r-md);
  font: 600 13.5px var(--d2-font); padding: 9px 14px; cursor: pointer;
}
.d2-wl-tab .n {
  font-size: 11px; font-weight: 800; background: var(--d2-surface3);
  border-radius: var(--d2-r-pill); padding: 2px 8px; color: var(--d2-muted);
}
.d2-wl-tab[aria-selected="true"] { border-color: var(--d2-volt); color: var(--d2-ink); }
.d2-wl-tab[aria-selected="true"] .n { background: var(--d2-volt); color: var(--d2-volt-ink); }
.d2-wl-tab kbd {
  font: 700 11px var(--d2-font); color: var(--d2-faint);
  border: 1px solid var(--d2-line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px;
}
.d2-wl-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.d2-wl-add { display: flex; gap: 8px; flex: 1; min-width: 220px; max-width: 420px; position: relative; }
.d2-wl-add input {
  flex: 1; min-width: 0; background: var(--d2-surface2); border: 1px solid var(--d2-line);
  border-radius: var(--d2-r-md); color: var(--d2-ink);
  font: 500 14px var(--d2-font); padding: 10px 14px;
}
.d2-wl-add input::placeholder { color: var(--d2-faint); }
.d2-wl-add input:focus { border-color: var(--d2-volt); outline: none; }
.d2-wl-suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--d2-surface2); border: 1px solid var(--d2-line);
  border-radius: var(--d2-r-md); overflow: hidden; box-shadow: var(--d2-shadow);
  max-height: 260px; overflow-y: auto;
}
.d2-wl-suggest button {
  display: flex; justify-content: space-between; width: 100%;
  background: none; border: 0; color: var(--d2-ink); text-align: left;
  font: 600 13.5px var(--d2-font); padding: 10px 14px; cursor: pointer;
}
.d2-wl-suggest button small { color: var(--d2-muted); font-weight: 500; }
.d2-wl-suggest button:hover, .d2-wl-suggest button.active { background: var(--d2-surface3); }
.d2-wl-keys { font-size: 12.5px; color: var(--d2-faint); }
.d2-wl-keys kbd {
  font: 700 11px var(--d2-font); color: var(--d2-ink-soft);
  border: 1px solid var(--d2-line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px;
  background: var(--d2-surface2);
}
.d2-wl-list { display: flex; flex-direction: column; border: 1px solid var(--d2-line-soft); border-radius: var(--d2-r-md); overflow: hidden; }
.d2-wl-row {
  display: grid; grid-template-columns: 1fr auto auto auto 34px;
  gap: 14px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--d2-line-soft);
  background: var(--d2-surface);
}
.d2-wl-row:last-child { border-bottom: 0; }
.d2-wl-row:hover { background: var(--d2-surface2); }
.d2-wl-sym { font-weight: 800; font-size: 14.5px; color: var(--d2-ink); }
.d2-wl-sym small { display: block; font-weight: 500; color: var(--d2-muted); font-size: 12px; }
.d2-wl-px { font-weight: 750; font-size: 14.5px; text-align: right; }
.d2-wl-chg { font-size: 13px; font-weight: 700; text-align: right; min-width: 76px; }
.d2-wl-chg.up { color: var(--d2-gain); }
.d2-wl-chg.dn { color: var(--d2-loss); }
.d2-verdict {
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--d2-r-pill); white-space: nowrap;
}
.d2-verdict.buy { background: var(--d2-gain-bg); color: var(--d2-gain); }
.d2-verdict.hold { background: rgba(201, 168, 111, .14); color: var(--d2-gold); }
.d2-verdict.exit, .d2-verdict.avoid { background: var(--d2-loss-bg); color: var(--d2-loss); }
.d2-wl-x {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid transparent;
  background: transparent; color: var(--d2-faint); font-size: 16px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.d2-wl-row:hover .d2-wl-x, .d2-wl-row:focus-within .d2-wl-x { opacity: 1; }
.d2-wl-x:hover { color: var(--d2-loss); border-color: var(--d2-loss); }
/* Touch devices have no hover: keep the remove action reachable. */
@media (hover: none) {
  .d2-wl-x { opacity: 1; }
}
.d2-wl-empty { padding: 34px 20px; text-align: center; color: var(--d2-muted); font-size: 14px; }

/* ---------- valuation lab (S6) ---------- */
.d2-val-grid { display: grid; grid-template-columns: 340px 1fr; gap: 22px; }
.d2-val-label { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--d2-faint); font-weight: 700; margin-bottom: 10px; }
.d2-bank-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.d2-bank-chips button {
  border: 1px solid var(--d2-line); background: var(--d2-surface2); color: var(--d2-ink-soft);
  font: 700 12.5px var(--d2-font); padding: 6px 12px; border-radius: var(--d2-r-pill); cursor: pointer;
}
.d2-bank-chips button[aria-pressed="true"] { background: var(--d2-volt); border-color: var(--d2-volt); color: var(--d2-volt-ink); }
.d2-val-co { border: 1px solid var(--d2-line-soft); border-radius: var(--d2-r-md); padding: 16px; margin-bottom: 16px; background: var(--d2-surface2); }
.d2-val-co-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.d2-val-co-sym { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.d2-val-co-name { font-size: 12.5px; color: var(--d2-muted); }
.d2-val-co-price { text-align: right; }
.d2-val-co-price .p { font-size: 20px; font-weight: 800; }
.d2-val-co-price .c { font-size: 13px; font-weight: 700; }
.d2-val-co-price .c.up { color: var(--d2-gain); }
.d2-val-co-price .c.dn { color: var(--d2-loss); }
.d2-metric-rows { display: flex; flex-direction: column; gap: 6px; }
.d2-metric-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--d2-r-md);
  padding: 10px 12px; color: var(--d2-ink); font-family: var(--d2-font);
}
.d2-metric-row:hover { background: var(--d2-surface2); }
.d2-metric-row[aria-pressed="true"] { background: var(--d2-surface2); border-color: var(--d2-volt); }
.d2-metric-row .m-name { font-size: 13.5px; font-weight: 600; }
.d2-metric-row .m-name small { display: block; color: var(--d2-faint); font-weight: 500; font-size: 11.5px; }
.d2-metric-row .m-val { font-size: 14px; font-weight: 750; }
.d2-val-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.d2-val-chart-head strong { font-size: 16px; }
.d2-val-chart-head span { display: block; font-size: 12.5px; color: var(--d2-muted); font-weight: 500; }
.d2-val-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--d2-muted); }
.d2-val-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.d2-val-chart { height: 340px; }
.d2-val-chart canvas { width: 100%; height: 100%; display: block; }

/* ---------- freshness line inside cards ---------- */
.d2-fresh {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--d2-line-soft);
  margin-top: 18px; padding-top: 14px;
  font-size: 12.5px; color: var(--d2-muted);
}
.d2-fresh b { color: var(--d2-ink-soft); }

/* ---------- skeleton ---------- */
.d2-skl {
  border-radius: var(--d2-r-sm);
  background: linear-gradient(90deg, var(--d2-surface2) 25%, var(--d2-surface3) 50%, var(--d2-surface2) 75%);
  background-size: 200% 100%;
  animation: d2-shimmer 1.4s infinite;
  min-height: 14px;
}
@keyframes d2-shimmer { to { background-position: -200% 0; } }

/* ---------- footer ---------- */
.d2-footer { border-top: 1px solid var(--d2-line-soft); margin-top: auto; }
.d2-footer .d2-wrap { padding-top: 26px; padding-bottom: 30px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--d2-muted); }
.d2-footer a { color: var(--d2-ink-soft); }

/* ---------- search ---------- */
.d2-search { position: relative; max-width: 420px; }
.d2-search input {
  width: 100%; background: var(--d2-surface2); border: 1px solid var(--d2-line);
  border-radius: var(--d2-r-md); color: var(--d2-ink);
  font: 500 14px var(--d2-font); padding: 11px 14px 11px 38px;
}
.d2-search input::placeholder { color: var(--d2-faint); }
.d2-search input:focus { border-color: var(--d2-volt); outline: none; }
.d2-search::before {
  content: ""; position: absolute; left: 13px; top: 50%;
  width: 15px; height: 15px; transform: translateY(-50%);
  border: 2px solid var(--d2-faint); border-radius: 50%;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 0 70%);
}
.d2-search::after {
  content: ""; position: absolute; left: 24px; top: 50%;
  width: 8px; height: 2.5px; background: var(--d2-faint);
  transform: translateY(2px) rotate(45deg); border-radius: 2px;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .d2-side { display: none; }
  .d2-topbar { display: flex; }
  .d2-mobilenav { display: flex; }
  /* Keep the fixed theme toggle clear of the sticky mobile sub-nav
     (it occupies ~53–103px; the toggle's default top:76px would sit on it). */
  body.d2 .theme-toggle.fixed { top: 112px; }
  .d2-hero-grid { grid-template-columns: 1fr; }
  .d2-val-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .d2-wrap { padding: 20px 14px 52px; }
  .d2-card { padding: 16px; }
  .d2-wl-row { grid-template-columns: 1fr auto auto 30px; }
  .d2-wl-row .d2-verdict { display: none; }
  .d2-pulse-row { grid-template-columns: 84px auto auto minmax(0,1fr); gap: 6px 10px; }
  .d2-treemap { height: 340px; }
  .d2-val-chart { height: 260px; }
}

/* ---------- motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  .d2-ticker-track { animation: none; }
  .d2-dot.live, .nlv-badge.live .dot { animation: none; }
  .d2-skl { animation: none; }
  .d2-pulse-row { animation: none; }
  * { scroll-behavior: auto !important; }
}
@media print {
  .d2-side, .d2-topbar, .d2-mobilenav, .d2-ticker { display: none !important; }
  body.d2 { background: #fff; color: #000; }
}

/* 2026-10-02: market stat cards */
.d2-stat-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.d2-stat{ background:var(--d2-surface2); border:1px solid var(--d2-line-soft); border-radius:var(--d2-r-md); padding:12px 14px; }
.d2-stat-l{ font-size:11px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:var(--d2-muted); margin-bottom:6px; }
.d2-stat-v{ font-size:1.28rem; font-weight:800; letter-spacing:-.01em; color:var(--d2-ink); font-variant-numeric:tabular-nums; }
@media (max-width:520px){ .d2-stat{ padding:10px 12px; } .d2-stat-v{ font-size:1.12rem; } }
/* 2026-10-02: sparkline value tooltip (hover / tap) */
.d2-hero-chart{ position:relative; }
.d2-hero-chart canvas{ cursor:crosshair; touch-action:pan-y; }
.d2-spark-tip{ position:absolute; z-index:5; display:none; pointer-events:none; background:var(--d2-surface3); border:1px solid var(--d2-line); border-radius:8px; padding:8px 10px; font-size:12px; line-height:1.5; color:var(--d2-ink); white-space:nowrap; box-shadow:var(--d2-shadow); font-variant-numeric:tabular-nums; }
.d2-spark-tip .tt-d{ color:var(--d2-muted); font-weight:600; }
.d2-spark-tip .tt-v{ font-weight:800; }

/* ============================================================
 * Premium 3D layer — d2 design system
 * ============================================================ */

/* Cards: floating panels */
.d2-card{
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,0) 40%), var(--d2-surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s;
}
.d2-card:hover{
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 8px rgba(0,0,0,.45), 0 18px 44px rgba(0,0,0,.35);
}

/* Primary buttons: physical press */
.d2-btn{
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 45%), var(--d2-volt);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), inset 0 -1px 0 rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s, filter .2s;
}
.d2-btn:hover{ transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 3px 8px rgba(0,0,0,.45), 0 14px 32px rgba(0,0,0,.35); }
.d2-btn:active{ transform: translateY(1px) scale(.98); box-shadow: inset 0 2px 5px rgba(0,0,0,.25); transition-duration: .08s; }

/* Ghost buttons: lift on hover */
.d2-btn-ghost{
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 50%), transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s, border-color .2s, color .2s;
}
.d2-btn-ghost:hover{
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 3px 8px rgba(0,0,0,.4);
}
.d2-btn-ghost:active{ transform: translateY(1px) scale(.98); }

/* Pill buttons: tactile toggles */
.d2-pill-btn{
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 50%), var(--d2-surface2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 3px rgba(0,0,0,.35);
  transition: transform .18s cubic-bezier(.22,1,.36,1), box-shadow .18s, background .18s, color .18s;
}
.d2-pill-btn:hover{ transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 2px 6px rgba(0,0,0,.4); }
.d2-pill-btn:active{ transform: translateY(1px) scale(.97); }
.d2-pill-btn[aria-pressed="true"]{
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 45%), var(--d2-volt);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 0 0 2px rgba(184,230,46,.2), 0 2px 6px rgba(0,0,0,.4);
}

/* Segmented control: recessed track, raised active */
.d2-seg{
  background: var(--d2-bg, #07090d);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
}
.d2-seg button{ transition: background .18s, color .18s, box-shadow .18s, transform .18s; }
.d2-seg button[aria-pressed="true"]{
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,0) 50%), var(--d2-surface3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 3px rgba(0,0,0,.4);
}
.d2-seg button:active{ transform: scale(.96); }

/* Chips: subtle depth */
.d2-chip{
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 50%), var(--d2-surface2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 3px rgba(0,0,0,.35);
}

/* Filter buttons */
.d2-fbtn{
  transition: transform .18s cubic-bezier(.22,1,.36,1), box-shadow .18s, border-color .18s, color .18s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.d2-fbtn:hover{
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 6px rgba(0,0,0,.4);
}
.d2-fbtn:active{ transform: translateY(1px) scale(.97); }

/* Metric rows: hover lift */
.d2-metric-row{
  transition: background .18s, transform .18s;
  border-radius: 8px;
}
.d2-metric-row:hover{
  background: rgba(255,255,255,.02);
  transform: translateX(2px);
}

@media (prefers-reduced-motion: reduce){
  .d2-card, .d2-btn, .d2-btn-ghost, .d2-pill-btn, .d2-fbtn{ transition: none; }
  .d2-card:hover, .d2-btn:hover, .d2-btn-ghost:hover,
  .d2-pill-btn:hover, .d2-fbtn:hover{ transform: none; }
}
