/* Murus Fracta — space landing + founders + backtest shell */
:root {
  --nav-bg: #0a1528;
  --space-black: #000000;
  --text: #f4f7fc;
  --text-dim: rgba(244, 247, 252, 0.65);
  --glow-blue: #3eb6ff;
  --glow-blue-soft: rgba(62, 182, 255, 0.45);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-display: "Orbitron", system-ui, sans-serif;
  --header-h: 56px;
  --bt-session-hud-h: 2.95rem;
  --max: 1120px;
  --space: clamp(1rem, 4vw, 2rem);
}

/* ——— Homepage (screenshot match: Earth horizon + TAKE OFF) ——— */
body.home-page {
  background: var(--space-black);
}

.logo-display {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.82rem, 2.2vw, 0.98rem);
  letter-spacing: 0.22em;
  text-transform: lowercase;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--space-black);
  -webkit-font-smoothing: antialiased;
}

body.page-sub {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--glow-blue);
  color: var(--space-black);
  z-index: 200;
  font-weight: 600;
}

.skip:focus {
  left: var(--space);
  top: 0.5rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--text);
  white-space: nowrap;
}

.logo:hover {
  opacity: 0.9;
}

.nav-center {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 2.25rem);
  font-size: clamp(0.78rem, 2vw, 0.9rem);
  font-weight: 500;
  color: var(--text);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: 55%;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    gap: 0.5rem 1rem;
  }

  .nav-center {
    position: static;
    transform: none;
    max-width: none;
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .site-header {
    height: auto;
  }
}

.nav-center a {
  opacity: 0.92;
  transition: opacity 0.2s ease;
}

.nav-center a:hover {
  opacity: 1;
}

.nav-center a[aria-current="page"] {
  opacity: 1;
  color: var(--glow-blue);
}

/* Active manual backtest workspace: no leaving via header (simulation lock-in) */
body.bt-session-active .site-header a[href] {
  pointer-events: none;
  cursor: default;
  opacity: 0.38;
  text-decoration: none;
}

body.bt-session-active .site-header a[href]:hover {
  opacity: 0.38;
}

body.bt-session-active .site-header .nav-auth .avatar {
  pointer-events: none;
}

/* Simulated session clock — fixed below header, full viewport width */
.bt-session-hud {
  position: fixed;
  top: var(--bt-hud-top, var(--header-h));
  left: 0;
  right: 0;
  z-index: 150;
  min-height: var(--bt-session-hud-h);
  padding: 0.4rem var(--space);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(5, 8, 15, 0.92), rgba(5, 8, 15, 0.72));
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.bt-session-hud__time {
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 1.8vw, 0.8rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 240, 255, 0.95);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85);
  max-width: 46%;
  text-align: left;
}

.bt-session-hud__date-block {
  margin-left: auto;
  max-width: min(52%, 22rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.12rem;
  text-align: right;
}

.bt-session-hud__date-label {
  font-family: var(--font);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232, 240, 255, 0.48);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
}

.bt-session-hud__date-value {
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 1.55vw, 0.76rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  line-height: 1.25;
  color: rgba(232, 240, 255, 0.96);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85);
}

body.bt-session-active .backtest-main {
  padding-top: var(--bt-session-hud-h);
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.nav-auth a {
  opacity: 0.92;
}

.nav-auth a:hover {
  opacity: 1;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #1e3a5f, #0f1f35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.avatar svg {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

/* Hero */
.hero-space {
  position: relative;
  min-height: calc(100dvh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 var(--space);
  overflow: hidden;
  background: #000000;
}

.home-page .hero-space {
  background: #000000;
}

.home-page .hero-photo-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.home-page .hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  display: block;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* No star/noise layer over the photo — it was reading as blur; hard-off for home */
.home-page .hero-space .stars {
  display: none;
}

.home-page .hero-space .stars::after {
  display: none;
}

.hero-space .stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 25% 65%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(1px 1px at 40% 12%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 55% 40%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 72% 78%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 88% 15%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1px 1px at 15% 88%, rgba(255, 255, 255, 0.22), transparent),
    radial-gradient(1px 1px at 92% 55%, rgba(255, 255, 255, 0.28), transparent),
    radial-gradient(1px 1px at 33% 38%, rgba(255, 255, 255, 0.18), transparent),
    radial-gradient(1px 1px at 66% 22%, rgba(255, 255, 255, 0.32), transparent),
    radial-gradient(1px 1px at 48% 92%, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(1.5px 1.5px at 20% 45%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 80% 40%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 5% 50%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(1px 1px at 95% 30%, rgba(255, 255, 255, 0.22), transparent);
  background-size: 100% 100%;
  opacity: 0.9;
}

.hero-space .stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
}

.hero-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse 70% 55% at 50% 35%, transparent 0%, rgba(0, 0, 0, 0.45) 100%);
}

.home-page .hero-vignette {
  background: radial-gradient(
    ellipse 88% 75% at 50% 28%,
    transparent 0%,
    rgba(0, 0, 0, 0.05) 50%,
    rgba(0, 0, 0, 0.28) 100%
  );
}

.home-page .hero-content {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 56rem;
  margin: 0;
  padding-top: clamp(4.5rem, 12vh, 9rem);
  padding-bottom: 2rem;
}

.hero-title {
  margin: 0 0 clamp(2rem, 5vh, 3rem);
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.2vw, 2.85rem);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: 0.06em;
  color: #ffffff;
  text-wrap: balance;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.6);
}

.hero-title-line {
  display: block;
}

.hero-title-line + .hero-title-line {
  margin-top: clamp(1.1em, 4.5vh, 1.85em);
}

/* Glass TAKE OFF — lit from Earth below */
.home-page .btn-takeoff {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1.05rem clamp(2.75rem, 7vw, 4rem);
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 1.8vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #f4f9ff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  isolation: isolate;
  background: linear-gradient(
    165deg,
    rgba(35, 55, 78, 0.55) 0%,
    rgba(12, 18, 28, 0.75) 45%,
    rgba(6, 10, 16, 0.9) 100%
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(62, 182, 255, 0.15),
    0 24px 80px rgba(62, 182, 255, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.home-page .btn-takeoff::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  background: radial-gradient(ellipse 100% 80% at 50% 100%, rgba(94, 210, 255, 0.45), transparent 62%);
  opacity: 0.85;
  pointer-events: none;
}

.home-page .btn-takeoff::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 42%);
  pointer-events: none;
}

.home-page .btn-takeoff:hover {
  transform: translateY(-3px);
  border-color: rgba(94, 210, 255, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 72px rgba(62, 182, 255, 0.28),
    0 28px 100px rgba(62, 182, 255, 0.45);
}

.home-page .btn-takeoff:focus-visible {
  outline: 2px solid var(--glow-blue);
  outline-offset: 4px;
}

/* Subpages: pill CTA without homepage glass treatment */
body:not(.home-page) .btn-takeoff {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem clamp(2.5rem, 6vw, 3.75rem);
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  background: linear-gradient(180deg, #1a2838 0%, #0d141c 45%, #080c12 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 4px 24px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(62, 182, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body:not(.home-page) .btn-takeoff::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(62, 182, 255, 0.35), transparent 65%);
  pointer-events: none;
}

body:not(.home-page) .btn-takeoff:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 56px rgba(62, 182, 255, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

body:not(.home-page) .btn-takeoff:focus-visible {
  outline: 2px solid var(--glow-blue);
  outline-offset: 4px;
}

.earth-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: clamp(340px, 52vh, 680px);
  pointer-events: none;
  z-index: 2;
}

.earth-glow-below {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(140vw, 2000px);
  height: 55%;
  background: radial-gradient(ellipse 52% 42% at 50% 0%, rgba(100, 220, 255, 0.55), transparent 72%);
  filter: blur(28px);
  opacity: 0.9;
  pointer-events: none;
}

.earth-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 -4px 32px rgba(62, 182, 255, 0.35));
}

/* Founders */
.founders {
  position: relative;
  padding: clamp(4rem, 10vw, 6.5rem) var(--space);
  background: linear-gradient(180deg, var(--space-black) 0%, #050a12 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.founders::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, rgba(62, 182, 255, 0.04), transparent);
  pointer-events: none;
}

.founders-inner {
  max-width: var(--max);
  margin: 0 auto;
}

.founders h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.founders .sub {
  margin: 0 auto 3rem;
  max-width: 36ch;
  text-align: center;
  color: var(--text-dim);
  font-size: 1rem;
}

.founders-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .founders-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .founders-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 52rem;
    margin-left: auto;
    margin-right: auto;
  }
}

.founder-card {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, rgba(20, 35, 55, 0.5) 0%, rgba(8, 12, 20, 0.8) 100%);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.founder-card:hover {
  border-color: rgba(62, 182, 255, 0.25);
  transform: translateY(-3px);
}

.founder-photo {
  aspect-ratio: 4 / 5;
  background: linear-gradient(160deg, #1a3048, #0a1520);
  position: relative;
}

.founder-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  position: relative;
  z-index: 0;
}

.founder-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 30%, rgba(62, 182, 255, 0.15), transparent 55%);
}

.founder-silhouette {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 45%;
  height: 55%;
  background: radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.5), transparent);
  border-radius: 50% 50% 0 0;
  opacity: 0.4;
}

.founder-body {
  padding: 1.25rem 1.35rem 1.5rem;
}

.founder-body h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.founder-body .role {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--glow-blue-soft);
  opacity: 0.95;
}

.founder-body .bio {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.founder-body h3 + .bio {
  margin-top: 0.45rem;
}

/* Blank subpages */
.blank-main {
  flex: 1;
  min-height: calc(100dvh - var(--header-h));
  background: var(--space-black);
}

.site-footer-min {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem var(--space) 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.site-footer-min .logo {
  display: inline-block;
  margin-bottom: 0.35rem;
}

/* ——— Backtest intro (typewriter on black) ——— */
.bt-intro {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: var(--space);
  background: #000000;
  transition: opacity 0.95s ease, visibility 0.95s ease;
}

.bt-intro-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.75rem, 5vh, 2.75rem);
  max-width: min(40rem, 92vw);
}

.bt-intro-stack .bt-intro-inner {
  max-width: none;
}

.bt-intro-begin {
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 2vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #f4f9ff;
  padding: 0.95rem clamp(2.25rem, 8vw, 3.5rem);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(165deg, rgba(40, 65, 95, 0.5), rgba(8, 14, 24, 0.95));
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(62, 182, 255, 0.15), 0 0 36px rgba(62, 182, 255, 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.75s ease,
    visibility 0.75s ease,
    transform 0.55s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.bt-intro-begin.bt-intro-begin--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.bt-intro-begin:hover {
  border-color: rgba(94, 210, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(62, 182, 255, 0.25), 0 0 48px rgba(62, 182, 255, 0.35);
  transform: translateY(-2px);
}

.bt-intro-begin:focus-visible {
  outline: 2px solid var(--glow-blue);
  outline-offset: 4px;
}

.bt-intro--done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.bt-intro-inner {
  margin: 0;
  max-width: min(40rem, 92vw);
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.2vw, 1.65rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.45;
  color: #f0f7ff;
  text-align: center;
  text-wrap: balance;
}

.bt-intro-cursor {
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--glow-blue);
  animation: bt-cursor-blink 0.95s step-end infinite;
}

.bt-intro--done .bt-intro-cursor {
  animation: none;
  opacity: 0;
}

@keyframes bt-cursor-blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bt-intro {
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .bt-intro-cursor {
    animation: none;
    opacity: 1;
  }

  .bt-intro-begin {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .bt-intro-begin.bt-intro-begin--visible {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .bt-intro-begin:hover {
    transform: none;
  }
}

/* ——— Backtest mode picker (thirds) ——— */
.bt-choose {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 450;
  display: flex;
  flex-direction: column;
  padding: clamp(0.75rem, 2vh, 1.25rem) 0 0;
  background: linear-gradient(180deg, #010408 0%, #050a14 50%, #070f1a 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.bt-choose--hidden {
  display: none;
}

.bt-choose-title {
  margin: 0 auto 0.75rem;
  padding: 0 var(--space);
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-dim);
}

.bt-choose-inner {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  gap: 1px;
  width: 100%;
  min-height: 0;
  background: rgba(255, 255, 255, 0.06);
}

@media (min-width: 720px) {
  .bt-choose-inner {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr;
  }
}

.bt-choose-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 0;
  min-height: 140px;
  padding: clamp(1rem, 3vw, 1.75rem) var(--space);
  font-family: var(--font);
  text-align: center;
  color: var(--text);
  background: linear-gradient(180deg, rgba(12, 22, 38, 0.95) 0%, rgba(4, 8, 14, 0.98) 100%);
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 720px) {
  .bt-choose-tile {
    min-height: 0;
  }
}

.bt-choose-tile:hover {
  background: linear-gradient(180deg, rgba(18, 35, 58, 0.98) 0%, rgba(8, 14, 26, 1) 100%);
  box-shadow: inset 0 0 0 1px rgba(62, 182, 255, 0.12);
}

.bt-choose-tile:focus-visible {
  outline: 2px solid var(--glow-blue);
  outline-offset: -2px;
  z-index: 1;
}

.bt-choose-tile-k {
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 2vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.bt-choose-tile-d {
  font-size: clamp(0.78rem, 1.8vw, 0.88rem);
  line-height: 1.5;
  color: var(--text-dim);
  max-width: 28ch;
}

/* ——— Rules / code placeholder flows ——— */
.bt-extra-flow {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 450;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.5rem, 5vh, 3rem) var(--space);
  overflow: auto;
  background: linear-gradient(180deg, #010408 0%, #050c18 45%, #081424 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bt-extra-flow--hidden {
  display: none;
}

.bt-extra-flow-card {
  width: min(100%, 26rem);
  padding: 1.5rem 1.35rem 1.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, rgba(20, 35, 55, 0.55) 0%, rgba(8, 12, 20, 0.92) 100%);
}

.bt-extra-flow-h {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text);
}

.bt-extra-flow-p {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-dim);
}

.bt-extra-flow-back {
  width: auto;
  min-width: 8rem;
}

/* ——— Backtest setup (after intro) ——— */
.bt-setup {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 450;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vh, 2.25rem) var(--space) 2rem;
  overflow: auto;
  background: linear-gradient(180deg, #010408 0%, #050c18 45%, #081424 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bt-setup--hidden {
  display: none;
}

.bt-setup-card {
  width: min(100%, 28rem);
  margin: 0 auto;
}

.bt-setup-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.bt-setup-sub {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.bt-setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.bt-setup-field--wide {
  grid-column: 1 / -1;
}

.bt-setup-field label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.3rem;
}

.bt-setup-field input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  box-sizing: border-box;
}

.bt-setup-field input:focus {
  outline: none;
  border-color: var(--glow-blue);
  box-shadow: 0 0 0 2px rgba(62, 182, 255, 0.2);
}

.bt-setup-select {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  box-sizing: border-box;
  cursor: pointer;
}

.bt-setup-select:focus {
  outline: none;
  border-color: var(--glow-blue);
  box-shadow: 0 0 0 2px rgba(62, 182, 255, 0.2);
}

.bt-setup-hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.bt-setup-btn {
  width: 100%;
  align-self: stretch;
  padding: 0.7rem 1.25rem;
}

@media (max-width: 480px) {
  .bt-setup-grid {
    grid-template-columns: 1fr;
  }
}

/* ——— Backtester app layout ——— */
.backtest-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--header-h));
  background: #05080f;
}

/* UA [hidden] loses to this rule's display:flex (same specificity). Force hide until session opens. */
#bt-workspace[hidden],
.backtest-main[hidden] {
  display: none !important;
}

.backtest-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem var(--space);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 21, 40, 0.6);
}

.backtest-toolbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: auto;
}

.backtest-toolbar .tb-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.backtest-toolbar label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.2rem;
}

.backtest-toolbar input,
.backtest-toolbar select {
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  min-width: 0;
}

.backtest-toolbar input:focus,
.backtest-toolbar select:focus {
  outline: none;
  border-color: var(--glow-blue);
  box-shadow: 0 0 0 2px rgba(62, 182, 255, 0.2);
}

.btn-run {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--space-black);
  background: linear-gradient(180deg, var(--glow-blue), #2a8cc4);
  align-self: flex-end;
}

.btn-run:hover {
  filter: brightness(1.08);
}

.backtest-body {
  flex: 1;
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

@media (min-width: 960px) {
  .backtest-body {
    grid-template-columns: 1fr 260px;
    grid-template-rows: 1fr;
  }
}

.bt-colt-chart {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* Portfolio column: grid/flex min-height fix so long holdings scroll inside the rail */
.bt-colt-port {
  min-height: 0;
}

.bt-colt-port.bt-panel {
  overflow: hidden;
}

.bt-colt-port .bt-side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 960px) {
  .bt-colt-port .bt-side-scroll {
    /* Let the grid row define height; inner list scrolls (see global .bt-side-scroll max-height) */
    max-height: none;
  }
}

.bt-panel {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (min-width: 960px) {
  .bt-panel {
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }

  .bt-panel:last-child {
    border-right: none;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
  }
}

.bt-panel-h {
  padding: 0.65rem var(--space);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
}

.bt-chart {
  flex: 1;
  min-height: 280px;
  position: relative;
  background: radial-gradient(ellipse at 50% 0%, rgba(62, 182, 255, 0.06), transparent 50%),
    linear-gradient(180deg, #070b12 0%, #030508 100%);
}

.bt-chart-grid {
  position: absolute;
  inset: 1.25rem;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 48px, 64px 100%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  opacity: 0.7;
}

.bt-chart-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 35%;
  height: 40%;
  pointer-events: none;
}

.bt-chart-line svg {
  width: 100%;
  height: 100%;
}

.bt-chart-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 28ch;
  margin: auto;
}

.bt-side-scroll {
  flex: 1;
  overflow: auto;
  padding: 0.75rem var(--space) 1.25rem;
  min-height: 160px;
}

@media (min-width: 960px) {
  .bt-side-scroll {
    max-height: calc(100dvh - var(--header-h) - 52px);
  }
}

.bt-metric {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bt-metric:last-child {
  border-bottom: none;
}

.bt-metric .k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.bt-metric .v {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.15rem;
}

.bt-metric .v.pos {
  color: #4ade80;
}

.bt-metric .v.neg {
  color: #f87171;
}

.bt-positions {
  font-size: 0.8rem;
}

.bt-positions table {
  width: 100%;
  border-collapse: collapse;
}

.bt-positions th,
.bt-positions td {
  text-align: left;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bt-positions th {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.bt-colt-port .bt-positions thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(5, 8, 15, 0.97);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.bt-bottom-nav {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0));
}

.bt-bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.65rem 0.25rem;
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.bt-bottom-nav button:hover,
.bt-bottom-nav button[aria-current="page"] {
  color: #00c805;
}

.bt-bottom-nav .ic {
  font-size: 1.1rem;
  line-height: 1;
}
