/* ============================================================
   PokéCollect — Main stylesheet (Step 10: polished)
   Place in /assets/css/app.css
   ============================================================ */

/* ── Theme tokens ── */
:root {
  --bg:       #eeedf8;
  --page:     #ffffff;
  --ink:      #1a1830;
  --muted:    #8886a8;
  --line:     #e0dff0;
  --shadow:   rgba(26,24,48,.13);
  --fire:     #e8431a;
  --water:    #1a8fe8;
  --grass:    #1ab852;
  --electric: #d4a800;
  --psychic:  #b83adb;
  --dragon:   #4a52e8;
  --radius:   14px;
}
[data-theme="dark"] {
  --bg:     #12111a;
  --page:   #1e1c2e;
  --ink:    #e8e6f5;
  --muted:  #8884aa;
  --line:   #35325a;
  --shadow: rgba(0,0,0,.4);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  min-height: 100vh;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Topbar ── */
.topbar {
  background: var(--page);
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background .25s, border-color .25s;
}
.logo {
  font-family: 'Fredoka One', sans-serif;
  font-size: 22px;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo span { color: var(--fire); }

/* ── Search ── */
.topbar-search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 30px;
  padding: 0 14px;
  height: 36px;
  transition: border-color .2s, background .25s;
}
.topbar-search.focused,
.topbar-search:focus-within { border-color: var(--electric); }
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  width: 100%;
}
.topbar-search input::placeholder { color: var(--muted); }

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 420px;
  max-width: calc(100vw - 24px);
  background: var(--page);
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px var(--shadow);
  z-index: 150;
  overflow: hidden;
  max-height: 520px;
  overflow-y: auto;
}
.sd-enter         { transition: opacity .15s, transform .15s; }
.sd-enter-start   { opacity: 0; transform: translateY(-6px); }
.sd-enter-end     { opacity: 1; transform: translateY(0); }
.sd-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; color: var(--muted); font-size: 13px;
}
.sd-empty {
  padding: 18px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.sd-section { border-bottom: 1px solid var(--line); }
.sd-section:last-child { border-bottom: none; }
.sd-section-label {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted);
}
.sd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background .1s;
}
.sd-row:hover { background: var(--bg); }
.sd-poke-img {
  width: 36px; height: 36px;
  object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.15));
}
.sd-card-img {
  width: 28px; height: 39px;
  object-fit: cover; border-radius: 4px;
  border: 1px solid var(--line); flex-shrink: 0;
  background: var(--bg);
}
.sd-set-logo {
  width: 48px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sd-row-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.sd-row-name {
  font-weight: 700; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-row-meta {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sd-type-pip {
  font-size: 10px; font-weight: 700;
  color: #fff; padding: 2px 7px;
  border-radius: 20px; text-transform: capitalize;
  flex-shrink: 0; white-space: nowrap;
}
.sd-rarity {
  font-size: 10px; color: var(--psychic);
  font-weight: 700; flex-shrink: 0;
  white-space: nowrap; max-width: 80px;
  overflow: hidden; text-overflow: ellipsis; text-align: right;
}

/* ── Topbar right ── */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 30px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  border: none;
  transition: filter .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.92); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.btn-primary { background: var(--ink); color: var(--page); }
.btn-outline { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn-sm { padding: 5px 13px; font-size: 12px; }

/* ── Avatar ── */
.avatar-wrap { position: relative; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--psychic); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 13px;
  cursor: pointer; flex-shrink: 0;
  border: 2px solid transparent;
  transition: border-color .15s;
  user-select: none;
}
.avatar:hover { border-color: var(--psychic); }

/* ── Account panel ── */
.account-panel {
  position: absolute;
  top: calc(100% + 10px); right: 0;
  width: 296px;
  background: var(--page);
  border: 2px solid var(--line);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 36px var(--shadow);
  z-index: 200; display: none;
  transition: background .25s, border-color .25s;
}
.account-panel.open { display: block; }
.acct-header {
  padding: 14px 16px; border-bottom: 2px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.acct-avatar-big {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--psychic); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px; flex-shrink: 0;
}
.acct-name { font-weight: 900; font-size: 14px; }
.acct-role { font-size: 11px; color: var(--muted); }
.acct-section { padding: 12px 16px; border-bottom: 2px solid var(--line); }
.acct-section:last-child { border-bottom: none; }
.acct-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.acct-actions { display: flex; gap: 8px; }
.theme-presets { display: flex; gap: 8px; }
.preset {
  flex: 1; border-radius: 10px; overflow: hidden;
  cursor: pointer; border: 2px solid var(--line);
  transition: border-color .15s; position: relative;
}
.preset.active { border-color: var(--ink); }
.preset-preview { height: 38px; display: flex; gap: 3px; padding: 5px; }
.preset-swatch { flex: 1; border-radius: 3px; }
.preset-label {
  font-size: 11px; font-weight: 700; text-align: center;
  padding: 5px 0 6px; background: var(--bg); color: var(--ink);
  transition: background .25s, color .25s;
}
.preset-check {
  position: absolute; top: 4px; right: 5px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ink); color: var(--page);
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 900;
}
.color-rows { display: flex; flex-direction: column; gap: 7px; }
.color-row { display: flex; align-items: center; justify-content: space-between; }
.color-row-label { font-size: 12px; font-weight: 700; }
.color-row-right { display: flex; align-items: center; gap: 8px; }
.color-val { font-size: 10px; color: var(--muted); font-family: monospace; }
.swatch-btn {
  width: 26px; height: 26px; border-radius: 6px;
  border: 2px solid var(--line); cursor: pointer;
  position: relative; transition: transform .1s; flex-shrink: 0;
}
.swatch-btn:hover { transform: scale(1.1); }
.swatch-btn input[type=color] {
  position: absolute; inset: 0; opacity: 0;
  cursor: pointer; width: 100%; height: 100%;
}
.reset-link {
  font-size: 11px; color: var(--muted);
  cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.reset-link:hover { color: var(--ink); }

/* ── Binder tabs ── */
.binder-tabs-wrap {
  background: var(--bg);
  padding-top: 16px;
  transition: background .25s;
}
.binder-tabs {
  display: flex; align-items: flex-end;
  padding: 0 20px; gap: 3px;
  overflow-x: auto; scrollbar-width: none;
}
.binder-tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 16px 12px;
  border-radius: 12px 12px 0 0;
  font-weight: 700; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  background: var(--page);
  border: 2px solid var(--line); border-bottom: none;
  color: var(--muted);
  transition: color .15s, background .25s, border-color .25s;
  position: relative; margin-bottom: -2px;
  user-select: none;
}
.tab.active { color: var(--ink); z-index: 2; padding-bottom: 14px; }
.tab.active::after {
  content: ''; position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 3px; background: var(--page);
}
.tab-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tab-prog {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  background: var(--bg); transition: background .25s;
}
.tab-add {
  padding: 8px 14px 12px;
  border-radius: 12px 12px 0 0;
  cursor: pointer; color: var(--muted);
  font-size: 20px; line-height: 1;
  transition: color .15s; margin-bottom: -2px;
  user-select: none;
}
.tab-add:hover { color: var(--ink); }

/* ── Binder body ── */
.binder {
  background: var(--page);
  border: 2px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  margin: 0 20px 24px;
  padding: 20px;
  position: relative; z-index: 1;
  transition: background .25s, border-color .25s;
  min-height: 300px;
}

/* ── Collection header ── */
.coll-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.coll-header-left { flex: 1; min-width: 0; }
.coll-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 24px; line-height: 1.1;
}
.coll-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  border: 1.5px solid currentColor; white-space: nowrap;
}

/* ── Stats ── */
.stats-row {
  display: flex; background: var(--bg);
  border-radius: 12px; overflow: hidden;
  margin-bottom: 18px; border: 2px solid var(--line);
  transition: background .25s, border-color .25s;
}
.stat-cell {
  flex: 1; padding: 12px 14px;
  border-right: 2px solid var(--line);
  text-align: center; transition: border-color .25s;
}
.stat-cell:last-child { border-right: none; }
.stat-num {
  font-family: 'Fredoka One', sans-serif;
  font-size: 22px; line-height: 1;
}
.stat-lbl {
  font-size: 10px; color: var(--muted);
  font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; margin-top: 2px;
}

/* ── Progress ── */
.prog-wrap { margin-bottom: 18px; }
.prog-bar {
  height: 10px; background: var(--bg);
  border-radius: 5px; overflow: hidden;
  border: 2px solid var(--line);
  transition: background .25s, border-color .25s;
}
.prog-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.prog-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); font-weight: 700; margin-top: 4px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px; padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap; transition: border-color .25s;
}
.chips { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.chip {
  padding: 5px 13px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
  background: var(--bg); color: var(--muted);
  border: 2px solid var(--line);
  transition: all .15s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); }
.scale-wrap {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
}
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 84px; height: 4px;
  background: var(--line); border-radius: 2px; outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--page);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.view-toggle { display: flex; gap: 4px; }
.view-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 2px solid var(--line);
  border-radius: 8px; color: var(--muted);
  transition: all .15s; font-size: 14px;
}
.view-btn.on { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-size, 130px), 1fr));
  gap: 10px;
}
.poke-slot {
  border-radius: 12px; overflow: hidden;
  cursor: pointer; position: relative;
  transition: transform .2s, box-shadow .2s;
  background: var(--page); border: 2px solid var(--line);
}
.poke-slot:hover {
  transform: translateY(-5px) rotate(.4deg);
  box-shadow: 0 10px 28px var(--shadow);
  border-color: var(--ink); z-index: 2;
}
.poke-slot:focus-visible {
  outline: 3px solid var(--electric);
  outline-offset: 2px;
}
.poke-slot.uncollected { background: var(--bg); }
.poke-slot.uncollected .card-img-wrap { filter: saturate(.25) opacity(.7); }
.poke-slot.uncollected:hover .card-img-wrap { filter: saturate(.5) opacity(.9); }
.card-img-wrap {
  width: 100%; aspect-ratio: 2.5/3.5;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  background: var(--bg); transition: filter .2s;
}
.card-art { width: 100%; height: 100%; object-fit: cover; }
.poke-art {
  width: 68%; max-width: 88px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.15));
}
.card-footer {
  padding: 6px 8px 7px;
  border-top: 2px solid var(--line);
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 4px;
  transition: border-color .25s;
}
.poke-slot.uncollected .card-footer { background: var(--bg); }
.card-name { font-weight: 900; font-size: 11px; line-height: 1.2; }
.card-num { font-size: 10px; color: var(--muted); font-weight: 700; }
.check-badge {
  position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--grass); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 900;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.type-corner {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0; border-style: solid;
  border-width: 26px 26px 0 0; opacity: .8;
}

/* ── Skeleton shimmer ── */
.shimmer {
  background: linear-gradient(90deg, var(--line) 25%, var(--bg) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton .card-img-wrap { height: 100%; }

/* ── Table view ── */
.table-wrap { overflow-x: auto; }
.tcg-table { width: 100%; border-collapse: collapse; }
.tcg-table th {
  background: var(--bg); color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  padding: 9px 12px; text-align: left;
  border-bottom: 2px solid var(--line); font-weight: 700;
}
.tcg-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px; vertical-align: middle;
}
.tcg-table tr:hover td { background: var(--bg); }
.table-thumb {
  width: 32px; height: 45px; border-radius: 4px;
  object-fit: cover; background: var(--bg); border: 1px solid var(--line);
}
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }

/* ── Empty states ── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center; padding: 56px 20px; color: var(--muted);
}
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 20px; color: var(--ink); margin-bottom: 6px;
}
.empty-sub { font-size: 13px; line-height: 1.6; max-width: 280px; margin: 0 auto; }
.empty-action {
  display: inline-flex; margin-top: 16px;
}

/* No collections state */
.no-collections {
  text-align: center; padding: 64px 20px; color: var(--muted);
}
.no-collections .empty-icon { font-size: 52px; margin-bottom: 16px; }
.no-collections .empty-title { font-size: 22px; margin-bottom: 8px; }
.no-collections .empty-sub { max-width: 320px; margin: 0 auto 20px; }

/* ── Error states ── */
.error-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(232,67,26,.1);
  border: 1.5px solid var(--fire);
  border-radius: 12px; padding: 12px 16px;
  color: var(--fire); font-size: 13px; font-weight: 700;
  margin-bottom: 16px;
}
.error-banner-icon { font-size: 18px; flex-shrink: 0; }
.error-banner-text { flex: 1; }
.error-banner-retry {
  background: none; border: 1.5px solid var(--fire);
  color: var(--fire); border-radius: 20px;
  padding: 4px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
.error-banner-retry:hover { background: rgba(232,67,26,.15); }

/* ── Overlays / Modals ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,48,.55);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--page);
  border: 2px solid var(--line);
  border-radius: 20px;
  width: 100%; max-width: 680px;
  max-height: 88vh; overflow-y: auto;
  padding: 22px;
  box-shadow: 0 24px 60px var(--shadow);
  transform: translateY(10px);
  transition: transform .2s;
}
.overlay.open .modal { transform: translateY(0); }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.modal-thumb {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.modal-thumb img { width: 80%; }
.modal-title-text {
  font-family: 'Fredoka One', sans-serif; font-size: 20px;
}
.modal-sub { color: var(--muted); font-size: 12px; }
.modal-close {
  margin-left: auto; width: 30px; height: 30px;
  background: var(--bg); border: 2px solid var(--line);
  border-radius: 8px; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .15s;
}
.modal-close:hover { color: var(--ink); border-color: var(--ink); }

/* Modal loading */
.modal-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 32px; color: var(--muted); justify-content: center;
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--electric);
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal card grid */
.modal-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.modal-card {
  border-radius: 10px; overflow: hidden;
  border: 2px solid var(--line);
  cursor: pointer; transition: all .18s;
  background: var(--bg);
}
.modal-card:hover {
  border-color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 8px 18px var(--shadow);
}
.modal-card-owned { border-color: var(--grass) !important; }
.modal-card img {
  width: 100%; aspect-ratio: 2.5/3.5;
  object-fit: cover;
  background: var(--bg);
}
.modal-card-info { padding: 5px 7px 7px; }
.modal-card-set  { font-size: 10px; color: var(--muted); font-weight: 700; }
.modal-card-num  { font-size: 11px; font-weight: 900; }
.modal-card-rarity { font-size: 10px; color: var(--psychic); font-weight: 700; }
.modal-card-owned-badge {
  font-size: 9px; color: var(--grass); font-weight: 900;
  margin-top: 2px; text-transform: uppercase; letter-spacing: .5px;
}

/* Modal error state */
.modal-error {
  text-align: center; padding: 32px 20px; color: var(--muted);
}
.modal-error .empty-icon { font-size: 32px; margin-bottom: 10px; }
.modal-error p { font-size: 13px; margin-bottom: 14px; }

/* ── Confirm box ── */
.confirm-box {
  background: var(--page); border: 2px solid var(--line);
  border-radius: 20px; padding: 24px;
  width: 100%; max-width: 660px;
  text-align: center;
  box-shadow: 0 24px 60px var(--shadow);
}
.confirm-preview {
  width: 100%; max-width: 600px; margin: 0 auto 14px;
  border-radius: 10px; overflow: hidden;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--bg);
  min-height: 140px;
  display: flex; align-items: center; justify-content: center;
}
.confirm-preview img { width: 100%; display: block; }

/* ── Mobile: make the card preview as large as the screen allows ── */
@media (max-width: 600px) {
  .overlay:has(.confirm-box) {
    align-items: stretch;
    padding: 0;
  }
  .confirm-box {
    border-radius: 0;
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: none;
  }
  .confirm-preview {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-height: 0;
    box-shadow: none;
    border-width: 2px;
  }
  .confirm-preview img {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .confirm-title  { flex-shrink: 0; margin-top: 12px; }
  .confirm-sub    { flex-shrink: 0; }
  .coll-options, .confirm-no-coll { flex-shrink: 0; max-height: 30vh; overflow-y: auto; }
  .confirm-actions { flex-shrink: 0; }
}
.confirm-title {
  font-family: 'Fredoka One', sans-serif;
  font-size: 18px; margin-bottom: 4px;
}
.confirm-sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.coll-options { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; text-align: left; }
.coll-option {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px;
  cursor: pointer; font-size: 13px; font-weight: 700;
  transition: border-color .15s;
}
.coll-option.sel { border-color: var(--ink); background: var(--page); }
.coll-option-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.confirm-actions { display: flex; gap: 8px; justify-content: center; }

/* No collections in confirm — helpful hint */
.confirm-no-coll {
  text-align: center; padding: 12px;
  color: var(--muted); font-size: 13px;
}

/* ── Form elements ── */
.form-group { margin-bottom: 14px; }
.form-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); display: block; margin-bottom: 5px;
}
.form-input {
  width: 100%; background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px;
  padding: 8px 12px; color: var(--ink);
  font-family: 'Nunito', sans-serif; font-size: 14px;
  outline: none; transition: border-color .15s, background .25s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--ink); }
.form-input.error { border-color: var(--fire); }
.form-error { font-size: 11px; color: var(--fire); font-weight: 700; margin-top: 4px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700;
}
.tog {
  width: 34px; height: 19px; background: var(--line);
  border-radius: 10px; cursor: pointer; position: relative;
  transition: background .2s; flex-shrink: 0;
}
.tog.on { background: var(--grass); }
.tog::after {
  content: ''; position: absolute;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.tog.on::after { left: 18px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--page);
  padding: 10px 22px; border-radius: 30px;
  font-weight: 700; font-size: 14px; z-index: 999;
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--fire); }

/* ── Connection / loading banner ── */
.loading-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 24px; color: var(--muted); font-size: 13px;
  grid-column: 1 / -1;
}

/* ── Responsive — tablet ── */
@media (max-width: 860px) {
  .binder { margin: 0 14px 20px; }
  .binder-tabs { padding: 0 14px; }
  .topbar { padding: 0 14px; }
}

/* ── Responsive — mobile ── */
@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 8px; height: 52px; }
  .logo { font-size: 18px; }
  .topbar-search-wrap { max-width: 160px; }
  .search-dropdown {
    width: calc(100vw - 24px);
    left: 50%;
    transform: translateX(-50%);
  }
  .topbar-right { gap: 6px; }
  .btn-sm { padding: 4px 10px; font-size: 11px; }

  .binder-tabs-wrap { padding-top: 12px; }
  .binder-tabs { padding: 0 10px; gap: 2px; }
  .tab { padding: 7px 12px 10px; font-size: 12px; }
  .tab.active { padding-bottom: 12px; }
  .tab-prog { display: none; }

  .binder { margin: 0 8px 16px; padding: 14px 12px; border-radius: 0 12px 12px 12px; }
  .coll-title { font-size: 20px; }
  .coll-header { gap: 8px; }

  .stats-row { flex-wrap: wrap; }
  .stat-cell {
    min-width: 50%;
    border-right: none;
    border-bottom: 2px solid var(--line);
    padding: 10px;
  }
  .stat-cell:nth-child(odd) { border-right: 2px solid var(--line); }
  .stat-cell:nth-last-child(-n+2) { border-bottom: none; }
  .stat-num { font-size: 18px; }

  .toolbar {
    gap: 8px; padding-bottom: 14px; margin-bottom: 14px;
    flex-wrap: wrap;
  }
  .chips { gap: 4px; order: 1; }
  .chip { padding: 4px 10px; font-size: 11px; }
  .scale-wrap {
    order: 2;
    width: 100%;
    justify-content: flex-start;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    margin-top: 4px;
  }
  .scale-wrap input[type=range] { width: calc(100% - 60px); max-width: 200px; }
  .view-toggle { order: 0; margin-left: auto; }

  .card-grid { gap: 7px; }

  /* Modals go full-screen on mobile */
  .overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    padding: 18px 16px;
    transform: translateY(20px);
  }
  .overlay.open .modal { transform: translateY(0); }
  .confirm-box {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    padding: 20px 16px;
  }
  .modal-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

/* ── Accessibility ── */
:focus-visible {
  outline: 3px solid var(--electric);
  outline-offset: 2px;
}
.btn:focus-visible,
.chip:focus-visible {
  outline: 3px solid var(--electric);
  outline-offset: 2px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Best sets to open ── */
.setrecs-sub {
  font-size: 12px; color: var(--muted);
  margin: 0 0 14px;
}
.setrecs-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 60vh; overflow-y: auto;
}
.setrec-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--bg); border: 2px solid var(--line);
  border-radius: 12px;
}
.setrec-rank {
  font-family: 'Fredoka One', sans-serif;
  font-size: 16px; color: var(--electric);
  min-width: 22px; text-align: right; flex-shrink: 0;
}
.setrec-logo {
  width: 48px; height: 48px; object-fit: contain;
  flex-shrink: 0;
}
.setrec-info { flex: 1; min-width: 0; }
.setrec-name {
  font-weight: 700; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.setrec-meta {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}

.setrecs-banner {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--bg); border: 2px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  font-size: 12px; color: var(--muted);
  margin-bottom: 14px; line-height: 1.5;
}
.setrecs-banner.low {
  background: rgba(255,193,7,.12);
  border-color: #ffc107;
  color: var(--ink);
}
.setrecs-banner strong { color: var(--ink); }