:root {
  /* Default: dark theme — gothic plum + rose. */
  --bg: #120820;
  --bg-2: #1a0d26;
  --panel: #25153a;
  --panel-2: #311a4a;
  --panel-hi: #3d2257;
  --ink: #f3e6ff;
  --ink-dim: #b598d4;
  --ink-mute: #7d6394;
  --rose: #c43d6e;
  --rose-hi: #ff5fa8;
  --rose-soft: rgba(255, 95, 168, 0.15);
  --gold: #e6b85e;
  --retired: #d4a35e;
  --danger: #ff4d6d;
  --bg-grad-1: rgba(122, 59, 143, 0.35);
  --bg-grad-2: rgba(196, 61, 110, 0.25);
  --header-bg-1: rgba(26, 13, 38, 0.95);
  --header-bg-2: rgba(18, 8, 32, 0.85);
  --header-border: rgba(196, 61, 110, 0.25);
  --modal-backdrop: rgba(6, 2, 14, 0.7);

  /* Rose border tints — six tiers from a faint divider to a strong glow. */
  --border-rose-mist:    rgba(255, 95, 168, 0.05);
  --border-rose-faint:   rgba(255, 95, 168, 0.10);
  --border-rose-vague:   rgba(255, 95, 168, 0.12);
  --border-rose-mild:    rgba(255, 95, 168, 0.18);
  --border-rose:         rgba(255, 95, 168, 0.25);
  --border-rose-strong:  rgba(255, 95, 168, 0.30);
  --border-rose-hi:      rgba(255, 95, 168, 0.45);
  --border-rose-glow:    rgba(255, 95, 168, 0.50);

  /* Glows used in text-shadow / drop-shadow / box-shadow color slots. */
  --rose-glow-soft:      rgba(255, 95, 168, 0.35);
  --rose-glow-med:       rgba(255, 95, 168, 0.45);
  --rose-glow-hard:      rgba(255, 95, 168, 0.50);

  /* Magenta button drop-shadow. */
  --rose-shadow:         rgba(196, 61, 110, 0.40);
  --rose-shadow-md:      rgba(196, 61, 110, 0.45);
  --rose-shadow-hi:      rgba(196, 61, 110, 0.60);

  /* Soft hover surfaces / focus rings. */
  --rose-hover-bg:       rgba(255, 95, 168, 0.04);
  --row-hover-bg:        rgba(255, 95, 168, 0.05);
  --focus-ring:          rgba(255, 95, 168, 0.15);

  /* Card / modal shadow colors (the rgba slot inside box-shadow). */
  --shadow-card:         rgba(0, 0, 0, 0.40);
  --shadow-strong:       rgba(0, 0, 0, 0.45);
  --shadow-deep:         rgba(0, 0, 0, 0.55);
  --shadow-soft:         0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-hi:           0 12px 32px rgba(0, 0, 0, 0.60);

  /* Status badges — dark chip + neon text on dark mode. */
  --badge-bg:            rgba(20, 8, 32, 0.85);
  --badge-border-white:  rgba(255, 255, 255, 0.15);
  --owned-text:          #ffd8a8;
  --stock-blue:          #74c0ff;
  --stock-blue-border:   #4a7ab8;
  --stock-blue-glow:     rgba(116, 192, 255, 0.40);
  --stock-purple:        #c4a3ff;
  --stock-purple-border: #8a6fc4;
  --stock-purple-glow:   rgba(196, 163, 255, 0.40);
  --mini-grad-1:         #5a3a78;
  --mini-grad-2:         #3d2257;
  --mini-text:           #f3e6ff;
  --retired-grad-2:      #b88940;
  --text-on-gold:        #2a1500;
  --text-on-rose:        #ffffff;
  --ink-on-pill:         #1a0d26;
  --watermark-bg:        rgba(8, 4, 14, 0.78);
  --watermark-border:    rgba(255, 255, 255, 0.15);

  /* Success / available-to-buy green family. */
  --success:             #6effa6;
  --success-strong:      #aaffcc;
  --success-bg:          rgba(110, 255, 168, 0.12);
  --success-border:      rgba(110, 255, 168, 0.45);
  --teal-text:           #6effd8;
  --teal-grad-1:         #2a4d4f;
  --teal-grad-2:         #1a2f30;
  --teal-border:         rgba(110, 255, 216, 0.30);

  /* Danger / destructive red family. */
  --danger-hi:           #ff7a8a;
  --danger-bg:           rgba(255, 77, 109, 0.12);
  --danger-border:       rgba(255, 77, 109, 0.35);

  /* Gold accent tints. */
  --gold-bg:             rgba(255, 215, 142, 0.08);
  --gold-border:         rgba(255, 215, 142, 0.35);
  --gold-glow:           rgba(255, 215, 142, 0.30);
  --gold-soft-border:    rgba(212, 175, 55, 0.40);
  --gold-soft-bg:        rgba(212, 175, 55, 0.15);
  --gold-inset-glow:     rgba(255, 215, 142, 0.05);

  /* Misc. */
  --ink-link-underline:  rgba(181, 152, 212, 0.40);
  /* SVG arrow inside .filter-select — color matches --rose-hi per theme. */
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23ff5fa8' d='M5 6 0 0h10z'/></svg>");

  --radius: 14px;
  --radius-sm: 8px;
  --serif: 'Cormorant Garamond', 'Georgia', serif;
  --display: 'Cinzel Decorative', 'Georgia', serif;
}

/* Light theme — same gothic palette, but soft parchment-lavender base.
   Activate by setting data-theme="light" on <html>; persisted via Account →
   Appearance. The early-load script in <head> applies it before render to
   avoid a flash. */
[data-theme="light"] {
  --bg: #f7f1fb;
  --bg-2: #ece1f0;
  --panel: #fcfaff;
  --panel-2: #f5e8f0;
  --panel-hi: #ebd9e9;
  --ink: #2a1244;
  --ink-dim: #6a4f80;
  --ink-mute: #a092ad;
  --rose: #a8295c;
  --rose-hi: #c43d6e;
  --rose-soft: rgba(196, 61, 110, 0.10);
  --gold: #a87a35;
  --retired: #b88940;
  --danger: #c43050;
  --bg-grad-1: rgba(168, 90, 180, 0.10);
  --bg-grad-2: rgba(196, 61, 110, 0.08);
  --header-bg-1: rgba(252, 250, 255, 0.95);
  --header-bg-2: rgba(245, 235, 250, 0.85);
  --header-border: rgba(168, 41, 92, 0.20);
  --modal-backdrop: rgba(60, 30, 80, 0.35);

  --border-rose-mist:    rgba(168, 41, 92, 0.04);
  --border-rose-faint:   rgba(168, 41, 92, 0.08);
  --border-rose-vague:   rgba(168, 41, 92, 0.10);
  --border-rose-mild:    rgba(168, 41, 92, 0.15);
  --border-rose:         rgba(168, 41, 92, 0.25);
  --border-rose-strong:  rgba(168, 41, 92, 0.30);
  --border-rose-hi:      rgba(168, 41, 92, 0.45);
  --border-rose-glow:    rgba(168, 41, 92, 0.40);

  /* Glows nearly vanish on a light surface — keep barely-there hint of rose. */
  --rose-glow-soft:      rgba(168, 41, 92, 0.10);
  --rose-glow-med:       rgba(168, 41, 92, 0.18);
  --rose-glow-hard:      rgba(168, 41, 92, 0.22);

  --rose-shadow:         rgba(168, 41, 92, 0.18);
  --rose-shadow-md:      rgba(168, 41, 92, 0.22);
  --rose-shadow-hi:      rgba(168, 41, 92, 0.32);

  --rose-hover-bg:       rgba(168, 41, 92, 0.04);
  --row-hover-bg:        rgba(168, 41, 92, 0.05);
  --focus-ring:          rgba(168, 41, 92, 0.12);

  /* Lavender-tinted shadows feel softer on cream than pure black. */
  --shadow-card:         rgba(120, 90, 140, 0.18);
  --shadow-strong:       rgba(120, 90, 140, 0.22);
  --shadow-deep:         rgba(120, 90, 140, 0.30);
  --shadow-soft:         0 4px 14px rgba(120, 90, 140, 0.16);
  --shadow-hi:           0 10px 28px rgba(120, 90, 140, 0.24);

  /* Status badges flip — cream chip + deep, legible text. */
  --badge-bg:            rgba(252, 250, 255, 0.92);
  --badge-border-white:  rgba(60, 30, 80, 0.20);
  --owned-text:          #8a4a18;
  --stock-blue:          #2e5fa8;
  --stock-blue-border:   #6b8fc8;
  --stock-blue-glow:     rgba(46, 95, 168, 0.18);
  --stock-purple:        #6b3ec4;
  --stock-purple-border: #9b7fd4;
  --stock-purple-glow:   rgba(107, 62, 196, 0.18);
  --mini-grad-1:         #d9c8e8;
  --mini-grad-2:         #c4adde;
  --mini-text:           #2a1244;
  --retired-grad-2:      #b88940;
  --text-on-gold:        #2a1500;
  --text-on-rose:        #ffffff;
  --ink-on-pill:         #2a1244;
  --watermark-bg:        rgba(252, 250, 255, 0.86);
  --watermark-border:    rgba(60, 30, 80, 0.18);

  --success:             #1f8956;
  --success-strong:      #166842;
  --success-bg:          rgba(31, 137, 86, 0.10);
  --success-border:      rgba(31, 137, 86, 0.40);
  --teal-text:           #1a7559;
  --teal-grad-1:         #d8ece4;
  --teal-grad-2:         #c2e0d3;
  --teal-border:         rgba(26, 117, 89, 0.30);

  --danger-hi:           #b8253f;
  --danger-bg:           rgba(196, 48, 80, 0.08);
  --danger-border:       rgba(196, 48, 80, 0.30);

  --gold-bg:             rgba(168, 122, 53, 0.08);
  --gold-border:         rgba(168, 122, 53, 0.30);
  --gold-glow:           rgba(168, 122, 53, 0.18);
  --gold-soft-border:    rgba(168, 122, 53, 0.35);
  --gold-soft-bg:        rgba(168, 122, 53, 0.10);
  --gold-inset-glow:     rgba(168, 122, 53, 0.06);

  --ink-link-underline:  rgba(120, 90, 140, 0.45);
  --select-arrow: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23c43d6e' d='M5 6 0 0h10z'/></svg>");
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(ellipse 60% 40% at 15% 0%, var(--bg-grad-1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, var(--bg-grad-2) 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: 64px;
}

/* ─── Header ────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--header-bg-1), var(--header-bg-2));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--header-border);
  padding-top: env(safe-area-inset-top);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.bat-logo {
  width: 60px;
  height: 40px;
  filter: drop-shadow(0 0 6px var(--border-rose-hi));
  animation: floatBat 4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes floatBat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-shadow: 0 0 12px var(--rose-glow-soft);
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border-rose-strong);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--panel-2); border-color: var(--rose-hi); }
.icon-btn.active {
  background: var(--rose);
  border-color: var(--rose-hi);
  box-shadow: 0 0 12px var(--rose-glow-hard);
}

/* ─── Tabs ────────────────────────────── */
.tabs {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { scroll-snap-align: start; flex-shrink: 0; }

.tab {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  padding: 14px 16px 12px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--rose-hi); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--rose-hi), transparent);
  border-radius: 2px;
}

/* ─── Main ────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

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

#search {
  flex: 1;
  min-width: 200px;
  padding: 11px 16px;
  background: var(--panel);
  border: 1px solid var(--border-rose);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
}
#search::placeholder { color: var(--ink-mute); }
#search:focus {
  outline: none;
  border-color: var(--rose-hi);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--border-rose);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-size: 0.92rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--rose); }
.chip.active {
  background: var(--rose);
  color: var(--text-on-rose);
  border-color: var(--rose-hi);
  box-shadow: 0 2px 10px var(--rose-shadow);
}
.chip-action { color: var(--rose-hi); border-color: var(--rose); }
.chip-action:hover { background: var(--rose-soft); color: var(--rose-hi); }

.chip-toggle::before {
  content: '○';
  margin-right: 6px;
  opacity: 0.5;
}
.chip-toggle.active::before { content: '●'; opacity: 1; }
.chip-toggle.active {
  background: transparent;
  color: var(--rose-hi);
  border-color: var(--rose);
  box-shadow: inset 0 0 0 1px var(--rose);
}
.chip-sep {
  width: 1px;
  height: 18px;
  background: var(--border-rose-strong);
  margin: 0 4px;
}
.chip-select {
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--border-rose);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-size: 0.92rem;
  cursor: pointer;
}
.chip-select:focus { outline: none; border-color: var(--rose-hi); color: var(--ink); }

/* ─── Filter widgets ──────────────────────────────
   Replacements for the old chip rows. Native <select> for single-value
   filters; <details>/<summary> + checkboxes for multi-value. */
.filter-select {
  padding: 9px 30px 9px 14px;
  background: var(--panel) var(--select-arrow) no-repeat right 12px center;
  border: 1px solid var(--border-rose);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.92rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 130px;
}
.filter-select:focus { outline: none; border-color: var(--rose-hi); }

.filter-multi {
  position: relative;
}
.filter-multi summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--border-rose);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.92rem;
  cursor: pointer;
  min-width: 130px;
}
.filter-multi summary::-webkit-details-marker { display: none; }
.filter-multi summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--rose-hi);
  font-size: 0.7rem;
}
.filter-multi[open] summary { border-color: var(--rose-hi); }
.filter-multi .filter-label {
  color: var(--ink-dim);
  font-style: italic;
}
.filter-multi .filter-summary {
  color: var(--gold);
  font-weight: 600;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--border-rose-strong);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 12px 30px var(--shadow-strong);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.9rem;
  cursor: pointer;
}
.filter-options label:hover { background: var(--bg-2); }
.filter-options input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--rose-hi);
  cursor: pointer;
}

.filter-clear, .filter-action {
  background: transparent;
  border: 1px solid var(--border-rose);
  color: var(--ink-dim);
  font-family: var(--serif);
  font-size: 0.88rem;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-style: italic;
  margin-left: auto;
}
.filter-clear:hover, .filter-action:hover {
  border-color: var(--rose-hi);
  color: var(--rose-hi);
}
.filter-action {
  color: var(--gold);
  border-color: var(--gold-border);
  margin-left: 0;
}

.add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.add-btn {
  background: linear-gradient(135deg, var(--rose), var(--rose-hi));
  border: none;
  color: var(--text-on-rose);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--rose-shadow-md);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.add-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px var(--rose-shadow-hi); }
.add-btn:active { transform: translateY(0); }

.count {
  color: var(--ink-mute);
  font-style: italic;
  font-size: 0.9rem;
}

/* ─── Grid & Cards ────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
/* List view: one card per row, small photo on the left, body on the right.
   Used for My Collection so filled-in fields have room and the photo doesn't
   dominate. */
.grid-list {
  grid-template-columns: 1fr;
  gap: 10px;
}
.grid-list .card {
  display: grid;
  grid-template-columns: 88px 1fr;
  grid-template-rows: auto auto;
  align-items: stretch;
}
.grid-list .card-photo {
  grid-row: 1 / span 2;
  aspect-ratio: 1 / 1;
  height: 100%;
}
.grid-list .card-body { padding: 10px 14px 4px; }
.grid-list .card-actions {
  padding: 4px 14px 10px;
  border-top: 0;
  flex-wrap: wrap;
}

.grid-tight {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.card-status {
  font-family: var(--display);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  background: var(--watermark-bg);
  color: var(--ink);
  border: 1px solid var(--badge-border-white);
  white-space: nowrap;
}
.card-status.owned { color: var(--owned-text); border-color: var(--gold); }
.card-status.wished { color: var(--rose-hi); border-color: var(--rose); }

.card-actions .btn-have { color: var(--gold); border-color: var(--gold-soft-border); }
.card-actions .btn-have:hover { background: var(--gold-soft-bg); color: var(--owned-text); }
.card-actions .btn-want { color: var(--rose-hi); border-color: var(--rose); }
.card-actions .btn-want:hover { background: var(--rose); color: var(--text-on-rose); }

.grid-tight .card-name { font-size: 0.95rem; }
.grid-tight .card-body { padding: 10px 10px 8px; }
.grid-tight .card-actions { padding: 8px 10px 10px; gap: 4px; }
.grid-tight .card-actions button { font-size: 0.78rem; padding: 6px 4px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--rose-hi);
  box-shadow: var(--shadow-hi);
}

.card-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, var(--panel-2), var(--bg-2));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-photo .no-photo {
  font-size: 3rem;
  opacity: 0.4;
}

.badge-stack {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  pointer-events: none;
}
.badge {
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow: 0 2px 8px var(--shadow-card);
  white-space: nowrap;
}
.badge-retired {
  background: linear-gradient(135deg, var(--retired), var(--retired-grad-2));
  color: var(--text-on-gold);
}
.badge-oos {
  background: var(--badge-bg);
  color: var(--rose-hi);
  border: 1px solid var(--rose);
  text-shadow: 0 0 6px var(--rose-glow-hard);
}
.badge-soon {
  background: var(--badge-bg);
  color: var(--stock-blue);
  border: 1px solid var(--stock-blue-border);
  text-shadow: 0 0 6px var(--stock-blue-glow);
}
.badge-fyc {
  background: var(--badge-bg);
  color: var(--stock-purple);
  border: 1px solid var(--stock-purple-border);
  text-shadow: 0 0 6px var(--stock-purple-glow);
}
.badge-mini {
  background: linear-gradient(135deg, var(--mini-grad-1), var(--mini-grad-2));
  color: var(--mini-text);
  border: 1px solid var(--rose-glow-hard);
}

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

.card-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.card-meaning {
  font-style: italic;
  color: var(--ink-dim);
  font-size: 0.95rem;
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}
/* Subtitle: the original catalog name when a nickname is set. */
.card-product {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mute);
  font-size: 0.88rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 1rem;
  color: var(--ink-dim);
  margin-top: 2px;
  font-family: var(--serif);
}
.card-meta span::before { content: '· '; color: var(--ink-mute); }
.card-meta span:first-child::before { content: ''; }
.card-meta .meta-warn { color: var(--rose-hi); font-style: italic; }
/* On the tight catalog grid keep the type scale a notch smaller so the cards stay compact. */
.grid-tight .card-meta { font-size: 0.95rem; }

/* Quantity control on collection cards */
.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border-radius: 999px;
  padding: 2px;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.qty-btn:hover { background: var(--panel); color: var(--gold); }
.qty-display {
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--gold);
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.badge-qty {
  background: linear-gradient(135deg, var(--gold), var(--retired-grad-2));
  color: var(--text-on-gold);
  font-variant-numeric: tabular-nums;
}

.card-actions {
  display: flex;
  gap: 6px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border-rose-faint);
  margin-top: auto;
}
.card-actions button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-rose);
  color: var(--ink-dim);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--serif);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.card-actions button:hover { color: var(--ink); border-color: var(--rose); background: var(--rose-soft); }
.card-actions .btn-got { color: var(--rose-hi); border-color: var(--rose); }
.card-actions .btn-got:hover { background: var(--rose); color: var(--text-on-rose); }
.card-actions .btn-danger:hover { color: var(--danger); border-color: var(--danger); }

/* Icon-only trash button used for collection delete. Small, red, no label —
   the row is busy enough already and the icon is unambiguous. */
.card-actions .btn-trash {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--danger-border);
  background: transparent;
  color: var(--danger);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}
.card-actions .btn-trash:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}
.card-actions .btn-link {
  flex: 0 0 auto;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-actions .btn-buy {
  flex: 0 0 auto;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--success);
  border: 1px solid var(--success-border);
  font-family: var(--serif);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}
.card-actions .btn-buy:hover {
  background: var(--success-bg);
  color: var(--success-strong);
  border-color: var(--success);
}

/* ─── Active filters bar ────────────────────────────── */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius-sm);
  font-family: var(--serif);
  font-size: 0.9rem;
}
.active-filters.hidden { display: none; }
.active-filters .active-count {
  color: var(--ink-dim);
  margin-right: 6px;
  font-style: italic;
}
.active-pill {
  background: var(--bg-2);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 0.82rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: all 0.12s ease;
}
.active-pill:hover { background: var(--panel-2); border-color: var(--gold); }
.active-clear-all {
  background: transparent;
  border: 0;
  color: var(--rose-hi);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  margin-left: auto;
  cursor: pointer;
  padding: 3px 6px;
  text-decoration: underline;
}
.active-clear-all:hover { color: var(--rose); }

/* ─── Pens checklist ────────────────────────────── */
.pens-progress {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius);
}
.pens-progress-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--display);
  letter-spacing: 0.05em;
}
.pens-count { font-size: 1.7rem; color: var(--gold); font-weight: 700; }
.pens-total { color: var(--ink-dim); font-size: 0.9rem; }
.pens-bar {
  height: 8px;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
}
.pens-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--rose-glow-med);
}

.pens-list { display: flex; flex-direction: column; gap: 24px; }
.pens-group { }
.pens-group-title {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--rose-hi);
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-rose-mild);
  padding-bottom: 6px;
}
.pens-group-count {
  font-size: 0.8rem;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  letter-spacing: 0.02em;
}

.pen-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.pen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border-rose-vague);
  border-radius: var(--radius-sm);
  font-family: var(--serif);
  transition: all 0.12s ease;
}
.pen-row.owned {
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  border-color: var(--gold);
}
.pen-row.owned .pen-name { color: var(--ink); font-style: normal; }
.pen-name {
  font-size: 0.98rem;
  color: var(--ink-dim);
  font-style: italic;
  flex: 1;
  min-width: 0;
}
.pen-qty {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.pen-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-rose-strong);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pen-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--panel); }
.pen-btn:active { transform: scale(0.92); }
.pen-count {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.pen-row:not(.owned) .pen-count { color: var(--ink-dim); }
.pens-total-grand {
  color: var(--gold);
  font-size: 0.9rem;
  font-family: var(--serif);
  font-style: italic;
}

/* ─── Empty ────────────────────────────── */
.empty {
  text-align: center;
  padding: 72px 24px;
  color: var(--ink-dim);
}
.empty .ghost {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: floatGhost 3s ease-in-out infinite;
}
.empty p {
  font-style: italic;
  font-size: 1.05rem;
  margin: 0;
}
@keyframes floatGhost {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hidden { display: none !important; }

/* ─── Modal ────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border-rose-strong);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hi);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 6px;
}
.modal-close:hover { color: var(--rose-hi); }
.modal-card h2 {
  font-family: var(--display);
  margin: 0 0 6px;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--rose-hi);
}
.modal-name {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--gold);
  font-size: 1.05rem;
}

/* ─── Form ────────────────────────────── */
.photo-upload {
  text-align: center;
  margin-bottom: 18px;
}
.photo-label { display: inline-block; cursor: pointer; }
.photo-preview {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 2px dashed var(--rose-glow-med);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 auto;
  transition: border-color 0.15s ease;
}
.photo-preview:hover { border-color: var(--rose-hi); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-hint {
  color: var(--ink-mute);
  font-family: var(--display);
  font-size: 0.85rem;
  text-align: center;
  letter-spacing: 0.08em;
}
.link-btn {
  background: none;
  border: none;
  color: var(--ink-dim);
  text-decoration: underline;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 8px;
}
.link-btn:hover { color: var(--rose-hi); }

.field {
  display: block;
  margin-bottom: 14px;
}
.field span {
  display: block;
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 5px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
}
.field textarea { resize: vertical; min-height: 60px; font-style: italic; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--rose-hi);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--rose-hi);
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.btn-ghost, .btn-primary {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border-rose-strong);
  color: var(--ink-dim);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--rose); }
.btn-primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-hi));
  color: var(--text-on-rose);
  box-shadow: 0 4px 14px var(--rose-shadow-md);
}
.btn-primary:hover { box-shadow: 0 6px 18px var(--rose-shadow-hi); }

/* ─── Footer ────────────────────────────── */
.app-footer {
  max-width: 1100px;
  margin: 40px auto 0;
  padding: 24px 20px 8px;
  border-top: 1px solid var(--border-rose-vague);
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
.footer-links {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
  color: var(--ink-mute);
}
.footer-link {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--ink-link-underline);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.footer-link:hover { color: var(--rose-hi); }

/* ─── Legal modal ────────────────────────────── */
/* Sits above the auth overlay (z-index 1000) so it can be opened from the
   sign-in card's Terms/Privacy links before the user is authenticated. */
#legal-modal { z-index: 1100; }
.legal-section { padding: 12px 0; }
.legal-section.hidden { display: none; }
.legal-section h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  color: var(--rose-hi);
  margin: 0 0 12px;
  letter-spacing: 0.04em;
}
.legal-section p { margin: 0 0 12px; line-height: 1.55; color: var(--ink); }
.legal-section ul { margin: 0 0 12px; padding-left: 22px; }
.legal-section li { margin-bottom: 8px; line-height: 1.5; color: var(--ink); }
.legal-section strong { color: var(--gold); font-weight: 600; }
.legal-section a { color: var(--rose-hi); }
.footer-note {
  flex-basis: 100%;
  margin: 4px 0 0;
  color: var(--ink-mute);
  font-style: italic;
  font-size: 0.82rem;
}

/* ─── Toast ────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-hi);
  border: 1px solid var(--rose);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-style: italic;
  z-index: 200;
  box-shadow: var(--shadow-hi);
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.card-clickable {
  cursor: pointer;
  transition: background 0.12s ease;
}
.card-clickable:hover { background: var(--rose-hover-bg); }
.card-clickable::after {
  content: '›';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-dim);
  font-size: 1.4rem;
  pointer-events: none;
}
.grid-list .card-body.card-clickable { position: relative; padding-right: 28px; }

.trade-history-toggle {
  margin: 14px 0;
  text-align: center;
}
.trade-history-toggle button {
  background: transparent;
  border: 1px dashed var(--border-rose-strong);
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.trade-history-toggle button:hover { color: var(--rose-hi); border-color: var(--rose); }

/* ─── Trade tab ────────────────────────────── */
.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: var(--gold);
  color: var(--ink-on-pill);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9px;
  vertical-align: middle;
  line-height: 18px;
  text-align: center;
}

.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-rose-mild);
  overflow-x: auto;
  scrollbar-width: none;
}
.subtabs::-webkit-scrollbar { display: none; }
.subtab { flex-shrink: 0;
  background: transparent;
  border: 0;
  color: var(--ink-dim);
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.12s ease;
}
.subtab:hover { color: var(--rose-hi); }
.subtab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.subview { display: block; }
.subview.hidden { display: none; }

.badge-trade {
  background: linear-gradient(135deg, var(--teal-grad-1), var(--teal-grad-2));
  color: var(--teal-text);
  border: 1px solid var(--teal-border);
}

.trader-group, .my-items-section, .trades-section { margin-bottom: 28px; }
.trader-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--rose-hi);
  border-bottom: 1px solid var(--border-rose-mild);
  padding-bottom: 6px;
  margin: 0 0 12px;
}
.empty-note {
  color: var(--ink-dim);
  font-style: italic;
  font-family: var(--serif);
  padding: 8px 0;
}

.card-small { font-size: 0.92rem; }
.card-small .card-name { font-size: 1rem; }

.trade-card {
  background: var(--panel);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.trade-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  align-items: baseline;
}
.trade-with {
  font-family: var(--display);
  letter-spacing: 0.04em;
  color: var(--gold);
  margin-right: 10px;
}
.trade-status {
  display: inline-block;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  font-size: 0.9rem;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-rose-mild);
}
/* Color-coded so users can scan their trade list for what needs action. */
.trade-status-your  { color: var(--gold); border-color: var(--gold-border); background: var(--gold-bg); font-weight: 600; }
.trade-status-their { color: var(--ink-dim); border-color: var(--border-rose-mild); }
.trade-status-done  { color: var(--success); border-color: var(--success-border); }
.trade-status-dead  { color: var(--ink-mute); border-color: var(--border-rose-faint); }

.trade-filters { margin-bottom: 16px; }
.trade-list .empty-note { padding: 24px 12px; text-align: center; }
.trade-lines {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 10px;
}
.trade-lines h4 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 0.85rem;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.trade-lines ul { margin: 0; padding-left: 18px; }
.trade-lines li { margin-bottom: 2px; }
.trade-lines li.dim { color: var(--ink-dim); font-style: italic; list-style: none; padding-left: 0; }
.trade-message {
  margin: 6px 0 10px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  border-left: 2px solid var(--gold-border);
  padding-left: 10px;
}
.ship-first-banner {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--gold-bg);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink);
}
.dim { color: var(--ink-dim); font-style: italic; font-size: 0.9rem; }

/* Offer builder */
.modal-card-wide { max-width: 600px; }
.picker-panel {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
}
.picker-panel h3 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: var(--rose-hi);
}
.picker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-rose-faint);
}
.picker-row:last-child { border-bottom: 0; }
.picker-name { font-family: var(--serif); }
.picker-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.picker-count {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  font-family: var(--display);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* Feedback modal — three structured thumbs rows. */
.thumb-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}
.thumb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border-rose-mild);
  border-radius: var(--radius-sm);
}
.thumb-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thumb-label strong { font-family: var(--display); font-size: 0.9rem; letter-spacing: 0.04em; color: var(--ink); }
.thumb-label .dim { font-family: var(--serif); font-style: italic; font-size: 0.85rem; line-height: 1.3; }
.thumb-choice { display: flex; gap: 6px; flex-shrink: 0; }
.thumb-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-rose-mild);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.12s ease;
}
.thumb-btn:hover { border-color: var(--rose-hi); }
.thumb-btn.selected[data-value="up"] {
  background: var(--success-bg);
  border-color: var(--success-border);
  box-shadow: 0 0 10px var(--success-bg);
}
.thumb-btn.selected[data-value="down"] {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  box-shadow: 0 0 10px var(--danger-bg);
}

/* Reputation badge — used everywhere a username appears next to a
   trade context. Format: "@user · 12t · 92%". Clickable; opens the
   mini-profile popover. */
.rep-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-rose-mild);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.12s ease;
  vertical-align: baseline;
}
.rep-badge:hover { border-color: var(--rose-hi); background: var(--rose-hover-bg); }
.rep-badge .rep-name { font-weight: 600; }
.rep-badge .rep-sep { color: var(--ink-mute); }
.rep-badge .rep-count, .rep-badge .rep-percent { color: var(--ink-dim); font-size: 0.85rem; }
.rep-badge .rep-percent.rep-good   { color: var(--success); }
.rep-badge .rep-percent.rep-meh    { color: var(--gold); }
.rep-badge .rep-percent.rep-bad    { color: var(--danger-hi); }
.rep-badge .rep-percent.rep-empty  { color: var(--ink-mute); font-style: italic; }
.rep-badge.rep-large {
  font-size: 1.05rem;
  padding: 6px 14px;
  border-radius: 999px;
}

/* Mini-profile popover — opens from any rep-badge. */
.mini-profile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-rose-mild);
  padding-bottom: 12px;
}
.mini-profile-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--rose-hi);
  letter-spacing: 0.04em;
}
.mini-profile-pct {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
}
.mini-profile-pct.rep-good  { color: var(--success); }
.mini-profile-pct.rep-meh   { color: var(--gold); }
.mini-profile-pct.rep-bad   { color: var(--danger-hi); }
.mini-profile-pct.rep-empty { color: var(--ink-mute); font-style: italic; font-size: 1rem; }
.mini-profile-meta {
  display: block;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.85rem;
}
.mini-profile-cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.mini-profile-cat {
  padding: 10px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  text-align: center;
}
.mini-profile-cat .cat-name {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
.mini-profile-cat .cat-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}
.mini-profile-cat .cat-up   { color: var(--success); }
.mini-profile-cat .cat-down { color: var(--danger-hi); }
.mini-profile-cat .cat-empty { color: var(--ink-mute); font-style: italic; font-size: 0.85rem; }

.mini-profile-comments h3 {
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  text-transform: uppercase;
  margin: 0 0 10px;
}
.mini-profile-comment {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--panel-2);
  border-left: 3px solid var(--border-rose-mild);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.mini-profile-comment.rating-good { border-left-color: var(--success); }
.mini-profile-comment.rating-meh  { border-left-color: var(--gold); }
.mini-profile-comment.rating-bad  { border-left-color: var(--danger-hi); }
.mini-profile-comment-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-family: var(--serif);
  font-size: 0.85rem;
}
.mini-profile-comment-head .from { color: var(--gold); }
.mini-profile-comment-head .when { color: var(--ink-mute); font-style: italic; }
.mini-profile-comment p {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink);
}
.mini-profile-empty {
  color: var(--ink-dim);
  font-style: italic;
  font-family: var(--serif);
  padding: 20px 0;
  text-align: center;
}

@media (max-width: 768px) {
  .thumb-row { padding: 10px 12px; gap: 8px; }
  .thumb-label .dim { font-size: 0.8rem; }
  .thumb-btn { width: 40px; height: 40px; font-size: 1.05rem; }
  .mini-profile-cats { grid-template-columns: 1fr; gap: 6px; }
}

/* ─── Account modal ────────────────────────────── */
.account-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-rose-vague);
}
.account-section:last-child { border-bottom: 0; }
.account-section h3 {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--rose-hi);
  margin: 0 0 12px;
}
.account-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 8px;
}
.account-row.right { justify-content: flex-end; align-items: center; }
.account-row .field { flex: 1; margin-bottom: 0; }
.account-hint {
  margin: 6px 0 0;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.88rem;
}

.feedback-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  text-align: center;
}
.fb-cell {
  padding: 10px 6px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fb-num {
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.fb-num.fb-good { color: var(--teal-text); }
.fb-num.fb-meh  { color: var(--ink-dim); }
.fb-num.fb-bad  { color: var(--danger-hi); }
.fb-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.75rem;
  color: var(--ink-dim);
  text-transform: lowercase;
}
.active-dot { color: var(--gold); margin-right: 4px; }

/* ─── Share modal & menu ────────────────────────────── */
.menu-section { padding: 4px 0; }
.menu-section.hidden { display: none; }
.menu-divider {
  height: 1px;
  background: var(--border-rose-mild);
  margin: 4px 6px;
}
.menu-item.active { color: var(--gold); }

.share-section { margin-top: 18px; }
.share-section h3 {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--rose-hi);
  margin: 0 0 8px;
}
.share-hint {
  margin: 0 0 12px;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
}
.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.member-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-rose-faint);
  font-family: var(--serif);
}
.member-list li:last-child { border-bottom: 0; }
.role-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  background: var(--gold);
  color: var(--ink-on-pill);
  border-radius: 9px;
  font-family: var(--display);
}
.role-tag.editor { background: var(--rose); color: var(--text-on-rose); }
.role-tag.viewer { background: var(--ink-dim); color: var(--bg); }

.invite-link-wrap {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.invite-link-wrap.hidden { display: none; }
.invite-link-wrap input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border-rose);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--ink);
  font-family: monospace;
  font-size: 0.78rem;
}

/* ─── Address modal ────────────────────────────── */
.address-their {
  background: var(--bg-2);
  border: 1px solid var(--gold-glow);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 14px;
}
.address-their.hidden { display: none; }
.address-their h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}
.address-their pre {
  margin: 0;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink);
  white-space: pre-wrap;
}

/* ─── Auth overlay ────────────────────────────── */
body.locked { overflow: hidden; }
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background:
    radial-gradient(circle at 30% 20%, var(--bg-grad-1), transparent 50%),
    radial-gradient(circle at 70% 80%, var(--bg-grad-2), transparent 50%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border-rose);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: 0 30px 60px var(--shadow-deep), 0 0 0 1px var(--gold-inset-glow) inset;
  text-align: center;
}
.auth-mark {
  font-size: 2.4rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px var(--rose-glow-hard));
}
.auth-spinner {
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  animation: pulse 1.4s ease-in-out infinite;
  padding: 30px 0;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
.auth-title {
  font-family: var(--display);
  font-size: 1.7rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}
.auth-sub {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-dim);
  font-size: 1rem;
  line-height: 1.5;
  margin: 0 0 22px;
}
.auth-sub code {
  background: var(--bg-2);
  color: var(--rose-hi);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
.auth-card .field { text-align: left; margin-bottom: 16px; }
.auth-card .btn { width: 100%; }
.auth-hint {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-dim);
  font-style: italic;
}
.auth-error {
  margin-top: 14px;
  color: var(--danger-hi);
  font-size: 0.9rem;
  font-family: var(--serif);
}

/* Consent row on the sign-in form — keeps the magic-link button disabled
   until the checkbox is ticked. */
.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 0.92rem;
  color: var(--ink-dim);
  text-align: left;
  line-height: 1.45;
  cursor: pointer;
}
.auth-consent input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--rose-hi);
  cursor: pointer;
}
.auth-consent .inline-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--rose-hi);
  font-family: inherit;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.auth-consent .inline-link:hover { color: var(--rose); }
.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ─── User badge & menu ────────────────────────────── */
.user-badge {
  background: var(--panel-2);
  border: 1px solid var(--border-rose);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
}
.user-badge:hover { border-color: var(--gold); color: var(--gold); }
.user-badge .user-name { letter-spacing: 0.02em; }
.user-badge .user-caret { font-size: 0.7rem; opacity: 0.7; }

.user-menu {
  position: fixed;
  z-index: 950;
  background: var(--panel);
  border: 1px solid var(--border-rose-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px var(--shadow-deep);
  min-width: 160px;
  padding: 6px;
}
.user-menu .menu-item {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.95rem;
  text-align: left;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.user-menu .menu-item:hover { background: var(--bg-2); color: var(--gold); }

/* ─── Admin ────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--serif);
  margin-top: 12px;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-rose-vague);
  text-align: left;
  vertical-align: middle;
}
.admin-table th {
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.admin-table tr:hover td { background: var(--border-rose-mist); }
.admin-table button {
  background: var(--panel-2);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  padding: 5px 10px;
  border-radius: 999px;
  font-family: var(--serif);
  cursor: pointer;
}
.admin-back { margin-bottom: 12px; }
.admin-back button {
  background: transparent;
  border: 0;
  color: var(--rose-hi);
  font-family: var(--serif);
  font-size: 0.95rem;
  cursor: pointer;
}

/* ─── Mobile ────────────────────────────── */
@media (max-width: 768px) {
  /* Header */
  h1 { font-size: 1.25rem; letter-spacing: 0.05em; }
  .bat-logo { width: 44px; height: 30px; }
  .header-inner { padding: 12px 14px 4px; gap: 8px; }
  .brand { gap: 10px; }
  .header-actions { gap: 6px; }
  .user-badge { padding: 5px 10px; font-size: 0.85rem; }
  .icon-btn { padding: 6px; font-size: 1rem; }

  /* Tabs: scrollable strip, smaller padding */
  .tabs { padding: 0 12px; gap: 0; }
  .tab { padding: 12px 14px 10px; font-size: 0.85rem; letter-spacing: 0.04em; }
  .tab.active::after { left: 8px; right: 8px; }

  /* Sub-tabs */
  .subtab { padding: 10px 12px; font-size: 0.78rem; }

  /* Main padding */
  main { padding: 14px 12px; }

  /* Search bar: full width, then filters wrap below */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  #search { min-width: 0; padding: 10px 14px; font-size: 0.95rem; }

  /* Filter widgets: shrink and wrap to multiple short rows */
  .filters { flex-wrap: wrap; gap: 6px; }
  .filter-select, .filter-multi summary {
    padding: 8px 28px 8px 12px;
    font-size: 0.85rem;
    min-width: 0;
    flex: 1 1 calc(50% - 6px);
  }
  .filter-multi summary { padding-right: 12px; }
  .filter-clear, .filter-action {
    padding: 8px 12px;
    font-size: 0.82rem;
    margin-left: 0;
    flex: 1 1 100%;
  }
  .filter-options {
    left: 0;
    right: 0;
    min-width: 0;
  }

  /* Active filters bar — wrap normally, smaller text */
  .active-filters { padding: 6px 10px; font-size: 0.82rem; }
  .active-pill { padding: 3px 8px; font-size: 0.78rem; }
  .active-clear-all { font-size: 0.8rem; }

  /* Cards / grids */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  /* Re-assert single-column for list view — the .grid rule above and this
     .grid-list rule have equal specificity, and the .grid rule otherwise
     wins by source order. */
  .grid-list { grid-template-columns: 1fr; }
  .grid-tight { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .card-name { font-size: 0.98rem; }
  .card-meaning { font-size: 0.88rem; }
  .card-actions { padding: 8px 10px 10px; gap: 4px; }
  .card-actions button, .card-actions .btn-buy { font-size: 0.82rem; padding: 6px 8px; }
  .qty-control { padding: 1px; }
  .qty-btn { width: 28px; height: 28px; font-size: 0.95rem; }
  .qty-display { font-size: 0.85rem; min-width: 22px; }

  /* List view (My Collection) — compact photo, body fills rest */
  .grid-list .card { grid-template-columns: 96px 1fr; }
  .grid-list .card-body { padding: 8px 10px 2px; }
  .grid-list .card-actions {
    padding: 4px 10px 8px;
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-rose-faint);
    margin-top: 4px;
  }
  .grid-list .card-photo { aspect-ratio: 1 / 1; }

  /* Modals: full-width, less inner padding, sticky close */
  .modal-card { max-width: 100%; padding: 18px 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
  .modal-card-wide { max-width: 100%; }
  .modal-card h2 { font-size: 1.2rem; }
  .modal-name { font-size: 0.95rem; }
  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions button { width: 100%; }

  /* User menu / dropdowns */
  .user-menu { left: 12px; right: 12px; }

  /* Trade lines: stack the two columns */
  .trade-lines { grid-template-columns: 1fr; gap: 8px; }
  .trade-card { padding: 10px 12px; }
  .trade-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .trade-with { margin-right: 0; }

  /* Offer builder — already vertical, just tighten spacing */
  .picker-panel { padding: 10px; }

  /* Account modal sections */
  .account-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .account-row.right { flex-direction: row; justify-content: flex-end; }
  .feedback-summary { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .fb-cell { padding: 8px 4px; }
  .fb-num { font-size: 1.05rem; }
  .fb-label { font-size: 0.68rem; }

  /* Pens */
  .pens-progress { padding: 12px 14px; }
  .pens-progress-text { gap: 6px; }
  .pen-rows { grid-template-columns: 1fr; }
  .pen-row { padding: 8px 12px; }

  /* Admin table → make horizontally scrollable so columns don't squish */
  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Auth overlay */
  .auth-card { padding: 28px 22px; }
  .auth-title { font-size: 1.4rem; }
}

/* Extra-small phones — squeeze even more */
@media (max-width: 380px) {
  h1 { font-size: 1.1rem; }
  .bat-logo { width: 36px; height: 24px; }
  .tab { padding: 11px 11px 9px; font-size: 0.8rem; }
  .grid-list .card { grid-template-columns: 80px 1fr; }
  .grid { grid-template-columns: 1fr; }
  .grid-tight { grid-template-columns: repeat(2, 1fr); }
  .card-actions button, .card-actions .btn-buy { font-size: 0.78rem; padding: 5px 7px; }
}
