/* ═══════════════════════════════════════════════════════════
   Quant Mini App — Editorial Atelier
   ───────────────────────────────────────────────────────────
   Dark glass-morphism for a BTC quant trading dashboard.
   Serif italic brand mark + system sans body + mono numerics.
   Slow rotating conic halo behind hero. Instrumental corner
   brackets on key cards. Editorial 01/02/03 card indexing.
   Dotted ledger leaders between label/value pairs.
   ═══════════════════════════════════════════════════════════ */

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

html {
  -webkit-text-size-adjust: 100%;
}

/* ── Design Tokens ─────────────────────────────────────── */

:root {
  /* Typography */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif:
    ui-serif, "New York", "Iowan Old Style", Charter, "Apple Garamond",
    Georgia, "Songti SC", serif;
  --font-mono:
    ui-monospace, "SF Mono", Menlo, "JetBrains Mono", "Cascadia Code",
    "Source Code Pro", monospace;

  /* Ink (base) */
  --ink: #0a0a0f;
  --ink-2: #11111a;
  --ink-3: #16161f;

  /* Glass surfaces */
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hi: rgba(255, 255, 255, 0.065);
  --surface-hover: rgba(255, 255, 255, 0.045);

  /* Hairlines */
  --hairline: rgba(255, 255, 255, 0.075);
  --hairline-hi: rgba(255, 255, 255, 0.14);
  --hairline-marker: rgba(255, 255, 255, 0.22);

  /* Text */
  --text: #fafafa;
  --text-2: rgba(250, 250, 250, 0.62);
  --text-3: rgba(250, 250, 250, 0.38);
  --text-4: rgba(250, 250, 250, 0.22);

  /* Accent · violet → indigo */
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --indigo: #6366f1;
  --indigo-2: #818cf8;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --accent-edge: rgba(139, 92, 246, 0.32);
  --accent-grad: linear-gradient(135deg, #a78bfa 0%, #818cf8 100%);

  /* Signal */
  --up: #34d399;
  --up-soft: rgba(52, 211, 153, 0.12);
  --down: #fb7185;
  --down-soft: rgba(251, 113, 133, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.14);

  /* Spacing */
  --pad-x: 14px;
  --gap: 12px;

  /* Radii */
  --r-card: 18px;
  --r-tile: 14px;
  --r-btn: 12px;
  --r-pill: 999px;

  --topbar-h: 56px;
}

@media (min-width: 700px) {
  :root {
    --pad-x: 24px;
    --gap: 14px;
  }
}

/* ── Body / Root ───────────────────────────────────────── */

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--ink);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

/* ── Decorative Background Layers ──────────────────────── */

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

/* Faint grid — gives a sense of measured space */
.bg-grid {
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: 0 0;
  mask-image: radial-gradient(
    ellipse 75% 65% at center 35%,
    black,
    transparent 85%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 75% 65% at center 35%,
    black,
    transparent 85%
  );
}

/* Ambient glows */
.bg-glow {
  background:
    radial-gradient(
      ellipse 80% 50% at 50% -10%,
      rgba(139, 92, 246, 0.22),
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 40% at 85% 80%,
      rgba(99, 102, 241, 0.14),
      transparent 70%
    ),
    radial-gradient(
      ellipse 40% 30% at 8% 55%,
      rgba(196, 122, 255, 0.06),
      transparent 70%
    );
}

/* Subtle film grain */
.bg-noise {
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.45;
  mix-blend-mode: overlay;
}

/* ── Topbar ────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: rgba(10, 10, 15, 0.65);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
}
@supports not (backdrop-filter: blur(1px)) {
  .topbar {
    background: rgba(10, 10, 15, 0.95);
  }
}

.topbar-inner {
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: -0.03em;
  box-shadow:
    0 6px 18px -4px rgba(139, 92, 246, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.brand-name {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

/* Pill tab control */
.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
}

.tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease,
    border-color 0.18s ease;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-edge);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(0, 0, 0, 0.25);
}

/* ── Main Container / Panels ───────────────────────────── */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--pad-x) var(--pad-x) calc(var(--pad-x) * 3);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.panel {
  display: none;
}
.panel.active {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Stagger entrance for cards in the active panel */
.panel.active > .card,
.panel.active > .regime-grid {
  animation: card-rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.panel.active > :nth-child(1) {
  animation-delay: 0ms;
}
.panel.active > :nth-child(2) {
  animation-delay: 60ms;
}
.panel.active > :nth-child(3) {
  animation-delay: 120ms;
}
.panel.active > :nth-child(4) {
  animation-delay: 180ms;
}
.panel.active > :nth-child(5) {
  animation-delay: 240ms;
}

@keyframes card-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

/* ── Glass Card Base ───────────────────────────────────── */

.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 20px 22px;
  overflow: hidden;
  isolation: isolate;
}
@supports not (backdrop-filter: blur(1px)) {
  .card {
    background: rgba(22, 22, 31, 0.86);
  }
}

/* Soft top-edge highlight — refracted-light feel */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.015) 22%,
    transparent 60%
  );
  pointer-events: none;
  z-index: 0;
}

/* Hairline of brightness across the top */
.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 16%;
  right: 16%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.18),
    transparent
  );
  pointer-events: none;
}

.card > * {
  position: relative;
  z-index: 1;
}

/* Instrumental corner brackets (hero card) */
.card-corner {
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--hairline-marker);
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}
.card-corner.tl {
  top: 9px;
  left: 9px;
  border-width: 1px 0 0 1px;
}
.card-corner.tr {
  top: 9px;
  right: 9px;
  border-width: 1px 1px 0 0;
}
.card-corner.bl {
  bottom: 9px;
  left: 9px;
  border-width: 0 0 1px 1px;
}
.card-corner.br {
  bottom: 9px;
  right: 9px;
  border-width: 0 1px 1px 0;
}

/* ── Card Head / Eyebrow / Live ────────────────────────── */

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.eyebrow-idx {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  padding: 2px 6px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.02);
}

.eyebrow-text {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--text-3);
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 10px var(--up);
  animation: live-pulse 2.2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.38;
  }
}

/* ═══════════════════════════════════════════════════════
   Hero Price Card
   ═══════════════════════════════════════════════════════ */

.price-hero {
  padding: 24px 22px 22px;
}

.hero-body {
  position: relative;
  padding: 16px 0 24px;
}

/* Slowly rotating conic halo behind hero number */
.hero-halo {
  position: absolute;
  top: 50%;
  left: 14%;
  width: 340px;
  height: 340px;
  transform: translateY(-50%);
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    rgba(139, 92, 246, 0.26) 90deg,
    transparent 180deg,
    rgba(99, 102, 241, 0.18) 270deg,
    transparent 360deg
  );
  filter: blur(54px);
  border-radius: 50%;
  animation: halo-spin 64s linear infinite;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}
@keyframes halo-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.price-hero-value {
  position: relative;
  z-index: 1;
  font-family: var(--font-sans);
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  font-feature-settings: "tnum" 1;
  min-height: 1em;
  transition: color 0.5s ease;
}

.price-hero-value .num-int,
.price-hero-value .num-cur {
  transition: color 0.5s ease;
}

.price-hero-value .num-dec,
.price-hero-value .num-sep {
  color: var(--text-3);
  font-weight: 500;
  transition: color 0.5s ease;
}

/* Bloomberg-style tick flash: green when price tick up, rose when down */
.price-hero-value.flash-up,
.price-hero-value.flash-up .num-int,
.price-hero-value.flash-up .num-cur,
.price-hero-value.flash-up .num-sep,
.price-hero-value.flash-up .num-dec {
  color: var(--up);
  transition: color 0.1s ease;
}
.price-hero-value.flash-down,
.price-hero-value.flash-down .num-int,
.price-hero-value.flash-down .num-cur,
.price-hero-value.flash-down .num-sep,
.price-hero-value.flash-down .num-dec {
  color: var(--down);
  transition: color 0.1s ease;
}

.hero-meta {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  flex-wrap: wrap;
}

.price-hero-delta {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.price-hero-delta.up {
  color: var(--up);
}
.price-hero-delta.down {
  color: var(--down);
}

.hero-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-4);
}

.price-hero-regime {
  color: var(--text-2);
}

/* Mini stats grid at base of hero */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 2px 0;
  min-width: 0;
}

.mini-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mini-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  min-height: 1.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-value.up {
  color: var(--up);
}
.mini-value.down {
  color: var(--down);
}

/* ═══════════════════════════════════════════════════════
   Regime Tiles (2-col grid)
   ═══════════════════════════════════════════════════════ */

.regime-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.regime-tile {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
}

.regime-tile-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 0 14px;
}

.regime-emoji {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 9px;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.45));
}

.regime-label {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  min-height: 1.2em;
}

.regime-foot {
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
}

.regime-foot .meta-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Dotted ledger leader between key and value */
.meta-leader {
  flex: 1;
  height: 1px;
  background-image: linear-gradient(
    to right,
    rgba(255, 255, 255, 0.2) 30%,
    transparent 30%
  );
  background-size: 4px 1px;
  background-repeat: repeat-x;
  background-position: bottom;
  position: relative;
  top: -3px;
}

.regime-tile-ci {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
  font-size: 11px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   Equity Curve Card
   ═══════════════════════════════════════════════════════ */

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
  margin: 0 -4px;
}

.canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 13px;
  font-family: var(--font-mono);
  text-align: center;
  padding: 20px;
  letter-spacing: 0.02em;
}

.equity-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 2px;
  min-width: 0;
}

.stat-tile.big {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-tile);
  position: relative;
  overflow: hidden;
}

.stat-tile.big::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-tile.big .stat-num {
  font-size: 20px;
  font-weight: 600;
}

.stat-num.up {
  color: var(--up);
}
.stat-num.down {
  color: var(--down);
}

/* ═══════════════════════════════════════════════════════
   Funding Card
   ═══════════════════════════════════════════════════════ */

.funding-headline {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.funding-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.funding-value.up {
  color: var(--up);
}
.funding-value.down {
  color: var(--down);
}

.funding-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-hi);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  white-space: nowrap;
}
.funding-pill.hot {
  background: var(--down-soft);
  border-color: rgba(251, 113, 133, 0.32);
  color: var(--down);
}
.funding-pill.cold {
  background: var(--info-soft);
  border-color: rgba(96, 165, 250, 0.32);
  color: var(--info);
}
.funding-pill.bull {
  background: var(--up-soft);
  border-color: rgba(52, 211, 153, 0.32);
  color: var(--up);
}
.funding-pill.bear {
  background: var(--down-soft);
  border-color: rgba(251, 113, 133, 0.32);
  color: var(--down);
}
.funding-pill.warn {
  background: var(--warn-soft);
  border-color: rgba(251, 191, 36, 0.32);
  color: var(--warn);
}

.funding-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

.meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.meta-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.meta-val {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   History Table
   ═══════════════════════════════════════════════════════ */

.history-wrap {
  max-height: 360px;
  overflow-y: auto;
  margin: 0 -22px -20px;
  padding: 0 22px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.history-wrap::-webkit-scrollbar {
  width: 6px;
}
.history-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.history-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.history-table thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 15, 0.7),
    rgba(10, 10, 15, 0.4)
  );
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 1;
}

.history-table .num-col {
  text-align: right;
  font-family: var(--font-mono);
}

.history-table tbody td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.history-table tbody tr {
  transition: background 0.12s ease;
}
.history-table tbody tr:hover {
  background: var(--surface-hover);
}
.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-empty td {
  text-align: center !important;
  color: var(--text-3);
  padding: 30px 8px !important;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════
   Backtest · Parameters
   ═══════════════════════════════════════════════════════ */

.param-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 18px;
  margin-bottom: 20px;
}

@media (min-width: 540px) {
  .param-grid {
    grid-template-columns: 1fr 1fr;
  }
  .param-full {
    grid-column: 1 / -1;
  }
}

.param {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  align-items: baseline;
}

.param-label {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.param-out {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  letter-spacing: -0.005em;
}

.param input[type="range"] {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 6px;
}

/* Custom range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--violet-2), var(--indigo-2));
  border-radius: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right, var(--violet-2), var(--indigo-2));
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--ink);
  box-shadow:
    0 0 0 1px var(--hairline-hi),
    0 0 18px rgba(139, 92, 246, 0.62),
    0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--ink);
  box-shadow:
    0 0 0 1px var(--hairline-hi),
    0 0 18px rgba(139, 92, 246, 0.62),
    0 2px 6px rgba(0, 0, 0, 0.45);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.08);
}
input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.18);
}
input[type="range"]:focus {
  outline: none;
}

/* ── Run Button ────────────────────────────────────────── */

.run-btn {
  position: relative;
  width: 100%;
  appearance: none;
  border: 1px solid rgba(139, 92, 246, 0.42);
  background: var(--accent-grad);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: var(--r-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 10px 28px -8px rgba(139, 92, 246, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 0.16s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
  isolation: isolate;
  letter-spacing: -0.005em;
}

.run-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.18),
    transparent 55%
  );
  pointer-events: none;
}

.run-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 14px 36px -8px rgba(139, 92, 246, 0.72),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

.run-btn:active {
  transform: translateY(0);
}

.run-btn:disabled {
  opacity: 0.62;
  cursor: progress;
  transform: none;
}

.run-btn-icon {
  font-size: 10px;
  letter-spacing: -0.04em;
  position: relative;
}

.run-btn-text {
  position: relative;
}

.run-btn-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  opacity: 0.6;
  letter-spacing: 0.04em;
  position: relative;
}

.run-status {
  min-height: 1.4em;
  margin-top: 12px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  letter-spacing: 0.03em;
}
.run-status.up {
  color: var(--up);
}
.run-status.down {
  color: var(--down);
}

/* ── Backtest Result Stats ─────────────────────────────── */

.bt-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

@media (min-width: 540px) {
  .bt-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Folds Table ───────────────────────────────────────── */

.folds-wrap {
  max-height: 420px;
  overflow-y: auto;
  margin: 0 -22px -20px;
  padding: 0 22px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.folds-wrap::-webkit-scrollbar {
  width: 6px;
}
.folds-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.folds-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.folds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.folds-table thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 15, 0.7),
    rgba(10, 10, 15, 0.4)
  );
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 1;
}

.folds-table .num-col {
  text-align: right;
  font-family: var(--font-mono);
}

.folds-table tbody td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.folds-table tbody tr {
  transition: background 0.12s ease;
}
.folds-table tbody tr:hover {
  background: var(--surface-hover);
}
.folds-table tbody tr:last-child td {
  border-bottom: none;
}

/* ═══════════════════════════════════════════════════════
   Skeleton Shimmer
   ═══════════════════════════════════════════════════════ */

.sk {
  display: inline-block;
  height: 1em;
  width: 60%;
  min-width: 56px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.045) 0%,
    rgba(255, 255, 255, 0.11) 50%,
    rgba(255, 255, 255, 0.045) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite ease-in-out;
  vertical-align: middle;
}
.sk-lg {
  width: 140px;
  height: 1.4em;
}
.sk-hero {
  width: 60%;
  min-width: 200px;
  height: 0.85em;
  margin-top: 0.075em;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ═══════════════════════════════════════════════════════
   Responsive · ≥ 700px
   ═══════════════════════════════════════════════════════ */

@media (min-width: 700px) {
  .price-hero {
    padding: 30px 28px 24px;
  }

  .hero-meta {
    font-size: 14px;
  }

  .mini-stats {
    gap: 14px;
  }
  .mini-value {
    font-size: 14px;
  }
  .mini-label {
    font-size: 10px;
  }

  .regime-tile {
    min-height: 184px;
    padding: 20px 22px 16px;
  }
  .regime-emoji {
    font-size: 40px;
    margin-bottom: 10px;
  }
  .regime-label {
    font-size: 18px;
  }
  .regime-tile-ci {
    font-size: 12px;
  }

  .canvas-wrap {
    height: 280px;
  }

  .stat-num {
    font-size: 16px;
  }

  .funding-value {
    font-size: 32px;
  }

  .meta-row {
    font-size: 13px;
  }
  .meta-val {
    font-size: 13px;
  }

  .param-grid {
    gap: 18px 24px;
  }

  .run-btn {
    padding: 16px 22px;
    font-size: 15px;
  }
}

/* ═══════════════════════════════════════════════════════
   Responsive · ≤ 374px (iPhone SE etc.)
   ═══════════════════════════════════════════════════════ */

@media (max-width: 374px) {
  :root {
    --pad-x: 12px;
  }
  .price-hero-value {
    font-size: clamp(28px, 8vw, 38px);
  }
  .mini-stats {
    gap: 6px;
  }
  .mini-value {
    font-size: 12px;
  }
  .funding-value {
    font-size: 24px;
  }
  .stat-tile.big .stat-num {
    font-size: 18px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .hero-halo {
    animation: none !important;
  }
  .live-dot {
    animation: none !important;
  }
}
