:root {
  --bg:       #09090b;
  --surface:  #111113;
  --border:   #1f1f24;
  --muted:    #3f3f46;
  --text:     #e4e4e7;
  --sub:      #a1a1aa;
  --bull:     #22c55e;
  --bear:     #ef4444;
  --neutral:  #f59e0b;
  --accent:   #7c3aed;
  --accent2:  #06b6d4;
}
:root.light-mode {
  --bg:      #f8fafc;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --muted:   #94a3b8;
  --text:    #0f172a;
  --sub:     #64748b;
}

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

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Page header ─────────────────────────────────────────── */
.pg-hero {
  background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 60%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.pg-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(124,58,237,.15) 0%, transparent 70%);
  pointer-events: none;
}
.pg-hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff 30%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .75rem;
}
.pg-hero p {
  color: var(--sub);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto 2rem;
}

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 1.5rem;
}
.tab-btn {
  padding: .55rem 1.4rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--sub);
  font-family: 'Sora', sans-serif;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.tab-btn.active, .tab-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Main layout ─────────────────────────────────────────── */
.pg-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── Section heading ─────────────────────────────────────── */
.section-hd {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.75rem;
}
.section-hd .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.section-hd h2 {
  font-size: 1.4rem;
  font-weight: 700;
}
.section-hd .count {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: .2rem .75rem;
  font-size: .8rem;
  color: var(--sub);
}

/* ── Pattern card grid ───────────────────────────────────── */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
}

.pattern-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.pattern-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124,58,237,.15);
}
.pattern-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
}
.pattern-card.bull::before  { background: var(--bull); }
.pattern-card.bear::before  { background: var(--bear); }
.pattern-card.neutral::before { background: var(--neutral); }

.card-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .75rem;
}
.card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.bull  .card-icon { background: rgba(34,197,94,.12); }
.bear  .card-icon { background: rgba(239,68,68,.12); }
.neutral .card-icon { background: rgba(245,158,11,.12); }

.card-name {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.3;
}
.badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 9999px;
  margin-top: .25rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bull  .badge { background: rgba(34,197,94,.15);  color: var(--bull); }
.bear  .badge { background: rgba(239,68,68,.15);  color: var(--bear); }
.neutral .badge { background: rgba(245,158,11,.15); color: var(--neutral); }

.card-desc {
  font-size: .83rem;
  color: var(--sub);
  line-height: 1.55;
  margin-bottom: .9rem;
}

/* SVG chart illustration */
.card-chart {
  background: #0d0d10;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: .5rem;
  margin-bottom: .9rem;
  overflow: hidden;
}

.card-stats {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.stat-pill {
  background: #0d0d10;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .75rem;
  color: var(--sub);
}
.stat-pill strong { color: var(--text); }

/* ── Detail modal ────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem 1rem;
}
.modal-bg.open { display: flex; align-items: flex-start; justify-content: center; }

.modal {
  background: #111116;
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  padding: 2rem;
  position: relative;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: translateY(20px); }
  to   { opacity:1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  color: var(--sub);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .2s, color .2s;
}
.modal-close:hover { border-color: var(--bear); color: var(--bear); }

.modal h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.modal-sub {
  color: var(--sub);
  font-size: .9rem;
  margin-bottom: 1.5rem;
}

.modal-section { margin-bottom: 1.5rem; }
.modal-section h4 {
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--sub);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

.criteria-list {
  list-style: none;
}
.criteria-list li {
  display: flex;
  gap: .75rem;
  padding: .45rem 0;
  font-size: .875rem;
  color: var(--sub);
  border-bottom: 1px dashed #1a1a20;
}
.criteria-list li:last-child { border-bottom: none; }
.criteria-list li::before {
  content: '→';
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 700;
}

.example-box {
  background: #0d0d10;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
}
.example-box .ex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.ex-stock { font-weight: 700; font-size: .9rem; }
.ex-date  { font-size: .78rem; color: var(--sub); }
.ex-result {
  font-size: .82rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 9999px;
}
.ex-result.pos { background: rgba(34,197,94,.15); color: var(--bull); }
.ex-result.neg { background: rgba(239,68,68,.15); color: var(--bear); }

.ex-desc {
  font-size: .83rem;
  color: var(--sub);
  line-height: 1.55;
}

/* Case studies tab */
.case-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.case-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.case-logo {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: #0d0d10;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.case-title h3 { font-size: 1.05rem; font-weight: 700; }
.case-title p  { font-size: .82rem; color: var(--sub); margin-top: .15rem; }

.case-outcome {
  display: flex;
  gap: .6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.outcome-pill {
  padding: .3rem .8rem;
  border-radius: 9999px;
  font-size: .78rem;
  font-weight: 600;
}
.outcome-pill.green { background: rgba(34,197,94,.12); color: var(--bull); border: 1px solid rgba(34,197,94,.25); }
.outcome-pill.red   { background: rgba(239,68,68,.12);  color: var(--bear); border: 1px solid rgba(239,68,68,.25); }
.outcome-pill.blue  { background: rgba(6,182,212,.12);  color: var(--accent2); border: 1px solid rgba(6,182,212,.25); }
.outcome-pill.purple{ background: rgba(124,58,237,.12); color: #a78bfa; border: 1px solid rgba(124,58,237,.25); }

.case-body { font-size: .875rem; color: var(--sub); line-height: 1.65; }
.case-body strong { color: var(--text); font-weight: 600; }

.case-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem;
  margin-top: 1rem;
}
.metric-box {
  background: #0d0d10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .8rem;
  text-align: center;
}
.metric-box .mv {
  font-size: 1.05rem;
  font-weight: 700;
  display: block;
  margin-bottom: .1rem;
}
.metric-box .ml {
  font-size: .72rem;
  color: var(--sub);
}
.mv.pos { color: var(--bull); }
.mv.neg { color: var(--bear); }

/* Search/filter bar */
.filter-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem 1rem;
  font-family: 'Sora', sans-serif;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem 1rem;
  font-family: 'Sora', sans-serif;
  font-size: .875rem;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}
.filter-select:focus { border-color: var(--accent); }

/* Info box */
.info-box {
  background: rgba(124,58,237,.06);
  border: 1px solid rgba(124,58,237,.2);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  font-size: .85rem;
  color: var(--sub);
  margin-bottom: 2rem;
  line-height: 1.6;
}
.info-box strong { color: #a78bfa; }

/* tab sections */
.tab-section { display: none; }
.tab-section.active { display: block; }

/* Probability bar */
.prob-bar { margin-top: .3rem; }
.prob-track {
  height: 4px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
}
.prob-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width .6s ease;
}
.bull  .prob-fill { background: var(--bull); }
.bear  .prob-fill { background: var(--bear); }
.neutral .prob-fill { background: var(--neutral); }
.prob-label {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  color: var(--muted);
  margin-top: .2rem;
}

@media (max-width: 640px) {
  .pattern-grid { grid-template-columns: 1fr; }
  .case-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ── Light-mode overrides for hardcoded dark values ─────────── */
:root.light-mode .pg-hero h1 {
  background: linear-gradient(135deg, #1e1b4b 30%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root.light-mode .card-chart {
  background: #f1f5f9;
}
:root.light-mode .stat-pill {
  background: #f1f5f9;
}
:root.light-mode .modal {
  background: #ffffff;
}
:root.light-mode .criteria-list li {
  border-bottom-color: #e2e8f0;
}
:root.light-mode .example-box {
  background: #f8fafc;
}
:root.light-mode .case-logo {
  background: #f1f5f9;
}
:root.light-mode .metric-box {
  background: #f1f5f9;
}
