:root {
  color-scheme: dark;

  /* Core palette — financial terminal, dark + neon accents */
  --bg: #0a0e14;
  --panel: rgba(255, 255, 255, 0.025);
  --panel-strong: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #e8e8e8;
  --muted: #888;
  --muted-dim: #555;

  --up: #00ff88;
  --down: #ff5252;
  --accent: #00ff88;
  --accent-alt: #00d4ff;
  --gold: #ffd166;
  --warn: #f97316;
  --purple: #a855f7;

  /* Hunter Paul quadrant colors */
  --sweet: #00ff88;
  --hidden: #a855f7;
  --hot: #f97316;
  --avoid: #6b7280;
}

* { box-sizing: border-box; }

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'SF Pro Text',
    'Apple SD Gothic Neo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ambient radial glow behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 30%, rgba(0, 255, 136, 0.07), transparent 50%),
    radial-gradient(circle at 85% 70%, rgba(0, 212, 255, 0.06), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
}

/* ─── Mono font for numeric/data tokens ───────────────────────────── */

.mono, code, pre, .num {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-variant-numeric: tabular-nums;
}

/* ─── Auto-mono inside common data containers (KPI, scores, etc.) ─── */
.kpi-num, .score-num, .price-num, table .num-col {
  font-family: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
  font-variant-numeric: tabular-nums;
}

/* ─── Gradient hero title ─────────────────────────────────────────── */

.hp-hero-title {
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, #00ff88 0%, #00d4ff 50%, #b0ff8a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ─── Standard page title (used by sub-pages) ─────────────────────── */

.hp-page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f1f5f9;
}
@media (min-width: 768px) {
  .hp-page-title { font-size: 26px; }
}
.hp-page-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ─── Ticker bar (auto-scrolling top strip) ───────────────────────── */

.ticker-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  overflow: hidden;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
}
.ticker-track {
  display: flex;
  gap: 36px;
  animation: hp-ticker-scroll 80s linear infinite;
  white-space: nowrap;
  width: max-content;
}
@keyframes hp-ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ticker-item { display: inline-flex; gap: 8px; align-items: baseline; }
.ticker-symbol { color: var(--muted); }
.ticker-price { color: #fff; font-weight: 700; }
.ticker-up { color: var(--up); }
.ticker-down { color: var(--down); }

/* ─── Pill / chip ─────────────────────────────────────────────────── */

.cat-leader { background: rgba(59, 130, 246, 0.18); color: #93c5fd; border-color: rgba(59, 130, 246, 0.4); }
.cat-monopoly { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.4); }
.cat-bottleneck { background: rgba(244, 63, 94, 0.18); color: #fda4af; border-color: rgba(244, 63, 94, 0.4); }
.cat-undervalued { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.cat-default { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.3); }
.cat-pill {
  display: inline-block;
  border: 1px solid;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  margin-right: 4px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.cat-pill[data-active="false"] { opacity: 0.35; }

.q-sweet_spot { color: var(--sweet); }
.q-hidden_gem { color: var(--hidden); }
.q-hot_fomo { color: var(--hot); }
.q-avoid { color: var(--avoid); }
.q-neutral { color: #cbd5e1; }

/* ─── Pulse animation for score / price changes ───────────────────── */

@keyframes hp-pulse {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.45); }
  40%  { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(0, 255, 136, 0); }
  100% { transform: scale(1); }
}
.pulse { animation: hp-pulse 0.55s ease; }

/* ─── Card / panel ────────────────────────────────────────────────── */

.hp-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.hp-card:hover { border-color: var(--border-strong); }

/* ─── Bottom tab bar ──────────────────────────────────────────────── */

.tab-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  min-width: 52px;
  font-size: 11px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.2s, background-color 0.2s;
}
.tab-link:hover { color: #fff; background: rgba(255,255,255,0.04); }
.tab-link.active {
  color: var(--accent);
  background: rgba(0, 255, 136, 0.08);
}
.tab-link.active .tab-label { font-weight: 600; }

/* ─── File-tree flow diagram ──────────────────────────────────────── */

.hp-tree {
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.6;
}
.tree-root {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.tree-children {
  list-style: none;
  padding: 0;
  margin: 0;
  margin-left: 0;
}
.tree-children.root {
  margin-left: 4px;
}
.tree-branch {
  margin: 4px 0;
}
.tree-branch.mega {
  padding-left: 0;
}
.tree-branch.mega > .tree-children {
  margin-left: 24px;
  padding-left: 12px;
  border-left: 1px dashed rgba(255,255,255,0.08);
  margin-top: 4px;
}
.tree-node-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s;
}
.tree-node-link:hover {
  background: rgba(255,255,255,0.04);
}
.tree-pipe {
  font-family: 'JetBrains Mono', monospace;
  color: rgba(255,255,255,0.18);
  font-size: 12px;
  margin-right: 4px;
  user-select: none;
}
.tree-leaves {
  list-style: none;
  padding: 0;
  margin: 4px 0 4px 28px;
  padding-left: 8px;
  border-left: 1px dashed rgba(255,255,255,0.06);
}
.tree-leaf {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 12px;
}
.tree-leaf:hover { background: rgba(255,255,255,0.03); }

/* Stage / sub headers within the sector tree */
.tree-stage-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  margin: 12px 0 4px;
  background: rgba(255,255,255,0.025);
  border-left: 2px solid rgba(0, 212, 255, 0.55);
  border-radius: 0 6px 6px 0;
}
.tree-stage-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #cbd5e1;
  text-transform: uppercase;
}
.tree-branch.sub {
  margin: 6px 0 8px;
}
.tree-branch.sub > .tree-sub-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 6px;
}
.tree-branch.sub > .tree-sub-header:hover {
  background: rgba(255,255,255,0.04);
}
.tree-branch.sub > .tree-leaves {
  margin-left: 18px;
  border-left: 1px dashed rgba(255,255,255,0.05);
  padding-left: 10px;
}
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 11px; font-weight: 500; }

/* ─── Telegram Mini App ──────────────────────────────────────────── */

html.tma .ticker-bar { display: none; }
html.tma .app-header { top: 0 !important; }
html.tma .app-header .text-lg { font-size: 14px; }
html.tma main { padding-bottom: 88px; }

/* ─── Mobile ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  select, input[type="search"] {
    font-size: 14px;
    min-height: 36px;
  }
  .cat-pill {
    font-size: 12px;
    padding: 4px 10px;
    margin: 2px 4px 2px 0;
  }
  #cycle-indicator { display: none; }
}

@media (min-width: 768px) and (max-width: 1100px) {
  section .md\:flex-row {
    overflow-x: auto;
  }
}
