/* ============================================================
   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);
}

.role-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  cursor: help;
}

.role-tag--staple {
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
}

.role-tag--build-around {
  background: color-mix(in srgb, var(--color-warning, #c48a2e) 15%, transparent);
  color: var(--color-warning, #c48a2e);
  border-color: color-mix(in srgb, var(--color-warning, #c48a2e) 40%, transparent);
}

.row-label--sub {
  padding-left: var(--space-md);
  color: var(--color-text-secondary);
  font-size: 13px;
  cursor: help;
}

.split-row .row-value {
  font-size: 13px;
}

.sort-group {
  flex-shrink: 0;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

.sort-group .filter-label {
  margin-bottom: 0;
  white-space: nowrap;
}

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

.filter-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.pagy-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
  padding: var(--space-md) 0;
  font-size: 14px;
}

.pagy-nav a,
.pagy-nav span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  text-decoration: none;
  background: var(--color-surface);
}

.pagy-nav a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pagy-nav .current {
  background: var(--color-accent);
  color: var(--color-bg);
  border-color: var(--color-accent);
}

.pagy-nav .gap {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
}

.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; }
.col-pattern { text-align: left; white-space: nowrap; }

.pattern-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.pattern-tag--none {
  color: var(--color-text-secondary);
  opacity: 0.5;
  font-weight: 400;
}

.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);
  }
}

/* Leader compare bar (compare page) */
.leader-compare-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  position: relative;
}
.leader-compare-bar::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-accent);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.leader-compare-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  white-space: nowrap;
}
.leader-compare-bar .leader-select {
  max-width: 340px;
}
.leader-adjusted-section {
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-accent) 20%, var(--color-border));
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
}
.leader-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-xs);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 20%, var(--color-border));
}
/* Compare page leader tournament stats */
.leader-compare-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  border-top: 1px solid color-mix(in srgb, var(--color-accent) 15%, var(--color-border));
  padding-top: 6px;
  margin-top: 6px;
}
.lcs-label {
  font-size: 10px;
  color: var(--color-text-secondary);
}
.lcs-value {
  font-size: 11px;
  font-weight: 600;
  float: right;
}

@media (max-width: 767px) {
  .leader-compare-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .leader-compare-bar .leader-select {
    max-width: 100%;
  }
}

/* ============================================================
   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;
  }
}

/* ── Leader-Adjusted Score ───────────────────────────────────────────── */

.leader-adjusted-panel {
  margin-top: var(--space-lg);
}

.leader-select-form {
  margin-bottom: var(--space-md);
}

.leader-select-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.leader-select-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  white-space: nowrap;
}

.leader-select {
  flex: 1;
  max-width: 360px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237a8a9e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.leader-select:hover {
  border-color: var(--color-accent);
}

.leader-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 25%, transparent);
}

.leader-select option {
  background: var(--color-surface);
  color: var(--color-text);
}

.leader-adjusted-result {
  margin-top: var(--space-sm);
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-accent) 20%, var(--color-border));
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
}

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

.leader-adjusted-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

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

.leader-adjusted-arrow {
  font-size: 20px;
  color: var(--color-accent);
}

.leader-adjusted-delta {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.leader-adjusted-breakdown {
  list-style: none;
  padding: 0;
  margin: var(--space-sm) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.leader-adjusted-line {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  transition: border-color 150ms ease-out;
}

.leader-adjusted-line:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.leader-adjusted-empty {
  font-size: 13px;
  color: var(--color-text-secondary);
  padding: var(--space-sm) 0;
  font-style: italic;
}

@media (max-width: 768px) {
  .leader-select-row {
    flex-direction: column;
    align-items: stretch;
  }

  .leader-select {
    max-width: 100%;
  }

  .leader-adjusted-comparison {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Leader tournament stats (card show page) */
.leader-tournament-stats {
  border-top: 1px solid color-mix(in srgb, var(--color-accent) 20%, var(--color-border));
  padding-top: var(--space-sm);
  margin-top: var(--space-sm);
}
.leader-tournament-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}
.leader-tournament-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}
.leader-tournament-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tournament-sub {
  font-size: 10px;
  color: var(--color-text-secondary);
}
.aspect-pills {
  display: flex;
  gap: 4px;
  margin-left: var(--space-xs);
}
.aspect-pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}
@media (max-width: 768px) {
  .leader-tournament-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 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);
}

/* ── Auth Pages (Devise) ─────────────────────────────────────────────── */

.auth-card {
  max-width: 400px;
  margin: var(--space-xl) auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-lg);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.auth-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

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

.auth-input {
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-mono);
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.auth-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
  color: var(--color-text-secondary);
}

.auth-checkbox input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
}

.auth-checkbox label {
  cursor: pointer;
}

.auth-actions {
  margin-top: var(--space-sm);
}

.auth-submit {
  width: 100%;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.auth-submit:hover {
  opacity: 0.9;
}

.auth-links {
  margin-top: var(--space-md);
  text-align: center;
}

.auth-links a {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.auth-links a:hover {
  color: var(--color-accent);
}

.auth-errors {
  padding: var(--space-sm);
  background: #7f1d1d22;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
}

.auth-errors p {
  margin: 0;
}

.auth-errors p + p {
  margin-top: var(--space-xs);
}

/* ── Flash Bars ──────────────────────────────────────────────────────── */

.flash-bar {
  padding: var(--space-sm) 0;
  font-size: 13px;
  font-weight: 500;
}

.flash-bar--notice {
  background: #22c55e18;
  border-bottom: 1px solid #22c55e44;
  color: #86efac;
}

.flash-bar--alert {
  background: #ef444418;
  border-bottom: 1px solid #ef444444;
  color: #fca5a5;
}

.flash-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.flash-bar-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 var(--space-xs);
  opacity: 0.7;
  line-height: 1;
}

.flash-bar-close:hover {
  opacity: 1;
}

/* ── Site Footer ─────────────────────────────────────────────────────── */

.site-footer {
  margin-top: var(--space-xl);
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--color-border);
}

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

.footer-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-sm);
}

.footer-text {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.subscribe-form {
  max-width: 400px;
}

.subscribe-row {
  display: flex;
  gap: var(--space-xs);
}

.subscribe-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.subscribe-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.subscribe-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.subscribe-btn:hover {
  opacity: 0.9;
}

.footer-link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-link-list li {
  margin-bottom: var(--space-xs);
}

.footer-link-list a {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.footer-link-list a:hover {
  color: var(--color-accent);
}

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

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

/* ── Feedback Form ───────────────────────────────────────────────────── */

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.feedback-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.feedback-input,
.feedback-select {
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-mono);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.feedback-input:focus,
.feedback-select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.feedback-editor {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 14px;

  /* Editor sizing — taller editing area */
  --lexxy-editor-rows: 16lh;

  /* Toolbar button sizing — consistent icon heights */
  --lexxy-toolbar-button-size: 32px;
  --lexxy-toolbar-icon-size: 16px;

  /* Override Lexxy variables for dark theme */
  --lexxy-color-ink: #f5f7fa;
  --lexxy-color-ink-medium: #94a3b8;
  --lexxy-color-ink-light: #64748b;
  --lexxy-color-ink-lighter: #334155;
  --lexxy-color-ink-lightest: #1e293b;
  --lexxy-color-ink-inverted: #05070f;
  --lexxy-color-canvas: var(--color-surface);
  --lexxy-color-text: var(--color-text);
  --lexxy-color-text-subtle: var(--color-text-secondary);
  --lexxy-color-link: var(--color-accent);
  --lexxy-color-selected: #1e3a5f;
  --lexxy-color-selected-hover: #264b7a;
  --lexxy-color-selected-dark: var(--color-accent);
  --lexxy-color-code-bg: #0f1424;
  --lexxy-color-accent-dark: var(--color-accent);
  --lexxy-color-accent-medium: #7dd3fc;

  /* Dark mode syntax highlighting */
  --lexxy-color-code-token-att: #f97583;
  --lexxy-color-code-token-comment: #8b949e;
  --lexxy-color-code-token-function: #d2a8ff;
  --lexxy-color-code-token-operator: #f97583;
  --lexxy-color-code-token-property: #79c0ff;
  --lexxy-color-code-token-punctuation: #c9d1d9;
  --lexxy-color-code-token-selector: #7ee787;
  --lexxy-color-code-token-variable: #ffa657;
}

/* Ensure content area inside editor inherits the mono font */
.feedback-editor .lexxy-editor__content {
  font-family: var(--font-mono);
  font-size: 14px;
}

/* Align all toolbar buttons and dropdowns to same height */
.feedback-editor .lexxy-editor__toolbar-button,
.feedback-editor .lexxy-editor__toolbar-dropdown summary {
  block-size: 32px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.feedback-editor .lexxy-editor__toolbar-dropdown summary svg,
.feedback-editor .lexxy-editor__toolbar-button svg {
  block-size: 16px;
  inline-size: 16px;
}

.feedback-errors {
  padding: var(--space-sm);
  background: #7f1d1d22;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
}

.feedback-submit {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--color-bg);
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.feedback-submit:hover {
  opacity: 0.9;
}

/* ── Admin Dashboard ─────────────────────────────────────────────────── */

.admin-body { background: var(--color-bg); color: var(--color-text); }

.admin-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-md);
}

.admin-nav-inner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 1200px;
  margin: 0 auto;
}

.admin-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  white-space: nowrap;
}

.admin-nav-links {
  display: flex;
  list-style: none;
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  flex: 1;
}

.admin-nav-links a { font-size: 13px; color: var(--color-text-secondary); text-decoration: none; }
.admin-nav-links a:hover { color: var(--color-text); }

.admin-user { font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; }
.admin-user a { color: var(--color-accent); text-decoration: none; }

.admin-main { padding: var(--space-lg) 0; }
.admin-container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-md); }

.admin-page-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

.admin-section-heading {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin: var(--space-lg) 0 var(--space-md);
}

.admin-flash {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: var(--space-md);
}

.admin-flash--notice { background: #22c55e22; border: 1px solid #22c55e44; color: #86efac; }
.admin-flash--alert { background: #ef444422; border: 1px solid #ef444444; color: #fca5a5; }

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.admin-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.admin-stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: var(--color-accent); }
.admin-stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-secondary); }
.admin-stat-link { font-size: 12px; color: var(--color-accent); text-decoration: none; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-secondary); padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--color-border);
}
.admin-table td { padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--color-border); vertical-align: top; }
.admin-table tr:hover { background: var(--color-surface); }

.admin-table-link-row td a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.admin-table-link-row { cursor: pointer; }
.admin-table-link-row:hover td a { color: var(--color-accent); }

.admin-badge {
  font-size: 11px; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--color-surface); border: 1px solid var(--color-border); white-space: nowrap;
}

.admin-status-badge { font-size: 11px; padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.admin-status--pending { background: #facc1522; color: #facc15; }
.admin-status--considered { background: #22c55e22; color: #22c55e; }
.admin-status--dismissed { background: #94a3b822; color: #94a3b8; }

.admin-form { display: flex; flex-direction: column; gap: var(--space-md); max-width: 600px; }
.admin-form-field { display: flex; flex-direction: column; gap: var(--space-xs); }
.admin-form-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-secondary); }

.admin-form-input,
.admin-form-textarea {
  padding: 8px 12px; font-size: 14px; font-family: var(--font-mono);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.admin-form-textarea { min-height: 150px; resize: vertical; }
.admin-form-input:focus, .admin-form-textarea:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; }

.admin-btn {
  display: inline-flex; padding: 8px 16px; font-size: 13px; font-weight: 600;
  font-family: var(--font-display); border: none; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; text-align: center;
}
.admin-btn--primary { background: var(--color-accent); color: var(--color-bg); }
.admin-btn--success { background: #22c55e; color: #000; }
.admin-btn--muted { background: var(--color-surface); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.admin-btn--danger { background: #ef4444; color: #fff; }
.admin-btn:hover { opacity: 0.9; }

.admin-btn-row { display: flex; gap: var(--space-sm); margin-top: var(--space-md); }

.admin-detail-row { display: flex; gap: var(--space-md); margin-bottom: var(--space-sm); font-size: 13px; }
.admin-detail-label { font-weight: 600; color: var(--color-text-secondary); min-width: 100px; }
.admin-detail-value { color: var(--color-text); }

.admin-body-preview {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: var(--space-md);
  font-size: 14px; line-height: 1.6; margin: var(--space-md) 0;
}

.admin-filter-tabs { display: flex; gap: var(--space-sm); margin-bottom: var(--space-md); }
.admin-filter-tab {
  padding: 6px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; text-decoration: none; border-radius: var(--radius-sm);
  color: var(--color-text-secondary); background: var(--color-surface); border: 1px solid var(--color-border);
}
.admin-filter-tab--active { color: var(--color-accent); border-color: var(--color-accent); }

/* Synergy pills (archetypes page) */
.synergy-pill {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}
.synergy-pill--positive {
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
}
.synergy-pill--negative {
  color: var(--color-below-curve);
  background: color-mix(in srgb, var(--color-below-curve) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-below-curve) 30%, transparent);
}
.card-breakdown-row--gem {
  border-left: 2px solid var(--color-accent);
}
.panel-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}
