/* ============================================================
   SWU Metrics — Global CSS
   Design system tokens and base styles from DESIGN.md
   Ported verbatim from the Astro src/styles/global.css, with
   page/component styles appended at the bottom (Astro had them
   scoped inside each .astro file; Rails needs one stylesheet).
   ============================================================ */

/* --- @font-face: Geist Sans --- */
@font-face {
  font-family: 'Geist';
  src: url("/fonts/geist-400.woff2") format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist';
  src: url("/fonts/geist-500.woff2") format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist';
  src: url("/fonts/geist-600.woff2") format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist';
  src: url("/fonts/geist-700.woff2") format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- @font-face: Geist Mono --- */
@font-face {
  font-family: 'Geist Mono';
  src: url("/fonts/geist-mono-400.woff2") format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --- Design Tokens --- */
:root {
  /* Colors — derived from SWU Metrics logo palette (deep space navy +
     electric blue + signal red). Semantic tokens (above/below curve)
     stay green/red for readability. */
  --color-bg:            #05070f;
  --color-surface:       #0f1424;
  --color-border:        #1f2937;
  --color-text:          #f5f7fa;
  --color-text-secondary:#94a3b8;
  --color-accent:        #38bdf8;
  --color-above-curve:   #22c55e;
  --color-below-curve:   #ef4444;
  --color-on-curve:      #94a3b8;

  /* Rarity colors — tuned to stay distinguishable from brand accent. */
  --color-rarity-common:    #94a3b8;
  --color-rarity-uncommon:  #22c55e;
  --color-rarity-rare:      #38bdf8;
  --color-rarity-legendary: #facc15;

  /* Spacing scale (DESIGN.md: 2/4/8/16/24/32/48/64px) */
  --space-2xs:  2px;
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   32px;
  --space-2xl:  48px;
  --space-3xl:  64px;

  /* Border radius: sm(4px) md(6px) lg(8px) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Fonts */
  --font-display: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'SFMono-Regular', 'Cascadia Code', 'Fira Code', monospace;

  /* Layout */
  --max-width: 1280px;

  /* Motion */
  --duration-micro:  50ms;
  --duration-short:  150ms;
  --duration-medium: 250ms;
  --duration-long:   500ms;
  --ease-enter:  ease-out;
  --ease-exit:   ease-in;
  --ease-move:   ease-in-out;
}

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

/* --- Base body styles --- */
html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mobile: space for bottom tab bar */
@media (max-width: 767px) {
  body {
    padding-bottom: 64px;
  }
}

/* --- Links --- */
a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Focus: gold accent ring for keyboard users --- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Utility: Typography scale (DESIGN.md: 12/14/16/20/24/32/48px) --- */
.text-xs   { font-size: 12px; line-height: 1.4; }
.text-sm   { font-size: 14px; line-height: 1.4; }
.text-base { font-size: 16px; line-height: 1.5; }
.text-lg   { font-size: 20px; line-height: 1.4; }
.text-xl   { font-size: 24px; line-height: 1.3; }
.text-2xl  { font-size: 32px; line-height: 1.2; }
.text-3xl  { font-size: 48px; line-height: 1.1; }

/* --- Utility: Color --- */
.text-secondary { color: var(--color-text-secondary); }
.text-accent    { color: var(--color-accent); }
.text-above     { color: var(--color-above-curve); }
.text-below     { color: var(--color-below-curve); }

/* --- Utility: Font family --- */
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* --- Utility: Font weight --- */
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* --- Layout: Container --- */
.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

/* --- Accessibility: Screen reader only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Layout: Full-width breakout (e.g. scatter plot) --- */
.full-width {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
}

/* ============================================================
   Primary nav (desktop): from Nav.astro
   ============================================================ */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: none;
}

@media (min-width: 768px) {
  .site-nav {
    display: block;
  }
}

.site-nav .nav-inner {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-md);
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav .brand {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.site-nav .brand:hover {
  text-decoration: none;
  opacity: 0.85;
}

.site-nav .brand-logo {
  height: 60px;
  width: auto;
  display: block;
}

.site-nav .nav-links {
  list-style: none;
  display: flex;
  gap: var(--space-xl);
  align-items: center;
}

.site-nav .nav-links a {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-short) var(--ease-enter);
  padding: 12px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-nav .nav-links a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.site-nav .nav-links a.active {
  color: var(--color-accent);
}

/* ============================================================
   Mobile nav (bottom tab bar): from MobileNav.astro
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  height: 64px;
  flex-direction: row;
  align-items: stretch;
}

@media (max-width: 767px) {
  .mobile-nav {
    display: flex;
  }
}

.mobile-nav .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: 44px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-short) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav .tab:hover {
  color: var(--color-text);
  text-decoration: none;
}

.mobile-nav .tab.active {
  color: var(--color-accent);
}

.mobile-nav .tab-icon {
  font-size: 20px;
  line-height: 1;
}

.mobile-nav .tab-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ============================================================
   Format toggle bar: from BaseLayout.astro
   ============================================================ */
.format-toggle-bar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0;
}

.format-toggle {
  display: flex;
  gap: 0;
  width: fit-content;
}

.format-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  min-height: 44px;
  cursor: pointer;
  transition: color var(--duration-short) var(--ease-enter),
              border-color var(--duration-short) var(--ease-enter);
}

.format-btn.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.format-btn:hover:not(.active) {
  color: var(--color-text);
}

/* ============================================================
   Home page (pages/index.astro)
   ============================================================ */
.headline-stat {
  font-size: 14px;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-lg);
  letter-spacing: 0.01em;
}

.above-curve-link {
  color: var(--color-above-curve);
  text-decoration: none;
  border-bottom: 1px dashed var(--color-above-curve);
}

.above-curve-link:hover {
  text-decoration: none;
  border-bottom-style: solid;
}

.home-search {
  max-width: 400px;
  margin-top: var(--space-md);
}

/* ============================================================
   SearchBar component (components/SearchBar.astro)
   ============================================================ */
.search-bar {
  position: relative;
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-sm);
  color: var(--color-text-secondary);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-sm) var(--space-sm) calc(var(--space-sm) + 16px + var(--space-sm));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.4;
  min-height: 44px;
  outline: none;
  transition: border-color var(--duration-short) var(--ease-enter);
}

.search-input::placeholder {
  color: var(--color-text-secondary);
}

.search-input:focus {
  border-color: var(--color-accent);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  z-index: 100;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-results {
  list-style: none;
  max-height: 400px;
  overflow-y: auto;
}

.search-bar--compact .search-results {
  max-height: 280px;
}

.search-result {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color var(--duration-micro) var(--ease-enter);
  min-height: 44px;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result--focused,
.search-result:focus {
  background-color: rgba(212, 160, 23, 0.06);
  outline: none;
}

.search-result--empty {
  grid-template-columns: 1fr;
  cursor: default;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-style: italic;
}

.search-result--empty:hover,
.search-result--empty:focus {
  background-color: transparent;
}

.result-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-width: 0;
}

.result-subtitle {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
}

.result-meta {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.result-delta {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.delta-above { color: var(--color-above-curve); }
.delta-below { color: var(--color-below-curve); }
.delta-on    { color: var(--color-on-curve); }

/* ============================================================
   Search page (pages/search.astro)
   ============================================================ */
.search-page {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-3xl);
}

.search-page .page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

.search-bar-wrapper {
  margin-bottom: var(--space-md);
}

.search-layout {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
}

.filter-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: sticky;
  top: var(--space-lg);
}

.sidebar-header { display: none; }

.sidebar-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.filter-toggle  { display: none; }
.filter-backdrop { display: none; }

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  border: none;
  padding: 0;
  min-width: 0;
}

.filter-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2xs);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
}

.checkbox-group-vertical {
  flex-direction: column;
  gap: 0;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text);
  min-height: 32px;
  white-space: nowrap;
}

.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.filter-select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 13px;
  padding: var(--space-xs) var(--space-sm);
  min-height: 36px;
  width: 100%;
  cursor: pointer;
  outline: none;
  transition: border-color var(--duration-short) var(--ease-enter);
}

.filter-select:focus {
  border-color: var(--color-accent);
}

/* Range sliders */
.range-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.range-values {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.range-track {
  position: relative;
  height: 20px;
}

.range-input {
  position: absolute;
  width: 100%;
  height: 4px;
  top: 8px;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-text);
  border: 2px solid var(--color-border);
  cursor: pointer;
  pointer-events: all;
  position: relative;
  z-index: 2;
}

.range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-text);
  border: 2px solid var(--color-border);
  cursor: pointer;
  pointer-events: all;
}

.range-input::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
}

.range-input-min::-webkit-slider-runnable-track {
  background: transparent;
}

/* Results area */
.results-area {
  flex: 1;
  min-width: 0;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--space-sm);
  gap: var(--space-md);
}

.sort-group {
  flex-shrink: 0;
}

.sort-group .filter-select {
  width: auto;
  min-width: 180px;
}

.results-table-wrapper {
  overflow-x: auto;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-display);
  font-size: 14px;
}

.results-table thead th {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  white-space: nowrap;
  text-align: left;
  background: var(--color-surface);
}

.results-table thead th.num { text-align: right; }

.results-table tbody td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.3;
}

.results-table tbody tr:last-child td { border-bottom: none; }

.results-table tbody tr:hover td {
  background-color: var(--color-surface);
}

.col-name { text-align: left; padding-left: var(--space-md) !important; }
.col-set { text-align: left; }
.col-type { text-align: center; text-transform: capitalize; }
.col-cost, .col-delta, .col-conf, .col-adj-delta { text-align: center; }

.results-table .num {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.col-name a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.col-name a:hover {
  color: var(--color-accent);
}

.results-table .subtitle {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  font-weight: 400;
  margin-top: 1px;
}

.results-table .delta-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: var(--space-xl) var(--space-lg);
  color: var(--color-text-secondary);
  font-size: 14px;
  text-align: center;
}

.results-count {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  margin: 0;
}

.col-compare { width: 40px; text-align: center; }

.compare-icon {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14px;
  opacity: 0.5;
  transition: opacity var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter);
}

.compare-icon:hover {
  opacity: 1;
  color: var(--color-accent);
  text-decoration: none;
}

.col-adj-delta { width: 80px; }

@media (min-width: 768px) and (max-width: 1024px) {
  .filter-sidebar {
    width: 200px;
  }
}

@media (max-width: 767px) {
  .search-layout {
    flex-direction: column;
  }

  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    margin-bottom: var(--space-sm);
    min-height: 44px;
  }

  .filter-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 80vw);
    z-index: 100;
    border-radius: 0;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--duration-medium) var(--ease-move);
  }

  .filter-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .filter-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.6);
    z-index: 99;
  }

  .filter-backdrop[hidden] {
    display: none;
  }

  .col-set, .col-type { display: none; }
  .col-adj-delta { display: none; }
  .col-compare { display: none; }
}

/* ============================================================
   Sets index page (pages/sets/index.astro)
   ============================================================ */
.sets-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-3xl);
}

.sets-list .set-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
  min-height: 44px;
  transition:
    border-color var(--duration-short) var(--ease-enter),
    color var(--duration-short) var(--ease-enter);
}

.sets-list .set-card:hover {
  border-color: var(--color-accent);
  text-decoration: none;
}

.sets-list .set-card:hover .set-name {
  color: var(--color-accent);
}

.set-rank {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.sets-list .set-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--duration-short) var(--ease-enter);
}

.set-stats {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.set-count { color: var(--color-text-secondary); }
.set-divider { color: var(--color-border); }
.set-avg { font-weight: 600; }
.set-above { color: var(--color-text-secondary); }

.set-avg.above { color: var(--color-above-curve); }
.set-avg.below { color: var(--color-below-curve); }
.set-avg.on    { color: var(--color-on-curve); }

@media (max-width: 767px) {
  .sets-list {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Set show page (pages/sets/[name].astro)
   ============================================================ */
.breadcrumb {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  font-size: 14px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.stat-divider { color: var(--color-border); }

.small-sample-warning {
  margin-top: var(--space-sm);
  font-size: 13px;
  color: var(--color-below-curve);
  font-weight: 500;
}

.scatter-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-top: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.section-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

.rankings {
  margin-bottom: var(--space-2xl);
}

.rankings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.ranking-heading {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-md);
}

.above-heading { color: var(--color-above-curve); }
.below-heading { color: var(--color-below-curve); }

.ranking-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ranking-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.ranking-item:last-child {
  border-bottom: none;
}

.ranking-item .card-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--duration-short) var(--ease-enter);
  flex: 1;
  min-width: 0;
}

.ranking-item .card-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.ranking-item .card-subtitle {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

.all-cards {
  margin-bottom: var(--space-3xl);
}

.report-card-link {
  display: inline-block;
  margin-top: var(--space-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration-short) var(--ease-enter);
}

.report-card-link:hover {
  text-decoration: none;
  color: var(--color-text);
}

@media (max-width: 767px) {
  .stats-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .stat-divider { display: none; }

  .rankings-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .scatter-section {
    padding: var(--space-sm);
  }
}

/* ============================================================
   CardTable component (components/CardTable.astro)
   ============================================================ */
.card-table-wrapper {
  overflow-x: auto;
  width: 100%;
}

.card-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-display);
  font-size: 14px;
}

.card-table thead th {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  white-space: nowrap;
  text-align: left;
  user-select: none;
}

.card-table thead th.num {
  text-align: right;
}

.card-table tbody td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.card-table tbody tr:hover td {
  background-color: var(--color-surface);
}

.card-table tbody tr:last-child td {
  border-bottom: none;
}

.card-table .col-name,
.card-table .col-set,
.card-table .col-type {
  text-align: left;
}

.card-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.card-table .col-name a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

.card-table .col-name a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.card-table .subtitle {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 400;
  margin-top: var(--space-2xs);
}

[data-sortable] thead th[data-sort] {
  cursor: pointer;
}

[data-sortable] thead th[data-sort]:hover {
  color: var(--color-text);
}

/* ============================================================
   Set report card page (pages/sets/[name]/report-card.astro)
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-3xl);
  align-items: start;
}

.grade-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.grade-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.grade-letter {
  font-size: 48px;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
}

.grade-score {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  font-variant-numeric: tabular-nums;
}

.grade-stats {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-xs) 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.stat-row dt {
  color: var(--color-text-secondary);
}

.stat-row dd {
  color: var(--color-text);
  font-weight: 500;
}

.text-on { color: var(--color-on-curve); }

.type-grades {
  padding: var(--space-md);
}

.type-grades-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.type-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-xs) 0;
  font-size: 14px;
}

.type-label { color: var(--color-text); }

.type-grade {
  color: var(--color-accent);
  font-weight: 600;
  font-family: var(--font-mono);
}

.footnote-mark {
  color: var(--color-text-secondary);
  font-size: 11px;
}

.footnote {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: var(--space-sm);
  line-height: 1.4;
}

.histogram-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.histogram-container {
  position: relative;
  width: 100%;
}

.histogram-svg-wrapper {
  width: 100%;
  position: relative;
}

.histogram-svg-wrapper svg {
  display: block;
}

.standouts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.standout-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.standout-heading {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
}

.sleeper-heading {
  color: var(--color-above-curve);
  border-bottom: 2px solid var(--color-above-curve);
}

.trap-heading {
  color: var(--color-below-curve);
  border-bottom: 2px solid var(--color-below-curve);
}

.standout-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.standout-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.standout-item:last-child {
  border-bottom: none;
}

.standout-item .card-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  transition: color var(--duration-short) var(--ease-enter);
}

.standout-item .card-link:hover {
  color: var(--color-accent);
}

.standout-item .card-subtitle {
  display: block;
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 400;
  margin-top: 2px;
}

.expand-details {
  margin-top: var(--space-sm);
}

.expand-toggle {
  font-size: 13px;
  color: var(--color-accent);
  cursor: pointer;
  list-style: none;
  padding: var(--space-xs) 0;
}

.expand-toggle::-webkit-details-marker {
  display: none;
}

.expand-toggle:hover {
  text-decoration: underline;
}

.expanded-list {
  margin-top: var(--space-sm);
}

@media (max-width: 767px) {
  .dashboard {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .grade-hero {
    padding: var(--space-lg);
  }

  .grade-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--space-md);
  }

  .standouts-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

/* ============================================================
   Aspects page (pages/aspects.astro)
   ============================================================ */
.aspects-page,
.sets-page,
.archetypes-page {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.aspects-page .page-title,
.sets-page .page-title,
.archetypes-page .page-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-2xs);
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xl);
}

.aspects-page .section-heading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}

/* Heatmap */
.heatmap-section {
  margin-bottom: var(--space-2xl);
}

.heatmap-wrapper {
  overflow-x: auto;
}

.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.heatmap-corner {
  background: var(--color-bg);
}

.heatmap-set {
  padding: var(--space-xs) var(--space-sm);
  text-align: center;
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 11px;
  white-space: nowrap;
}

.heatmap-aspect {
  padding: var(--space-sm) var(--space-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 13px;
}

.heatmap-cell {
  padding: var(--space-xs) var(--space-sm);
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-bg);
  font-weight: 500;
}

.heatmap-cell--empty {
  color: var(--color-text-secondary);
  opacity: 0.3;
}

/* Aspect summary panels */
.panels-section {
  margin-bottom: var(--space-2xl);
}

.panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

@media (max-width: 767px) {
  .panels-grid {
    grid-template-columns: 1fr;
  }
}

.aspect-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.aspect-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-sm);
}

.aspect-stats-row {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.aspect-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.aspect-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.aspect-stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.aspect-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.aspect-list-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  font-weight: 500;
  display: block;
  margin-bottom: var(--space-xs);
}

.aspect-card-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 3px 0;
  text-decoration: none;
  font-size: 12px;
}

.aspect-card-row:hover {
  text-decoration: none;
}

.aspect-card-name {
  color: var(--color-text);
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.aspect-card-set {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  flex-shrink: 0;
}

/* Card list island */
.cardlist-section {
  margin-bottom: var(--space-xl);
}

.aspect-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.aspect-filters {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}

.aspect-results-count {
  color: var(--color-text-secondary);
  font-size: 12px;
  margin-bottom: var(--space-sm);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

.page-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-display);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter);
}

.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--color-text-secondary);
  color: var(--color-text);
}

.page-btn.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(200, 150, 12, 0.08);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--color-text-secondary);
  font-size: 13px;
  padding: 0 var(--space-xs);
}

.page-size-select {
  margin-left: var(--space-sm);
}

.cardlist-section .result-list {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--space-xs);
}

.cardlist-section .result-row {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
  transition: border-color var(--duration-short) var(--ease-enter),
              transform var(--duration-short) var(--ease-enter);
}

.cardlist-section .result-row:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.cardlist-section .result-art-wrap {
  aspect-ratio: 3 / 4;
  background: var(--color-bg);
  overflow: hidden;
}

.cardlist-section .result-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cardlist-section .result-body {
  padding: var(--space-xs) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cardlist-section .result-name {
  color: var(--color-text);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cardlist-section .result-meta {
  color: var(--color-text-secondary);
  font-size: 10px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cardlist-section .result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-xs) var(--space-xs);
}

.cardlist-section .result-delta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cardlist-section .filter-chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter),
              background-color var(--duration-short) var(--ease-enter);
}

.cardlist-section .filter-chip:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.cardlist-section .filter-chip.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(200, 150, 12, 0.08);
}

.cardlist-section .sort-select {
  appearance: none;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a8a9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-xl) var(--space-sm) var(--space-sm);
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--font-display);
  font-weight: 500;
  cursor: pointer;
}

.cardlist-section .sort-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.cardlist-section .filter-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

@media (max-width: 767px) {
  .cardlist-section .result-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   Compare page (pages/compare.astro + components/CompareView.astro)
   ============================================================ */
.compare-page {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.compare-root {
  max-width: var(--max-width);
  margin-inline: auto;
}

.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-lg);
}

.compare-header-left { flex: 1; }

.compare-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-2xs);
}

.compare-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0;
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  min-height: 40px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  transition: color var(--duration-short) var(--ease-enter),
              border-color var(--duration-short) var(--ease-enter),
              background-color var(--duration-short) var(--ease-enter);
}

.clear-btn:hover {
  color: var(--color-below-curve);
  border-color: var(--color-below-curve);
  background: rgba(248, 81, 73, 0.06);
}

/* Slots */
.compare-slots {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.slot {
  flex: 1;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 72px;
  transition: border-color var(--duration-short) var(--ease-enter);
}

.slot.active { border-color: var(--color-accent); }

.slot.filled {
  border-style: solid;
  border-color: var(--color-border);
  background: var(--color-surface);
}

.slot-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.slot.filled .slot-number {
  background: var(--color-accent);
  color: var(--color-bg);
}

.slot-empty {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.slot-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.slot-art {
  width: 40px;
  height: 56px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  object-fit: cover;
}

.slot-info {
  flex: 1;
  min-width: 0;
}

.slot-name {
  color: var(--color-text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-meta {
  color: var(--color-text-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
}

.slot-delta {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.slot-remove {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: var(--space-xs);
  line-height: 1;
}

.slot-remove:hover { color: var(--color-text); }

/* Compare picker — search */
.compare-root .search-wrapper {
  position: relative;
  margin-bottom: var(--space-md);
}

.compare-root .search-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  font-size: 16px;
  pointer-events: none;
}

.compare-root .search-input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 14px 16px 14px 40px;
  min-height: 48px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  font-family: var(--font-display);
  box-sizing: border-box;
  transition: border-color var(--duration-short) var(--ease-enter),
              background-color var(--duration-short) var(--ease-enter);
}

.compare-root .search-input::placeholder {
  color: var(--color-text-secondary);
}

.compare-root .search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-bg);
}

/* Compare results — same card grid as aspects */
.compare-root .filter-chips {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}

.compare-root .filter-chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter),
              background-color var(--duration-short) var(--ease-enter);
}

.compare-root .filter-chip:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.compare-root .filter-chip.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(212, 160, 23, 0.08);
}

.compare-root .filter-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.compare-root .sort-select {
  appearance: none;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: var(--space-sm) var(--space-xl) var(--space-sm) var(--space-sm);
  min-height: 36px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--font-display);
  font-weight: 500;
  cursor: pointer;
}

.compare-root .sort-select:focus {
  outline: none;
  border-color: var(--color-accent);
  color: var(--color-text);
}

.compare-root .results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.compare-root .results-count {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.compare-root .result-list {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--space-xs);
}

.compare-root .result-row {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--duration-short) var(--ease-enter),
              transform var(--duration-short) var(--ease-enter);
}

.compare-root .result-row:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.compare-root .result-art-wrap {
  aspect-ratio: 3 / 4;
  background: var(--color-bg);
  overflow: hidden;
}

.compare-root .result-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.compare-root .result-body {
  padding: var(--space-xs) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.compare-root .result-name {
  color: var(--color-text);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.compare-root .result-meta {
  color: var(--color-text-secondary);
  font-size: 10px;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-root .result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-xs) var(--space-xs);
}

.compare-root .result-delta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-add {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: 2px var(--space-xs);
  border-radius: var(--radius-sm);
  font-size: 10px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 500;
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter),
              background-color var(--duration-short) var(--ease-enter);
}

.result-add:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: rgba(212, 160, 23, 0.08);
}

/* Comparison area */
.comparison-area { position: relative; }

.compare-columns {
  display: flex;
  gap: var(--space-lg);
  align-items: stretch;
}

.card-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-col-art {
  height: 200px;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-col-art img {
  height: 100%;
  width: auto;
}

.card-col-info { padding: var(--space-md); }

.card-col-name {
  color: var(--color-text);
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 2px;
}

.card-col-meta {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-family: var(--font-mono);
  margin-bottom: var(--space-md);
}

.score-section { padding: 0 var(--space-md) var(--space-md); }

.score-section-title {
  color: var(--color-text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
  font-weight: 500;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px var(--space-sm);
  border-bottom: 1px solid var(--color-bg);
  font-size: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.score-row:last-child { border-bottom: none; }

.score-label  { color: var(--color-text-secondary); }
.score-winner { color: var(--color-above-curve); font-weight: 600; }
.score-loser  { color: var(--color-below-curve); }
.score-tie    { color: var(--color-text); }

.delta-row {
  border-radius: var(--radius-md);
  margin-top: var(--space-sm);
  padding: var(--space-sm) !important;
  border: none !important;
}

.delta-row.winner { background: rgba(63, 185, 80, 0.1); }
.delta-row.loser  { background: rgba(248, 81, 73, 0.06); }

.keywords-section,
.ability-section { padding: 0 var(--space-md) var(--space-md); }

.ability-section { flex: 1; }

.archetype-summary {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archetype-leader {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.archetype-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}

.keyword-pill {
  display: inline-block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin: 2px;
  font-family: var(--font-mono);
}

.keyword-pill.unique {
  border-color: var(--color-above-curve);
  color: var(--color-above-curve);
}

.ability-text {
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.5;
  font-style: italic;
}

.confidence-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  margin-top: auto;
  border-top: 1px solid var(--color-border);
}

.confidence-bar .conf-title {
  font-size: 11px;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.confidence-bar.winner .conf-title {
  color: var(--color-above-curve);
}

.conf-track {
  flex: 1;
  height: 4px;
  background: var(--color-bg);
  border-radius: 2px;
  overflow: hidden;
}

.conf-fill { height: 100%; border-radius: 2px; }

.conf-label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.vs-badge {
  position: absolute;
  left: 50%;
  top: 220px;
  transform: translate(-50%, -50%);
  z-index: 10;
  background: var(--color-accent);
  color: var(--color-bg);
  font-weight: 700;
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767px) {
  .compare-slots { flex-direction: column; }
  .compare-columns { flex-direction: column; }
  .vs-badge {
    position: static;
    transform: none;
    margin: var(--space-sm) auto;
  }
  .compare-root .result-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   Scatter plot (components/ScatterPlot.astro)
   ============================================================ */
.scatter-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  width: fit-content;
}

.scatter-mode-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-md);
  line-height: 1.4;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-short) var(--ease-enter);
}

.toggle-btn.active {
  background: var(--color-accent);
  color: var(--color-bg);
}

.toggle-btn:hover:not(.active) {
  color: var(--color-text);
}

.scatter-container {
  position: relative;
  width: 100%;
}

.scatter-svg-wrapper {
  position: relative;
  width: 100%;
}

.scatter-svg-wrapper svg {
  display: block;
}

.scatter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 12px;
  font-family: var(--font-display, Geist, system-ui, sans-serif);
  font-size: 12px;
  color: var(--color-text-secondary, #94a3b8);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-item svg {
  flex-shrink: 0;
}

.legend-curve svg {
  overflow: visible;
}

.scatter-tooltip {
  max-width: 300px;
  min-width: 180px;
  white-space: normal;
  word-break: break-word;
}

.axis-x .domain,
.axis-y .domain {
  display: none;
}

@media (max-width: 767px) {
  .scatter-legend {
    gap: 4px 10px;
    font-size: 11px;
  }
}

.scatter-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-top: var(--space-md);
}

.explainer {
  margin-top: var(--space-2xl);
}

.explainer-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.explainer-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.explainer-body em {
  font-style: normal;
  color: var(--color-text);
}

.learn-re-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  margin-top: var(--space-sm);
  transition: opacity var(--duration-short) var(--ease-enter);
}

.learn-re-btn:hover {
  opacity: 0.85;
}

/* RE Modal */
.re-modal {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  max-width: 1000px;
  width: calc(100% - var(--space-2xl));
  padding: 0;
  overflow: hidden;
  margin: auto;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.re-modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.re-modal-inner {
  padding: var(--space-xl);
  max-height: 80vh;
  overflow-y: auto;
}

.re-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.re-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.re-modal-close {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--duration-short) var(--ease-enter),
              border-color var(--duration-short) var(--ease-enter);
}

.re-modal-close:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.re-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.re-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.re-block-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.re-block-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.re-block-body strong {
  color: var(--color-text);
  font-weight: 600;
}

.re-scale {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.re-scale-row {
  display: flex;
  gap: var(--space-md);
  align-items: baseline;
}

.re-scale-row dt {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  min-width: 140px;
  text-transform: none;
  letter-spacing: 0;
  padding: 0;
}

.re-scale-row dd {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.4;
  padding: 0;
}

@media (max-width: 767px) {
  .re-grid {
    grid-template-columns: 1fr;
  }
}

/* Browse by Set */
.browse-sets {
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

.sets-heading {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

.sets-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

.sets-grid .set-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  height: 56px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter);
}

.sets-grid .set-card:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

.sets-grid .set-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.set-grade-badge {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-accent);
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

@media (max-width: 767px) {
  .scatter-hero {
    padding: var(--space-sm);
  }

  .sets-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .explainer {
    margin-top: var(--space-xl);
  }

  .browse-sets {
    margin-top: var(--space-xl);
  }
}

/* ============================================================
   Delta + confidence badges (DeltaBadge.astro, ConfidenceBadge.astro)
   ============================================================ */
.delta-badge {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.delta-badge.above { color: var(--color-above-curve); }
.delta-badge.below { color: var(--color-below-curve); }
.delta-badge.on    { color: var(--color-on-curve); }

.confidence-badge {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-xs);
}

.confidence-badge .pct {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 16px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
}

.confidence-badge .low-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--color-below-curve);
  line-height: 1;
}

/* ============================================================
   Card detail page (pages/card/[id].astro)
   ============================================================ */
.page {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
  transition: color var(--duration-short) var(--ease-enter);
}

.back-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.card-header {
  display: flex;
  gap: var(--space-xl);
  align-items: flex-start;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-lg);
}

.card-art {
  flex-shrink: 0;
}

.card-art img {
  border-radius: var(--radius-lg);
  display: block;
  width: 200px;
  height: auto;
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.card-name {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

.card-subtitle {
  font-weight: 400;
  color: var(--color-text-secondary);
}

.badge-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
}

.rotation-badge {
  background: var(--color-below-curve);
  color: var(--color-bg);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: var(--space-sm);
}

.compare-link {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 4px 12px;
  border-radius: var(--radius-md);
  transition: border-color var(--duration-short) var(--ease-enter),
              color var(--duration-short) var(--ease-enter);
}

.compare-link:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

@media (max-width: 767px) {
  .card-header {
    flex-direction: column;
    align-items: center;
  }
  .card-art img {
    width: 160px;
  }
}

.body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

@media (max-width: 767px) {
  .body-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.panel-heading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

/* Δ tier badges (Exceptional / Above Curve / Fair Value / Below Curve / Significantly Overcosted) */
.tier-badge {
  display: inline-block;
  margin-left: var(--space-xs);
  padding: 2px 8px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  vertical-align: middle;
  white-space: nowrap;
}

.tier-badge.tier-exceptional {
  color: #fff;
  background: var(--color-above-curve);
  border-color: var(--color-above-curve);
}

.tier-badge.tier-above {
  color: var(--color-above-curve);
  border-color: var(--color-above-curve);
  background: rgba(34, 197, 94, 0.1);
}

.tier-badge.tier-fair {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.tier-badge.tier-below {
  color: var(--color-below-curve);
  border-color: var(--color-below-curve);
  background: rgba(239, 68, 68, 0.1);
}

.tier-badge.tier-overcosted {
  color: #fff;
  background: var(--color-below-curve);
  border-color: var(--color-below-curve);
}

/* Score-explainer tooltip used on card detail + compare pages */
.score-tt {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--color-text-secondary);
  display: inline;
}

.score-tt__content {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 200;
  min-width: 260px;
  max-width: 360px;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text);
  text-align: left;
  white-space: normal;
  cursor: default;
}

.score-tt:hover .score-tt__content,
.score-tt:focus .score-tt__content,
.score-tt:focus-within .score-tt__content {
  display: block;
}

.score-tt__title {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.score-tt__line {
  display: block;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}

.score-tt__line + .score-tt__line {
  border-top: 1px dashed var(--color-border);
}

.breakdown-table tr + tr td {
  border-top: 1px solid var(--color-border);
}

.breakdown-explainer {
  margin-top: var(--space-md);
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
}

.breakdown-explainer strong {
  color: var(--color-text);
  font-weight: 600;
}

.breakdown-explainer--muted {
  border-left-color: var(--color-border);
  font-style: italic;
}

.row-label {
  padding: var(--space-sm) 0;
  font-size: 14px;
  color: var(--color-text-secondary);
}

.row-detail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-left: var(--space-xs);
}

.row-value {
  padding: var(--space-sm) 0;
  text-align: right;
  font-size: 14px;
  color: var(--color-text);
}

.row-tier {
  padding: var(--space-sm) 0;
  text-align: center;
  width: 1%; /* shrink to content; label + value flex around it */
  white-space: nowrap;
}

.row-tier .tier-badge {
  margin-left: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.total-row td {
  font-weight: 700;
  color: var(--color-text);
  border-top: 1px solid var(--color-border) !important;
  padding-top: var(--space-sm);
}

.total-row .row-label {
  color: var(--color-text);
}

.metadata-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-lg);
  align-items: baseline;
}

.metadata-grid dt {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  white-space: nowrap;
  padding: var(--space-xs) 0;
}

.metadata-grid dd {
  font-size: 14px;
  color: var(--color-text);
  padding: var(--space-xs) 0;
}

.metadata-grid dd.capitalize {
  text-transform: capitalize;
}

/* Abilities sections */
.abilities-section {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.abilities-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.ability-pill {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.5;
}

.ability-pill--unscored {
  background: transparent;
  border-style: dashed;
  color: var(--color-text-secondary);
}

.unscored-note {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-below-curve);
}

/* Variant printings */
.printings-section {
  margin-top: var(--space-xl);
}

.printings-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.printing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.printing-card img {
  border-radius: var(--radius-md);
  display: block;
  width: 140px;
  height: auto;
}

.printing-set {
  text-align: center;
  max-width: 140px;
}

/* Similar cards row */
.similar-section {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.similar-grid {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
}

.similar-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  padding: var(--space-sm);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-short) var(--ease-enter);
  width: 140px;
}

.similar-card:hover {
  border-color: var(--color-accent);
  text-decoration: none;
}

.similar-art {
  width: 120px;
  height: 168px;
  border-radius: var(--radius-md);
  object-fit: cover;
  display: block;
}

.similar-art--placeholder {
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.similar-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.similar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.similar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.similar-cost {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 767px) {
  .similar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow-x: visible;
  }

  .similar-card {
    width: auto;
  }
}

.page-footer {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
  margin-top: var(--space-sm);
}

/* Tournament data panel */
.tournament-panel {
  margin-bottom: var(--space-xl);
}

.tournament-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-md);
}

.tournament-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tournament-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.tournament-value {
  font-size: 14px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.tournament-divider {
  border-top: 1px solid var(--color-border);
  margin: var(--space-md) 0;
}

.tournament-grid-secondary .tournament-stat {
  gap: 2px;
}

.tournament-value-sm {
  font-size: 16px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.play-pattern-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Per-format score sections (card detail + compare) ────────────────── */

/* Small label that appears above each format's score block */
.format-score-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

/* Container for one format's Theoretical + Adjusted rows on the detail page */
.format-score-section {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: opacity var(--duration-short) var(--ease-enter),
              border-color var(--duration-short) var(--ease-enter);
}

/* Active format: subtle gold glow, full opacity.
   Uses box-shadow instead of border-left to avoid AI Slop anti-pattern #8
   ("colored left-border on cards"). Gold from DESIGN.md accent (#c8960c). */
.format-score-section--active {
  box-shadow: inset 0 0 0 1px rgba(200, 150, 12, 0.3);
  background: rgba(200, 150, 12, 0.04);
  opacity: 1;
}

/* Inactive format: dimmed but legible (0.65, not 0.45 which was too aggressive
   on the dark background — secondary text became nearly invisible). */
.format-score-section--dim {
  opacity: 0.65;
}

/* Inner table inside a format section — no extra top margin */
.format-score-table {
  margin-top: var(--space-xs);
}

/* Panel heading format indicator (e.g. "(Premier)") */
.panel-heading-fmt {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--color-text-secondary);
}

/* Badge indicating a card is Eternal-only */
.format-label-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
}

.format-label-badge--eternal {
  color: #58a6ff;
  border-color: #58a6ff;
  background: rgba(88, 166, 255, 0.08);
}

/* Note line in tournament panel when other format also has data */
.tournament-other-fmt-note {
  margin-top: var(--space-md);
  font-size: 11px;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* Compare page: format score section inside a card column */
.card-col .format-score-section {
  margin-top: var(--space-sm);
}

.card-col .format-score-label {
  margin-bottom: 2px;
}

/* ── Archetype usage on card detail ──────────────────────────────────── */

.archetype-usage-panel {
  margin-top: var(--space-lg);
}

.archetype-usage-list {
  display: flex;
  flex-direction: column;
}

.archetype-usage-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  text-decoration: none;
  color: var(--color-text);
}

.archetype-usage-row + .archetype-usage-row {
  border-top: 1px solid var(--color-border);
}

.archetype-usage-row:hover .archetype-usage-name {
  color: var(--color-accent);
}

.archetype-usage-thumb {
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.archetype-usage-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archetype-usage-stats {
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
}

.archetype-usage-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

@media (max-width: 768px) {
  .archetype-usage-row {
    flex-wrap: wrap;
  }

  .archetype-usage-stats {
    width: 100%;
    justify-content: space-between;
    padding-left: 44px;
  }
}

/* ── Archetypes page ─────────────────────────────────────────────────── */

.archetype-table-wrapper {
  overflow-x: auto;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.archetype-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-display);
  font-size: 14px;
}

.archetype-table thead th {
  padding: var(--space-sm) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  white-space: nowrap;
  text-align: left;
  background: var(--color-surface);
}

.archetype-table thead th.col-num { text-align: center; }

.archetype-table tbody td {
  padding: var(--space-sm) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.3;
}

.archetype-table tbody tr:last-child td { border-bottom: none; }

.archetype-table tbody tr:hover td {
  background-color: var(--color-surface);
}

.archetype-table .col-num {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.leader-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text);
  text-decoration: none;
  padding-left: var(--space-xs);
}

.leader-link:hover .leader-name {
  color: var(--color-accent);
}

.leader-thumb {
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.leader-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.leader-name {
  font-weight: 500;
  font-size: 14px;
}

.leader-base {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.col-cards {
  max-width: 320px;
}

.top-card-pill {
  display: inline-block;
  padding: var(--space-2xs) var(--space-xs);
  margin: var(--space-2xs);
  font-size: 11px;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
}

.top-card-pill:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}

@media (max-width: 768px) {
  .col-cards,
  .archetype-table thead th.col-cards { display: none; }

  .leader-thumb { width: 36px; height: 50px; }
}

/* ── Archetype detail page ───────────────────────────────────────────── */

.archetype-detail .page-title {
  margin-bottom: var(--space-2xs);
}

.archetype-detail .panel {
  margin-bottom: var(--space-md);
}

.archetype-hero {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.archetype-hero-art {
  border-radius: var(--radius-md);
  object-fit: contain;
  flex-shrink: 0;
}

.archetype-hero-info {
  flex: 1;
}

.archetype-hero-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.hero-winrate {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hero-winrate-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

/* Base tabs */
.base-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
}

.base-tab {
  padding: var(--space-xs) var(--space-sm);
  font-size: 12px;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 150ms, color 150ms;
}

.base-tab:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

.base-tab--active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* Stat bar */
.archetype-stats-panel {
  padding: var(--space-md) var(--space-lg);
}

.archetype-stat-row {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) 0;
}

.archetype-stat-row + .archetype-stat-row {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-md);
  margin-top: var(--space-xs);
}

.archetype-stat-row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  min-width: 60px;
  flex-shrink: 0;
}

.archetype-stat-row .tournament-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

.archetype-stat-row .tournament-stat {
  text-align: center;
}

.archetype-stat-row .tournament-value-sm {
  font-size: 18px;
  font-weight: 600;
}

/* Card breakdown grid (core + flex) */
.card-breakdown-grid {
  display: flex;
  flex-direction: column;
}

.card-breakdown-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  text-decoration: none;
  color: var(--color-text);
  transition: background 150ms;
  margin: 0 calc(-1 * var(--space-sm));
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
  border-radius: var(--radius-sm);
}

.card-breakdown-row + .card-breakdown-row {
  border-top: none;
}

.card-breakdown-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.card-breakdown-row:hover .card-breakdown-name {
  color: var(--color-accent);
}

.card-breakdown-thumb {
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.card-breakdown-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.card-breakdown-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 150ms;
}

.card-breakdown-subtitle {
  font-size: 11px;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-breakdown-stats {
  display: grid;
  grid-template-columns: 70px 70px 50px 70px;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.card-breakdown-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.card-breakdown-stat .tournament-label {
  font-size: 9px;
}

.card-breakdown-stat .tournament-value-sm {
  font-size: 13px;
}

/* Flex panel */
.archetype-flex-panel {
  opacity: 0.8;
  transition: opacity 200ms;
}

.archetype-flex-panel:hover {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .archetype-hero {
    flex-wrap: wrap;
  }

  .archetype-hero-stat {
    width: 100%;
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-sm);
  }

  .hero-winrate { font-size: 28px; }

  .archetype-stat-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .archetype-stat-row .tournament-grid {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .card-breakdown-stats {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .card-breakdown-row {
    flex-wrap: wrap;
  }
}

/* ── Scoring page ────────────────────────────────────────────────────── */

.scoring-page {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.scoring-page .panel {
  margin-bottom: var(--space-md);
}

.scoring-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
}

.scoring-body p {
  margin: 0 0 var(--space-md);
}

.scoring-body p:last-child {
  margin-bottom: 0;
}

.scoring-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px var(--space-xs);
  border-radius: var(--radius-sm);
}

.scoring-body ol {
  padding-left: var(--space-lg);
  margin: 0 0 var(--space-md);
}

.scoring-body li {
  margin-bottom: var(--space-sm);
}

.scoring-formula {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md) 0;
}

.formula-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}

.formula-row + .formula-row {
  border-top: 1px solid var(--color-border);
}

.formula-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  min-width: 100px;
}

.formula-value {
  font-size: 13px;
  color: var(--color-text);
}

.scoring-scale {
  margin: var(--space-md) 0;
}

.scale-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
}

.scale-row + .scale-row {
  border-top: 1px solid var(--color-border);
}

.scale-badge {
  font-size: 13px;
  min-width: 160px;
  flex-shrink: 0;
}

.scale-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.scoring-patterns {
  margin: var(--space-md) 0;
}

.pattern-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.pattern-row + .pattern-row {
  border-top: 1px solid var(--color-border);
}

.pattern-badge {
  font-size: 12px;
  font-weight: 500;
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.pattern-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.scoring-steps {
  padding-left: var(--space-lg);
}

.scoring-metric {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
}

.source-list {
  margin: 0;
}

.source-row {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.source-row + .source-row {
  border-top: 1px solid var(--color-border);
}

.source-row dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 140px;
  flex-shrink: 0;
}

.scoring-expand {
  margin-top: var(--space-md);
}

.scoring-expand-toggle {
  cursor: pointer;
  font-size: 13px;
  color: var(--color-accent);
  font-weight: 500;
}

.scoring-expand-toggle:hover {
  text-decoration: underline;
}

.scoring-expand-body {
  margin-top: var(--space-md);
}

.scoring-expand-body h4 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm);
}

.scoring-tier-group {
  margin-bottom: var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.scoring-tier-group[open] {
  margin-bottom: var(--space-sm);
}

.scoring-tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  list-style: none;
}

.scoring-tier-header::-webkit-details-marker {
  display: none;
}

.scoring-tier-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tier-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

.tier-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.scoring-tier-group .scoring-formula {
  border-top: 1px solid var(--color-border);
  margin: 0;
  border-radius: 0;
  padding: var(--space-xs) var(--space-md);
}

.scoring-subheading {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin: var(--space-lg) 0 var(--space-sm);
}

.source-row dd {
  font-size: 13px;
  margin: 0;
}

.text-accent {
  color: var(--color-accent);
}
