/**
 * PoGO Pal - Styles
 * Design System v4 - "Pokédex Companion" Light Theme
 */

/* ============================================
   DESIGN SYSTEM TOKENS
   ============================================ */
:root {
  /* Background Hierarchy (light to dark for depth) */
  --bg-page: #F5F0E6;
  --bg-surface: #EDE8DC;
  --bg-surface-alt: #E5DFD0;
  --bg-inset: #DDD7C7;

  /* Legacy aliases (for compatibility during migration) */
  --bg-primary: var(--bg-page);
  --bg-secondary: var(--bg-surface);
  --bg-card: var(--bg-surface);

  /* Brand Colors */
  --color-primary: #DC0A2D;
  --color-primary-hover: #B8082A;
  --color-primary-active: #9A0623;
  --color-secondary: #3B7A8C;
  --color-secondary-hover: #2D5F6D;
  --color-secondary-active: #1F444E;

  /* Legacy alias */
  --accent: var(--color-primary);

  /* Text Colors */
  --text-primary: #2D3436;
  --text-secondary: #5A6366;
  --text-muted: #8B9396;
  --text-inverse: #FFFFFF;

  /* Border Colors */
  --border-default: #C4BBA8;
  --border-strong: #9A9282;
  --border-subtle: #D9D2C2;
  --border-color: var(--border-default);

  /* State Colors */
  --color-success: #4CAF50;
  --color-warning: #FF9800;
  --color-error: #F44336;
  --color-info: #2196F3;

  /* Shadows */
  --shadow-inset: inset 2px 2px 4px rgba(0,0,0,0.1);
  --shadow-panel: inset 1px 1px 0 rgba(255,255,255,0.5), 2px 2px 0 rgba(0,0,0,0.15);

  /* Typography */
  --font-display: "Press Start 2P", monospace;
  --font-body: "VT323", monospace;
  --font-pixel: "Press Start 2P", monospace;

  /* Font Sizes - Display */
  --text-display-lg: 16px;
  --text-display-md: 12px;
  --text-display-sm: 10px;
  --text-display-xs: 8px;

  /* Font Sizes - Body */
  --text-body-lg: 24px;
  --text-body-md: 20px;
  --text-body-sm: 18px;
  --text-body-xs: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition-normal: 0.2s ease;

  /* Layout constants */
  --appbar-h: 52px;
  --appbar-real-h: var(--appbar-h);
  --modebar-h: 44px;
  --modebar-real-h: 44px;
  --utilbar-h: 44px;
  --utilbar-real-h: var(--utilbar-h);
  --typebar-h: 48px;
  --collectionbar-h: 60px;
  --collectionbar-real-h: var(--collectionbar-h);
  --filterzone-real-h: 0px;
  --sticky-offset: 0px;
  --table-sticky-top: 0px;
  --sticky-stack-h: 0px;

  /* Type colors (Pokemon GO palette) */
  --t-normal: #A8A878;
  --t-fire: #F08030;
  --t-water: #6890F0;
  --t-electric: #F8D030;
  --t-grass: #78C850;
  --t-ice: #98D8D8;
  --t-fighting: #C03028;
  --t-poison: #A040A0;
  --t-ground: #E0C068;
  --t-flying: #A890F0;
  --t-psychic: #F85888;
  --t-bug: #A8B820;
  --t-rock: #B8A038;
  --t-ghost: #705898;
  --t-dragon: #7038F8;
  --t-dark: #705848;
  --t-steel: #B8B8D0;
  --t-fairy: #EE99AC;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Subtle scanline overlay for device feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.015) 2px,
    rgba(0,0,0,0.015) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

button { font-family: inherit; }

/* ============================================
   LAYOUT
   ============================================ */
.app {
  max-width: 1200px;
  margin: 0 auto;
}

/* Sticky app bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--bg-surface);
  border-bottom: 3px solid var(--border-strong);
}

.appbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.appbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 54vw;
}

/* ============================================
   COMPONENTS
   ============================================ */
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-surface-alt);
}

.icon-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.close-x {
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1;
}


.skin-mark {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.6px;
  opacity: 0.95;
  user-select: none;
}

/* Hidden file input */
.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   GBA/DS SKIN - Design System v4 Light Theme
   ============================================ */
html[data-skin="gba-ds"] {
  /* Typography aliases for legacy compatibility */
  --font-ui: var(--font-display);
  --font-size-label: var(--text-display-xs);
  --letter-spacing-label: 0.5px;
}

/* Title uses display font */
html[data-skin="gba-ds"] .title {
  font-family: var(--font-display);
  font-size: var(--text-display-md);
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-primary);
}

/* Labels use display font */
html[data-skin="gba-ds"] .collection-note,
html[data-skin="gba-ds"] .sheet-title,
html[data-skin="gba-ds"] .panel-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Skin mark styling */
html[data-skin="gba-ds"] .skin-mark {
  font-family: var(--font-display);
}

/* ============================================
   APP WINDOW (Browser-style container)
   ============================================ */
.app-window {
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.window-tabs {
  display: flex;
  background: var(--bg-inset);
  border-bottom: 2px solid var(--border-default);
  padding: 0;
}

.window-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.window-tab:hover {
  background: rgba(255, 255, 255, 0.5);
}

.window-tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: normal;
}

.window-content {
  padding: var(--space-md);
}

/* ============================================
   MODE BAR (Legacy - kept for reference)
   ============================================ */
.modebar {
  position: sticky;
  top: var(--appbar-real-h);
  z-index: 190;
  height: var(--modebar-h);
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  gap: var(--space-md);
  background: var(--bg-page);
}

.modebar-inner {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--bg-inset);
  box-shadow: var(--shadow-inset);
}

.mode-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  line-height: 1;
  height: 28px;
  padding: 0 var(--space-md);
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--transition-fast);
}

.mode-tab:hover:not(.is-active) {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.mode-tab.is-active {
  background: var(--color-primary);
  color: var(--text-inverse);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.2), 1px 1px 0 rgba(0,0,0,0.2);
}

/* ============================================
   UTILITY ROW
   ============================================ */
.utility-row {
  position: sticky;
  top: calc(var(--appbar-real-h) + var(--modebar-real-h));
  z-index: 195;
  height: var(--utilbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  gap: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.utility-left { display: flex; align-items: center; gap: var(--space-md); }
.utility-right { display: flex; align-items: center; gap: var(--space-md); }

.util-btn {
  appearance: none;
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  height: 32px;
  padding: 0 var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  transition: all var(--transition-fast);
}

.util-btn:hover {
  background: var(--bg-surface-alt);
}

.util-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.util-icon .icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.util-label {
  font-weight: inherit;
  letter-spacing: 0.5px;
}

/* Help button (? icon) */
.icon-btn.gbp-q {
  width: 28px;
  height: 28px;
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1;
  background: var(--bg-surface-alt);
  border: 2px solid var(--border-default);
  border-radius: 50%;
  color: var(--text-secondary);
}

.icon-btn.gbp-q:hover {
  background: var(--color-secondary);
  color: var(--text-inverse);
  border-color: var(--color-secondary);
}

/* ============================================
   COLLECTION BAR & FILTER ZONE
   ============================================ */
.collectionbar {
  min-height: var(--collectionbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-md);
  border-bottom: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
}

.collection-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.collection-stat {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.25;
  color: var(--text-primary);
  white-space: nowrap;
}

.collection-stat strong {
  color: var(--color-primary);
}

.collection-note {
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.filterzone {
  border-bottom: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
}

/* Active filters strip */
.active-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
}

.active-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.types-open-btn {
  touch-action: manipulation;
  z-index: 2;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  height: 32px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.types-open-btn:hover {
  background: var(--bg-surface-alt);
}

.types-open-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.types-open-icon {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  background: var(--color-primary);
  border: 1px solid var(--color-primary-hover);
  color: var(--text-inverse);
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}

.active-icons {
  z-index: 1;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  overflow: visible;
  padding: 2px 0;
}

.active-all {
  color: var(--text-secondary);
  font-size: 0.92rem;
  white-space: nowrap;
}

.icon-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.2);
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.2);
  flex: 0 0 auto;
}

.icon-chip.is-selected {
  box-shadow: 0 0 0 2px var(--bg-page), 0 0 0 4px var(--text-primary);
}

.icon-chip svg {
  width: 16px;
  height: 16px;
  fill: var(--text-inverse);
  opacity: 0.95;
}

.icon-chip-btn {
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-chip-btn:hover {
  background: var(--bg-surface-alt);
}

.icon-chip-btn:active { transform: translateY(1px); }

.clear-btn {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  align-self: flex-start;
}

.clear-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

/* ============================================
   BOTTOM SHEET
   ============================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-bottom: none;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  max-height: 78vh;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.sheet-actions {
  display: inline-flex;
  gap: var(--space-sm);
  align-items: center;
}

.sheet-btn {
  height: 28px;
  padding: 0 var(--space-md);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.sheet-btn:hover {
  background: var(--bg-surface-alt);
}

.sheet-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.sheet-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

.sheet-btn.ghost:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.sheet-body {
  padding: var(--space-md);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

@media (min-width: 520px) {
  .type-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Universal type pill - used everywhere for type indicators */
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
}

.type-pill .icon-chip {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.type-pill .type-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Interactive pill states (buttons) */
button.type-pill {
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

button.type-pill:hover {
  background: var(--bg-surface-alt);
}

.type-pill.is-selected {
  border-color: var(--text-primary);
  background: var(--bg-inset);
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.1);
}

.sheet-hint {
  margin-top: var(--space-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  padding: var(--space-md);
}

.showing-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin: var(--space-sm) 0 var(--space-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 18px;
}

.showing-row strong {
  color: var(--text-primary);
}

.hint {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
  margin: 0 0 var(--space-md);
}

/* ============================================
   PANELS
   ============================================ */
.panel {
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}

.panel-header {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0;
}

.panel-header .sub {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
}

/* ============================================
   TABLE
   ============================================ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-family: var(--font-body);
  font-size: 20px;
}

th, td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

th {
  position: sticky;
  top: var(--table-sticky-top);
  z-index: 20;
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border-strong);
}

td {
  color: var(--text-primary);
}

tr:hover td {
  background: var(--bg-surface-alt);
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  background: var(--bg-inset);
}

th.sortable:active { transform: translateY(1px); }

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.sort-ind {
  font-size: 10px;
  color: var(--color-primary);
}

.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================================
   ERROR PANEL
   ============================================ */
.error-panel {
  margin: var(--space-sm) var(--space-md) 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-error);
  background: #fff5f5;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.3;
}

.error-panel .error-title {
  font-family: var(--font-display);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--color-error);
  margin-bottom: var(--space-xs);
}

.error-panel .error-meta {
  color: var(--text-secondary);
  font-size: 16px;
}

.error-panel code {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-error);
  background: transparent;
}

/* ============================================
   INFO DRAWER
   ============================================ */
body.no-scroll { overflow: hidden; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2100;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(380px, 92vw);
  background: var(--bg-surface);
  border-left: 3px solid var(--border-strong);
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
  transform: translateX(104%);
  transition: transform 180ms ease;
  z-index: 2200;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  position: sticky;
  top: 0;
  background: var(--bg-surface-alt);
  border-bottom: 2px solid var(--border-default);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-primary);
}

.drawer-content {
  padding: var(--space-md);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-content details {
  border: 2px solid var(--border-default);
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  box-shadow: var(--shadow-inset);
}

.drawer-content summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 8px;
  text-transform: uppercase;
  color: var(--text-primary);
  list-style: none;
}

.drawer-content summary::-webkit-details-marker { display: none; }

.drawer-content .gloss {
  margin-top: var(--space-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  line-height: 1.35;
  font-size: 18px;
}

.drawer-content code {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg-surface-alt);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.grade-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xs) var(--space-sm);
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  font-size: 16px;
}

.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface-alt);
  font-family: var(--font-display);
  font-size: 8px;
  color: var(--text-primary);
  min-width: 32px;
}

/* ============================================
   DEBUG PANEL
   ============================================ */
.debug-details {
  margin: var(--space-sm) var(--space-md) 0 var(--space-md);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-default);
  background: var(--bg-inset);
  overflow: hidden;
}

.debug-details > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--text-primary);
}

.debug-details > summary::-webkit-details-marker { display: none; }
.debug-details > summary .mono { color: var(--text-muted); font-size: 16px; }

.debug-body {
  padding: var(--space-sm) var(--space-md) var(--space-md) var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.debug-block + .debug-block { margin-top: var(--space-sm); }
.debug-label { font-family: var(--font-display); font-size: 8px; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-xs); }
.debug-chipwrap { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

.debug-chip {
  font-family: var(--font-body);
  font-size: 16px;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debug-mapping, .debug-sample {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

/* ============================================
   VS MODE
   ============================================ */
.vs-panel {
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-panel);
}

.vs-panel-header {
  position: relative;
  background: var(--bg-surface-alt);
  margin: calc(-1 * var(--space-md));
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-default);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.panel-section-header {
  background: var(--bg-surface-alt);
  margin: var(--space-md) calc(-1 * var(--space-md));
  padding: var(--space-sm) var(--space-md);
  border-top: 2px solid var(--border-default);
  border-bottom: 2px solid var(--border-default);
}

.vs-panel-title {
  font-family: var(--font-display);
  font-size: var(--text-display-sm);
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.panel-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
}

.info-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: var(--space-xs);
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: var(--bg-surface-alt);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 8px;
  cursor: pointer;
  vertical-align: middle;
}

.info-icon-btn:hover {
  background: var(--color-secondary);
  color: var(--text-inverse);
  border-color: var(--color-secondary);
}

/* Modal styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}

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

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: 101;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-default);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.modal-close-btn {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-md);
}

.modal-body .t {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.modal-body .t + .t {
  margin-top: var(--space-sm);
}

.vs-block {
  margin-top: var(--space-md);
}

.vs-block-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.vs-k {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  text-transform: uppercase;
  color: var(--text-secondary);
}

.vs-details {
  margin: var(--space-sm) 0;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  background: var(--bg-inset);
  box-shadow: var(--shadow-inset);
}

.vs-details:not([open]) {
  display: none;
}

.vs-summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
}

.vs-summary::-webkit-details-marker { display: none; }

.vs-actions {
  margin-top: var(--space-sm);
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}


.vs-hero {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
}

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

.vs-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
}

.vs-empty-upload {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.vs-note {
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

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

.brief-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
}

.brief-k {
  font-family: var(--font-display);
  font-size: var(--text-display-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.brief-k strong {
  color: var(--text-primary);
}

.brief-v {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

/* Battle elements */
.battle-selected-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

/* Hide selected pills row when picker is expanded */
.vs-block:has(.vs-details[open]) .battle-selected-wrap {
  display: none;
}

.battle-selected {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.battle-selected-note {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
}

.battle-selected-note.flash {
  animation: flash-note 0.4s ease;
}

@keyframes flash-note {
  0%, 100% { color: var(--text-muted); }
  50% { color: var(--color-error); }
}

.battle-tiprow {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
  position: relative;
}

.battle-tiprow .tip-label {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-muted);
}

.battle-tiprow .tip-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.battle-tiprow .tip-btn:hover {
  background: var(--color-secondary);
  color: var(--text-inverse);
  border-color: var(--color-secondary);
}

.battle-tooltip {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: var(--space-xs);
  width: min(320px, calc(100vw - 56px));
  border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  padding: var(--space-md);
  color: var(--text-primary);
  z-index: 10;
}

.battle-tooltip .t {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.battle-tooltip .t + .t { margin-top: var(--space-sm); }

/* Poke cards */
.poke-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
}

.poke-name {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.poke-meta {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.poke-types {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* ============================================
   UTILITIES
   ============================================ */
#viewVersus,
#viewCollection,
#viewTrade { display: contents; }

#viewVersus[hidden],
#viewCollection[hidden],
#viewTrade[hidden] { display: none !important; }

.icon {
  width: 18px;
  height: 18px;
  opacity: 0.95;
  fill: currentColor;
}

/* ============================================
   MOBILE TWEAKS
   ============================================ */
@media (max-width: 480px) {
  :root {
    --appbar-h: 50px;
    --typebar-h: 46px;
  }
  .title { max-width: 52vw; }
  th, td { padding: 9px 10px; font-size: 0.9rem; }
  .main { padding: 10px; }
}
