@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg:           #0E0F12;
  --bg-card:      #16181D;
  --bg-card-2:    #1E2128;
  --border:       #2C303A;
  --border-light: #3A3F4B;
  --text-primary: #FFFFFF;
  --text-secondary:#D5D9E0;
  --text-muted:   #8A90A0;

  /* ── New palette ─────────────────────────────
     accent = warm amber/gold (brand, was lime)
     blue   = teal (secondary, was blue)          */
  --accent:       #FFC24B;
  --accent-rgb:   255, 194, 75;
  --danger:       #F1573E;
  --danger-rgb:   241, 87, 62;
  --blue:         #2DD4BF;
  --blue-rgb:     45, 212, 191;
  --purple:       #B084F5;
  --purple-rgb:   176, 132, 245;
  --neutral:      #D9D9D9;

  --font-mono: 'Space Mono', monospace;
  --font-ui:   'DM Sans', sans-serif;
}

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

html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #000; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Layout ── */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-card) 0%, #13151a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar__logo {
  height: 78px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}
.sidebar__logo-mark {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 8px;
  padding: 6px 9px;
  line-height: 1;
}
.sidebar__logo-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.sidebar__nav { flex: 1; padding: 14px 0; overflow-y: auto; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 46px;
  padding: 0 24px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-align: left;
  transition: color 150ms, background 150ms;
}
.nav-btn:hover { color: var(--text-secondary); background: var(--bg-card-2); }
.nav-btn.active {
  color: var(--accent);
  background: var(--bg-card-2);
  border-left-color: var(--accent);
}
.nav-btn svg { flex-shrink: 0; width: 16px; height: 16px; }

.sidebar__footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.main { flex: 1; min-width: 0; overflow-y: auto; padding: 30px 36px; display: flex; flex-direction: column; gap: 16px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px 30px;
}
.card--flush { padding: 0; overflow: hidden; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 13px;
  border-radius: 20px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.badge--accent   { color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.badge--danger   { color: var(--danger); }
.badge--blue     { color: var(--blue); background: rgba(var(--blue-rgb), 0.08); }
.badge--muted    { color: var(--text-muted); }
.badge--purple   { color: var(--purple); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ── Stat grid ── */
.stat-row { display: grid; gap: 16px; }
.stat-row--4 { grid-template-columns: repeat(4, 1fr); }
.stat-row--3 { grid-template-columns: repeat(3, 1fr); }
.stat-row--2 { grid-template-columns: repeat(2, 1fr); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card__label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}
.stat-card__value {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-card__sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ── Dot bar ── */
.dot-bar { display: flex; align-items: center; gap: 4px; }
.dot { width: 5px; height: 5px; border-radius: 1px; background: var(--border); flex-shrink: 0; transition: background 300ms; }
.dot--on { background: var(--accent); }
.dot--blue { background: var(--blue); }
.dot--danger { background: var(--danger); }
.dot--purple { background: var(--purple); }
.dot--muted { background: var(--text-muted); }

/* ── Two-col layout ── */
.two-col { display: grid; grid-template-columns: 60fr 40fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Heatmap ── */
.heatmap-wrap { overflow-x: auto; }
.heatmap-grid {
  display: grid;
  gap: 3px;
}
.heatmap-cell {
  width: 56px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  cursor: default;
  transition: transform 120ms;
  position: relative;
}
.heatmap-cell:hover { transform: scale(1.12); z-index: 10; }
.heatmap-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}
.heatmap-axis-row {
  display: grid;
  gap: 3px;
  align-items: center;
}

/* ── Pipeline steps ── */
.pipeline { display: flex; flex-direction: column; gap: 0; }
.pipeline-step {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.pipeline-step:last-child { border-bottom: none; }
.pipeline-step__num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  min-width: 44px;
  padding-top: 2px;
  flex-shrink: 0;
}
.pipeline-step__label {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.pipeline-step__desc {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.pipeline-step__formula {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 10px;
  display: inline-block;
  letter-spacing: 0.02em;
}

/* ── Model comparison table ── */
.cmp-table { width: 100%; border-collapse: collapse; }
.cmp-table th {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.cmp-table td {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.cmp-table tr:last-child td { border-bottom: none; }
.cmp-table tr.best td { color: var(--accent); }
.cmp-table tr.best td:first-child::before {
  content: '★ ';
  color: var(--accent);
}

/* ── Live demo ── */
.feature-sliders { display: flex; flex-direction: column; gap: 18px; }
.slider-row { display: flex; flex-direction: column; gap: 6px; }
.slider-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.slider-row__label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}
.slider-row__value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.slider-wrap {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
.slider-wrap input[type=range] {
  position: absolute;
  inset: -8px 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}
.slider-wrap:has(input[type=range]:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 3px;
}
.slider-track {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  pointer-events: none;
  transition: width 80ms;
}
.slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 15px;
  height: 15px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18);
  transition: left 80ms;
}

/* ── Classification result ── */
.result-box {
  background: var(--bg-card-2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 20px 24px;
  margin-top: 10px;
}
.result-class {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.result-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
}
.result-bar-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  min-width: 80px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.result-bar-track {
  flex: 1;
  height: 9px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.result-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 300ms ease;
}
.result-pct {
  font-family: var(--font-mono);
  font-size: 13px;
  min-width: 52px;
  text-align: right;
}

/* ── Interaction pairs ── */
.pair-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.pair-names {
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 200px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.pair-names__sep { color: var(--text-muted); font-size: 10px; }
.pair-score {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  min-width: 48px;
  text-align: right;
}

/* ── k slider ── */
.k-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  padding: 16px 22px;
  background: var(--bg-card-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.k-row__label { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); letter-spacing: 0.08em; }
.k-row__val { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--accent); min-width: 36px; }
.k-row input[type=range] { flex: 1; accent-color: var(--accent); cursor: pointer; height: 6px; }
.k-row__info { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Chart canvas ── */
.chart-wrap { position: relative; }
canvas { display: block; }

/* ── Page transitions ── */
.page { display: none; flex-direction: column; gap: 16px; animation: fadeUp 0.22s ease; }
.page.active { display: flex; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Page header ── */
.page-header { margin-bottom: 6px; }
.page-header__eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}
.page-header__title {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.page-header__sub {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 8px;
  max-width: 760px;
  line-height: 1.7;
}

/* Inspector title row — responsive single-line heading */
.inspector-title-row { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.inspector-title-cs,
.inspector-title-name {
  font-family: var(--font-mono);
  font-size: clamp(18px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Enriched features display ── */
.enrich-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.enrich-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-card-2);
}
.enrich-chip--new {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

/* ── Delta-R tooltip ── */
.hm-tooltip {
  position: fixed;
  background: var(--bg-card-2);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  display: none;
}

/* ── About section ── */
.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.about-row:last-child { border-bottom: none; }
.about-row__key { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); letter-spacing: 0.06em; }
.about-row__val { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--text-secondary); text-align: right; }
.about-row__val--accent { color: var(--accent); }

/* ── Sidebar toggle button ── */
.sidebar__toggle { display: none; }

/* ── Sidebar backdrop overlay ── */
.sidebar-backdrop { display: none; }

/* ── Responsive ── */

/* Tablet: 1100px and below */
@media (max-width: 1100px) {
  .stat-row--4 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
}

/* Tablet: 920px and below */
@media (max-width: 920px) {
  .sidebar { width: 220px; }
  .main { padding: 24px 20px; }
}

/* Mobile: 768px and below — icon-only sidebar rail */
@media (max-width: 768px) {
  .shell {
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
  }

  /* Narrow icon rail */
  .sidebar {
    width: 52px;
    flex-shrink: 0;
    height: 100vh;
    overflow: hidden;
    border-right: 1px solid var(--border);
    border-bottom: none;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* Logo: show only the CS mark, hide name */
  .sidebar__logo {
    width: 100%;
    height: 56px;
    padding: 0;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    border-right: none;
    gap: 0;
  }
  .sidebar__logo-name { display: none; }
  .sidebar__logo-mark {
    font-size: 13px;
    padding: 5px 7px;
  }

  /* Nav: icon-only centered buttons */
  .sidebar__nav {
    flex: 1;
    width: 100%;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    gap: 2px;
  }

  .nav-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 0;
    border-left: none;
    border-right: 3px solid transparent;
    border-bottom: none;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    gap: 0;
  }

  .nav-btn svg { width: 18px; height: 18px; }
  .nav-btn.active {
    border-right-color: var(--accent);
    background: var(--bg-card-2);
    color: var(--accent);
    border-radius: 8px 0 0 8px;
  }

  .sidebar__footer { display: none; }

  /* Main scrolls independently */
  .main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 14px 12px;
    gap: 12px;
    margin-top: 0;
  }

  .page-header { margin-bottom: 10px; }
  .page-header__eyebrow { font-size: 10px; }
  .page-header__title { font-size: 22px; }
  .page-header__sub { font-size: 13px; max-width: 100%; }

  /* Inspector header title row — single line, fluid size */
  .inspector-title-row {
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
  .inspector-title-row .inspector-title-cs {
    font-size: clamp(16px, 5vw, 26px) !important;
  }
  .inspector-title-row .inspector-title-name {
    font-size: clamp(16px, 5vw, 26px) !important;
  }

  .stat-row--4 { grid-template-columns: repeat(2, 1fr); }
  .stat-row--3 { grid-template-columns: repeat(3, 1fr); }
  .stat-row--2 { grid-template-columns: repeat(2, 1fr); }

  .card { padding: 14px 14px; }
  .card.card--flush { padding: 0; }

  .panel-header { margin-bottom: 14px; padding-bottom: 10px; }
  .panel-title { font-size: 10px; }
  .stat-card__value { font-size: 26px; }
  .stat-card__label { font-size: 10px; }
  .stat-card__sub { font-size: 10px; }

  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }

  .k-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .k-row input[type=range] { width: 100%; flex-basis: 100%; }
  .k-row__info { font-size: 11px; }

  .pair-names { min-width: auto; font-size: 11px; flex-wrap: wrap; }
  .result-bar-label { min-width: 58px; font-size: 11px; }

  .feature-sliders { gap: 14px; }
}

/* Smaller mobiles: 480px and below */
@media (max-width: 480px) {
  .sidebar { width: 48px; }

  .sidebar__logo { height: 50px; }
  .sidebar__logo-mark { font-size: 11px; padding: 4px 6px; }

  .nav-btn { width: 40px; height: 40px; }
  .nav-btn svg { width: 16px; height: 16px; }

  .main { padding: 10px 10px; gap: 10px; }

  .page-header__title { font-size: 20px; }

  .stat-row--4, .stat-row--3, .stat-row--2 { grid-template-columns: repeat(2, 1fr); }

  .card { padding: 12px 12px; }

  .stat-card__value { font-size: 22px; }
  .stat-card__label { font-size: 9px; }
  .stat-card__sub { font-size: 9px; }

  .heatmap-cell { width: 36px; height: 30px; font-size: 8px; }
  .heatmap-label { font-size: 8px; max-width: 50px; }

  .slider-row__label { font-size: 10px; }
  .slider-row__value { font-size: 11px; }

  .result-class { font-size: 22px; }
  .result-bar-label { font-size: 9px; min-width: 50px; }
  .result-bar-row { gap: 6px; margin-bottom: 6px; }

  .pipeline-step { gap: 10px; padding: 12px 0; }
  .pipeline-step__num { font-size: 18px; min-width: 28px; }
  .pipeline-step__label { font-size: 11px; }
  .pipeline-step__desc { font-size: 12px; line-height: 1.6; }
  .pipeline-step__formula { font-size: 10px; padding: 6px 10px; }

  .cmp-table th, .cmp-table td { padding: 6px 8px; font-size: 10px; }

  .about-row { padding: 6px 0; }
  .about-row__key { font-size: 10px; }
  .about-row__val { font-size: 11px; }

  .enrich-chip { font-size: 10px; padding: 4px 8px; }
  .enrich-wrap { gap: 5px; }

  .pair-row { gap: 6px; margin-bottom: 7px; }
  .pair-names { font-size: 10px; }
  .pair-score { font-size: 11px; min-width: 38px; }

  .k-row { padding: 10px 12px; margin-bottom: 12px; }
  .k-row__label { font-size: 10px; }
  .k-row__val { font-size: 18px; }
  .k-row__info { font-size: 10px; }

  .badge { font-size: 9px; padding: 3px 9px; }

  .chart-wrap canvas { max-width: 100% !important; }

  .divider { margin: 10px 0; }
}
