:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #0b0f17;
  --bg-surface: #131b2e;
  --bg-elevated: #1a243b;
  --bg-code: #090d16;
  --border-subtle: #24324f;
  --border-strong: #354971;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-kaggle: #20beff;
  --accent-kaggle-bg: rgba(32, 190, 255, 0.14);
  --accent-indigo: #818cf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-code: #0f172a;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --accent-kaggle: #0284c7;
  --accent-kaggle-bg: rgba(2, 132, 199, 0.1);
  --accent-indigo: #4f46e5;
  --accent-green: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  text-align: start;
  overflow-wrap: break-word;
}
a { color: var(--accent-kaggle); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
p { text-wrap: pretty; }
input, textarea, select { color: var(--text-primary); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
select option { background-color: var(--bg-surface); color: var(--text-primary); }
button:disabled {
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  border-color: var(--border-subtle);
  opacity: 1;
  cursor: not-allowed;
}

.container { max-width: 1400px; margin: 0 auto; padding: 0 1.25rem; }

.top-nav {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand-logo { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand-badge {
  background: var(--accent-kaggle);
  color: #06101e;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
}
.brand-slug { color: var(--text-primary); font-weight: 600; font-size: 0.92rem; }
.primary-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.nav-tab {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-tab:hover { background: var(--bg-elevated); text-decoration: none; }
.nav-tab.active {
  color: var(--accent-kaggle);
  background: var(--accent-kaggle-bg);
  border-color: var(--accent-kaggle);
}
.nav-actions { display: flex; align-items: center; gap: 0.6rem; }
.btn-ghost, .btn-kaggle, .btn-secondary {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.42rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-kaggle {
  background: var(--accent-kaggle);
  color: #04111f;
  border: none;
  text-decoration: none;
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--accent-kaggle);
  border: 1px solid var(--border-strong);
  text-decoration: none;
}

.hero-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.5rem 0 1.35rem;
}
.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.hero-meta-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.pill-accent { background: var(--accent-kaggle-bg); color: var(--accent-kaggle); border-color: var(--accent-kaggle); }
.pill-license { color: var(--accent-green); border-color: var(--accent-green); }
.hero-updated { font-size: 0.8rem; color: var(--text-muted); }
.hero-title { margin: 0 0 0.4rem; font-size: clamp(1.35rem, 1rem + 1.4vw, 1.7rem); font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.hero-subtitle { margin: 0 0 1.15rem; color: var(--text-secondary); font-size: 0.96rem; max-width: 80ch; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 1.45rem; font-weight: 800; }
.kpi-cyan { color: var(--accent-kaggle); }
.kpi-green { color: var(--accent-green); }
.kpi-indigo { color: var(--accent-indigo); }
.kpi-sub { font-size: 0.78rem; color: var(--text-secondary); }

.main-content { padding: 1.5rem 1.25rem 3rem; }
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.35rem;
  box-shadow: var(--shadow-card);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-title { margin: 0; font-size: 1.18rem; font-weight: 700; text-wrap: balance; }
.section-sub { margin: 0.15rem 0 0; font-size: 0.85rem; color: var(--text-secondary); max-width: 80ch; }

/* Responsive Table with Sticky Headers & Container Queries */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(720px, 82vh);
  container-type: inline-size;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}
thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 4;
}
thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--accent-kaggle); }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover td, tbody tr:hover th { background: var(--bg-elevated); }
tbody th, tbody td {
  padding: 0.68rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  background: var(--bg-surface);
  font-weight: 600;
  text-align: left;
  border-right: 1px solid var(--border-subtle);
}
.row-clickable { cursor: pointer; }
.num-cell { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

@container (width < 600px) {
  table.responsive-stack, table.responsive-stack thead, table.responsive-stack tbody,
  table.responsive-stack tr, table.responsive-stack th, table.responsive-stack td {
    display: block;
  }
  table.responsive-stack thead { display: none; }
  table.responsive-stack tr { margin-block-end: 1rem; border: 1px solid var(--border-subtle); border-radius: 8px; }
  table.responsive-stack tbody th { position: sticky; inset-block-start: 0; background: var(--bg-elevated); }
  table.responsive-stack td { text-align: left; }
  table.responsive-stack td:nth-child(2)::before { content: var(--label-2, "Score") ": "; font-weight: 700; }
  table.responsive-stack td:nth-child(3)::before { content: var(--label-3, "Metric") ": "; font-weight: 700; }
}

.score-bar-wrap { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; }
.score-bar { width: 64px; height: 7px; background: var(--bg-page); border-radius: 99px; overflow: hidden; border: 1px solid var(--border-subtle); }
.score-fill { height: 100%; border-radius: 99px; background: var(--accent-kaggle); }
.score-fill.ref-fill { background: var(--accent-green); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.78rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.rank-1 { background: #fbbf24; color: #1e1b4b; }
.rank-2 { background: #94a3b8; color: #0f172a; }
.rank-ref { background: var(--accent-kaggle-bg); color: var(--accent-kaggle); border: 1px solid var(--accent-kaggle); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.15rem; }
.grid-pillars { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 1rem; }
.pillar-card {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; margin-bottom: 1rem; }
.input-search, .select-filter {
  background: var(--bg-page);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0.48rem 0.75rem;
  font-size: 0.86rem;
}
.input-search { min-width: 260px; flex: 1; }

.code-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 1rem; }
.code-pane {
  background: var(--bg-code);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
}
.code-pane-header {
  background: var(--bg-elevated);
  padding: 0.55rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 600;
}
.code-block {
  margin: 0;
  padding: 0.9rem;
  overflow-x: auto;
  max-height: 540px;
  font-size: 0.79rem;
  line-height: 1.48;
  color: #e2e8f0;
}

.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  padding: 1.25rem 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
}
@supports (corner-shape: squircle) {
  .kpi-card, .section-card, .pillar-card, .btn-ghost, .btn-kaggle, .btn-secondary { corner-shape: squircle; }
}
@supports (reading-flow: grid-rows) {
  .kpi-strip, .grid-2, .grid-pillars, .code-split { reading-flow: grid-rows; }
  .nav-inner, .filter-bar { reading-flow: flex-visual; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
