/* ══════════════════════════════════════════════════════════════════════════
   Lorcana Market Tracker — "Inkwell Dark" Design System
   Cinzel display font · EB Garamond body · deep navy + liquid gold palette
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts fallback (already in <head>) ── */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-void:    #03050c;
  --bg-deep:    #070d1b;
  --bg-surface: #0d1627;
  --bg-raised:  #162038;
  --bg-panel:   #1a2a45;

  /* Gold scale */
  --gold-dim:       #6b4f2a;
  --gold-muted:     #8c6e3e;
  --gold-base:      #c9a96e;
  --gold-bright:    #e8c97e;
  --gold-brilliant: #f5d999;
  --gold-glow:      rgba(201,169,110,.14);
  --gold-glow-hi:   rgba(232,201,126,.30);

  /* Ink blue */
  --ink-base:  #2461d4;
  --ink-light: #5b90f5;
  --ink-glow:  rgba(36,97,212,.20);

  /* Sentiment */
  --rise:      #34d399;
  --rise-glow: rgba(52,211,153,.18);
  --fall:      #f87171;
  --fall-glow: rgba(248,113,113,.18);

  /* Alerts */
  --alert:     #fbbf24;
  --alert-dim: rgba(251,191,36,.18);
  --alert-hi:  rgba(251,191,36,.38);

  /* Text */
  --txt-hi:     #f0e8d8;
  --txt-base:   #b8c4d8;
  --txt-muted:  #627080;
  --txt-faint:  #3a4a60;

  /* Borders */
  --border-faint:   rgba(201,169,110,.08);
  --border-subtle:  rgba(201,169,110,.15);
  --border-base:    rgba(201,169,110,.28);
  --border-bright:  rgba(201,169,110,.55);

  /* Shadows */
  --shadow-base:  0 4px 24px rgba(0,0,0,.55);
  --shadow-gold:  0 0 22px var(--gold-glow), 0 0 44px rgba(201,169,110,.07);
  --shadow-alert: 0 0 24px var(--alert-dim), 0 0 48px rgba(251,191,36,.10);

  /* Motion */
  --ease:  cubic-bezier(.4,0,.2,1);
  --fast:  .15s;
  --mid:   .28s;
  --slow:  .45s;

  /* Radii */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;

  /* Fonts */
  --f-display: 'Cinzel', Georgia, serif;
  --f-body:    'EB Garamond', Georgia, serif;

  /* Compatibility aliases (legacy var names used in watch/portfolio sections) */
  --surface-2:     var(--bg-panel);
  --surface-3:     var(--bg-raised);
  --font-display:  var(--f-display);
  --font-body:     var(--f-body);
  --gold-light:    var(--gold-bright);
  --gold:          var(--gold-base);
  --txt-primary:   var(--txt-hi);
  --txt-secondary: var(--txt-base);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--txt-hi);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden; /* prevent any element from creating horizontal scroll */
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
a { color: inherit; }

/* ── Atmospheric Background ──────────────────────────────────────────────── */
.inkwell-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 15% -5%,  rgba(36,97,212,.13) 0%, transparent 60%),
    radial-gradient(ellipse 50% 45% at 88% 105%, rgba(201,169,110,.09) 0%, transparent 55%),
    radial-gradient(ellipse 90% 90% at 50%  50%, var(--bg-deep) 0%, var(--bg-void) 100%);
}

.particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .45;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,13,27,.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-faint);
  /* iOS safe area — content below notch */
  padding-top: env(safe-area-inset-top, 0px);
}
.header-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: .65rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Brand */
.brand { display: flex; align-items: center; gap: .9rem; }

.brand-drop {
  width: 38px;
  height: 44px;
  background: radial-gradient(circle at 42% 28%, var(--gold-bright) 0%, var(--gold-dim) 100%);
  clip-path: path('M19 1C19 1 36 13 36 24C36 33.4 28.4 40 19 40C9.6 40 2 33.4 2 24C2 13 19 1 19 1Z');
  box-shadow: 0 0 18px var(--gold-glow-hi), 0 0 6px var(--gold-glow);
  animation: drop-breathe 5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes drop-breathe {
  0%,100% { box-shadow: 0 0 18px var(--gold-glow-hi), 0 0 6px var(--gold-glow); }
  50%      { box-shadow: 0 0 32px var(--gold-glow-hi), 0 0 60px rgba(201,169,110,.15); }
}

.brand-title {
  font-family: var(--f-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: .07em;
  line-height: 1.15;
  color: var(--txt-hi);
}
.brand-title span { color: var(--gold-base); }
.brand-sub {
  font-size: .62rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--txt-muted);
  font-family: var(--f-display);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.last-update { text-align: right; }
.update-label {
  display: block;
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--txt-muted);
}
.update-time {
  font-family: var(--f-display);
  font-size: .75rem;
  color: var(--txt-base);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .95rem;
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  color: var(--gold-base);
  font-family: var(--f-display);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  transition: all var(--mid) var(--ease);
}
.btn-refresh:hover {
  background: var(--gold-glow);
  border-color: var(--border-bright);
  color: var(--gold-bright);
  box-shadow: var(--shadow-gold);
}
.btn-refresh svg { width: 14px; height: 14px; transition: transform .6s ease; }
.btn-refresh.spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  color: var(--txt-muted);
  transition: all var(--mid) var(--ease);
}
.btn-icon svg { width: 15px; height: 15px; }
.btn-icon:hover { border-color: var(--border-subtle); color: var(--gold-base); }

/* ── Alerts Section ──────────────────────────────────────────────────────── */
.alerts-section {
  position: relative;
  z-index: 10;
  max-width: 1560px;
  margin: 1.4rem auto 0;
  padding: 0 2rem;
}
.alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .85rem;
}
.section-label {
  font-family: var(--f-display);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--alert);
  color: #000;
  font-size: .62rem;
  font-weight: 800;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 .35rem;
  border-radius: 100px;
}

.threshold-control {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  color: var(--txt-muted);
  cursor: default;
}
.threshold-control input[type="range"] {
  width: 72px;
  accent-color: var(--gold-base);
  cursor: pointer;
}
.threshold-control strong { color: var(--gold-bright); font-weight: 700; min-width: 2.5ch; }

.alerts-scroll {
  display: flex;
  gap: .9rem;
  overflow-x: auto;
  padding-bottom: .6rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.placeholder-text {
  font-style: italic;
  color: var(--txt-muted);
  padding: .75rem;
  font-size: .9rem;
}

/* Alert card */
.alert-card {
  flex-shrink: 0;
  width: 190px;
  padding: .9rem;
  background: rgba(13,22,39,.85);
  border: 1px solid rgba(251,191,36,.22);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--mid) var(--ease);
  position: relative;
  overflow: hidden;
}
.alert-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top center, var(--alert-dim), transparent 70%);
  pointer-events: none;
}
.alert-card:hover {
  border-color: var(--alert);
  box-shadow: var(--shadow-alert);
  transform: translateY(-3px);
}
.alert-card.extreme { animation: alert-pulse 2.2s ease-in-out infinite; }
@keyframes alert-pulse {
  0%,100% { box-shadow: 0 0 12px rgba(251,191,36,.15); }
  50%      { box-shadow: 0 0 28px rgba(251,191,36,.40), 0 0 56px rgba(251,191,36,.12); }
}

.alert-badge {
  display: inline-block;
  font-family: var(--f-display);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 100px;
  margin-bottom: .45rem;
}
.alert-badge.extreme  { background: rgba(248,113,113,.2); color: var(--fall); }
.alert-badge.high     { background: rgba(251,191,36,.18); color: var(--alert); }
.alert-badge.moderate { background: rgba(52,211,153,.14); color: var(--rise); }

.alert-name {
  font-family: var(--f-display);
  font-size: .76rem;
  font-weight: 600;
  color: var(--txt-hi);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .2rem;
}
.alert-set   { font-size: .65rem; color: var(--txt-muted); margin-bottom: .4rem; }
.alert-pct   { font-family: var(--f-display); font-size: 1.05rem; font-weight: 700; color: var(--alert); }
.alert-price { font-size: .68rem; color: var(--txt-base); margin-top: .15rem; }

/* ── Stats Bar ───────────────────────────────────────────────────────────── */
.stats-bar {
  position: relative;
  z-index: 10;
  max-width: 1560px;
  margin: 1.3rem auto;
  padding: 0 2rem;
  display: flex;
  gap: 1px;
}
.stat-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .22rem;
  padding: .9rem .5rem;
  background: rgba(13,22,39,.65);
  border: 1px solid var(--border-faint);
  transition: background var(--mid) var(--ease);
}
.stat-pill:first-child { border-radius: var(--r-lg) 0 0 var(--r-lg); }
.stat-pill:last-child  { border-radius: 0 var(--r-lg) var(--r-lg) 0; }
.stat-pill:hover { background: rgba(13,22,39,.9); }

.stat-val {
  font-family: var(--f-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-base);
  line-height: 1;
}
.stat-lbl {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--txt-muted);
}

/* ── Main Layout ─────────────────────────────────────────────────────────── */
.main-layout {
  position: relative;
  z-index: 10;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 2rem calc(5rem + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.4rem;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 76px;
  height: fit-content;
}
.filter-panel {
  background: rgba(13,22,39,.82);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-2xl);
  padding: 1.4rem 1.2rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.filter-panel-title {
  font-family: var(--f-display);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--txt-muted);
  margin-bottom: 1.3rem;
}
.field-group { margin-bottom: 1.1rem; }
.field-label {
  display: block;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--txt-muted);
  margin-bottom: .35rem;
}
.field-input {
  width: 100%;
  padding: .46rem .7rem;
  background: rgba(7,13,27,.75);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  color: var(--txt-hi);
  font-size: .85rem;
  font-family: var(--f-body);
  transition: border-color var(--fast) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.field-input:focus {
  outline: none;
  border-color: var(--border-base);
}
.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '';
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--txt-muted);
  pointer-events: none;
}
.select-wrapper .field-input { padding-right: 2rem; }

.toggle-row { display: flex; gap: 4px; }
.toggle-btn {
  flex: 1;
  padding: .38rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-sm);
  color: var(--txt-muted);
  font-family: var(--f-display);
  font-size: .7rem;
  letter-spacing: .06em;
  transition: all var(--fast) var(--ease);
}
.toggle-btn:hover,
.toggle-btn.active {
  background: var(--gold-glow);
  border-color: var(--border-base);
  color: var(--gold-base);
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: .7rem;
  padding: .55rem;
  background: linear-gradient(135deg, rgba(201,169,110,.18), rgba(201,169,110,.06));
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  color: var(--gold-base);
  font-family: var(--f-display);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: all var(--mid) var(--ease);
}
.btn-primary:hover {
  background: var(--gold-glow);
  border-color: var(--border-bright);
  color: var(--gold-bright);
  box-shadow: var(--shadow-gold);
}
.btn-ghost {
  display: block;
  width: 100%;
  margin-top: .5rem;
  padding: .45rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  color: var(--txt-muted);
  font-size: .72rem;
  font-family: var(--f-display);
  letter-spacing: .06em;
  transition: all var(--fast) var(--ease);
}
.btn-ghost:hover { color: var(--txt-base); border-color: var(--border-subtle); }

/* ── Grid Section ────────────────────────────────────────────────────────── */
.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .9rem;
}
.grid-info {
  font-size: .78rem;
  color: var(--txt-muted);
  font-style: italic;
}
.view-switcher { display: flex; gap: 3px; }
.view-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-sm);
  color: var(--txt-muted);
  transition: all var(--fast) var(--ease);
}
.view-btn svg { width: 11px; height: 11px; }
.view-btn.active,
.view-btn:hover {
  background: var(--gold-glow);
  border-color: var(--border-subtle);
  color: var(--gold-base);
}

/* ── Card Grid ───────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: .95rem;
}
.card-grid.view-list {
  grid-template-columns: 1fr;
  gap: .45rem;
}

/* ── Card Item ───────────────────────────────────────────────────────────── */
.card-item {
  background: rgba(13,22,39,.72);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-lg);
  cursor: pointer;
  overflow: hidden;
  transition: all var(--mid) var(--ease);
  position: relative;
}
.card-item:hover {
  border-color: var(--border-base);
  box-shadow: var(--shadow-gold);
  transform: translateY(-4px);
}
.card-item.is-rising { border-color: rgba(52,211,153,.22); }
.card-item.is-rising:hover {
  border-color: var(--rise);
  box-shadow: 0 4px 22px var(--rise-glow), 0 0 40px rgba(52,211,153,.06);
}
.card-item.is-alert { border-color: rgba(251,191,36,.22); }
.card-item.is-alert:hover {
  border-color: var(--alert);
  box-shadow: var(--shadow-alert);
}
/* Enchanted cards — rainbow aurora glow */
.card-item.is-enchanted {
  border-color: rgba(180,110,240,.35);
  background: linear-gradient(160deg, rgba(22,12,42,.9) 0%, rgba(14,18,44,.9) 100%);
}
.card-item.is-enchanted:hover {
  border-color: rgba(210,150,255,.7);
  box-shadow:
    0 0 18px rgba(180,100,255,.25),
    0 0 40px rgba(100,160,255,.12),
    0 0 60px rgba(255,140,200,.08);
}
.card-item.is-enchanted .card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(180,100,255,.08) 0%,
    rgba(100,160,255,.06) 35%,
    rgba(255,200,100,.06) 65%,
    rgba(180,100,255,.08) 100%);
  pointer-events: none;
  animation: enchanted-shimmer 4s ease-in-out infinite;
}
@keyframes enchanted-shimmer {
  0%, 100% { opacity: .6; }
  50%       { opacity: 1; }
}

.card-thumb {
  position: relative;
  aspect-ratio: 5/7;
  background: var(--bg-void);
  overflow: hidden;
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--slow) var(--ease);
  display: block;
}
.card-item:hover .card-thumb img { transform: scale(1.06); }
.card-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-raised));
  color: var(--border-subtle);
  font-size: 2.2rem;
  user-select: none;
}

.slope-badge {
  position: absolute;
  top: 5px; right: 5px;
  font-family: var(--f-display);
  font-size: .58rem;
  font-weight: 700;
  padding: .18rem .38rem;
  border-radius: var(--r-sm);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  letter-spacing: .04em;
}
.slope-badge.pos-hi  { background: rgba(251,191,36,.90); color: #000; }
.slope-badge.pos-med { background: rgba(52,211,153,.88); color: #000; }
.slope-badge.neg     { background: rgba(248,113,113,.82); color: #fff; }
.slope-badge.neutral { display: none; }

/* Buy score badge */
.card-score-row {
  margin-top: .18rem;
  min-height: 1rem;
}
.buy-score-badge {
  display: inline-block;
  padding: .1rem .36rem;
  border-radius: var(--r-sm);
  font-size: .58rem;
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: .04em;
}
.buy-score-badge::before { content: '★ '; font-size: .55rem; }
.buy-score-high { background: rgba(52,211,153,.18); border: 1px solid rgba(52,211,153,.50); color: #34d399; }
.buy-score-mid  { background: rgba(251,191,36,.15); border: 1px solid rgba(251,191,36,.45); color: #fbbf24; }
.buy-score-low  { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: rgba(255,255,255,.4); }

/* Golden cross and pump badges on card thumb */
.golden-cross-badge {
  position: absolute;
  top: 5px; left: 5px;
  font-size: .85rem;
  line-height: 1;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.8));
  cursor: default;
}
.pump-badge {
  position: absolute;
  top: 26px; left: 5px;
  font-size: .8rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.8));
  cursor: default;
}

/* Buy score range slider */
.range-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255,255,255,.12);
  border-radius: 2px;
  outline: none;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold-base);
  cursor: pointer;
}
.range-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold-base);
  border: none;
  cursor: pointer;
}
.range-value {
  min-width: 2rem;
  text-align: right;
  font-size: .78rem;
  color: var(--gold-base);
  font-family: var(--f-display);
}

/* Rarity icon — bottom-left corner of card thumb */
.card-rarity-icon {
  position: absolute;
  bottom: 4px; left: 5px;
  font-size: .85rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.8));
}

/* Language badge — inline pill after expansion name */
.lang-badge {
  display: inline-block;
  margin-left: .3rem;
  padding: .06rem .32rem;
  border-radius: var(--r-sm);
  font-size: .54rem;
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: .05em;
  vertical-align: middle;
  background: rgba(201,169,110,.15);
  border: 1px solid rgba(201,169,110,.30);
  color: var(--gold-base);
  white-space: nowrap;
}
.lang-badge[data-lang="English"]  { background: rgba(36,97,212,.18); border-color: rgba(91,144,245,.35); color: var(--ink-light); }
.lang-badge[data-lang="French"]   { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.28); color: var(--rise); }
.lang-badge[data-lang="German"]   { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.28); color: var(--fall); }
.lang-badge[data-lang="Spanish"]  { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.28); color: var(--alert); }
.lang-badge[data-lang="Italian"]  { background: rgba(201,169,110,.15); border-color: rgba(201,169,110,.30); color: var(--gold-base); }
.lang-badge[data-lang="Japanese"] { background: rgba(180,110,200,.15); border-color: rgba(180,110,200,.30); color: #c87ee8; }

.card-meta {
  padding: .6rem .7rem;
}
.card-name {
  font-family: var(--f-display);
  font-size: .68rem;
  font-weight: 600;
  color: var(--txt-hi);
  line-height: 1.3;
  margin-bottom: .18rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-set-name {
  font-size: .6rem;
  color: var(--txt-muted);
  margin-bottom: .38rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-price {
  font-family: var(--f-display);
  font-size: .88rem;
  font-weight: 700;
  color: var(--gold-base);
}
.card-delta { font-size: .66rem; font-weight: 700; }
.card-delta.pos { color: var(--rise); }
.card-delta.neg { color: var(--fall); }
.card-delta.neutral { color: var(--txt-muted); }

/* List-view overrides */
.card-grid.view-list .card-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .65rem .9rem;
  border-radius: var(--r-md);
}
.card-grid.view-list .card-thumb {
  width: 44px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  aspect-ratio: 5/7;
}
.card-grid.view-list .card-meta {
  flex: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}
.card-grid.view-list .card-name { -webkit-line-clamp: 1; font-size: .82rem; }
.card-grid.view-list .card-price-row { flex-direction: column; align-items: flex-end; gap: .1rem; }

/* ── Skeleton Loading ────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-raised) 25%,
    rgba(30,50,80,.55) 50%,
    var(--bg-raised) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--txt-muted);
}
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: .8rem; }
.empty-state h3 {
  font-family: var(--f-display);
  font-size: .95rem;
  color: var(--txt-base);
  margin-bottom: .4rem;
}
.empty-state p { font-size: .85rem; font-style: italic; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 34px; height: 34px;
  padding: 0 .5rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  color: var(--txt-muted);
  font-family: var(--f-display);
  font-size: .75rem;
  transition: all var(--fast) var(--ease);
}
.page-btn:hover { border-color: var(--border-subtle); color: var(--txt-hi); }
.page-btn.active {
  background: var(--gold-glow);
  border-color: var(--border-base);
  color: var(--gold-base);
}
.page-btn:disabled { opacity: .3; cursor: not-allowed; pointer-events: none; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3,5,12,.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--mid) var(--ease);
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
  transform: translateY(24px) scale(.98);
  transition: transform var(--mid) var(--ease);
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

.modal-close {
  position: sticky;
  top: 1rem;
  float: right;
  margin: 1rem 1rem 0 0;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-faint);
  border-radius: 50%;
  color: var(--txt-muted);
  font-size: .75rem;
  z-index: 10;
  transition: all var(--fast) var(--ease);
}
.modal-close:hover {
  background: rgba(248,113,113,.15);
  border-color: var(--fall);
  color: var(--fall);
}

.modal-body { padding: 1.8rem 2rem 2.2rem; }

/* Modal card header */
.modal-hero { display: flex; gap: 1.5rem; margin-bottom: 1.6rem; }
.modal-art {
  width: 130px;
  flex-shrink: 0;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-base);
  background: var(--bg-void);
  aspect-ratio: 5/7;
}
.modal-art img { width: 100%; height: 100%; object-fit: cover; display: block; }

.modal-info { flex: 1; min-width: 0; }
.modal-card-name {
  font-family: var(--f-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--txt-hi);
  margin-bottom: .3rem;
}
.modal-card-set {
  font-size: .8rem;
  color: var(--txt-muted);
  margin-bottom: .5rem;
}

/* Rarity + ink badges row under set name */
.modal-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .75rem;
}
.rarity-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .22rem .55rem;
  border-radius: var(--r-sm);
  font-family: var(--f-display);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .07em;
  border: 1px solid transparent;
}
.rarity-badge.rarity-enchanted  { background: rgba(180,100,255,.18); border-color: rgba(210,150,255,.4); color: #d49cff; }
.rarity-badge.rarity-legendary  { background: rgba(251,191,36,.15);  border-color: rgba(251,191,36,.35); color: var(--alert); }
.rarity-badge.rarity-super-rare { background: rgba(91,144,245,.14);  border-color: rgba(91,144,245,.30); color: var(--ink-light); }
.rarity-badge.rarity-rare       { background: rgba(52,211,153,.12);  border-color: rgba(52,211,153,.28); color: var(--rise); }
.rarity-badge.rarity-uncommon   { background: rgba(201,169,110,.12); border-color: rgba(201,169,110,.28); color: var(--gold-base); }
.rarity-badge.rarity-common     { background: rgba(90,106,128,.12);  border-color: rgba(90,106,128,.25); color: var(--txt-muted); }
.rarity-badge.rarity-special    { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.28); color: var(--fall); }

.ink-badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .55rem;
  border-radius: var(--r-sm);
  font-family: var(--f-display);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .06em;
  background: rgba(201,169,110,.10);
  border: 1px solid rgba(201,169,110,.22);
  color: var(--gold-dim);
}
.ink-badge.ink-amber    { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.28); color: var(--alert); }
.ink-badge.ink-amethyst { background: rgba(180,100,255,.12); border-color: rgba(180,100,255,.28); color: #c87ee8; }
.ink-badge.ink-emerald  { background: rgba(52,211,153,.10); border-color: rgba(52,211,153,.25); color: var(--rise); }
.ink-badge.ink-ruby     { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.28); color: var(--fall); }
.ink-badge.ink-sapphire { background: rgba(91,144,245,.12); border-color: rgba(91,144,245,.28); color: var(--ink-light); }
.ink-badge.ink-steel    { background: rgba(150,160,175,.12); border-color: rgba(150,160,175,.25); color: #a0aab8; }

/* Language variants section in modal */
.lang-variants-section {
  margin-bottom: 1.4rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.lang-variants-heading {
  padding: .55rem .9rem;
  font-family: var(--f-display);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--txt-muted);
  background: rgba(7,13,27,.5);
  border-bottom: 1px solid var(--border-faint);
}
.lang-variants-grid {
  display: flex;
  flex-direction: column;
}
.lang-variant-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .9rem;
  border-bottom: 1px solid var(--border-faint);
  text-decoration: none;
  transition: background var(--fast) var(--ease);
}
.lang-variant-row:last-child { border-bottom: none; }
.lang-variant-row:hover { background: rgba(201,169,110,.06); }
.lang-variant-flag { font-size: 1rem; flex-shrink: 0; }
.lang-variant-name {
  font-family: var(--f-display);
  font-size: .72rem;
  color: var(--txt-base);
  flex: 1;
}
.lang-variant-price {
  font-family: var(--f-display);
  font-size: .88rem;
  font-weight: 700;
  color: var(--gold-base);
}
.lang-variant-low {
  font-size: .65rem;
  color: var(--txt-muted);
  min-width: 4.5rem;
  text-align: right;
}

/* Momentum score */
.momentum-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .75rem;
  border-radius: var(--r-md);
  font-family: var(--f-display);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin-bottom: .85rem;
}
.momentum-badge.strong-buy { background: rgba(251,191,36,.15); color: var(--alert);  border: 1px solid rgba(251,191,36,.30); }
.momentum-badge.buy        { background: rgba(52,211,153,.12); color: var(--rise);   border: 1px solid rgba(52,211,153,.25); }
.momentum-badge.watch      { background: rgba(91,144,245,.12); color: var(--ink-light); border: 1px solid rgba(91,144,245,.22); }
.momentum-badge.neutral    { background: rgba(90,106,128,.12); color: var(--txt-muted); border: 1px solid rgba(90,106,128,.20); }
.momentum-badge.caution    { background: rgba(248,113,113,.12); color: var(--fall); border: 1px solid rgba(248,113,113,.25); }

/* Price grid */
.price-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .65rem;
  margin-bottom: .65rem;
}
.price-cell {
  background: rgba(7,13,27,.6);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  padding: .55rem .5rem;
  text-align: center;
}
.price-cell-lbl {
  font-size: .55rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--txt-muted);
  margin-bottom: .18rem;
}
.price-cell-val {
  font-family: var(--f-display);
  font-size: .95rem;
  font-weight: 700;
  color: var(--gold-base);
}

/* Change grid */
.change-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-bottom: .85rem;
}
.change-cell {
  background: rgba(7,13,27,.5);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  padding: .45rem .4rem;
  text-align: center;
}
.change-cell-lbl {
  font-size: .55rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--txt-muted);
  margin-bottom: .15rem;
}
.change-cell-val {
  font-family: var(--f-display);
  font-size: .85rem;
  font-weight: 700;
}
.change-cell-val.pos { color: var(--rise); }
.change-cell-val.neg { color: var(--fall); }

/* ATH / ATL row in modal */
.ath-atl-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-top: -.3rem;
  margin-bottom: .85rem;
}
.ath-val { color: #fbbf24; }
.atl-val { color: #60a5fa; }
.change-cell-val.neu { color: var(--txt-muted); }

/* Modal links */
.modal-links { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .38rem .75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--txt-base);
  font-family: var(--f-display);
  font-size: .68rem;
  letter-spacing: .06em;
  text-decoration: none;
  transition: all var(--fast) var(--ease);
}
.btn-link:hover { border-color: var(--gold-base); color: var(--gold-base); background: var(--gold-glow); }

.btn-quick-watch { cursor: pointer; background: none; }
.btn-quick-watch:disabled { opacity: .55; cursor: default; }

/* ── Quick-watch mini-form ───────────────────────────────────────────────── */
.quick-watch-form {
  margin-top: .65rem;
  padding: .7rem .9rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  animation: fadeIn .15s ease;
}
.quick-watch-label {
  display: block;
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--txt-muted);
  margin-bottom: .4rem;
}
.quick-watch-row {
  display: flex;
  gap: .4rem;
  align-items: center;
}
.quick-watch-input {
  flex: 1;
  min-width: 0;
  padding: .4rem .6rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--txt-hi);
  font-size: .85rem;
}
.quick-watch-input:focus { outline: none; border-color: var(--gold-base); }
.quick-watch-submit {
  padding: .4rem .8rem;
  background: var(--gold-base);
  color: #0a0e1a;
  border: none;
  border-radius: var(--r-sm);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--fast);
}
.quick-watch-submit:hover { opacity: .85; }
.quick-watch-submit:disabled { opacity: .5; cursor: default; }
.quick-watch-cancel {
  padding: .4rem .6rem;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--txt-muted);
  font-size: .8rem;
  cursor: pointer;
}
.quick-watch-cancel:hover { color: var(--fall); border-color: var(--fall); }
.quick-watch-status {
  margin-top: .4rem;
  font-size: .72rem;
}
.quick-watch-status.success { color: var(--rise); }
.quick-watch-status.error   { color: var(--fall); }

/* Chart section */
.chart-section {
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border-faint);
}
.chart-heading {
  font-family: var(--f-display);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--txt-muted);
  margin-bottom: .75rem;
}
.chart-tabs { display: flex; gap: 3px; margin-bottom: .65rem; }
.chart-tab {
  padding: .28rem .65rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--r-sm);
  color: var(--txt-muted);
  font-family: var(--f-display);
  font-size: .65rem;
  letter-spacing: .06em;
  transition: all var(--fast) var(--ease);
}
.chart-tab:hover, .chart-tab.active {
  background: var(--gold-glow);
  border-color: var(--border-base);
  color: var(--gold-base);
}
.chart-wrap {
  position: relative;
  height: 210px;
  background: rgba(7,13,27,.5);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-lg);
  padding: .85rem;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-muted);
  font-style: italic;
  font-size: .85rem;
}

/* ── Settings Drawer ─────────────────────────────────────────────────────── */
.settings-drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100dvh;
  width: 280px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  z-index: 400;
  transform: translateX(100%);
  transition: transform var(--slow) var(--ease);
  overflow-y: auto;
  scrollbar-width: thin;
}
.settings-drawer.open {
  transform: translateX(0);
  box-shadow: -12px 0 48px rgba(0,0,0,.55);
}
.settings-inner { padding: 2rem 1.4rem; }
.settings-title {
  font-family: var(--f-display);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--txt-muted);
  margin-bottom: 1.8rem;
}
.setting-row { margin-bottom: 1.3rem; }
.setting-row label {
  display: block;
  font-size: .72rem;
  color: var(--txt-base);
  margin-bottom: .35rem;
}
.setting-row input,
.setting-row select {
  width: 100%;
  padding: .46rem .7rem;
  background: rgba(7,13,27,.8);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
  color: var(--txt-hi);
  font-size: .9rem;
  font-family: var(--f-body);
  appearance: none;
}
.setting-row input:focus,
.setting-row select:focus { outline: none; border-color: var(--border-base); }

/* ── Toast Stack ─────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 1.4rem;
  right: 1.4rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  pointer-events: none;
}
.toast {
  padding: .7rem 1.1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  color: var(--txt-hi);
  font-size: .82rem;
  box-shadow: var(--shadow-base);
  max-width: 290px;
  pointer-events: all;
  animation: toast-in .28s var(--ease) forwards, toast-out .28s var(--ease) 3.2s forwards;
}
.toast.success { border-left: 3px solid var(--rise); }
.toast.error   { border-left: 3px solid var(--fall); }
.toast.info    { border-left: 3px solid var(--gold-base); }
@keyframes toast-in  { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(20px); } }

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-base); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* Filter toggle button (JS-injected, hidden by default on desktop) */
.btn-filter-toggle {
  display: none;
  align-items: center;
  gap: .45rem;
  padding: .42rem .9rem;
  background: rgba(201,169,110,.10);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  color: var(--gold-base);
  font-family: var(--f-display);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  margin-bottom: .7rem;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
}
.btn-filter-toggle:hover,
.btn-filter-toggle:active { background: var(--gold-glow); border-color: var(--border-base); }
.btn-filter-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Close ✕ button inside filter overlay panel */
.filter-close-btn {
  width: 36px; height: 36px;
  position: absolute;
  top: .9rem; right: .85rem;
  display: none; /* shown only when overlay is open */
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border-faint);
  border-radius: 50%;
  color: var(--txt-muted);
  font-size: .8rem;
  cursor: pointer;
  z-index: 10;
  transition: all var(--fast) var(--ease);
}
.filter-close-btn:hover { background: rgba(248,113,113,.12); border-color: var(--fall); color: var(--fall); }
.sidebar.mobile-open .filter-close-btn { display: flex; }

/* ─ Collapsed sidebar breakpoint (≤ 860px — tablets + all phones) ──────── */
@media (max-width: 860px) {

  /* Layout: single column */
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0 1rem 4rem;
  }

  /* Sidebar: hidden, toggled open as full-screen overlay */
  .sidebar { display: none; }
  .sidebar.mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 600;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(3,5,12,.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.2rem 1rem 5rem;
  }
  .sidebar.mobile-open .filter-panel {
    position: relative;
    border-radius: var(--r-xl);
    max-width: 520px;
    margin: 0 auto;
    padding-top: 3rem; /* space for the ✕ button */
  }

  /* Show filter toggle button */
  .btn-filter-toggle { display: flex; }

  /* Header */
  .header-inner { padding: .55rem 1.1rem; }
  .brand-sub   { display: none; }
  .last-update { display: none; }

  /* Section padding */
  .alerts-section { padding-left: 1.1rem; padding-right: 1.1rem; }
  .stats-bar      { padding-left: 1.1rem; padding-right: 1.1rem; }

  /* Card grid */
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ─ Mobile (≤ 600px) ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* Header: compact for small screens */
  .header-inner { padding: .48rem .85rem; gap: .5rem; }
  .brand-drop   { width: 26px; height: 31px; }
  .brand-title  { font-size: 1.05rem; }
  .header-right { gap: .4rem; }
  .btn-refresh  { padding: .38rem .6rem; font-size: .66rem; }
  .btn-icon     { width: 36px; height: 36px; }

  /* Alerts section */
  .alerts-section   { margin-top: .75rem; padding: 0 .85rem; }
  .alerts-header    { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .threshold-control { width: 100%; justify-content: space-between; }
  .alert-card { min-width: 140px; }

  /* Stats bar: 4 equal pills, no scroll needed */
  #statDataPill { display: none; }  /* "Days of data" hidden on mobile — least actionable stat */
  .stats-bar {
    padding: 0 .85rem;
    flex-wrap: nowrap;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
    gap: .5rem;
    margin: .9rem auto;
  }
  .stat-pill {
    flex: 1 1 0;
    min-width: 0;
    border-radius: var(--r-lg) !important;
    padding: .65rem .5rem;
  }
  .stat-val { font-size: 1.15rem; }
  .stat-lbl { font-size: .58rem; }

  /* Main layout */
  .main-layout {
    padding: 0 .85rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
    gap: .7rem;
  }

  /* Filter toggle: slightly more compact */
  .btn-filter-toggle { font-size: .67rem; padding: .38rem .8rem; margin-bottom: .55rem; }

  /* Card grid: 2–3 columns */
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: .5rem; }
  .card-item { border-radius: var(--r-md); }
  .card-name        { font-size: .72rem; }
  .card-set-name    { font-size: .6rem; }
  .card-price       { font-size: .88rem; }
  .card-price-low   { font-size: .62rem; }
  .card-delta       { font-size: .62rem; }

  /* Rarity pills: horizontal scroll */
  .rarity-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: .35rem;
    padding-bottom: .35rem;
  }
  .rarity-pills::-webkit-scrollbar { display: none; }
  .rarity-pill {
    white-space: nowrap;
    flex-shrink: 0;
    padding: .3rem .65rem;
    font-size: .62rem;
  }

  /* Grid toolbar */
  .grid-toolbar { margin-bottom: .5rem; }
  .grid-info    { font-size: .72rem; }

  /* Pagination */
  .page-btn { min-width: 34px; height: 34px; font-size: .72rem; }

  /* Modal: bottom sheet slide-up */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border-base);
    border-radius: 2px;
    margin: .75rem auto .2rem;
  }
  .modal-backdrop.open .modal { transform: translateY(0); }
  .modal-body { padding: 1rem .9rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); }

  /* Modal: stack art + info vertically */
  .modal-hero { flex-direction: column; align-items: center; gap: .85rem; text-align: center; }
  .modal-art  { width: 90px; }
  .modal-info { width: 100%; }
  .modal-card-name { font-size: 1rem; }
  .modal-card-tags { justify-content: center; }
  .price-grid  { grid-template-columns: repeat(3, 1fr); }
  .change-grid { grid-template-columns: repeat(3, 1fr); }
  .ath-atl-grid       { grid-template-columns: repeat(2, 1fr); }
  .lang-variants-grid { grid-template-columns: 1fr; }

  /* Drawers: full-width */
  .watch-drawer    { width: 100vw; }
  .settings-drawer { width: 100vw; }
  .settings-inner  { padding: 1.1rem .85rem calc(2rem + env(safe-area-inset-bottom, 0px)); }

  /* Watch drawer */
  .watch-tab           { font-size: .73rem; padding: .5rem .45rem; }
  .watch-drawer-header { padding: .85rem 1rem .7rem; }
}

/* ─ Very small phones (≤ 390px — iPhone SE, older models) ─────────────── */
@media (max-width: 390px) {
  .brand-title { font-size: .9rem; }
  .card-grid   { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}

/* ── Watch/Settings drawer mobile overrides (≤ 860px) ───────────────────── */
@media (max-width: 860px) {
  /* Tabs: horizontal scroll so 4 tabs never overflow the drawer width */
  .watch-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .watch-tabs::-webkit-scrollbar { display: none; }
  .watch-tab {
    flex-shrink: 0;
    font-size: .75rem;
    padding: .55rem .7rem;
    white-space: nowrap;
  }

  /* Add-watch form fields: stack to single column */
  .watch-field-row { grid-template-columns: 1fr; }

  /* Scan bar: allow wrapping */
  .watch-scan-bar { flex-wrap: wrap; gap: .5rem; padding: .55rem 1rem; }

  /* Padding reductions for compact mobile layout */
  .watch-form        { padding: .5rem 1rem .85rem; }
  .watch-add-toggle  { padding: .6rem 1rem; }
  .watch-panel       { padding: .65rem 1rem; }
  .watch-row, .watch-alert-row, .sugg-row { padding: .65rem .75rem; }

  /* Portfolio stats: 2-column grid */
  .portfolio-stats { flex-wrap: wrap; }
  .portfolio-stat  { flex: 1 1 calc(50% - 5px); min-width: 80px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   PRICE WATCH SYSTEM
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Watch bell button + badge ───────────────────────────────────────────── */
.watch-btn { position: relative; }

.watch-alert-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--fall);
  color: #fff;
  font-family: var(--font-body);
  font-size: .65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  animation: badge-pop .25s var(--ease);
}

@keyframes badge-pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ── Watch drawer ────────────────────────────────────────────────────────── */
.watch-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100%;
  background: var(--surface-2);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -8px 0 40px rgba(0,0,0,.55);
  transform: translateX(100%);
  transition: transform .32s var(--ease);
  z-index: 1100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.watch-drawer.open { transform: translateX(0); }

.watch-drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.watch-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem .9rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.watch-drawer-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-base);
  letter-spacing: .03em;
  margin: 0;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.watch-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.watch-tabs::-webkit-scrollbar { display: none; }

.watch-tab {
  flex-shrink: 0;
  white-space: nowrap;
  padding: .65rem .85rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt-muted);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  position: relative;
}
.watch-tab:hover        { color: var(--txt-base); }
.watch-tab.active       { color: var(--gold-base); border-bottom-color: var(--gold-base); }

.watch-tab-badge {
  display: inline-block;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  margin-left: 4px;
  border-radius: 7px;
  background: var(--fall);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  vertical-align: middle;
}

/* ── Add-watch section ───────────────────────────────────────────────────── */
.watch-add-section {
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.watch-add-toggle {
  padding: .75rem 1.4rem;
  cursor: pointer;
  color: var(--gold-light);
  font-size: .85rem;
  font-weight: 500;
  user-select: none;
  list-style: none;
}
.watch-add-toggle::-webkit-details-marker { display: none; }
.watch-add-toggle:hover { color: var(--gold-base); }

.watch-form {
  padding: .6rem 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.watch-field {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.watch-field label {
  font-size: .72rem;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.watch-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

.watch-foil-field {
  justify-content: flex-end;
}

.watch-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-base);
  cursor: pointer;
  margin-top: .3rem;
}

.watch-url-hint {
  font-size: .7rem;
  color: var(--txt-muted);
  margin-top: 2px;
}

.watch-form-actions {
  display: flex;
  gap: .65rem;
  padding-top: .3rem;
}

/* ── Autocomplete suggestions ────────────────────────────────────────────── */
.watch-autocomplete-wrap { position: relative; }

.watch-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-base);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 100;
  overflow: hidden;
}

.watch-suggestion {
  padding: .55rem .85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background .15s;
}
.watch-suggestion:last-child { border-bottom: none; }
.watch-suggestion:hover { background: rgba(201,169,110,.08); }

.ws-name { font-size: .85rem; color: var(--txt-base); }
.ws-set  { font-size: .7rem;  color: var(--txt-muted); }

/* ── Scan bar ────────────────────────────────────────────────────────────── */
.watch-scan-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.4rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.watch-scan-status {
  font-size: .75rem;
  color: var(--txt-muted);
  flex: 1;
}

/* ── Panels & list ───────────────────────────────────────────────────────── */
.watch-panel {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.watch-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

/* ── Watch row ───────────────────────────────────────────────────────────── */
.watch-row {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: .7rem .9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: .2rem .75rem;
  transition: border-color .2s;
}
.watch-row:hover { border-color: var(--border-base); }
.watch-row.watch-hit {
  border-color: rgba(52,211,153,.4);
  background: rgba(52,211,153,.05);
}
.watch-row.watch-inactive { opacity: .5; }

.watch-row-main    { grid-column: 1; grid-row: 1; }
.watch-row-prices  { grid-column: 2; grid-row: 1; text-align: right; }
.watch-row-actions { grid-column: 2; grid-row: 2; display: flex; align-items: center; gap: .35rem; justify-content: flex-end; }
.watch-row-footer  { grid-column: 1; grid-row: 2; font-size: .68rem; color: var(--txt-muted); }

.watch-row-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--txt-base);
}

.watch-row-meta {
  font-size: .72rem;
  color: var(--txt-muted);
  margin-top: 2px;
}

.watch-unacked-dot {
  color: var(--fall);
  margin-right: 4px;
  font-size: .65rem;
  vertical-align: middle;
}

.watch-target { font-size: .8rem; color: var(--txt-muted); }
.watch-last   { font-size: .8rem; color: var(--txt-base); }
.watch-last.watch-hit { color: var(--rise); font-weight: 700; }

.watch-cm-link {
  font-size: .8rem;
  color: var(--txt-muted);
  text-decoration: none;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .15s;
}
.watch-cm-link:hover { color: var(--gold-base); }
.watch-cm-link.small { font-size: .72rem; }

.watch-toggle-btn,
.watch-delete-btn {
  padding: 3px 6px;
  font-size: .75rem;
  min-height: unset;
}

/* ── Alert rows ──────────────────────────────────────────────────────────── */
.watch-alert-row {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: .75rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: border-color .2s;
}
.watch-alert-row.unacked {
  border-color: rgba(52,211,153,.35);
  background: rgba(52,211,153,.04);
}
.watch-alert-row.acked { opacity: .55; }

.watch-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.watch-alert-name  { font-size: .88rem; font-weight: 600; color: var(--txt-base); }
.watch-alert-prices { font-size: .78rem; color: var(--txt-muted); }
.watch-alert-price  { color: var(--rise); }
.watch-alert-time   { font-size: .7rem; color: var(--txt-muted); }

.watch-ack-btn {
  padding: 2px 8px;
  font-size: .72rem;
  color: var(--rise);
  border-color: rgba(52,211,153,.35);
  min-height: unset;
}
.watch-ack-btn:hover { background: rgba(52,211,153,.12); }

.watch-acked-label {
  font-size: .72rem;
  color: var(--txt-muted);
}

/* ════════════════════════════════════════════════════════════════════════════
   SPIKE DETECTOR — SUGGESTIONS TAB
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Suggestions toolbar ──────────────────────────────────────────────────── */
.sugg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0 .65rem;
  flex-shrink: 0;
}

.sugg-toggle-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: var(--txt-muted);
  cursor: pointer;
  user-select: none;
}
.sugg-toggle-label input { accent-color: var(--gold-base); cursor: pointer; }

.sugg-legend {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .7rem;
  color: var(--txt-muted);
}

/* ── Suggestion row ───────────────────────────────────────────────────────── */
.sugg-row {
  background: var(--surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: .65rem .85rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: .2rem .75rem;
  transition: border-color .2s, opacity .2s;
}
.sugg-row:hover { border-color: var(--border-base); }
.sugg-row.dismissed { opacity: .45; }

/* Left side: badge + name + set */
.sugg-row-left  { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 2px; }
.sugg-row-right { grid-column: 2; grid-row: 1; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.sugg-actions   { grid-column: 1 / -1; grid-row: 2; display: flex; gap: .5rem; padding-top: .4rem; }

.sugg-name { font-size: .88rem; font-weight: 600; color: var(--txt-base); }
.sugg-set  { font-size: .72rem; color: var(--txt-muted); }

/* Interval badge (24h / 48h / 72h) */
.sugg-interval-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 3px;
  width: fit-content;
}
.sugg-interval-badge.moderate { background: rgba(201,169,110,.15); color: var(--gold-base); border: 1px solid rgba(201,169,110,.3); }
.sugg-interval-badge.high     { background: rgba(251,191,36,.15);  color: var(--alert);     border: 1px solid rgba(251,191,36,.3); }
.sugg-interval-badge.extreme  { background: rgba(248,113,113,.18); color: var(--fall);      border: 1px solid rgba(248,113,113,.3);
                                 animation: sugg-pulse 2s ease-in-out infinite; }

@keyframes sugg-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
  50%       { box-shadow: 0 0 6px 2px rgba(248,113,113,.35); }
}

/* Percentage display */
.sugg-pct {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.sugg-pct.moderate { color: var(--gold-base); }
.sugg-pct.high     { color: var(--alert); }
.sugg-pct.extreme  { color: var(--fall); }

.sugg-price { font-size: .78rem; color: var(--txt-muted); }

/* Status badges */
.sugg-status-badge {
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.sugg-status-badge.added     { background: rgba(52,211,153,.12); color: var(--rise); border: 1px solid rgba(52,211,153,.3); }
.sugg-status-badge.dismissed { background: rgba(148,148,148,.1); color: var(--txt-muted); border: 1px solid var(--border-subtle); }

/* Suggestion level border accents */
.sugg-row.moderate { border-left: 3px solid rgba(201,169,110,.45); }
.sugg-row.high     { border-left: 3px solid rgba(251,191,36,.5); }
.sugg-row.extreme  { border-left: 3px solid rgba(248,113,113,.6); }

/* Action buttons */
.sugg-add-btn {
  padding: 3px 10px;
  font-size: .75rem;
  min-height: unset;
}
.sugg-dismiss-btn,
.sugg-undismiss-btn {
  padding: 3px 8px;
  font-size: .75rem;
  min-height: unset;
}

/* The "40%+ 1d = auto-added" legend badge */
.sugg-badge.extreme {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .65rem;
  font-weight: 700;
  background: rgba(248,113,113,.18);
  color: var(--fall);
  border: 1px solid rgba(248,113,113,.3);
}

/* small btn-link variant */
.btn-link.small { font-size: .75rem; padding: 2px 6px; }

/* ── Confidence badges ──────────────────────────────────────────────────────── */
.sugg-badges { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; align-items: center; }

.sugg-confidence {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 10px; font-size: .68rem; font-weight: 600;
  letter-spacing: .02em;
}
.sugg-confidence.high   { background: rgba(52,211,153,.15); color: #6ee7b7; border: 1px solid rgba(52,211,153,.3); }
.sugg-confidence.medium { background: rgba(201,169,110,.12); color: var(--gold); border: 1px solid rgba(201,169,110,.25); }
.sugg-confidence.low    { background: rgba(148,148,148,.1);  color: var(--txt-muted); border: 1px solid var(--border-subtle); }

/* ── Streak badge ────────────────────────────────────────────────────────────── */
.sugg-streak {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 10px; font-size: .68rem; font-weight: 600;
  background: rgba(251,191,36,.12); color: var(--gold); border: 1px solid rgba(251,191,36,.25);
}

/* ── Range Position Index bar ────────────────────────────────────────────────── */
.sugg-rpi {
  display: flex; align-items: center; gap: 5px;
  margin-top: 3px; font-size: .68rem;
}
.sugg-rpi-label { color: var(--txt-muted); white-space: nowrap; }
.sugg-rpi-bar {
  width: 60px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.08);
}
.sugg-rpi-fill {
  height: 100%; border-radius: 3px; transition: width .3s;
}
.sugg-rpi-fill.rpi-low  { background: #6ee7b7; }   /* near 14d low = good entry */
.sugg-rpi-fill.rpi-mid  { background: var(--gold); }
.sugg-rpi-fill.rpi-high { background: var(--fall); } /* near 14d high = caution */
.sugg-rpi-pct { font-size: .65rem; min-width: 28px; }
.sugg-rpi-pct.rpi-low  { color: #6ee7b7; }
.sugg-rpi-pct.rpi-mid  { color: var(--gold); }
.sugg-rpi-pct.rpi-high { color: var(--fall); }

/* ── Alert type badges ────────────────────────────────────────────────────────── */
.alert-type-badge {
  display: inline-flex; align-items: center; padding: 1px 7px;
  border-radius: 10px; font-size: .68rem; font-weight: 600; margin-left: 6px;
}
.alert-type-badge.target  { background: rgba(52,211,153,.12); color: #6ee7b7; border: 1px solid rgba(52,211,153,.25); }
.alert-type-badge.fading  { background: rgba(251,191,36,.12); color: var(--gold); border: 1px solid rgba(251,191,36,.3); }

.watch-alert-row.fading { border-left: 3px solid rgba(251,191,36,.5); }

/* ── Alerts empty / building state ───────────────────────────────────────────── */
.alerts-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px 16px; text-align: center; min-width: 200px;
}
.alerts-empty-icon { font-size: 1.6rem; }
.alerts-empty-state p { margin: 0; font-size: .82rem; color: var(--txt-secondary); }
.alerts-empty-sub { font-size: .72rem !important; color: var(--txt-muted) !important; max-width: 280px; line-height: 1.5; }

/* ── Low price in card grid ──────────────────────────────────────────────────── */.card-price-low {
  font-size: .7rem;
  color: var(--txt-muted);
  margin-left: 4px;
}

/* ── Alert RPI badge ─────────────────────────────────────────────────────────── */
.alert-meta-row {
  display: flex; align-items: center; gap: 5px;
  margin-top: 3px; flex-wrap: wrap;
}
.alert-rpi {
  display: inline-flex; align-items: center; padding: 1px 6px;
  border-radius: 10px; font-size: .64rem; font-weight: 700;
  letter-spacing: .02em;
}
.alert-rpi.rpi-low  { background: rgba(110,231,183,.1); color: #6ee7b7; border: 1px solid rgba(110,231,183,.25); }
.alert-rpi.rpi-mid  { background: rgba(251,191,36,.1);  color: var(--gold); border: 1px solid rgba(251,191,36,.25); }
.alert-rpi.rpi-high { background: rgba(239,68,68,.1);   color: var(--fall); border: 1px solid rgba(239,68,68,.25); }

/* ── Alert data-age badge ────────────────────────────────────────────────────── */
.alert-data-age {
  display: inline-flex; align-items: center; padding: 1px 5px;
  border-radius: 8px; font-size: .62rem; color: var(--txt-muted);
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
}

/* ── Watch listing count badge ───────────────────────────────────────────────── */
.watch-listing-count {
  display: inline-flex; align-items: center; padding: 1px 7px;
  border-radius: 10px; font-size: .66rem; font-weight: 600;
  background: rgba(255,255,255,.06); color: var(--txt-muted);
  border: 1px solid rgba(255,255,255,.1); margin-left: 6px;
}

/* ── Settings hint text ──────────────────────────────────────────────────────── */
.setting-hint {
  font-size: .72rem; color: var(--txt-muted);
  margin-top: 3px; line-height: 1.4;
}
.setting-section-title {
  font-size: .72rem; font-weight: 700; color: var(--gold-base);
  text-transform: uppercase; letter-spacing: .07em;
  padding: .3rem 0 .5rem; margin-top: .5rem; margin-bottom: .25rem;
  border-top: 1px solid var(--border-faint);
}

/* ── Source badge (portfolio bought-from) ────────────────────────────────────── */
.source-badge {
  display: inline-flex; align-items: center; padding: 1px 7px;
  border-radius: 8px; font-size: .65rem; font-weight: 700;
  margin-left: 5px; vertical-align: middle;
  background: rgba(139,92,246,.15); color: #c4b5fd;
  border: 1px solid rgba(139,92,246,.25);
}
.source-badge.source-ebay       { background: rgba(251,191,36,.12); color: #fbbf24; border-color: rgba(251,191,36,.25); }
.source-badge.source-local      { background: rgba(52,211,153,.12); color: #34d399; border-color: rgba(52,211,153,.25); }
.source-badge.source-cardmarket { background: rgba(96,165,250,.12); color: #60a5fa; border-color: rgba(96,165,250,.25); }
.source-badge.source-facebook   { background: rgba(99,102,241,.15); color: #a5b4fc; border-color: rgba(99,102,241,.25); }

/* ── eBay deal tab — net margin rows ─────────────────────────────────────────── */
.ebay-row.deal    { background: rgba(52,211,153,.05); border: 1px solid rgba(52,211,153,.15); border-radius: 8px; padding: .5rem .65rem; margin-bottom: .4rem; }
.ebay-row.neutral { background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.06); border-radius: 8px; padding: .5rem .65rem; margin-bottom: .4rem; }
.ebay-row.loss    { background: rgba(239,68,68,.04); border: 1px solid rgba(239,68,68,.1); border-radius: 8px; padding: .5rem .65rem; margin-bottom: .4rem; }

.ebay-row-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }

.ebay-cost-breakdown,
.ebay-cm-row {
  display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  font-size: .75rem; color: var(--txt-secondary);
  margin-bottom: .2rem;
}
.ebay-sep    { color: var(--txt-muted); font-size: .72rem; }
.ebay-total  { font-weight: 700; color: var(--txt-hi); }
.ebay-profit { font-weight: 700; }
.ebay-profit.profit { color: #6ee7b7; }
.ebay-profit.loss   { color: var(--fall); }

.net-margin-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; flex-shrink: 0; margin-left: auto;
}
.net-margin-badge.profit  { background: rgba(52,211,153,.15); color: #6ee7b7; border: 1px solid rgba(52,211,153,.3); }
.net-margin-badge.neutral { background: rgba(251,191,36,.13); color: #fbbf24; border: 1px solid rgba(251,191,36,.28); }
.net-margin-badge.loss    { background: rgba(239,68,68,.12);  color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ── Portfolio panel ─────────────────────────────────────────────────────────── */
.portfolio-stats {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.portfolio-stat {
  flex: 1; min-width: 90px;
  background: var(--surface-2); border-radius: 8px; padding: 10px 12px;
}
.pstat-label {
  font-size: .68rem; color: var(--txt-muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em;
}
.pstat-value {
  font-size: 1.05rem; font-weight: 700; color: var(--txt-primary);
}
.pstat-value.profit { color: #6ee7b7; }
.pstat-value.loss   { color: var(--fall); }

.portfolio-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border-radius: 8px; margin-bottom: 8px;
  background: var(--surface-2); transition: background .15s;
}
.portfolio-row:hover { background: var(--surface-3); }

.portfolio-thumb {
  width: 44px; height: 62px; flex-shrink: 0;
  border-radius: 4px; object-fit: cover;
}
.portfolio-thumb.placeholder {
  width: 44px; height: 62px; flex-shrink: 0;
  border-radius: 4px; background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--txt-muted);
}

.portfolio-body { flex: 1; min-width: 0; }
.portfolio-card-name {
  font-size: .82rem; font-weight: 600; color: var(--txt-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.portfolio-row-meta {
  font-size: .7rem; color: var(--txt-muted); margin-top: 2px;
}
.portfolio-row-prices {
  display: flex; align-items: center; gap: 8px;
  margin-top: 5px; flex-wrap: wrap;
}
.portfolio-row-prices span {
  font-size: .75rem; color: var(--txt-secondary);
}
.portfolio-pnl {
  font-size: .78rem; font-weight: 700; padding: 1px 7px;
  border-radius: 10px;
}
.portfolio-pnl.profit { background: rgba(110,231,183,.12); color: #6ee7b7; border: 1px solid rgba(110,231,183,.2); }
.portfolio-pnl.loss   { background: rgba(239,68,68,.1);    color: var(--fall); border: 1px solid rgba(239,68,68,.2); }

.portfolio-notes {
  font-size: .68rem; color: var(--txt-muted); margin-top: 3px;
  font-style: italic;
}
.portfolio-row-actions {
  display: flex; align-items: flex-start; padding-top: 2px;
}
.portfolio-delete-btn {
  background: none; border: none; cursor: pointer;
  color: var(--txt-muted); padding: 4px 6px; border-radius: 6px;
  font-size: 1rem; transition: color .15s, background .15s;
}
.portfolio-delete-btn:hover { color: var(--fall); background: rgba(239,68,68,.1); }

/* ── Lang tag (inside portfolio card name row) ──────────────────────────────── */
.lang-tag {
  display: inline-flex; align-items: center; padding: 0 5px;
  border-radius: 6px; font-size: .62rem; font-weight: 600;
  background: rgba(139,92,246,.18); color: #c4b5fd;
  border: 1px solid rgba(139,92,246,.25); margin-left: 5px; vertical-align: middle;
}

/* ── Arbitrage tab ───────────────────────────────────────────────────────────── */
.arb-toolbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: .6rem; padding: .5rem 0 .65rem; flex-shrink: 0;
}
.arb-hint {
  font-size: .7rem; color: var(--txt-muted); flex: 1;
  text-align: right;
}
.arb-row {
  display: flex; flex-direction: column; gap: .3rem;
}
.arb-main {
  display: flex; align-items: center; gap: .5rem;
}
.arb-name {
  font-size: .88rem; font-weight: 600; color: var(--txt-hi); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.arb-ratio-badge {
  font-size: .72rem; font-weight: 700; padding: 2px 7px;
  border-radius: 10px;
  background: rgba(201,169,110,.15); color: var(--gold-base);
  border: 1px solid rgba(201,169,110,.3);
  flex-shrink: 0;
}
.arb-prices {
  display: flex; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--txt-base); flex-wrap: wrap;
}
.arb-sep { color: var(--txt-muted); }
.arb-price-en    { color: #6ee7b7; }
.arb-price-foreign { color: var(--gold-base); }
.arb-direction {
  font-size: .72rem; color: var(--txt-muted); font-style: italic;
}
.arb-actions {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin-top: .1rem;
}
.arb-acked {
  font-size: .72rem; color: var(--txt-muted); padding: 2px 6px;
  border: 1px solid var(--border-faint); border-radius: var(--r-sm);
}

/* ── Arbitrage sub-tabs ──────────────────────────────────────────────────────── */
.arb-subtabs {
  display: flex; gap: 4px; padding: .5rem .75rem .3rem;
  border-bottom: 1px solid var(--border-faint);
}
.arb-subtab {
  font-size: .75rem; padding: 4px 12px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-faint);
  color: var(--txt-muted); transition: background .15s, color .15s;
}
.arb-subtab:hover  { background: rgba(255,255,255,.06); color: var(--txt); }
.arb-subtab.active {
  background: rgba(201,169,110,.15); border-color: rgba(201,169,110,.3);
  color: var(--gold-base); font-weight: 600;
}
.arb-sample { color: var(--txt-muted); font-size: .72rem; }
.arb-ratio-badge.high { background: rgba(110,231,183,.15); color: #6ee7b7; border-color: rgba(110,231,183,.3); }
.arb-ratio-badge.mid  { background: rgba(251,191,36,.15);  color: #fbbf24; border-color: rgba(251,191,36,.3); }
.arb-ratio-badge.deal { background: rgba(251,191,36,.18);  color: #fcd34d; border-color: rgba(252,211,77,.35); }
.arb-ratio-badge.low  { background: rgba(239,68,68,.12);   color: #f87171; border-color: rgba(239,68,68,.25); }

/* ── eBay price section in card modal ────────────────────────────────────────── */
.ebay-section {
  margin: .75rem 0 0;
  padding: .6rem .75rem;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border-faint);
  border-radius: var(--r-md);
}
.ebay-section-label {
  font-size: .72rem; font-weight: 600; color: var(--txt-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem;
}
.ebay-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--txt-base); padding: .25rem 0;
  border-top: 1px solid rgba(255,255,255,.04);
}
.ebay-row:first-of-type { border-top: none; }
.ebay-lang   { font-weight: 600; color: var(--txt-hi); min-width: 2.5rem; }
.ebay-median { color: #6ee7b7; font-weight: 600; }
.ebay-range  { color: var(--txt-muted); font-size: .75rem; }
.ebay-margin {
  font-size: .72rem; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; margin-left: auto;
}
.ebay-margin.margin-high { background: rgba(110,231,183,.15); color: #6ee7b7; border: 1px solid rgba(110,231,183,.3); }
.ebay-margin.margin-mid  { background: rgba(251,191,36,.15);  color: #fbbf24; border: 1px solid rgba(251,191,36,.3); }
.ebay-margin.margin-low  { background: rgba(239,68,68,.12);   color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ── Scraper health indicator ────────────────────────────────────────────────── */
.scraper-health {
  font-size: .72rem; padding: 4px 10px; border-radius: 6px;
  margin-bottom: 10px; display: inline-block;
}
.scraper-health.ok      { background: rgba(110,231,183,.1); color: #6ee7b7; border: 1px solid rgba(110,231,183,.2); }
.scraper-health.error   { background: rgba(239,68,68,.1);   color: var(--fall); border: 1px solid rgba(239,68,68,.2); }
.scraper-health.unknown { background: rgba(255,255,255,.05); color: var(--txt-muted); border: 1px solid rgba(255,255,255,.08); }



/* -- Rarity quick-filter pills ----------------------------------------------- */
.rarity-pills {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.rarity-pills::-webkit-scrollbar { display: none; }
.rarity-pill {
  flex-shrink: 0;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  color: var(--txt-muted);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .78rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.rarity-pill:hover { background: rgba(255,255,255,.1); color: var(--txt); }
.rarity-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1209;
  font-weight: 600;
}

/* -- Price history sparklines ------------------------------------------------- */
.sparkline {
  display: block;
  width: 80px; height: 24px;
  overflow: visible;
}
.sparkline polyline {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.spark-up   polyline { stroke: #6ee7b7; }
.spark-down polyline { stroke: var(--fall, #ef4444); }
.spark-flat polyline { stroke: rgba(255,255,255,.3); }

/* -- Days of data stat pill --------------------------------------------------- */
#statDataPill .stat-val { color: var(--txt-muted); font-size: .95rem; }
