:root {
  --bg: #0e1014;
  --bg-2: #161a21;
  --card: #1b2029;
  --card-2: #222937;
  --line: #2c3340;
  --text: #e8ecf2;
  --muted: #8a93a3;
  --accent: #ffd23f;      /* signature gold */
  --accent-2: #4ea1ff;    /* link blue */
  --key: #ff5d5d;         /* key red */
  --green: #57d99a;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1c2433 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  padding: 22px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 30px; color: var(--accent);
  background: var(--card); width: 52px; height: 52px;
  display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; min-width: 96px;
}
.stat .v { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat.accent .v { color: var(--accent); }
.stat.green .v { color: var(--green); }

/* ---------- Header tools (search + settings cog) ---------- */
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.hsearch { position: relative; }
.hsearch input[type="search"] {
  width: 220px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-size: 14.5px; outline: none;
  transition: width .15s ease;
}
.hsearch input:focus { border-color: var(--accent-2); width: 270px; }
.icon-btn {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--card); color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 24px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
#settings-btn { font-size: 30px; padding: 0; line-height: 1; }   /* bigger, centered cog */

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 8px;
  padding: 16px clamp(16px, 4vw, 40px) 0;
  overflow-x: auto; flex-wrap: nowrap;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 10px 10px 0 0;
  padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  flex: 0 0 auto; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); background: var(--bg-2); border-color: var(--line); border-bottom-color: var(--bg-2); }
.pill {
  background: var(--card-2); color: var(--muted);
  border-radius: 20px; padding: 1px 8px; font-size: 12px; margin-left: 4px;
}

/* ---------- Controls ---------- */
.view { padding: 20px clamp(16px, 4vw, 40px) 60px; }
.controls {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px;
  align-items: center;
}
.controls input[type="search"], .controls select {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; outline: none;
}
.controls input[type="search"] { flex: 1 1 280px; min-width: 200px; }
.controls input:focus, .controls select:focus { border-color: var(--accent-2); }
.ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }

/* ---------- Advanced filters (collapsible) ---------- */
.filter-toggle { white-space: nowrap; }
.filter-toggle.is-open { color: var(--text); border-color: var(--accent-2); }
.filters-adv {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin: -10px 0 22px; padding: 14px 16px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.filters-adv[hidden] { display: none; }
.filters-adv select {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; outline: none;
}
.filters-adv select:focus { border-color: var(--accent-2); }

/* ---------- Collection grid ---------- */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.card.sig:hover { border-color: var(--accent); }

.cover-wrap {
  position: relative; aspect-ratio: 2 / 3; background: var(--bg-2);
  overflow: hidden;
}
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-wrap .fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 16px;
}
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; pointer-events: none; }
.badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 7px;
  backdrop-filter: blur(4px); background: rgba(10,12,16,.7);
}
.badge.grade { color: #0e1014; background: var(--green); }
.badge.grade.raw { background: #7d8597; color: #fff; }   /* raw / unslabbed */
.badge.grade.low { background: #e8a33d; }
.badge.sig { color: #0e1014; background: var(--accent); }
.ribbon-key {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, rgba(6,8,12,.97) 0%, rgba(6,8,12,.9) 55%, transparent);
  color: #fff; font-size: 11px; font-weight: 600; padding: 26px 10px 8px; line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0,0,0,.95);
}
.ribbon-key b { color: var(--key); font-weight: 800; }

.card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-series { font-size: 13px; color: var(--muted); }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.card-foot { margin-top: auto; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding-top: 8px; }
.card-value { font-size: 17px; font-weight: 700; }
.card-value small { font-size: 11px; color: var(--muted); font-weight: 500; }
.card-meta { font-size: 11px; color: var(--muted); }

/* ---------- Wishlist ---------- */
.wishgrid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.wish-group-head {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 10px;
  margin: 8px 0 -6px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 18px; font-weight: 700; letter-spacing: .02em;
}
.wish-group-head:not(:first-child) { margin-top: 18px; }
.wish-group-head span { font-size: 13px; font-weight: 600; color: var(--muted); }
.wishcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.wishcard:hover { transform: translateY(-4px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.wishcard.signed { border-color: var(--accent); }
.wishcard h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; line-height: 1.25; }
.wish-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag {
  font-size: 11px; padding: 2px 9px; border-radius: 20px;
  background: var(--card-2); color: var(--muted);
}
.tag.gold { background: rgba(255,210,63,.16); color: var(--accent); }
.tag.price { background: rgba(87,217,154,.14); color: var(--green); font-weight: 600; }
.wish-info { font-size: 13px; color: var(--text); margin: 6px 0; }
.wish-forecast { font-size: 12.5px; color: var(--muted); }
.wishcard .links { margin-top: 10px; display: flex; gap: 14px; }
.tag.theme { background: rgba(78,161,255,.14); color: var(--accent-2); font-weight: 600; }
.tag.ebay-active { background: rgba(78,161,255,.12); color: var(--accent-2); font-weight: 600; }
.tag.delta-down { background: rgba(87,217,154,.16); color: var(--green); font-weight: 700; }
.tag.delta-up { background: rgba(255,107,107,.16); color: #ff6b6b; font-weight: 700; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--muted); cursor: pointer; white-space: nowrap; }
.toggle input { accent-color: var(--accent); }
.watch-spark { display: flex; align-items: center; gap: 6px; margin: 6px 0 2px; }
.watch-spark .spark { width: 120px; height: 24px; }
.watch-spark .spark-cap { font-size: 10px; color: var(--muted); }

/* ---------- Watchlist focus strip ---------- */
.watch-source { color: var(--muted); font-size: 12.5px; margin: -6px 0 18px; }
.watch-source b { color: var(--text); font-weight: 600; }
.focus-note { color: var(--muted); font-size: 13.5px; max-width: 860px; margin: 0 0 16px; }
.focus-note b { color: var(--text); }
.focus-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip span { color: var(--muted); margin-left: 4px; font-weight: 500; }
.chip:hover { border-color: var(--accent-2); }
.chip.is-active { background: var(--accent-2); color: #0b1220; border-color: var(--accent-2); }
.chip.is-active span { color: rgba(11,18,32,.7); }

/* ---------- Links ---------- */
a.ext { color: var(--accent-2); text-decoration: none; font-size: 13px; font-weight: 600; }
a.ext:hover { text-decoration: underline; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,8,11,.78); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; z-index: 1; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 18px;
  max-width: 880px; width: 100%; max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 14px;
}
.modal-close:hover { border-color: var(--muted); }
.detail { display: grid; grid-template-columns: 280px 1fr; gap: 0; }
.detail-cover { background: var(--bg); padding: 24px; display: grid; place-items: start center; }
.detail-cover img { width: 100%; border-radius: 10px; box-shadow: var(--shadow); }
.detail-main { padding: 26px 28px; }
.detail-main h2 { margin: 0 0 2px; font-size: 22px; }
.detail-sub { color: var(--muted); margin-bottom: 16px; }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; margin: 14px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.detail-plot { font-size: 13.5px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.value-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin: 8px 0 18px;
}
.value-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.value-big { font-size: 28px; font-weight: 800; }
.value-edit { display: flex; align-items: center; gap: 8px; }
.value-edit input {
  width: 120px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 15px;
}
.cert-edit { display: inline-flex; align-items: center; gap: 8px; }
.cert-edit input {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font-size: 13px; font-family: inherit;
}
.value-sources { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; gap: 16px; flex-wrap: wrap; }
.ebay-box { margin-top: 14px; }
.ebay-box h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.ebay-sale { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.ebay-sale .p { color: var(--green); font-weight: 600; }
.ebay-box h4 small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.sold-box .sold-summary { font-size: 14px; margin-bottom: 6px; }
.sold-box .sold-summary b { color: var(--green); font-size: 16px; }
/* Sold-comp chip on collection cards. */
.sold-chip { display: inline-block; margin-top: 3px; font-size: 11px; color: var(--muted);
  background: var(--card-2, rgba(120,130,150,.12)); border-radius: 5px; padding: 1px 5px; white-space: nowrap; }
/* CGC census rarity line in the modal + top-pop badge on cards. */
.census-line { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.census-line b { color: var(--text); }
.census-line.top-pop { color: var(--gold, #d4af37); }
.census-line.top-pop b { color: var(--gold, #d4af37); }
/* Compact CGC population chip on watch cards. */
.tag.census-chip { background: rgba(78,161,255,.12); color: var(--accent-2); font-weight: 600; }
.tag.census-chip.top { background: rgba(255,210,63,.18); color: var(--accent); font-weight: 700; }
/* Sold / ended watched listing. */
.tag.ended-tag { background: rgba(138,147,163,.16); color: var(--muted); font-weight: 600; }
/* Expander for the rest of the variant-matched comps in the watch modal. */
.comps-more summary { cursor: pointer; color: var(--accent-2); font-size: 12.5px; padding: 7px 2px; list-style: none; }
.comps-more summary::-webkit-details-marker { display: none; }
.comps-more summary::before { content: "▸ "; }
.comps-more[open] summary::before { content: "▾ "; }
.comps-more .more-hide { display: none; }
.comps-more[open] .more-show { display: none; }
.comps-more[open] .more-hide { display: inline; }
/* Clickable wish/watch cards + their detail-modal bits. */
.wishcard.clickable { cursor: pointer; transition: border-color .12s, transform .12s; }
.wishcard.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
.wishcard.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vsub { color: var(--muted); font-size: 12px; }
/* Per-book "tune value & comps" disclosure in the modal. */
.sold-tune { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.sold-tune summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.sold-tune .tune-field { display: block; margin: 10px 0 4px; font-size: 12.5px; }
.sold-tune .tune-field small { display: block; color: var(--muted); font-weight: 400; margin: 2px 0 4px; }
.sold-tune input { width: 100%; box-sizing: border-box; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.hint-line { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.tag.note-tag { background: rgba(212,175,55,.16); }
.ebay-box h4 small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-left: 6px; }
a.ebay-sale { text-decoration: none; color: var(--text); }
a.ebay-sale:hover { color: var(--accent); }
.toppop-badge { position: absolute; top: 36px; left: 8px; z-index: 2;
  background: linear-gradient(180deg,#e9c84a,#b8902a); color: #2a1e02;
  font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 2px 6px; border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); }

#import-btn { cursor: pointer; }
.dropzone {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8,10,14,.82); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 40px;
}
.dropzone[hidden] { display: none; }
.dropzone-inner {
  border: 2.5px dashed var(--accent); border-radius: 18px;
  padding: 60px 80px; font-size: 22px; color: var(--text);
  background: rgba(27,32,41,.6); text-align: center;
}
.dropzone-inner b { color: var(--accent); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--green);
  color: var(--text); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 70; font-size: 14px; max-width: 90vw;
}
.toast.err { border-left-color: var(--key); }
.linkbtn { background: none; border: none; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* wishlist cover */
.wish-cover {
  position: relative; aspect-ratio: 2 / 3; background: var(--bg-2);
  overflow: hidden; display: grid; place-items: center;
}
.wish-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wish-cover .ph { color: var(--muted); font-size: 34px; }
.wbody { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.wbody .links { margin-top: auto; padding-top: 8px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.foot code { background: var(--card); padding: 2px 6px; border-radius: 5px; color: var(--text); }

@media (max-width: 640px) {
  .detail { grid-template-columns: 1fr; }
  .detail-cover { padding: 20px 20px 0; }
  /* Header: brand + cog on row 1; search full-width on row 2; stats/trend below. */
  .topbar { padding: 16px clamp(16px, 4vw, 40px); gap: 12px; }
  .brand { order: 1; flex: 1 1 auto; }
  .topbar-tools { order: 2; width: 100%; }
  .stats { order: 3; width: 100%; }
  .trend { order: 4; width: 100%; }
  .hsearch { flex: 1; }
  .hsearch input[type="search"], .hsearch input:focus { width: 100%; }
  .tagline { display: none; }
}

/* ---------- Settings panel (slide-over from the ⚙ cog) ---------- */
.settings-panel { position: fixed; inset: 0; z-index: 80; }
.settings-panel[hidden] { display: none; }
.settings-backdrop { position: absolute; inset: 0; background: rgba(6,8,12,.6); }
.settings-card {
  position: absolute; top: 0; right: 0; height: 100%; width: min(380px, 92vw);
  background: var(--bg-2); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 20px clamp(18px, 4vw, 26px) 32px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
}
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings-head h2 { margin: 0; font-size: 19px; }
.settings-sec { display: flex; flex-direction: column; gap: 10px; }
.settings-sec h3 {
  margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.settings-sec .ghost { text-align: left; width: 100%; }

/* ---------- Value trend (header) ---------- */
.trend { display: flex; align-items: center; gap: 12px; }
.trend[hidden] { display: none; }
.trend-empty { color: var(--muted); font-size: 12px; max-width: 220px; }
.spark { width: 160px; height: 44px; }
.spark.up path { stroke: var(--green); }
.spark.down path { stroke: var(--key); }
.trend-label { line-height: 1.2; }
.trend-now { font-size: 18px; font-weight: 700; }
.trend-delta { font-size: 12px; }
.trend-delta.up { color: var(--green); }
.trend-delta.down { color: var(--key); }
.book-trend { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.book-trend span { color: var(--muted); font-size: 11px; }

/* ---------- Grail / run progress bars ---------- */
.grail-progress { margin: 0 0 18px; }
.grail-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13.5px; margin-bottom: 6px; }
.grail-head b { color: var(--text); }
.grail-remain { color: var(--muted); }
.grail-bar { height: 8px; background: var(--card-2); border-radius: 20px; overflow: hidden; }
.grail-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--green)); border-radius: 20px; transition: width .3s ease; }

/* ---------- Wishlist acquired state ---------- */
.wishcard.acquired { opacity: .62; }
.wishcard.acquired:hover { opacity: 1; }
.acq-ribbon {
  position: absolute; top: 8px; left: 8px;
  background: var(--green); color: #06281a; font-weight: 800; font-size: 11px;
  padding: 3px 8px; border-radius: 6px; letter-spacing: .4px;
}
.wish-forecast {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.wish-acquire { font-size: 13px; }

/* ---------- Runs / sets ---------- */
.runsgrid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.run-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.run-card.done { border-color: var(--green); }
.run-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.run-head h3 { margin: 0; font-size: 16px; }
.run-done { color: var(--green); font-size: 12px; font-weight: 700; }
.run-count { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.run-issues { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.issue-chip { font-size: 12px; padding: 3px 9px; border-radius: 7px; font-weight: 600; }
.issue-chip.have { background: rgba(87,217,154,.16); color: var(--green); }
.issue-chip.need { background: var(--card-2); color: var(--muted); }
.run-note { color: var(--muted); font-size: 12.5px; margin-top: 12px; }
.run-cost { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--green); }
.run-cost small { color: var(--muted); font-weight: 400; }

/* ---------- Density toggle (compact / comfortable) ---------- */
.density-toggle { align-self: center; white-space: nowrap; }

/* Compact mode: smaller covers, denser grids, trimmed card text. Toggled
   globally via body.compact; the choice persists in localStorage. */
body.compact .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
body.compact .wishgrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
body.compact .card-body, body.compact .wbody { padding: 8px 9px 10px; gap: 2px; }
body.compact .card-series { font-size: 11px; }
body.compact .card-title, body.compact .wbody h3 { font-size: 12px; }
body.compact .card-value { font-size: 14px; }
body.compact .badge { font-size: 10px; padding: 2px 6px; }
body.compact .card-foot { padding-top: 6px; }

/* Mobile: shrink covers so several fit per row instead of one giant card. */
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .wishgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  body.compact .grid { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); gap: 8px; }
  body.compact .wishgrid { grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 8px; }
  .density-toggle { order: 5; }
}

/* ---------- Collection insights strip ---------- */
.insights { display: flex; gap: 10px; flex-wrap: wrap; margin: -4px 0 22px; }
.insights:empty { display: none; }
.insight {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; min-width: 150px; flex: 0 1 auto;
}
.insight .il { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.insight .iv { font-size: 16px; font-weight: 700; margin-top: 2px; }
.insight .iv small { font-size: 12px; font-weight: 500; color: var(--muted); }
.insight .iv .up { color: var(--green); }
.insight .iv .down { color: var(--key); }
.insight.accent .iv { color: var(--accent); }

/* ---------- Watchlist deal summary ---------- */
.watch-deals { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.watch-deals:empty { display: none; }
.deal-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 14px; font-size: 13px;
}
.deal-tile b { font-size: 16px; display: block; }
.deal-tile.good { border-color: rgba(87,217,154,.5); }
.deal-tile.good b { color: var(--green); }
.deal-tile.mover b { color: var(--key); }

/* ---------- Goal nudge on watch cards (completes a run / wishlist grail) ---------- */
.tag.goal { background: rgba(255,210,63,.18); color: var(--accent); font-weight: 700; }

/* ===================================================================
   NEW FEATURES — global search · notes · stats · signatures · radar
   =================================================================== */

/* ---------- Global search results (anchored under the header search) ---------- */
.gsearch-results {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(380px, 86vw);
  z-index: 60; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto; padding: 6px;
}
.gs-group + .gs-group { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.gs-group-h { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 8px 4px; }
.gs-group-h span { color: var(--accent-2); }
.gs-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 9px; padding: 7px 8px; cursor: pointer; color: var(--text);
}
.gs-row:hover { background: var(--card); }
.gs-thumb { width: 30px; height: 40px; flex: none; display: grid; place-items: center; font-size: 16px;
  background: var(--card); border-radius: 5px; overflow: hidden; }
.gs-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gs-text { display: flex; flex-direction: column; min-width: 0; }
.gs-text b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-empty { padding: 14px; color: var(--muted); font-size: 13px; }

/* ---------- 📝 note marker on collection cards ---------- */
.note-dot { position: absolute; bottom: 6px; right: 6px; font-size: 13px; line-height: 1;
  background: rgba(10,12,16,.72); border-radius: 7px; padding: 3px 5px; }

/* ---------- Notes box in the detail modal ---------- */
.notes-box { margin-top: 16px; }
.notes-box label { display: block; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.notes-box label small { color: var(--muted); font-weight: 400; }
.notes-box textarea {
  width: 100%; resize: vertical; min-height: 56px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13.5px;
}
.notes-box textarea:focus { border-color: var(--accent-2); outline: none; }

/* ---------- Stats / portfolio ---------- */
.pf-head { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 22px; }
.pf-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.pf-tile-v { font-size: 26px; font-weight: 800; }
.pf-tile.green .pf-tile-v { color: var(--green); }
.pf-tile.red .pf-tile-v { color: var(--key); }
.pf-tile-l { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 4px; }
.pf-tile-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pf-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.pf-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.pf-grid .pf-block { margin-bottom: 0; }
.pf-block h3 { margin: 0 0 12px; font-size: 14px; }
.pf-block h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.pf-row { margin-bottom: 11px; }
.pf-row-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 5px; }
.pf-row-head small { color: var(--muted); }
.pf-row-head .up { color: var(--green); font-weight: 700; }
.pf-row-head .down { color: var(--key); font-weight: 700; }
.pf-bar { height: 7px; background: var(--card-2); border-radius: 20px; overflow: hidden; }
.pf-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--green)); border-radius: 20px; }
.pf-leaders { display: grid; gap: 18px 24px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.pf-lead { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; width: 100%;
  text-align: left; background: transparent; border: 0; border-top: 1px solid var(--line); padding: 8px 0;
  cursor: pointer; color: var(--text); font-size: 13px; }
.pf-lead:hover { color: var(--accent-2); }
.pf-lead-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-lead-nums { color: var(--muted); white-space: nowrap; }
.pf-lead-nums b.up { color: var(--green); }
.pf-lead-nums b.down { color: var(--key); }

/* ---------- Signatures / creator board ---------- */
.sig-head { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.sig-creators { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.sig-creator { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.sig-creator-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.sig-creator-head b { font-size: 14px; }
.sig-creator-head span { font-size: 12px; color: var(--accent); font-weight: 600; }
.sig-books { display: flex; flex-wrap: wrap; gap: 6px; }
.sig-book { background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px;
  font-size: 12px; cursor: pointer; color: var(--text); }
.sig-book:hover { border-color: var(--accent); color: var(--accent); }
.sig-none { color: var(--muted); font-size: 13.5px; margin: 0; }
.sig-hunt { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sig-hunt-theme { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.sig-hunt-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.sig-hunt-head b { font-size: 13.5px; }
.sig-hunt-head span { font-size: 12px; color: var(--muted); }
.sig-hunt-item { display: block; font-size: 12.5px; color: var(--accent-2); text-decoration: none;
  padding: 4px 0; border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-hunt-item:hover { color: var(--text); }

/* ---------- Grail deal radar (top of Watching) ---------- */
.deal-radar { margin: 4px 0 18px; border: 1px solid rgba(255,210,63,.35); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,210,63,.05), transparent); padding: 14px 16px; }
.radar-head { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.radar-head small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.radar-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.radar-card { cursor: pointer; display: flex; gap: 10px; flex: 0 0 270px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; text-decoration: none; color: var(--text); }
.radar-card:hover { border-color: var(--accent); }
.radar-cover { width: 46px; height: 64px; flex: none; border-radius: 6px; overflow: hidden; background: var(--bg-2);
  display: grid; place-items: center; }
.radar-cover img { width: 100%; height: 100%; object-fit: cover; }
.radar-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.radar-title { font-size: 12.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.radar-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; }
.radar-price { font-size: 12px; font-weight: 700; color: var(--green); }
/* Grail radar: highlight listings that first appeared today. */
.radar-cover { position: relative; }
.radar-card.is-new { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.new-badge { position: absolute; top: 2px; left: 2px; background: var(--accent); color: #061018;
  font-size: 9px; font-weight: 800; letter-spacing: .04em; padding: 1px 4px; border-radius: 4px; }
.grail-new-count { color: var(--accent); }
/* Upgrade/dupe detector badges on watch + wish cards. */
.tag.own-have { background: rgba(120,130,150,.18); color: var(--muted); }
.tag.own-up { background: rgba(45,180,120,.18); color: var(--green); border-color: rgba(45,180,120,.4); }
.tag.own-sig { background: rgba(212,175,55,.16); color: var(--gold, #d4af37); border-color: rgba(212,175,55,.4); }

/* ===== SaaS auth overlay (boot.js) — themed to match the dark UI ===== */
html.lb-locked, html.lb-locked body { overflow: hidden; }
#lb-auth {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #0e1014);
  padding: 1.25rem;
}
#lb-auth[hidden] { display: none; }
.lb-auth-card {
  width: 100%; max-width: 380px;
  background: var(--card, #171a21);
  border: 1px solid var(--line, #262b36);
  border-radius: 14px; padding: 1.6rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.lb-auth-brand { display: flex; align-items: center; gap: .55rem; }
.lb-auth-brand .brand-mark { font-size: 1.5rem; }
.lb-auth-brand h1 { font-size: 1.35rem; margin: 0; }
.lb-auth-tag { color: var(--muted, #97a0b0); margin: .35rem 0 1.2rem; font-size: .9rem; }
.lb-auth-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.lb-auth-tab {
  flex: 1; padding: .5rem; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted, #97a0b0);
  border: 1px solid var(--line, #262b36); font: inherit;
}
.lb-auth-tab.is-active {
  background: var(--accent, #4f8cff); color: #fff; border-color: transparent;
}
.lb-fld { display: block; margin-bottom: .85rem; }
.lb-fld > span { display: block; font-size: .78rem; color: var(--muted, #97a0b0); margin-bottom: .25rem; }
.lb-fld input {
  width: 100%; box-sizing: border-box; padding: .6rem .7rem;
  background: var(--bg, #0e1014); color: var(--text, #e8ecf3);
  border: 1px solid var(--line, #262b36); border-radius: 8px; font: inherit;
}
.lb-fld input:focus { outline: none; border-color: var(--accent, #4f8cff); }
.lb-fld small { color: var(--muted, #97a0b0); font-size: .72rem; }
.lb-auth-submit {
  width: 100%; padding: .65rem; margin-top: .3rem; cursor: pointer;
  background: var(--accent, #4f8cff); color: #fff;
  border: none; border-radius: 8px; font: inherit; font-weight: 600;
}
.lb-auth-submit:disabled { opacity: .6; cursor: default; }
.lb-auth-err { color: #ff6b6b; font-size: .82rem; min-height: 1em; margin: .6rem 0 0; }
