/* ===== DESIGN TOKENS ===== */
:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-lg:   clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1rem    + 1.5vw,  2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);
  --text-hero: clamp(3rem,     0.5rem  + 7vw,    8rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Fonts */
  --font-display: 'Clash Display', 'Inter', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content Widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
  --content-full: 100%;
}

/* ===== LIGHT MODE ===== */
:root, [data-theme="light"] {
  --color-bg:             #F0EDE8;
  --color-surface:        #F5F2ED;
  --color-surface-2:      #FAF8F5;
  --color-surface-offset: #E8E4DE;
  --color-surface-offset-2: #DDD9D2;
  --color-surface-dynamic: #D4D0C9;
  --color-divider:        #CCC8C0;
  --color-border:         #B8B4AC;
  --color-text:           #1A1714;
  --color-text-muted:     #6B6860;
  --color-text-faint:     #A8A49C;
  --color-text-inverse:   #F0EDE8;
  --color-primary:        #B8912E;
  --color-primary-hover:  #9A7825;
  --color-primary-active: #7C5F1C;
  --color-primary-highlight: #E8DCC4;
  --color-secondary:      #2E7AB8;
  --color-secondary-hover:#256498;
  --color-success:        #2A9E48;
  --color-success-hover:  #228838;
  --color-success-highlight: #D0E8D4;
  --color-error:          #D42B4A;
  --color-error-hover:    #B82240;
  --color-error-highlight: #E8CED4;
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 80 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 80 / 0.08);
  --shadow-lg: 0 12px 32px oklch(0.2 0.01 80 / 0.12);
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --color-bg:             #0D0F12;
  --color-surface:        #111318;
  --color-surface-2:      #161A22;
  --color-surface-offset: #1A1E27;
  --color-surface-offset-2: #1E2330;
  --color-surface-dynamic: #252A36;
  --color-divider:        #2A2F3A;
  --color-border:         #2A2F3A;
  --color-text:           #E8E6E1;
  --color-text-muted:     #8B8D94;
  --color-text-faint:     #52545A;
  --color-text-inverse:   #0D0F12;
  --color-primary:        #D4A843;
  --color-primary-hover:  #E8B84A;
  --color-primary-active: #C09838;
  --color-primary-highlight: #2A2418;
  --color-secondary:      #4A9FD9;
  --color-secondary-hover:#5BB0E8;
  --color-success:        #34C759;
  --color-success-hover:  #40D466;
  --color-success-highlight: #1A2E1E;
  --color-error:          #FF3B5C;
  --color-error-hover:    #FF5070;
  --color-error-highlight: #2E1A1E;
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.25);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0D0F12; --color-surface: #111318; --color-surface-2: #161A22;
    --color-surface-offset: #1A1E27; --color-surface-offset-2: #1E2330;
    --color-surface-dynamic: #252A36; --color-divider: #2A2F3A; --color-border: #2A2F3A;
    --color-text: #E8E6E1; --color-text-muted: #8B8D94; --color-text-faint: #52545A;
    --color-text-inverse: #0D0F12;
    --color-primary: #D4A843; --color-primary-hover: #E8B84A; --color-primary-active: #C09838;
    --color-primary-highlight: #2A2418;
    --color-secondary: #4A9FD9; --color-secondary-hover: #5BB0E8;
    --color-success: #34C759; --color-success-hover: #40D466; --color-success-highlight: #1A2E1E;
    --color-error: #FF3B5C; --color-error-hover: #FF5070; --color-error-highlight: #2E1A1E;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.25);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.35);
    --shadow-lg: 0 12px 32px oklch(0 0 0 / 0.5);
  }
}

/* ===== SKELETON LOADERS ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--color-surface-offset) 25%,
    var(--color-surface-dynamic) 50%,
    var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 1em; margin-bottom: var(--space-2); }
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 1.5em; width: 40%; margin-bottom: var(--space-4); }
.skeleton-image { aspect-ratio: 745/1040; width: 100%; border-radius: var(--radius-lg); }
.skeleton-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

/* ===== LAYOUT ===== */
.container {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-4);
}
.container-narrow {
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: oklch(from var(--color-bg) l c h / 0.85);
  backdrop-filter: blur(16px) saturate(1.8);
  -webkit-backdrop-filter: blur(16px) saturate(1.8);
  border-bottom: 1px solid var(--color-border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  max-width: var(--content-wide);
  margin-inline: auto;
}
.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.logo-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  cursor: pointer;
}
.logo-link:hover { color: var(--color-primary); }
.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo-text span { color: var(--color-primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
}
.nav-links a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-interactive),
              background var(--transition-interactive);
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--color-text);
  background: var(--color-surface-offset);
}
.nav-links a.active { color: var(--color-primary); }

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.cart-badge {
  position: relative;
}
.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  line-height: 1;
}
.cart-count:empty,
.cart-count[data-count="0"] { display: none; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-interactive),
              background var(--transition-interactive);
}
.icon-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}
.icon-btn svg { width: 20px; height: 20px; }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
}
@media (max-width: 767px) {
  .mobile-menu-btn { display: flex; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
  }
}

/* ===== TICKER STRIP ===== */
.ticker-strip {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
  white-space: nowrap;
  height: 36px;
  display: flex;
  align-items: center;
}
.ticker-track {
  display: inline-flex;
  gap: var(--space-8);
  animation: ticker 60s linear infinite;
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text-muted);
}
.ticker-item .ticker-name {
  font-weight: 600;
  color: var(--color-text);
}
.ticker-item .ticker-price {
  color: var(--color-text);
}
.ticker-item .up { color: var(--color-success); }
.ticker-item .down { color: var(--color-error); }
@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ===== HERO SECTION ===== */
.hero {
  padding: clamp(var(--space-12), 8vw, var(--space-32)) var(--space-4);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, oklch(from var(--color-primary) l c h / 0.06) 0%, transparent 70%);
  pointer-events: none;
}
.hero-tagline {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: var(--space-6);
  background: linear-gradient(135deg, #D4A843 0%, #E8B84A 40%, #D4A843 60%, #C09838 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: goldShimmer 4s ease-in-out infinite;
}
@keyframes goldShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.hero-sub {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
  max-width: 600px;
  margin-inline: auto;
}
.hero-search {
  max-width: 600px;
  margin: 0 auto var(--space-8);
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-12);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}
.hero-search input::placeholder { color: var(--color-text-faint); }
.hero-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.15);
}
.hero-search .search-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}
.hero-search .search-icon svg { width: 20px; height: 20px; }

/* Autocomplete dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.autocomplete-item:hover {
  background: var(--color-surface-offset);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
}
.hero-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums lining-nums;
}
.hero-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition-interactive),
              color var(--transition-interactive),
              box-shadow var(--transition-interactive),
              transform var(--transition-interactive);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-primary);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}
.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover {
  background: var(--color-error-hover);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
}
.badge-success {
  color: var(--color-success);
  background: var(--color-success-highlight);
}
.badge-error {
  color: var(--color-error);
  background: var(--color-error-highlight);
}
.badge-gold {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.badge-blue {
  color: var(--color-secondary);
  background: oklch(from var(--color-secondary) l c h / 0.12);
}

/* ===== SEARCH PAGE ===== */
.search-page {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-6);
  padding: var(--space-6) 0;
}
@media (max-width: 767px) {
  .search-page {
    grid-template-columns: 1fr;
  }
}

/* Filters */
.filter-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
@media (max-width: 767px) {
  .filter-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-3);
  }
}
.filter-group h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}
.filter-group {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.color-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.color-filter-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: border-color var(--transition-interactive),
              transform var(--transition-interactive);
  cursor: pointer;
}
.color-filter-btn:hover,
.color-filter-btn.active {
  border-color: var(--color-primary);
  transform: scale(1.1);
}
.color-filter-btn.white-btn { background: #F9FAF4; color: #333; }
.color-filter-btn.blue-btn { background: #0E68AB; color: #fff; }
.color-filter-btn.black-btn { background: #150B00; color: #999; }
.color-filter-btn.red-btn { background: #D3202A; color: #fff; }
.color-filter-btn.green-btn { background: #00733E; color: #fff; }

.filter-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text);
  cursor: pointer;
}
.price-range-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.price-input {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums lining-nums;
}
.price-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Search bar in search page */
.search-bar-wrapper {
  margin-bottom: var(--space-6);
}
.search-bar {
  position: relative;
  max-width: 100%;
}
.search-bar input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.15);
}
.search-bar .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--space-4);
}
.mtg-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition-interactive),
              border-color var(--transition-interactive),
              transform var(--transition-interactive);
}
.mtg-card:hover {
  box-shadow: 0 0 20px oklch(from var(--color-primary) l c h / 0.15);
  border-color: oklch(from var(--color-primary) l c h / 0.4);
  transform: translateY(-2px);
}
.mtg-card-image {
  aspect-ratio: 745/1040;
  background: var(--color-surface-offset);
  overflow: hidden;
  position: relative;
}
.mtg-card-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--color-surface-offset) 0%, var(--color-surface-dynamic) 100%);
  z-index: 0;
}
.mtg-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}
.mtg-card-info {
  padding: var(--space-3);
}
.mtg-card-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mtg-card-set {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.mtg-card-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mtg-card-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-sm);
}
.mtg-card-change {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
}
.price-up { color: var(--color-success); }
.price-down { color: var(--color-error); }

/* ===== CARD DETAIL ===== */
.card-detail {
  padding: var(--space-6) 0;
}
.card-detail-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: var(--space-8);
  align-items: start;
}
@media (max-width: 767px) {
  .card-detail-grid {
    grid-template-columns: 1fr;
  }
}
.card-detail-image {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 80px;
}
.card-detail-image img {
  width: 100%;
  display: block;
}
.card-detail-info h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.card-detail-set {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* Price breakdown */
.price-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.price-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.price-box-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.price-box-value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
}

/* Chart container */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}
.chart-container h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
}
.chart-container canvas {
  max-height: 300px;
}

/* Action buttons */
.card-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* Legality badges */
.legality-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.legality-badge {
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
}
.legality-legal {
  background: var(--color-success-highlight);
  color: var(--color-success);
}
.legality-not-legal {
  background: var(--color-surface-offset);
  color: var(--color-text-faint);
}

/* ===== PORTFOLIO ===== */
.portfolio-page {
  padding: var(--space-6) 0;
}
.portfolio-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--color-text);
  line-height: 1.2;
}
.kpi-delta {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Portfolio table */
.portfolio-table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.portfolio-table {
  width: 100%;
  border-collapse: collapse;
}
.portfolio-table thead {
  border-bottom: 1px solid var(--color-border);
}
.portfolio-table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-align: left;
  white-space: nowrap;
}
.portfolio-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums lining-nums;
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.portfolio-table tbody tr:hover {
  background: var(--color-surface-offset);
}
.portfolio-table .card-name-cell {
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}
.portfolio-table .card-name-cell:hover {
  color: var(--color-primary);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-4);
  color: var(--color-text-faint);
}
.empty-state h3 {
  font-family: var(--font-display);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
}
.empty-state p {
  max-width: 36ch;
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

/* ===== CART ===== */
.cart-page {
  padding: var(--space-6) 0;
}
.cart-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 767px) {
  .cart-grid {
    grid-template-columns: 1fr;
  }
}
.cart-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cart-item {
  display: flex;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  align-items: center;
}
.cart-item-image {
  width: 60px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cart-item-image img {
  width: 100%;
  display: block;
}
.cart-item-details {
  flex: 1;
  min-width: 0;
}
.cart-item-name {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 2px;
}
.cart-item-set {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.qty-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-offset);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--transition-interactive);
}
.qty-btn:hover { background: var(--color-surface-dynamic); }
.qty-value {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  font-size: var(--text-sm);
}
.cart-item-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-sm);
  min-width: 70px;
  text-align: right;
}
.cart-item-remove {
  color: var(--color-text-faint);
  transition: color var(--transition-interactive);
}
.cart-item-remove:hover { color: var(--color-error); }

/* Order summary */
.order-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: sticky;
  top: 80px;
}
.order-summary h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-4);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums lining-nums;
}
.summary-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  font-weight: 700;
  font-size: var(--text-base);
}
.checkout-btn {
  width: 100%;
  margin-top: var(--space-4);
  padding: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
}
.coming-soon-notice {
  text-align: center;
  padding: var(--space-4);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-primary);
}
.coming-soon-notice.hidden { display: none; }

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-4);
  text-align: center;
}
.footer-inner {
  max-width: var(--content-wide);
  margin-inline: auto;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.footer-links a {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-interactive);
}
.footer-links a:hover { color: var(--color-primary); }
.footer-credit {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.footer-credit a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-interactive);
}
.footer-credit a:hover { color: var(--color-primary); }

/* ===== LOADING / PAGE TRANSITIONS ===== */
.page-view {
  opacity: 0;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.page-view.active {
  opacity: 1;
}
.page-view:not(.active) {
  display: none;
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: var(--space-4);
  cursor: pointer;
  transition: color var(--transition-interactive);
}
.back-link:hover { color: var(--color-primary); }

/* ===== PAGE HEADING ===== */
.page-heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
}

/* ===== SCROLL REVEAL ===== */
@supports (animation-timeline: scroll()) {
  .fade-in {
    opacity: 0;
    animation: revealFade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}
@keyframes revealFade {
  to { opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767px) {
  .hero-stats { gap: var(--space-4); }
  .card-detail-image { position: static; }
  .price-breakdown { grid-template-columns: repeat(2, 1fr); }
}

/* ===== AI CHATBOT ===== */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #D4A843, #C09838);
  color: #0D0F12;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px oklch(from #D4A843 l c h / 0.35);
  z-index: 200;
  transition: transform var(--transition-interactive),
              box-shadow var(--transition-interactive);
}
.chatbot-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px oklch(from #D4A843 l c h / 0.5);
}
.chatbot-fab.hidden { display: none; }

.chatbot-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chatbot-panel.open {
  display: flex;
  animation: chatSlideUp 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-offset);
}
.chatbot-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
}
.chatbot-close {
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-interactive),
              color var(--transition-interactive);
}
.chatbot-close:hover {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.chat-msg {
  display: flex;
  max-width: 85%;
}
.chat-msg.bot-msg { align-self: flex-start; }
.chat-msg.user-msg { align-self: flex-end; }
.chat-bubble {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
  word-break: break-word;
}
.bot-msg .chat-bubble {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}
.user-msg .chat-bubble {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}
.chat-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--color-text-faint);
  border-radius: var(--radius-full);
  animation: typingDot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.chatbot-input-area {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-offset);
}
.chatbot-input-area input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive);
}
.chatbot-input-area input::placeholder { color: var(--color-text-faint); }
.chatbot-input-area input:focus {
  outline: none;
  border-color: var(--color-primary);
}
#chatbot-send {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  transition: background var(--transition-interactive);
}
#chatbot-send:hover { background: var(--color-primary-hover); }
#chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .chatbot-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ===== LOCAL STORES SECTION ===== */
.local-stores-section {
  padding: var(--space-16) 0 var(--space-20);
  position: relative;
  overflow: hidden;
}
.local-stores-section::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 600px;
  background: radial-gradient(ellipse, oklch(from var(--color-primary) l c h / 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.stores-header {
  text-align: center;
  margin-bottom: var(--space-10);
}
.stores-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.stores-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.stores-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}
@media (max-width: 767px) {
  .stores-grid {
    grid-template-columns: 1fr;
  }
}

.store-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color 300ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.store-card:hover {
  border-color: oklch(from var(--color-primary) l c h / 0.5);
  box-shadow: 0 0 24px oklch(from var(--color-primary) l c h / 0.12),
              inset 0 1px 0 oklch(from var(--color-primary) l c h / 0.08);
}

.store-card-header {
  padding: var(--space-5) var(--space-5) var(--space-3);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.store-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}
.store-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.2);
  white-space: nowrap;
  flex-shrink: 0;
}

.store-card-body {
  padding: 0 var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.store-detail {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.store-detail a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-interactive);
}
.store-detail a:hover {
  color: var(--color-primary-hover);
}
.store-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--color-primary);
  margin-top: 2px;
}

.store-card-footer {
  padding: var(--space-3) var(--space-5) var(--space-5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border-top: 1px solid var(--color-divider);
}
.store-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
}

/* ===== STORE PAGE (dedicated view) ===== */
.store-page {
  padding: var(--space-6) 0 var(--space-16);
}
.store-page-header {
  text-align: center;
  margin-bottom: var(--space-8);
}
.store-page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-3);
  background: linear-gradient(135deg, #D4A843 0%, #E8B84A 40%, #D4A843 60%, #C09838 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.store-page-intro {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 600px;
  margin-inline: auto;
  margin-bottom: var(--space-6);
}
.store-page-links {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.store-page .stores-grid {
  margin-bottom: var(--space-10);
}

/* Detailed store card in store page */
.store-card-detailed {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color 300ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.store-card-detailed:hover {
  border-color: oklch(from var(--color-primary) l c h / 0.5);
  box-shadow: 0 0 24px oklch(from var(--color-primary) l c h / 0.12);
}
.store-card-detailed .store-card-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
}
.store-card-detailed .store-name {
  font-size: var(--text-xl);
}
.store-card-detailed .store-card-body {
  padding: 0 var(--space-6) var(--space-5);
  gap: var(--space-4);
}
.store-card-detailed .store-detail {
  font-size: var(--text-sm);
}
.store-card-detailed .store-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
}
.store-card-detailed .store-card-footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  border-top: none;
}
.store-card-detailed .store-tag {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
}

.store-community-note {
  text-align: center;
  padding: var(--space-6);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-xl);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.15);
}
.store-community-note p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 500px;
  margin-inline: auto;
}
.store-community-note strong {
  color: var(--color-primary);
}

/* ===== FOOTER GUAM ===== */
.footer-guam {
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

/* ===== HERO SEARCH GRADIENT BORDER ON FOCUS ===== */
.hero-search input:focus {
  border-color: transparent;
  background-image: linear-gradient(var(--color-surface), var(--color-surface)),
                    linear-gradient(135deg, #D4A843, #E8B84A, #C09838, #D4A843);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.15),
              0 0 20px oklch(from var(--color-primary) l c h / 0.08);
}

/* ===== MOBILE MENU IMPROVEMENTS ===== */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.5);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-menu-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 767px) {
  .nav-links.open {
    animation: slideDown 300ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== BACK TO TOP BUTTON ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 300ms cubic-bezier(0.16, 1, 0.3, 1),
              background 180ms cubic-bezier(0.16, 1, 0.3, 1),
              color 180ms cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(10px);
  box-shadow: var(--shadow-md);
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

/* ===== CARD 3D TILT HOVER ===== */
.mtg-card {
  perspective: 800px;
}
.mtg-card:hover {
  transform: translateY(-2px) rotateX(1deg) rotateY(-1deg);
}

/* ===== PAGE LOAD FADE IN ===== */
@keyframes heroFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.hero {
  animation: heroFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.hero-tagline {
  animation: heroFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) 100ms both;
}
.hero-sub {
  animation: heroFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) 200ms both;
}
.hero-search {
  animation: heroFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) 300ms both;
}
.hero-stats {
  animation: heroFadeIn 600ms cubic-bezier(0.16, 1, 0.3, 1) 400ms both;
}

/* ===== ENHANCED SCROLL REVEAL ===== */
@supports (animation-timeline: scroll()) {
  .local-stores-section {
    opacity: 0;
    animation: revealFade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }
  .store-card {
    opacity: 0;
    animation: revealFade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 80%;
  }
}

/* ================================================================
   GUAM MARKETPLACE
   ================================================================ */

/* --- Marketplace Header --- */
.mp-header {
  text-align: center;
  margin-bottom: var(--space-6);
}
.mp-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
  background: linear-gradient(135deg, #D4A843 0%, #E8B84A 40%, #D4A843 60%, #C09838 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mp-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.mp-stats-bar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.mp-stats-bar .mp-stat-highlight {
  color: var(--color-primary);
  font-weight: 600;
}

/* --- Top Actions Bar --- */
.mp-top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* --- Marketplace Filters --- */
.mp-filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.mp-filter-search {
  flex: 1;
  min-width: 180px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive);
}
.mp-filter-search::placeholder { color: var(--color-text-faint); }
.mp-filter-search:focus {
  outline: none;
  border-color: var(--color-primary);
}
.mp-filter-select {
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text);
  cursor: pointer;
  min-width: 120px;
}
.mp-type-toggles {
  display: flex;
  gap: 2px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--color-border);
}
.mp-type-toggle {
  padding: var(--space-1) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition-interactive),
              color var(--transition-interactive);
  white-space: nowrap;
}
.mp-type-toggle:hover { color: var(--color-text); }
.mp-type-toggle.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

@media (max-width: 767px) {
  .mp-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .mp-filter-search { min-width: 100%; }
  .mp-type-toggles { justify-content: center; }
  .mp-top-actions { flex-direction: column; }
}

/* --- Marketplace Listing Grid --- */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

/* --- Marketplace Listing Card --- */
.mp-listing-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-interactive),
              border-color var(--transition-interactive),
              transform var(--transition-interactive);
}
.mp-listing-card:hover {
  box-shadow: 0 0 20px oklch(from var(--color-primary) l c h / 0.15);
  border-color: oklch(from var(--color-primary) l c h / 0.4);
  transform: translateY(-2px);
}
.mp-listing-image {
  aspect-ratio: 745/1040;
  background: linear-gradient(135deg, var(--color-surface-offset) 0%, var(--color-surface-dynamic) 100%);
  overflow: hidden;
  position: relative;
}
.mp-listing-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mp-listing-badges {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  right: var(--space-2);
  display: flex;
  justify-content: space-between;
  z-index: 2;
  pointer-events: none;
}
.mp-badge-condition {
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mp-badge-condition.cond-nm { background: rgba(52, 199, 89, 0.85); color: #fff; }
.mp-badge-condition.cond-lp { background: rgba(74, 159, 217, 0.85); color: #fff; }
.mp-badge-condition.cond-mp { background: rgba(212, 168, 67, 0.85); color: #1A1714; }
.mp-badge-condition.cond-hp { background: rgba(255, 59, 92, 0.85); color: #fff; }

.mp-badge-type {
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.mp-badge-type.type-sale { background: rgba(52, 199, 89, 0.15); color: #34C759; border: 1px solid rgba(52, 199, 89, 0.3); }
.mp-badge-type.type-trade { background: rgba(74, 159, 217, 0.15); color: #4A9FD9; border: 1px solid rgba(74, 159, 217, 0.3); }

.mp-listing-info {
  padding: var(--space-3);
}
.mp-listing-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-listing-set {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}
.mp-listing-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.mp-listing-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: var(--text-base);
  color: var(--color-primary);
}
.mp-listing-seller {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.mp-listing-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.mp-listing-actions .btn {
  flex: 1;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}
.mp-btn-buylocal {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.mp-btn-buylocal:hover {
  background: var(--color-primary-hover);
}
.mp-btn-msg {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.mp-btn-msg:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-primary);
  color: var(--color-text);
}

/* ===== LISTING MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 0.65);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: modalFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background var(--transition-interactive);
}
.modal-close:hover { background: var(--color-surface-offset); }
.modal-body {
  padding: var(--space-5);
}
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Form elements in modal */
.form-group {
  margin-bottom: var(--space-4);
}
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  font-family: inherit;
  transition: border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  text-align: center;
  animation: toastIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.toast-success { border-color: var(--color-success); color: var(--color-success); }
.toast.toast-error { border-color: var(--color-error); color: var(--color-error); }

/* ===== WATCHLIST SECTION ===== */
.watchlist-section {
  margin-bottom: var(--space-8);
}
.watchlist-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* ===== CART LOCAL PICKUP NOTE ===== */
.cart-local-pickup-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-lg);
  border: 1px solid oklch(from var(--color-primary) l c h / 0.15);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}
.cart-local-pickup-note svg {
  flex-shrink: 0;
}
