/* ===========================================================================
   Pokédex Library — premium dark "gallery" theme
   Animations use transform/opacity only so they stay buttery on cheap GPUs.
   =========================================================================== */
:root {
  --bg: #0a0b14;
  --bg-2: #0e1020;
  --surface: rgba(22, 25, 44, 0.55);
  --surface-solid: #14172a;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --text: #eef0ff;
  --muted: #9aa0c4;
  --muted-2: #6d73a0;
  --accent: #6c8cff;
  --accent-2: #b06bff;
  --gold: #ffcf5a;
  --good: #4ade80;
  --radius: 18px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.75);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* component display rules must not override the attribute */
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Outfit", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, #181b38 0%, transparent 60%),
              radial-gradient(900px 700px at 0% 0%, #1a1230 0%, transparent 55%),
              var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- animated aurora backdrop --------------------------------------------- */
/* Soft radial-gradient blobs (no blur filter) so the slow drift is pure GPU
   compositing — animating a blur()ed parent re-rasterises every frame. */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; opacity: 0.6; }
.blob {
  position: absolute; width: 75vw; height: 75vw; border-radius: 50%;
  mix-blend-mode: screen; will-change: transform; animation: float 28s ease-in-out infinite alternate;
}
.b1 { background: radial-gradient(circle, #5b6cff 0%, rgba(91,108,255,0) 60%); top: -20%; left: -15%; }
.b2 { background: radial-gradient(circle, #b454ff 0%, rgba(180,84,255,0) 60%); bottom: -25%; right: -15%; animation-delay: -9s; }
.b3 { background: radial-gradient(circle, #1f9bff 0%, rgba(31,155,255,0) 60%); top: 25%; left: 35%; animation-delay: -15s; }
@keyframes float { to { transform: translate3d(7%, 9%, 0) scale(1.18); } }

/* ---- top bar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 22px;
  padding: 16px clamp(16px, 4vw, 44px);
  /* More opaque background + lighter blur — backdrop-filter on a sticky bar is
     re-rasterised on every scroll frame, so keep the blur small. */
  background: linear-gradient(180deg, rgba(10,11,20,0.96), rgba(10,11,20,0.82));
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand h1 {
  font-size: 21px; font-weight: 800; letter-spacing: -0.02em; margin: 0; line-height: 1;
  display: flex; flex-direction: column;
}
.brand h1 span { font-size: 11px; font-weight: 600; letter-spacing: 0.32em; color: var(--muted); text-transform: uppercase; margin-top: 3px; }
.demo-badge { align-self: center; font-size: 10px; font-weight: 800; letter-spacing: 0.14em; color: #0b0d1a; background: linear-gradient(135deg, var(--gold), #ffb347); padding: 3px 8px; border-radius: 6px; box-shadow: 0 4px 12px -4px var(--gold); }
.pokeball {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 5px, #1a1a1a 5px 8px, #fff 8px 11px, transparent 11px),
    linear-gradient(#ee1515 0 50%, #f7f7f7 50% 100%);
  border: 2.5px solid #15151f;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 6px 18px -6px #ee1515aa;
  animation: spin-in 0.8s var(--ease) both;
}
@keyframes spin-in { from { transform: rotate(-140deg) scale(0.4); opacity: 0; } }

.search-shell {
  flex: 1; max-width: 640px; position: relative; display: flex; align-items: center;
}
.search-ico { position: absolute; left: 16px; width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
#search {
  width: 100%; padding: 13px 44px 13px 44px;
  background: var(--surface); border: 1px solid var(--stroke-strong);
  border-radius: 999px; color: var(--text); font-size: 15px; font-family: inherit;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  backdrop-filter: blur(8px);
}
#search::placeholder { color: var(--muted-2); }
#search:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(108,140,255,0.18), 0 8px 30px -12px rgba(108,140,255,0.5);
  background: rgba(22,25,44,0.8);
}
.clear-btn {
  position: absolute; right: 12px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.1); color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer; transition: background 0.2s, transform 0.2s;
}
.clear-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.1); }

.tabs { display: flex; gap: 6px; background: var(--surface); padding: 5px; border-radius: 999px; border: 1px solid var(--stroke); flex-shrink: 0; }
.tab {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
  display: flex; align-items: center; gap: 7px; transition: color 0.2s; position: relative;
}
.tab.is-active { color: #fff; }
.tab.is-active::before {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  z-index: -1; box-shadow: 0 6px 20px -8px var(--accent-2);
  animation: pop 0.3s var(--ease);
}
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: rgba(0,0,0,0.3); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab:not(.is-active) .badge { background: rgba(255,255,255,0.08); }
.tab-ico { display: none; width: 22px; height: 22px; flex-shrink: 0; }  /* shown only in the mobile bottom nav */

/* ---- currency toggle ------------------------------------------------------ */
.cur-toggle { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; border: 1px solid var(--stroke); flex-shrink: 0; }
.cur-toggle button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 700; padding: 7px 13px; border-radius: 999px;
  min-width: 36px; transition: color 0.2s;
}
.cur-toggle button.is-on { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 16px -8px var(--accent-2); }
.lang-toggle button { min-width: 0; padding: 7px 12px; font-size: 13px; }

/* accounts / login */
.auth { display: flex; align-items: center; flex-shrink: 0; }
.auth-btn {
  border: 1px solid var(--stroke-strong); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; transition: all 0.2s var(--ease); white-space: nowrap;
}
.auth-btn:hover { color: #fff; border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 8px 20px -10px var(--accent); }
.auth-btn.ghost { padding: 6px 12px; font-size: 12.5px; color: var(--muted); }
.auth-btn.ghost:hover { color: #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 999px; padding: 4px 6px 4px 12px; }
.user-ava { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex-shrink: 0; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15); }
.user-name { font-size: 13.5px; font-weight: 700; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-modal { z-index: 120; }
.auth-card {
  position: relative; z-index: 1; width: min(400px, 94vw);
  background: linear-gradient(180deg, #15182b, #0f1120); border: 1px solid var(--stroke-strong);
  border-radius: 20px; padding: 32px 30px 26px; box-shadow: 0 40px 100px -30px rgba(0,0,0,0.8);
  animation: pop 0.34s var(--ease);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-brand .pokeball { width: 38px; height: 38px; }
.auth-card h2 { margin: 0; text-align: center; font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }
.auth-sub { margin: 8px 0 22px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.auth-field { display: block; margin-bottom: 14px; }
.auth-field span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.auth-field input {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--bg); border: 1px solid var(--stroke-strong); border-radius: 11px; padding: 12px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.auth-error { background: rgba(255,93,93,0.12); border: 1px solid rgba(255,93,93,0.4); color: #ffb3b3; font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; padding: 12px; font-size: 15px; }
.auth-switch { margin: 16px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.auth-switch button { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.auth-switch button:hover { color: var(--accent-2); }

/* share bar (wishlist) */
.share-bar { margin: 0 0 18px; }
.share-box { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.share-box input { flex: 1; min-width: 220px; font-family: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--stroke-strong); border-radius: 10px; padding: 9px 12px; }
.share-trigger { white-space: nowrap; }

/* public (shared) wishlist view */
.pubwish-head { text-align: center; max-width: 640px; margin: 10px auto 30px; }
.pubwish-eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.pubwish-head h2 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.pubwish-meta { margin: 10px 0 20px; color: var(--muted); font-size: 15px; }
.pubwish-meta b { color: var(--gold); }
.pubwish-cm { font-size: 11px; color: var(--muted-2); margin-left: 4px; }
.pubwish-cta { display: inline-flex; }

/* public mode: read-only — hide interactive chrome */
.public-mode .search-shell,
.public-mode .tabs,
.public-mode #langToggle,
.public-mode .auth { display: none !important; }
.public-mode .heart-btn,
.public-mode .modal-actions .btn-primary { display: none !important; }

/* missing-image placeholder (some old Japanese cards have no scan) */
.no-img {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 14px; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.3;
  background: linear-gradient(135deg, #1a1d33, #0e1020);
}
.no-img span { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }

/* ---- wishlist tools ------------------------------------------------------- */
.wish-tools { display: flex; gap: 14px; flex-wrap: wrap; margin: -4px 0 22px; }
.wt-field { display: flex; flex-direction: column; gap: 5px; }
.wt-field > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); padding-left: 2px; }
.wt-field select {
  appearance: none; -webkit-appearance: none; min-width: 190px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%239aa0c4' stroke-width='1.6' stroke-linecap='round'/></svg>") no-repeat right 13px center;
  border: 1px solid var(--stroke-strong); color: var(--text); font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 10px 34px 10px 14px; border-radius: 11px; cursor: pointer; transition: border-color 0.2s;
}
.wt-field select:focus { outline: none; border-color: var(--accent); }

/* ---- discover filter/sort toolbar ----------------------------------------- */
.discover-tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.discover-tools .wt-field select { min-width: 150px; padding: 9px 32px 9px 12px; font-size: 13px; }
.discover-clear { align-self: flex-end; height: 38px; }

/* ---- price-board variant note --------------------------------------------- */
.pb-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--stroke); font-size: 11.5px; line-height: 1.5; color: var(--muted-2); }

/* ---- main / views --------------------------------------------------------- */
main { padding: 28px clamp(16px, 4vw, 44px) 80px; }
.view { display: none; animation: viewIn 0.45s var(--ease); }
.view.is-active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }

.chip {
  border: 1px solid var(--stroke-strong); background: var(--surface); color: var(--muted);
  padding: 8px 16px; border-radius: 999px; font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all 0.22s var(--ease); backdrop-filter: blur(6px);
}
.chip:hover { color: #fff; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px -10px var(--accent); }

.result-meta { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; min-height: 18px; }

/* ---- card grid ------------------------------------------------------------ */
.grid {
  display: grid; gap: clamp(14px, 1.6vw, 22px);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.card {
  position: relative; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--stroke); padding: 10px;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
  transform: translateY(12px); opacity: 0; animation: cardIn 0.5s var(--ease) forwards;
  /* Skip rendering off-screen cards — big win as the infinite-scroll grid grows.
     No per-card will-change (hundreds of compositor layers hurt more than help). */
  content-visibility: auto;
  contain-intrinsic-size: 280px 340px;
}
@keyframes cardIn { to { transform: translateY(0); opacity: 1; } }
.card:hover {
  transform: translateY(-6px); border-color: var(--stroke-strong);
  box-shadow: 0 26px 50px -24px rgba(0,0,0,0.85), 0 0 0 1px rgba(108,140,255,0.25);
}
.card-img-frame {
  position: relative; aspect-ratio: 245 / 342; border-radius: 9px; overflow: hidden;
  background: linear-gradient(135deg, #1a1d33, #0e1020);
}
.card-img-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.card-img-frame img.loaded { opacity: 1; }
.card:hover .card-img-frame img { transform: scale(1.05); }
/* moving holographic sheen on hover */
.card-img-frame::after {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 45%, rgba(180,200,255,0.15) 50%, transparent 65%);
  background-size: 250% 250%; mix-blend-mode: overlay; pointer-events: none;
}
.card:hover .card-img-frame::after { opacity: 1; animation: sheen 1.2s var(--ease); }
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -40% 0; } }

.card-meta { padding: 11px 4px 4px; }
.card-name { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; gap: 8px; }
.price-pill {
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  background: rgba(255,207,90,0.1); border: 1px solid rgba(255,207,90,0.2);
  padding: 3px 9px; border-radius: 8px; white-space: nowrap;
  max-width: 74%; overflow: hidden; text-overflow: ellipsis;
}
.price-pill.na { color: var(--muted-2); background: rgba(255,255,255,0.04); border-color: var(--stroke); }
.price-pill.rarity { font-size: 11px; color: #c9b6ff; background: rgba(176,107,255,0.13); border-color: rgba(176,107,255,0.32); }
.heart-btn {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all 0.22s var(--ease);
  color: var(--muted);
}
.heart-btn svg { width: 16px; height: 16px; transition: transform 0.25s var(--ease); }
.heart-btn:hover { color: #ff6b9d; border-color: rgba(255,107,157,0.4); transform: scale(1.08); }
.heart-btn.is-on { color: #ff5d8f; background: rgba(255,93,143,0.14); border-color: rgba(255,93,143,0.4); }
.heart-btn.is-on svg { fill: currentColor; animation: pulse 0.4s var(--ease); }
@keyframes pulse { 50% { transform: scale(1.35); } }

/* rarity glow accent strip */
.card[data-rare="1"] { box-shadow: 0 0 0 1px rgba(255,207,90,0.16); }
.card[data-rare="1"]:hover { box-shadow: 0 26px 50px -24px rgba(0,0,0,0.85), 0 0 0 1px rgba(255,207,90,0.4), 0 0 30px -10px rgba(255,207,90,0.5); }

/* ---- skeletons ------------------------------------------------------------ */
.skeleton { pointer-events: none; }
.skeleton .card-img-frame { animation: shimmer 1.4s linear infinite; background: linear-gradient(100deg, #15182b 30%, #20243f 50%, #15182b 70%); background-size: 200% 100%; }
.skeleton .card-name, .skeleton .card-sub { background: #1a1d33; border-radius: 6px; color: transparent; }
.skeleton .card-name { width: 70%; } .skeleton .card-sub { width: 45%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- empty / loading messages --------------------------------------------- */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty h3 { font-size: 19px; color: var(--text); margin: 0 0 6px; }
.sentinel { height: 1px; }

/* ---- wishlist ------------------------------------------------------------- */
/* trending */
.trend-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.trend-head h2 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.trend-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 56ch; }
.trend-toggle button { white-space: nowrap; }
.mom-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 12px; font-weight: 800; letter-spacing: 0.01em;
  padding: 4px 8px; border-radius: 7px; color: #06130b;
  box-shadow: 0 4px 12px -4px rgba(0,0,0,0.7); backdrop-filter: blur(2px);
}
.mom-badge.up { background: linear-gradient(135deg, #4ade80, #16a34a); }
.mom-badge.down { background: linear-gradient(135deg, #fca5a5, #dc2626); color: #1a0606; }
.mom-badge.views { background: linear-gradient(135deg, #fb923c, #f97316); color: #fff; }

.wish-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.wish-head h2 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.wish-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.wish-total {
  text-align: right; background: var(--surface); border: 1px solid var(--stroke-strong);
  border-radius: 14px; padding: 12px 20px; backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 2px;
}
.wt-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.wt-value { font-size: 26px; font-weight: 800; color: var(--gold); letter-spacing: -0.02em; }
.wt-note { font-size: 11px; color: var(--muted-2); }

/* ---- modal ---------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,6,14,0.72); backdrop-filter: blur(10px); animation: fade 0.3s; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(900px, 100%); max-height: 90vh; overflow: auto;
  background: linear-gradient(180deg, #15182b, #0e1020); border: 1px solid var(--stroke-strong);
  border-radius: 24px; box-shadow: var(--shadow); padding: 28px;
  animation: modalIn 0.42s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
.modal-close {
  position: absolute; top: 16px; right: 16px; z-index: 3; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--stroke); background: rgba(255,255,255,0.06); color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { background: rgba(255,255,255,0.16); transform: rotate(90deg); }
.modal-grid { display: grid; grid-template-columns: minmax(0, 0.85fr) 1fr; gap: 30px; align-items: start; }

/* 3D holo tilt card in modal */
.modal-img-wrap { perspective: 1200px; }
.tilt-card {
  position: relative; border-radius: 16px; overflow: hidden; transform-style: preserve-3d;
  transition: transform 0.2s var(--ease); aspect-ratio: 245/342;
  box-shadow: 0 30px 60px -25px rgba(0,0,0,0.9);
}
.tilt-card img { width: 100%; height: 100%; display: block; object-fit: cover; backface-visibility: hidden; }
.tilt-card .holo {
  position: absolute; inset: 0; mix-blend-mode: color-dodge; opacity: 0; transition: opacity 0.3s; pointer-events: none;
  background: linear-gradient(115deg, transparent 25%, rgba(120,180,255,0.5) 42%, rgba(255,140,255,0.5) 50%, rgba(120,255,200,0.5) 58%, transparent 75%);
  background-size: 200% 200%;
}
.tilt-card .glare {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.55), transparent 45%);
  mix-blend-mode: overlay;
}
.tilt-card.active .holo, .tilt-card.active .glare { opacity: 1; }

.modal-info h2 { margin: 0 0 4px; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.modal-info .set-line { color: var(--muted); font-size: 14px; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tag { font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--stroke-strong); background: rgba(255,255,255,0.04); }
.tag.type { color: #fff; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.spec { background: rgba(255,255,255,0.03); border: 1px solid var(--stroke); border-radius: 12px; padding: 11px 14px; }
.spec .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); }
.spec .v { font-size: 15px; font-weight: 600; margin-top: 3px; }

.price-board { background: linear-gradient(135deg, rgba(255,207,90,0.08), rgba(176,107,255,0.06)); border: 1px solid var(--stroke-strong); border-radius: 16px; padding: 16px 18px; margin-bottom: 20px; }
.price-board .pb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.price-board .pb-head span { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.cm-logo { font-size: 12px; font-weight: 700; color: var(--accent); }
.price-row { display: flex; gap: 22px; }
.price-cell .pc-label { font-size: 11.5px; color: var(--muted); }
.price-cell .pc-val { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.price-cell.trend .pc-val { color: var(--gold); }

.modal-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  font-family: inherit; font-size: 15px; font-weight: 600; padding: 13px 22px; border-radius: 12px;
  cursor: pointer; border: 1px solid var(--stroke-strong); background: rgba(255,255,255,0.05); color: var(--text);
  transition: all 0.22s var(--ease); display: inline-flex; align-items: center; gap: 9px;
}
.btn:hover { transform: translateY(-2px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 30px -12px var(--accent-2); }
.btn-primary.is-on { background: linear-gradient(135deg, #ff5d8f, #ff8f6b); box-shadow: 0 12px 30px -12px #ff5d8f; }
.btn-primary.is-on svg { fill: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

/* ---- toast ---------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid); border: 1px solid var(--stroke-strong); color: var(--text);
  padding: 13px 22px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 200;
  box-shadow: var(--shadow); opacity: 0; transition: opacity 0.3s, transform 0.3s var(--ease);
  display: flex; align-items: center; gap: 10px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

/* ===========================================================================
   GRADE PAGE
   =========================================================================== */
.grade-hero { max-width: 720px; margin-bottom: 26px; }
.grade-hero h2 { margin: 0 0 8px; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.grade-hero p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }

.grade-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.grade-main { min-width: 0; }

/* dropzone */
.dropzone {
  display: flex; align-items: center; justify-content: center; position: relative;
  min-height: 320px; border-radius: 18px; cursor: pointer; overflow: hidden;
  border: 1.5px dashed var(--stroke-strong); background: var(--surface);
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
  backdrop-filter: blur(8px);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent); background: rgba(108,140,255,0.07); outline: none;
}
.dropzone.drag { transform: scale(1.01); }
.dz-empty { text-align: center; color: var(--muted); padding: 30px; pointer-events: none; }
.dz-empty svg { width: 48px; height: 48px; color: var(--accent); margin-bottom: 14px; }
.dz-title { font-size: 17px; font-weight: 600; color: var(--text); }
.dz-title .dz-opt { font-size: 11px; font-weight: 600; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.08em; margin-left: 6px; }
.dz-sub { font-size: 13px; margin-top: 6px; max-width: 320px; }
#frontPreview, #backPreview { width: 100%; height: 100%; max-height: 460px; object-fit: contain; display: block; background: #0b0d18; }

/* two-up upload (front + back) */
.dz-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dz-pair .dropzone { min-height: 240px; }
@media (max-width: 520px) { .dz-pair { grid-template-columns: 1fr; } }

/* corner/edge/surface soft-status chips */
.sub-chips { padding: 16px 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .sub-chips { grid-template-columns: 1fr; } }
.sub-chip { border: 1px solid var(--stroke); border-radius: 12px; padding: 12px; background: rgba(255,255,255,0.02); }
.sub-chip .sc-name { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sub-chip .sc-val { display: block; font-size: 15px; font-weight: 800; margin-top: 3px; }
.sub-chip .sc-note { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; line-height: 1.4; }
.sub-chip.ok { border-color: rgba(74,222,128,0.4); }
.sub-chip.ok .sc-val { color: #4ade80; }
.sub-chip.check { border-color: rgba(255,207,90,0.45); }
.sub-chip.check .sc-val { color: var(--gold); }
.sub-chip.na .sc-val { color: var(--muted); }
.cen-readout { padding: 0 22px 4px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

.grade-actions { display: flex; gap: 12px; margin: 16px 0; }
.grade-actions .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* result */
.grade-result:empty { display: none; }
.grade-loading { text-align: center; padding: 40px 20px; color: var(--muted); }
.grade-loading .ring {
  width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.grade-loading .gl-step { font-size: 13px; opacity: 0.7; margin-top: 4px; }

.result-card {
  border: 1px solid var(--stroke-strong); border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, #15182b, #0e1020); animation: viewIn 0.4s var(--ease);
}
.rc-top { display: flex; gap: 20px; align-items: center; padding: 22px; border-bottom: 1px solid var(--stroke); }
.grade-badge {
  flex-shrink: 0; width: 96px; height: 96px; border-radius: 18px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,0.12), transparent 70%), linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 16px 40px -16px var(--accent-2); position: relative;
}
.grade-badge .gb-num { font-size: 42px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.grade-badge .gb-psa { position: absolute; top: 9px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 0.2em; opacity: 0.8; }
.rc-top-info { min-width: 0; }
.rc-label { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.rc-card-name { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--stroke-strong); }
.conf .dot { width: 7px; height: 7px; border-radius: 50%; }
.conf.low { color: #ffb27a; } .conf.low .dot { background: #ff9d52; }
.conf.medium { color: #ffe07a; } .conf.medium .dot { background: var(--gold); }
.conf.high { color: var(--good); } .conf.high .dot { background: var(--good); }

.subgrades { padding: 18px 22px; display: grid; gap: 14px; }
.sg { display: grid; grid-template-columns: 92px 1fr 30px; gap: 12px; align-items: center; }
.sg-name { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.sg-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.sg-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: growBar 0.7s var(--ease) both; }
@keyframes growBar { from { transform: scaleX(0); } }
.sg-val { font-size: 15px; font-weight: 800; text-align: right; }
.sg-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted-2); margin-top: -6px; padding-left: 104px; }
.sg-note:empty { display: none; }

.rc-section { padding: 0 22px 18px; }
.rc-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); margin: 14px 0 8px; }
.rc-summary { font-size: 14.5px; line-height: 1.55; color: var(--text); padding: 0 22px 6px; }
.rc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rc-list li { font-size: 13.5px; color: var(--muted); padding-left: 18px; position: relative; }
.rc-list li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.rc-list.defects li::before { background: #ff7a9c; }
.quality-warn { margin: 0 22px 18px; padding: 12px 14px; border-radius: 12px; background: rgba(255,157,82,0.1); border: 1px solid rgba(255,157,82,0.3); color: #ffc79a; font-size: 13.5px; }
.centering-pill { font-size: 12.5px; color: var(--muted); }

/* side panels */
.grade-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 92px; }
.panel { border: 1px solid var(--stroke); border-radius: 16px; padding: 18px 20px; background: var(--surface); backdrop-filter: blur(8px); }
.panel h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.edu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.edu-list li { font-size: 13.5px; color: var(--muted); line-height: 1.5; padding-left: 16px; position: relative; }
.edu-list li::before { content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px; border-radius: 2px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.edu-list b { color: var(--text); }
.edu-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--stroke); line-height: 1.5; }
.edu-note b { color: var(--gold); }

/* PSA reference panel */
.grade-scale { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.grade-scale span { font-size: 11px; color: var(--muted); background: rgba(255,255,255,0.04); border: 1px solid var(--stroke); border-radius: 7px; padding: 4px 8px; }
.grade-scale b { color: var(--text); margin-right: 3px; }
.cen-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cen-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); font-weight: 600; padding: 0 0 6px; }
.cen-table td { padding: 6px 0; border-top: 1px solid var(--stroke); color: var(--muted); }
.cen-table td:first-child { color: var(--text); font-weight: 500; }
.cen-table td:not(:first-child) { text-align: right; color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }

.est-intro { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.est-rows { display: flex; flex-direction: column; gap: 13px; }
.est-row { display: grid; grid-template-columns: 80px 1fr 26px; gap: 10px; align-items: center; }
.est-row label { font-size: 13px; color: var(--muted); }
.est-row input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.1); outline: none; }
.est-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); cursor: pointer; box-shadow: 0 2px 8px -2px var(--accent-2); }
.est-row .ev { font-size: 14px; font-weight: 700; text-align: right; }
.est-out { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--stroke); }
.est-out > span:first-child { font-size: 13px; color: var(--muted); }
.est-grade { font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: -0.02em; }

.grade-disclaimer { margin: 26px 0 0; padding: 14px 16px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid var(--stroke); color: var(--muted); font-size: 12.5px; line-height: 1.55; max-width: 900px; }
.grade-disclaimer b { color: var(--muted); }

@media (max-width: 900px) {
  .grade-cols { grid-template-columns: 1fr; }
  .grade-side { position: static; }
}

/* ---- responsive: tablet --------------------------------------------------- */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 14px; }
  .search-shell { order: 3; max-width: none; flex-basis: 100%; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-img-wrap { max-width: 280px; margin: 0 auto; }
}

/* ===========================================================================
   MOBILE — "extremely optimized": app-style bottom nav, compact topbar,
   16px inputs (no iOS zoom), 2-col grid, fullscreen modal, safe-area insets.
   =========================================================================== */
@media (max-width: 720px) {
  /* --- topbar: brand + compact controls on top, search full width --------- */
  .topbar {
    gap: 10px 8px; padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    row-gap: 10px;
    /* A backdrop-filter here would make it the containing block for the fixed
       bottom nav (trapping it at the top) — use a solid bg on mobile instead. */
    backdrop-filter: none; -webkit-backdrop-filter: none;
    background: rgba(9, 10, 18, 0.98);
  }
  .brand { order: 0; margin-right: auto; gap: 9px; }
  .brand h1 { font-size: 17px; }
  .pokeball { width: 26px; height: 26px; }
  .search-shell { order: 3; flex-basis: 100%; }
  #search { padding: 12px 42px; font-size: 16px; }        /* 16px → no iOS focus-zoom */
  .auth { order: 1; }
  #langToggle, #curToggle { order: 2; }
  .cur-toggle button { padding: 7px 11px; font-size: 13px; min-width: 0; }
  .lang-toggle button { padding: 7px 10px; }
  .auth-btn { padding: 8px 13px; font-size: 13px; }
  .user-name { max-width: 80px; }

  /* --- tabs → fixed bottom navigation (thumb-friendly) -------------------- */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    border: none; border-top: 1px solid var(--stroke); border-radius: 0;
    background: linear-gradient(0deg, rgba(8,9,16,0.98), rgba(10,11,20,0.94));
    backdrop-filter: blur(14px) saturate(130%); -webkit-backdrop-filter: blur(14px) saturate(130%);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    gap: 2px; justify-content: space-around; box-shadow: 0 -8px 30px -12px rgba(0,0,0,0.7);
  }
  .tab {
    flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; min-width: 0;
    font-size: 10.5px; font-weight: 600; border-radius: 14px; color: var(--muted-2);
  }
  .tab-ico { display: block; }
  .tab-label { white-space: nowrap; }
  .tab.is-active { color: #fff; }
  .tab.is-active::before { border-radius: 14px; background: linear-gradient(160deg, rgba(108,140,255,0.28), rgba(176,107,255,0.22)); box-shadow: none; }
  .tab .badge { position: absolute; top: 2px; right: 50%; margin-right: -22px; min-width: 16px; height: 16px; font-size: 10px; }

  /* --- content: leave room for the bottom nav + safe area ----------------- */
  main { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }

  /* --- grid: clean 2-up --------------------------------------------------- */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 8px; }
  .card-name { font-size: 13.5px; }
  .card:hover { transform: none; }            /* no sticky hover-lift on touch */
  .card:active { transform: scale(0.98); }

  /* --- section heads stack -------------------------------------------------*/
  .trend-head, .wish-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .trend-head h2, .wish-head h2 { font-size: 22px; }
  .wish-total { text-align: left; }
  .trend-toggle, .lang-toggle { align-self: flex-start; }

  /* --- discover filters: full-width, easy to tap -------------------------- */
  .discover-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .discover-tools .wt-field { min-width: 0; }
  .discover-tools .wt-field select { width: 100%; min-width: 0; font-size: 16px; padding: 11px 32px 11px 12px; }
  .discover-clear { grid-column: 1 / -1; height: auto; padding: 11px; }
  .wt-field select { font-size: 16px; }

  /* --- modal: near-fullscreen sheet -------------------------------------- */
  .modal { padding: 0; align-items: flex-end; }
  .modal-card {
    width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    animation: sheetIn 0.4s var(--ease);
  }
  @keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
  .modal-img-wrap { max-width: 240px; justify-self: center; margin: 0 auto; }
  .modal-info h2 { font-size: 23px; }
  .specs { grid-template-columns: 1fr 1fr; gap: 10px; }
  .price-row { gap: 16px; }
  .price-cell .pc-val { font-size: 19px; }
  .modal-actions .btn { flex: 1; justify-content: center; }

  /* --- bigger tap targets ------------------------------------------------- */
  .heart-btn { width: 36px; height: 36px; }
  .btn { padding: 13px 18px; }

  /* --- auth modal + inputs ------------------------------------------------ */
  .auth-card { padding: 26px 20px calc(22px + env(safe-area-inset-bottom)); border-radius: 22px; }
  .auth-field input { font-size: 16px; }
  .share-box input { font-size: 16px; }

  /* --- grade / public heads ---------------------------------------------- */
  .grade-hero h2 { font-size: 23px; }
  .pubwish-head h2 { font-size: 24px; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); width: max-content; max-width: 90vw; }
}

/* very small phones */
@media (max-width: 360px) {
  .discover-tools { grid-template-columns: 1fr; }
  .tab-label { font-size: 10px; }
  .brand h1 span { display: none; }   /* drop the "LIBRARY" sub-label to save width */
}

/* avoid sticky :hover effects on touch devices */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; }
  .btn:hover, .chip:hover, .auth-btn:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .blob { animation: none; }
}
