:root {
  --red: #e3000b;
  --red-dark: #b8000e;
  --yellow: #ffcf00;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #5f6368;
  --line: #e2e4e8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Sleek dark purple fading into sky blue */
  background: linear-gradient(165deg, #1d1240 0%, #34206b 34%, #2d5da6 68%, #6ab8e8 100%) fixed;
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Login gate ---------- */
body.locked main,
body.locked .hero,
body.locked .site-header,
body.locked .site-footer { display: none; }

#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 70%);
  padding: 20px;
}
#login-overlay.hidden { display: none; }

/* Login teaser: a curated peek beside the sign-in card */
.login-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 44px;
  width: 100%;
  max-width: 940px;
}
.login-preview { flex: 1 1 400px; max-width: 440px; color: #fff; }
.preview-title { margin: 0 0 8px; font-size: 1.9rem; line-height: 1.15; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.preview-tag { margin: 0 0 20px; font-size: 1.02rem; line-height: 1.5; opacity: .95; }
.preview-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .22);
}
.preview-card img {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.pc-info { display: flex; flex-direction: column; min-width: 0; }
.pc-name { font-size: .82rem; font-weight: 700; line-height: 1.15; }
.pc-price { font-size: .74rem; opacity: .85; }
.preview-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.preview-stats span {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .22);
  font-size: .8rem;
  font-weight: 600;
}
.preview-note { margin: 0; font-size: .88rem; font-weight: 600; opacity: .85; }

/* Below this width the login card stands alone (unchanged experience) */
@media (max-width: 860px) {
  .login-preview { display: none; }
  .login-hero { gap: 0; }
}

#login-form {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  padding: 34px 32px 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
}
#login-form h2 { margin: 4px 0 0; }
.login-sub { margin: 0 0 6px; color: var(--ink-soft); font-size: .9rem; }
#login-form input[type="text"],
#login-form input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}
#login-form input:focus { outline: 2px solid var(--yellow); }
#login-form .btn { width: 100%; padding: 11px; font-size: 1rem; }
.login-remember {
  display: flex; align-items: center; gap: 7px;
  font-size: .84rem; color: var(--ink-soft);
  user-select: none; cursor: pointer;
  align-self: flex-start;
}
.login-error { color: var(--red-dark); font-size: .88rem; margin: 0; }
.login-toggle {
  background: none;
  border: none;
  color: #0b62c4;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}
.login-toggle:hover { text-decoration: underline; }

.brand-brick.big { transform: scale(1.6); margin: 10px 0 8px; }

.tab.logout { background: rgba(0, 0, 0, .25); font-size: .82rem; }
.tab.logout:hover { background: rgba(0, 0, 0, .4); }

/* ---------- Header ---------- */
.site-header {
  background: var(--red);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.header-inner {
  max-width: 1660px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand h1 { font-size: 1.3rem; margin: 0; letter-spacing: .5px; }

.brand-brick {
  width: 34px; height: 26px;
  background: var(--yellow);
  border-radius: 4px;
  position: relative;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.15);
}
.brand-brick::before, .brand-brick::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 10px; height: 8px;
  background: var(--yellow);
  border-radius: 3px 3px 0 0;
}
.brand-brick::before { left: 4px; }
.brand-brick::after { right: 4px; }

.tabs { display: flex; gap: 8px; }

.tab {
  background: rgba(255, 255, 255, .15);
  border: none;
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.tab:hover { background: rgba(255, 255, 255, .28); }
.tab.active { background: var(--yellow); color: var(--ink); }

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .75rem;
  text-align: center;
}

/* ---------- Hero / stats ---------- */
.hero {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  text-align: center;
  padding: 10px 20px 16px;
}
.db-stats { margin: 0; font-size: .95rem; opacity: .95; }

/* ---------- Browse layout with popular rail ---------- */
.browse-layout {
  display: grid;
  grid-template-columns: 45% minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.browse-main { min-width: 0; }

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.popular-rail {
  /* scrolls away with the page rather than following you down */
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

.today-box {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.today-head {
  background: linear-gradient(120deg, #7c2caf 0%, #2d5da6 60%, #00a3da 100%);
}
.smart-head {
  background: linear-gradient(120deg, #00af4d 0%, #00a3a0 55%, #00a3da 100%);
}
.today-slot { padding: 12px; }
.today-slot .card { box-shadow: none; }
.today-slot .card:hover { transform: none; }
.rail-head {
  background: linear-gradient(120deg, #ff0018 0%, #ff6d00 70%, #ffcf00 100%);
  padding: 18px 20px 15px;
  color: #fff;
}
.rail-title { margin: 0; font-size: 1.5rem; font-weight: 900; text-shadow: 0 1px 3px rgba(0,0,0,.3); }
.rail-sub { margin: 3px 0 0; font-size: .9rem; font-weight: 600; opacity: .95; }

.popular-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.popular-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: none;
  background: none;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background .12s;
}
.popular-item:hover { background: #f2f4f8; }
.pop-rank {
  flex: 0 0 34px;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--red);
  text-align: center;
}
.popular-item img {
  flex: 0 0 140px;
  width: 140px;
  height: 140px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.pop-info { display: flex; flex-direction: column; min-width: 0; }
.pop-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pop-meta { font-size: 1rem; color: var(--ink-soft); margin-top: 6px; }

/* Mid-size laptops: slim the rail so the set grid keeps three columns */
@media (max-width: 1450px) {
  .browse-layout { grid-template-columns: 400px minmax(0, 1fr); }
  .popular-item img { flex-basis: 96px; width: 96px; height: 96px; }
  .pop-name { font-size: 1.05rem; }
  .pop-meta { font-size: .85rem; }
}

@media (max-width: 980px) {
  .browse-layout { display: block; }
  .popular-rail { margin-bottom: 18px; }
  .popular-list { flex-direction: row; overflow-x: auto; }
  .popular-list li { flex: 0 0 290px; }
}

/* ---------- Featured strip ---------- */
.featured {
  margin: 4px 0 26px;
  padding: 20px 18px 18px;
  border-radius: 18px;
  background: linear-gradient(120deg, #ff0018 0%, #ff2400 40%, #ff9100 68%, #f0ff00 100%);
  box-shadow: 0 8px 26px rgba(255, 0, 24, .45);
  position: relative;
  overflow: hidden;
}
.featured::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 14px, transparent 14px 28px);
  pointer-events: none;
}
.featured-title {
  margin: 0;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: .5px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.featured-sub {
  margin: 2px 0 14px;
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.feat-modes {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.feat-mode {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: .85rem;
  cursor: pointer;
  background: rgba(255, 255, 255, .3);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: background .12s, transform .12s;
  font-family: inherit;
}
.feat-mode:hover { transform: scale(1.05); }
.feat-mode.active { background: #fff; color: var(--ink); text-shadow: none; }

@media (max-width: 700px) {
  .feat-modes { position: static; margin-bottom: 10px; }
}

.featured-carousel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.featured-slot {
  width: min(320px, 78vw);
}
.featured-item {
  border-radius: 14px;
  padding: 5px;
  animation: feat-pop .3s ease;
}
@keyframes feat-pop {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
.featured-item.fc-0 { background: #ffcf00; }
.featured-item.fc-1 { background: #00af4d; }
.featured-item.fc-2 { background: #fff; }
.featured-item.fc-3 { background: #00a3da; }
.featured-item.fc-4 { background: #ff6d00; }
.featured-item .card { box-shadow: none; }
.featured-item .card:hover { transform: none; }

/* Every featured image gets the same fixed-height frame, and the whole set
   stays visible inside it (letterboxed on white, never cropped). */
.featured-item .card-img {
  height: 250px;
  aspect-ratio: auto;
  padding: 10px;
}
.featured-item .card-img img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.feat-arrow {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--red);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  transition: transform .12s, background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 5px;
}
.feat-arrow:hover { transform: scale(1.12); background: var(--yellow); color: var(--ink); }
.feat-arrow:active { transform: scale(.98); }

.feat-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  position: relative;
}
.feat-dots button {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .3);
  cursor: pointer;
  padding: 0;
  transition: transform .12s, background .12s;
}
.feat-dots button:hover { transform: scale(1.3); }
.feat-dots button.active { background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35); transform: scale(1.25); }

@media (max-width: 560px) {
  .feat-arrow { width: 42px; height: 42px; font-size: 1.6rem; }
  .featured-carousel { gap: 10px; }
}

/* ---------- Theme tiles ---------- */
.tiles-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.tiles-title {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 0 2px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.tiles-toggle { font-size: .82rem; padding: 7px 14px; }
.theme-tiles.expanded {
  flex-wrap: wrap;
  overflow-x: visible;
}
.theme-tiles {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-bottom: 14px;
  scroll-snap-type: x proximity;
}
.theme-tile {
  flex: 0 0 150px;
  height: 185px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px 0;
  scroll-snap-align: start;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
  font-family: inherit;
}
.theme-tile:hover { transform: translateY(-3px) scale(1.02); }
.theme-tile.active {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .25), 0 6px 18px rgba(0, 0, 0, .35);
}
.theme-tile .tile-name { font-size: 1rem; line-height: 1.15; }
.theme-tile .tile-count { font-size: .72rem; opacity: .9; font-weight: 600; margin-top: 3px; }
.theme-tile img {
  margin-top: auto;
  width: 100%;
  height: 100px;
  object-fit: contain;
  padding-bottom: 8px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .35));
}
.theme-tile.light-bg { color: var(--ink); }
.theme-tiles::-webkit-scrollbar { height: 8px; }
.theme-tiles::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .4); border-radius: 4px; }

/* ---------- Controls ---------- */
main { max-width: 1660px; margin: 0 auto; padding: 20px; }

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

#search {
  flex: 1 1 280px;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
#search:focus { outline: 2px solid var(--yellow); }

.controls select {
  padding: 10px 12px;
  font-size: .92rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  max-width: 220px;
}

.owned-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: .92rem; color: #e3e9f7;
  user-select: none; cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.result-count { color: #d5ddf0; font-size: .88rem; margin: 4px 2px 14px; text-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* ---------- Grid & cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  scroll-margin-top: 90px; /* clear the sticky header when jumped to */
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }

.card.owned { outline: 3px solid var(--yellow); }

.card-img {
  height: 210px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.card-title {
  font-size: .98rem;
  font-weight: 700;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.card-meta { font-size: .82rem; color: var(--ink-soft); }
.card-meta .setnum { font-weight: 600; color: var(--ink); }

.card-theme {
  font-size: .78rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 6px;
}
.price { font-size: 1.05rem; font-weight: 800; color: var(--red); }
.price.tbd { color: var(--ink-soft); }
.price-label { font-size: .68rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.card-links { font-size: .78rem; }
.card-links a { color: #0b62c4; text-decoration: none; }
.card-links a:hover { text-decoration: underline; }

.card-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .12s;
}
.btn:hover { filter: brightness(.94); }
.btn.add { background: var(--red); color: #fff; flex: 1; }
.btn.wish {
  background: #e8eaee;
  color: var(--ink-soft);
  flex: 0 0 40px;
  font-size: 1.15rem;
  padding: 6px 0;
}
.btn.wish.active { background: var(--yellow); color: var(--ink); }
.btn.secondary { background: #e8eaee; color: var(--ink); }
.btn.danger { background: #fbe3e4; color: var(--red-dark); }

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.qty-stepper button {
  border: none;
  background: var(--yellow);
  font-size: 1rem;
  font-weight: 800;
  width: 34px;
  height: 34px;
  cursor: pointer;
}
.qty-stepper button:hover { filter: brightness(.95); }
.qty-stepper .qty {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: .9rem;
}

.load-more-row { display: flex; justify-content: center; margin: 22px 0 6px; }
.btn.load-more { padding: 12px 28px; font-size: .95rem; }

.sentinel { height: 1px; }

.load-error {
  grid-column: 1 / -1;
  background: #fff;
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 24px 28px;
  color: var(--ink);
}
.load-error h2 { margin-top: 0; color: var(--red); }
.load-error code { background: #f0f1f3; padding: 1px 5px; border-radius: 4px; }
.load-error .err-detail { color: var(--ink-soft); font-size: .82rem; margin-bottom: 0; }

.empty {
  text-align: center;
  color: #e3e9f7;
  padding: 60px 20px;
  font-size: 1.05rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

/* ---------- Minifigs ---------- */
.fig-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.fig-img { aspect-ratio: auto; height: 170px; }
.fig-title { font-size: .88rem; min-height: 2.4em; }
.fig-owned-badge {
  align-self: flex-start;
  background: var(--yellow);
  color: var(--ink);
  font-size: .75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 4px;
}
.collection-figs-title { margin-top: 34px; }

/* ---------- Dashboard ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.dash-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.dash-title {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
}
.dash-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 30px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: .82rem;
}
.dash-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dash-bar-track { height: 12px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.dash-bar-fill { display: block; height: 100%; border-radius: 999px; }
.dash-bar-count { font-weight: 800; color: var(--ink-soft); text-align: right; }

.dash-cols { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 6px; }
.dash-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.dash-col-bar {
  width: 100%;
  max-width: 46px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--yellow), #ff6d00);
}
.dash-col-count { font-size: .75rem; font-weight: 800; color: var(--ink-soft); }
.dash-col-label { font-size: .75rem; font-weight: 700; color: var(--ink-soft); }

.dash-line { width: 100%; height: auto; }
.dash-svg-label { font-size: 10px; fill: var(--ink-soft); font-weight: 700; }
.dash-note { color: var(--ink-soft); font-size: .88rem; margin: 0; }

.hl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: none;
  padding: 7px 4px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.hl-row:hover { background: #f2f4f8; }
.hl-row img {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.hl-text { display: flex; flex-direction: column; min-width: 0; }
.hl-label { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.hl-value { font-size: .88rem; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.collection-group-title {
  grid-column: 1 / -1;
  margin: 14px 2px 0;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  border-bottom: 2px solid rgba(255, 255, 255, .3);
  padding-bottom: 6px;
}

/* ---------- Theme completion bars ---------- */
.theme-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 26px;
}
.theme-progress {
  display: grid;
  grid-template-columns: 220px 1fr 150px;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.theme-progress:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0,0,0,.25); }
.tp-name {
  font-weight: 800;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}
.tp-bar {
  height: 14px;
  background: #e8eaee;
  border-radius: 999px;
  overflow: hidden;
}
.tp-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), #ff6d00, var(--red));
}
.tp-count {
  font-size: .85rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .theme-progress { grid-template-columns: 1fr; gap: 6px; }
  .tp-count { text-align: left; }
}

/* ---------- Collection ---------- */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.summary-tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-align: center;
}
.summary-tile .value { font-size: 1.5rem; font-weight: 800; color: var(--red); }
.summary-tile .label { font-size: .78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.collection-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.sync-status { color: #e3e9f7; font-size: .85rem; text-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* ---------- Set detail modal ---------- */
.card-clickable { cursor: pointer; }
.card-title.card-clickable:hover { color: var(--red); }
body.modal-open { overflow: hidden; }

.set-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 30, .72);
}
.modal-panel {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
  width: min(940px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px 28px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: #e8eaee;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  z-index: 1;
}
.modal-close:hover { background: var(--yellow); }

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.modal-img {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-img img { max-width: 100%; max-height: 100%; object-fit: contain; }

.modal-info h2 { margin: 4px 0 8px; font-size: 1.5rem; line-height: 1.2; padding-right: 30px; }
.modal-meta { color: var(--ink-soft); margin: 0 0 2px; font-weight: 600; }
.modal-theme { color: var(--ink-soft); margin: 0 0 14px; font-size: .9rem; }
.modal-price { margin-bottom: 14px; }
.modal-price-big { font-size: 1.7rem; }
.modal-price-note { color: var(--ink-soft); font-size: .85rem; margin-top: 6px; }
.modal-breakdown {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: .88rem;
}
.bd-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
}
.bd-row:last-child { border-bottom: none; }
.bd-row span:last-child { font-weight: 700; white-space: nowrap; }
.bd-subtotal { background: #f6f7f9; font-weight: 600; }
.bd-total { background: var(--yellow); font-weight: 800; }
.bd-total span:last-child { color: var(--red-dark); }
.modal-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: .9rem; }

.modal-figs-wrap { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.modal-figs-title { margin: 0 0 12px; }
.modal-figs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.modal-fig {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: box-shadow .12s, transform .12s;
}
.modal-fig:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.modal-fig img { width: 84px; height: 84px; object-fit: contain; }
.modal-fig-name {
  font-size: .74rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.modal-fig-qty { font-size: .72rem; font-weight: 800; color: var(--red); }

@media (max-width: 700px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-img { height: 240px; }
}

/* ---------- Toast & footer ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  transition: transform .25s, opacity .25s;
  pointer-events: none;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.site-footer {
  max-width: 1660px;
  margin: 30px auto 0;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, .25);
  color: #ccd7ec;
  font-size: .82rem;
}
.site-footer a { color: #9ed4ff; }

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card-title { font-size: .88rem; }
}

/* Recovery-code reminder banner */
.recovery-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 214, 68, 0.14);
  border: 1px solid rgba(255, 214, 68, 0.45);
  color: #ffe9a3;
  font-size: 0.92rem;
}
.recovery-banner span { flex: 1 1 320px; }

/* "Your copy" editor in the set modal (the modal is white — dark text) */
.modal-owned {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f6f7f9;
  border: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.modal-owned-title { width: 100%; margin: 0; font-size: 0.95rem; color: #b8860b; }
.owned-field { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--ink); font-weight: 600; }
.owned-field input, .owned-field select {
  background: #fff;
  color: var(--ink);
  border: 1px solid #c9cdd6;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.88rem;
  font-weight: 400;
}
.owned-field input:focus, .owned-field select:focus, .owned-field textarea:focus { outline: 2px solid var(--yellow); }
.owned-field input { width: 100px; }
.owned-note { width: 100%; font-size: 0.85rem; color: var(--ink-soft); font-weight: 400; }
.owned-note.gain { color: #15803d; font-weight: 700; }
.owned-note.loss { color: #b91c1c; font-weight: 700; }
.summary-tile .value.gain { color: #6ee787; }
.summary-tile .value.loss { color: #ff8a8a; }
.paid-hint { width: 100%; font-size: 0.85rem; color: #cfd9ee; padding: 4px 2px 0; }

/* Missing-minifig tracker */
.fig-missing .card-img img { filter: grayscale(1) opacity(0.5); }
.fig-miss-toggle {
  margin: 8px 10px 10px;
  font-size: 0.8rem;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.fig-miss-toggle.active {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgba(255, 100, 100, 0.5);
  color: #ffb3b3;
}

/* Shared (read-only) collection view */
.share-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(96, 165, 250, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #cfe3ff;
  font-size: 0.95rem;
}
.share-banner a { color: #ffd644; font-weight: 700; text-decoration: none; }
.share-banner a:hover { text-decoration: underline; }
.share-mode .tabs,
.share-mode .collection-actions,
.share-mode .btn.add,
.share-mode .btn.wish,
.share-mode .qty-stepper,
.share-mode .fig-miss-toggle,
.share-mode #modal-actions,
.share-mode .paid-hint,
.share-mode #view-browse,
.share-mode #view-wishlist,
.share-mode #view-minifigs {
  display: none !important;
}
.share-mode .theme-progress { pointer-events: none; }

/* Loose minifig ownership controls */
.fig-own-ctrl { margin: 8px 10px 10px; display: flex; align-items: center; gap: 8px; }
.fig-own-add {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 12px;
  background: #16a34a;
  border: 1px solid #22c55e;
  color: #fff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.35);
}
.fig-own-add:hover { background: #22c55e; }
.fig-own-step {
  font-size: 0.9rem;
  padding: 3px 11px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.fig-own-qty { font-size: 0.82rem; color: #cfe3ff; }
.share-mode .fig-own-ctrl { display: none !important; }

/* Compare strip on shared views */
.compare-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e6edf9;
  font-size: 0.92rem;
}
.compare-strip b { color: #ffd644; }

/* "N missing →" chip on theme completion rows */
.tp-gaps {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  white-space: nowrap;
  background: rgba(255, 207, 0, 0.18);
  border: 1px solid rgba(180, 130, 0, 0.45);
  color: #8a6400;
  border-radius: 999px;
  cursor: pointer;
}
.tp-gaps:hover { background: rgba(255, 207, 0, 0.35); }

/* Yearly recap card */
.recap-grid { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.recap-item { flex: 1 1 80px; text-align: center; }
.recap-num { font-size: 1.35rem; font-weight: 800; color: #ffd644; }
.recap-label { font-size: 0.8rem; color: #aab6cf; }

/* Collection sort select matches the action buttons */
#collection-sort { appearance: auto; }

/* Phone-width pass */
@media (max-width: 600px) {
  .header-inner { justify-content: center; padding: 8px 10px; }
  .tabs { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .tab { font-size: .8rem; padding: 6px 11px; }
  main { padding: 14px 10px; }
  .hero { padding: 8px 12px 12px; }
  .db-stats { font-size: .8rem; }
  .controls input[type="search"] { min-width: 0; width: 100%; }
  .summary-bar { gap: 8px; }
  .summary-tile { padding: 10px 8px; }
  .summary-tile .value { font-size: 1.15rem; }
  .collection-actions { gap: 6px; }
  .collection-actions .btn, #collection-sort { font-size: .8rem; padding: 6px 10px; }
  .theme-progress { flex-wrap: wrap; }
  .tp-gaps { margin-left: 0; }
  .modal-owned { gap: 8px 12px; }
  .compare-strip { gap: 8px 16px; font-size: .85rem; }
}

/* Floating back-to-top arrow */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--red);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
}
.back-to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.back-to-top:hover { background: var(--red-dark); }
@media (max-width: 600px) {
  .back-to-top { right: 14px; bottom: 14px; width: 46px; height: 46px; }
}

/* Wishlist budget planner */
.wishlist-budget {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 10px;
  color: #e6edf9;
  font-size: 0.95rem;
}
.wishlist-budget input {
  width: 110px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 0.95rem;
}
#wish-budget-note { color: #a7f3b8; font-size: 0.9rem; }
.card.in-budget { outline: 3px solid #22c55e; outline-offset: -3px; }

/* Retiring-soon chip */
.retiring-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 150, 20, 0.15);
  border: 1px solid rgba(220, 120, 0, 0.4);
  color: #b45309;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Notes field in the owned editor */
.owned-note-field { width: 100%; align-items: flex-start; }
.owned-note-field textarea {
  flex: 1;
  resize: vertical;
  background: #fff;
  color: var(--ink);
  border: 1px solid #c9cdd6;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 400;
}

/* Achievements — the trophy case */
.ach-card { grid-column: 1 / -1; }
.ach-overall {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 14px;
}
.ach-overall-count { font-size: 0.85rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.ach-overall-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #e9ebf0;
  overflow: hidden;
}
.ach-overall-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f6c343, #ffcf00);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  transition: width 0.4s;
}
.ach-overall-pct { font-size: 0.85rem; font-weight: 800; color: #b8860b; }
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}
.ach {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 12px;
  border-radius: 14px;
  background: #f6f7f9;
  border: 1px solid var(--line);
  text-align: center;
  transition: transform 0.12s, box-shadow 0.12s;
}
.ach-badge {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e9ebf0;
  border: 2px solid #d7dae1;
}
.ach .ach-emoji { font-size: 1.65rem; filter: grayscale(1) opacity(0.45); }
.ach-corner {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  background: #fff;
  border: 1px solid var(--line);
}
.ach-name { font-size: 0.74rem; font-weight: 700; color: var(--ink-soft); line-height: 1.15; }
.ach-bar {
  width: 80%;
  height: 5px;
  border-radius: 999px;
  background: #e2e4e9;
  overflow: hidden;
}
.ach-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #9db4d8, #5b8ad4);
}
.ach.unlocked {
  background: linear-gradient(160deg, #fff9dd 0%, #ffefad 85%);
  border-color: #e6c94c;
  box-shadow: 0 3px 12px rgba(230, 180, 30, 0.3);
}
.ach.unlocked .ach-badge {
  background: radial-gradient(circle at 35% 30%, #ffe98f, #f6c02e);
  border-color: #d9a71a;
  box-shadow: 0 2px 8px rgba(214, 164, 20, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}
.ach.unlocked .ach-emoji { filter: none; }
.ach.unlocked .ach-corner { background: #22c55e; border-color: #15803d; color: #fff; font-weight: 900; }
.ach.unlocked .ach-name { color: var(--ink); }
.ach { cursor: pointer; font-family: inherit; }
.ach:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12); }
.ach.unlocked:hover { box-shadow: 0 6px 16px rgba(230, 180, 30, 0.45); }

/* Recently viewed rail */
.recent-head { background: linear-gradient(120deg, #4b5563 0%, #2d5da6 100%); }
.recent-item img { flex-basis: 72px; width: 72px; height: 72px; }
.recent-item .pop-name { font-size: 0.95rem; }
.share-mode #recent-box { display: none !important; }

/* "Did you mean" suggestion */
.suggest-link {
  background: none;
  border: none;
  padding: 0;
  color: #ffd644;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
}

/* Duplicates card */
.dup-list { margin: 6px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--ink-soft); }

/* Printable report: invisible on screen, the only thing on paper */
.print-report { display: none; }
@media print {
  body { background: #fff !important; }
  body > *:not(#print-report) { display: none !important; }
  .print-report { display: block; color: #000; font-size: 11px; }
  .print-report h1 { font-size: 18px; margin: 0 0 4px; }
  .print-report table { width: 100%; border-collapse: collapse; margin-top: 10px; }
  .print-report th, .print-report td { border: 1px solid #999; padding: 3px 6px; text-align: left; }
  .print-report th { background: #eee; }
  .print-report .print-foot { margin-top: 10px; color: #555; font-size: 9px; }
}

/* Toast action (Undo) */
.toast-action {
  margin-left: 12px;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: #ffd644;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.toast-action:hover { background: rgba(255, 255, 255, 0.3); }

/* Help / feature guide */
.help-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 8, 30, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px;
  overflow-y: auto;
}
.help-panel {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  max-width: 720px;
  width: 100%;
  padding: 26px 30px 22px;
  color: var(--ink);
  margin-bottom: 4vh;
}
.help-panel h2 { margin: 0 42px 6px 0; }
.help-panel h3 { margin: 18px 0 6px; font-size: 1.02rem; }
.help-panel ul { margin: 0; padding-left: 20px; }
.help-panel li { margin: 4px 0; font-size: 0.92rem; line-height: 1.5; }
.help-panel kbd {
  background: #eef0f4;
  border: 1px solid #c9cdd6;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 0.85em;
  font-family: inherit;
}
.help-foot { margin: 16px 0 0; font-size: 0.82rem; color: var(--ink-soft); }

/* Keyboard focus visibility */
.btn:focus-visible, .tab:focus-visible, .theme-tile:focus-visible,
.ach:focus-visible, .popular-item:focus-visible, .tp-gaps:focus-visible,
.feat-arrow:focus-visible, .suggest-link:focus-visible, .toast-action:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--yellow); }
.modal-affiliate-note { margin: 8px 0 0; font-size: 0.72rem; color: var(--ink-soft); line-height: 1.4; }

/* Shared gift-registry wishlist */
.shared-wishlist { margin-bottom: 24px; }
.shared-wishlist .card.claimed { opacity: 0.72; }
.claim-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 10px 10px;
}
.claim-btn {
  flex: 1;
  font-size: 0.86rem;
  font-weight: 700;
  background: #16a34a;
  border: 1px solid #22c55e;
  color: #fff;
}
.claim-btn:hover { background: #22c55e; }
.claim-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: #15803d;
}
.claim-undo { font-size: 0.78rem; padding: 4px 10px; }
#support-line a, .help-support a { color: #ffd644; font-weight: 700; text-decoration: none; }
#support-line a:hover, .help-support a:hover { text-decoration: underline; }
.help-support { margin-top: 12px; font-weight: 600; }
