/* =====================================================================
   Fabricard - Precon Deckbuilder styles
   ALL selectors are prefixed with "pmdb-" to guarantee zero collision
   with the host app. Host design tokens (--accent, --bg-app, …) are
   global on :root and referenced directly.
   ===================================================================== */

/* ---- color identity tokens (local) -------------------------------- */
.pmdb-overlay {
  --pmdb-W: #f8f6d8;
  --pmdb-U: #3b82f6;
  --pmdb-B: #3b3b47;
  --pmdb-R: #ef4444;
  --pmdb-G: #22c55e;
  --pmdb-C: #9ca3af;
  --pmdb-z: 9999;
}

/* prevent host page scroll behind the overlay */
body.pmdb-noscroll { overflow: hidden; }

/* ---- overlay & backdrop ------------------------------------------- */
.pmdb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 2vw, 28px);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary, #EBECF0);
  -webkit-font-smoothing: antialiased;
}
.pmdb-overlay.pmdb-open { display: flex; }

.pmdb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 11, 0.74);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  backdrop-filter: blur(8px) saturate(120%);
  animation: pmdb-fade 0.22s ease;
}

/* ---- panel -------------------------------------------------------- */
.pmdb-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  /* ~1/3 larger popup for more room in the sub-menus (font sizes unchanged). */
  width: min(1520px, 100%);
  height: min(96vh, 1300px);
  max-height: 100%;
  background: var(--bg-app, #0C0D13);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(200, 169, 81, 0.06);
  overflow: hidden;
  animation: pmdb-pop 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- topbar ------------------------------------------------------- */
.pmdb-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light, #1E2336);
  background: linear-gradient(180deg, var(--bg-sidebar, #111318), var(--bg-app, #0C0D13));
}
.pmdb-topbar-left { display: flex; align-items: center; min-width: 0; }
.pmdb-topbar-center { display: flex; flex: 1 1 auto; justify-content: center; }
.pmdb-topbar-right { display: flex; align-items: center; margin-left: auto; }

.pmdb-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-primary, #EBECF0);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 6px 8px;
  border-radius: var(--radius-md, 8px);
  transition: color 0.15s ease, background 0.15s ease;
}
.pmdb-brand:hover { background: var(--bg-hover, #232840); }
.pmdb-brand .pmdb-ico { color: var(--accent, #C8A951); display: inline-flex; }
.pmdb-brand-text { font-size: 15px; }

.pmdb-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border, #272D42);
  background: var(--bg-section, #181B24);
  color: var(--text-secondary, #8B92A8);
  cursor: pointer;
  transition: all 0.15s ease;
}
.pmdb-iconbtn:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); background: var(--bg-hover, #232840); }
.pmdb-back { width: auto; padding: 0 14px 0 10px; }
.pmdb-back-label { font-size: 13px; font-weight: 600; }

/* format toggle */
.pmdb-toggle {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: 999px;
}
.pmdb-toggle-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #8B92A8);
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  transition: all 0.18s ease;
}
.pmdb-toggle-btn:hover { color: var(--text-primary, #EBECF0); }
.pmdb-toggle-on {
  color: #14110a;
  background: linear-gradient(180deg, var(--accent-hover, #DFBF68), var(--accent, #C8A951));
  box-shadow: 0 2px 8px -2px rgba(200, 169, 81, 0.5);
}

/* ---- content & footer --------------------------------------------- */
.pmdb-content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px clamp(14px, 3vw, 30px) 30px;
  scroll-behavior: smooth;
}
.pmdb-footer {
  flex: none;
  padding: 10px 18px;
  border-top: 1px solid var(--border-light, #1E2336);
  background: var(--bg-sidebar, #111318);
  text-align: center;
}
.pmdb-footer-text { font-size: 11.5px; color: var(--text-muted, #6B7490); letter-spacing: 0.3px; }

/* ---- format choose ------------------------------------------------ */
.pmdb-choose {
  max-width: 1040px;
  margin: clamp(10px, 5vh, 60px) auto 0;
  text-align: center;
}
.pmdb-choose-title { font-size: clamp(24px, 4vw, 34px); font-weight: 800; margin: 0 0 8px; letter-spacing: -0.4px; }
.pmdb-choose-sub { color: var(--text-secondary, #8B92A8); font-size: 15px; margin: 0 0 34px; }
.pmdb-choose-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* Two equal columns of equal-size tiles (left: precons, right: tournament + my decks) */
.pmdb-choose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: stretch; text-align: left; }
.pmdb-choose-col { display: flex; flex-direction: column; gap: 16px; }
.pmdb-choose-colhead { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent, #C8A951); margin: 0 0 2px; }
.pmdb-ctile {
  flex: 1 1 0;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 188px; padding: 22px 22px 20px;
  text-align: left;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
  cursor: pointer; position: relative; overflow: hidden;
  color: inherit; font-family: inherit;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.pmdb-ctile:hover { border-color: var(--accent, #C8A951); transform: translateY(-3px); box-shadow: 0 14px 32px -16px rgba(0, 0, 0, 0.8); }
.pmdb-ctile:focus-visible { outline: none; border-color: var(--accent, #C8A951); box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.22)); }
.pmdb-ctile .pmdb-ico { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--accent, #C8A951); background: var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-ctile .pmdb-ico svg { width: 26px; height: 26px; }
.pmdb-ctile-blue .pmdb-ico { color: var(--accent2, #60A5FA); background: rgba(96, 165, 250, 0.12); }
.pmdb-ctile-title { font-size: 19px; font-weight: 700; margin: 2px 0 0; }
.pmdb-ctile-desc { font-size: 13.5px; line-height: 1.5; color: var(--text-secondary, #8B92A8); margin: 0; flex: 1 1 auto; }
.pmdb-ctile-cta { font-size: 13px; font-weight: 600; color: var(--accent, #C8A951); }
.pmdb-ctile-cta::after { content: " \2192"; }
.pmdb-ctile-blue .pmdb-ctile-cta { color: var(--accent2, #60A5FA); }
@media (max-width: 640px) { .pmdb-choose-grid { grid-template-columns: 1fr; } }

.pmdb-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 8px;
  padding: 30px 26px 26px;
  cursor: pointer;
  font: inherit;
  color: var(--text-primary, #EBECF0);
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(200, 169, 81, 0.10), transparent 55%),
    var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.pmdb-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.pmdb-hero:hover {
  transform: translateY(-4px);
  border-color: var(--accent, #C8A951);
  box-shadow: 0 22px 48px -24px rgba(0, 0, 0, 0.8);
}
.pmdb-hero .pmdb-ico {
  display: inline-flex;
  color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  padding: 14px;
  border-radius: var(--radius-md, 8px);
  margin-bottom: 6px;
}
.pmdb-hero-constructed .pmdb-ico { color: var(--accent2, #60A5FA); background: rgba(96, 165, 250, 0.12); }
.pmdb-hero-title { font-size: 21px; font-weight: 700; margin: 0; }
.pmdb-hero-desc { color: var(--text-secondary, #8B92A8); font-size: 13.5px; margin: 0; line-height: 1.5; }
.pmdb-hero-cta {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent, #C8A951);
}
.pmdb-hero-cta::after { content: " →"; }
.pmdb-hero-constructed .pmdb-hero-cta { color: var(--accent2, #60A5FA); }

/* ---- toolbar ------------------------------------------------------ */
.pmdb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.pmdb-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 180px;
}
.pmdb-search-wrap .pmdb-ico {
  position: absolute;
  left: 12px;
  display: inline-flex;
  color: var(--text-muted, #6B7490);
  pointer-events: none;
}
.pmdb-search {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 10px 12px 10px 38px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pmdb-search::placeholder { color: var(--text-muted, #6B7490); }
.pmdb-search:focus {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12));
}

.pmdb-select {
  font: inherit;
  font-size: 13px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 9px 12px;
  cursor: pointer;
  max-width: 200px;
}
.pmdb-select:focus { outline: none; border-color: var(--accent, #C8A951); }

.pmdb-favfilter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 8px 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pmdb-favfilter:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); }
.pmdb-favfilter .pmdb-ico { display: inline-flex; }
.pmdb-favfilter-on { color: var(--accent, #C8A951); border-color: var(--accent, #C8A951); background: var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-favfilter-on .pmdb-ico svg path { fill: var(--accent, #C8A951); }

/* color filter pips */
.pmdb-colorfilter { display: inline-flex; gap: 5px; align-items: center; }
.pmdb-profile-colorwrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.pmdb-profile-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.pmdb-profile-search { flex: 1 1 220px; max-width: 360px; }
.pmdb-deck-value { font-size: 11.5px; color: var(--success, #4ADE80); font-weight: 600; font-variant-numeric: tabular-nums; }
.pmdb-pipbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  cursor: pointer;
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: 999px;
  transition: all 0.15s ease;
}
.pmdb-pipbtn:hover { border-color: var(--accent, #C8A951); transform: translateY(-1px); }
.pmdb-pipbtn .pmdb-pip { width: 16px; height: 16px; opacity: 0.85; }
.pmdb-pipbtn-on {
  border-color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(200, 169, 81, 0.12));
}
.pmdb-pipbtn-on .pmdb-pip { opacity: 1; }

.pmdb-filterhint {
  font-size: 11.5px;
  color: var(--text-muted, #6B7490);
  margin: 0 0 16px;
}

/* ---- sections ----------------------------------------------------- */
.pmdb-section { margin-bottom: 30px; }
.pmdb-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 14px;
}

/* Top 5 featured strip */
.pmdb-top5-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(190px, 1fr);
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.pmdb-top5-row .pmdb-tile-wrap { scroll-snap-align: start; }

/* grid */
.pmdb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

/* ---- tile --------------------------------------------------------- */
.pmdb-tile-wrap { position: relative; }
.pmdb-tile {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.pmdb-tile:hover {
  transform: translateY(-4px);
  border-color: var(--accent, #C8A951);
  box-shadow: 0 16px 34px -18px rgba(0, 0, 0, 0.85);
}
.pmdb-tile:focus-visible {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12));
}

.pmdb-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 626 / 457; /* Scryfall art_crop ratio */
  background: linear-gradient(135deg, #1a1d28, #0f1117);
  overflow: hidden;
}
.pmdb-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.pmdb-tile:hover .pmdb-cover-img { transform: scale(1.05); }
.pmdb-cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.018) 0 12px, transparent 12px 24px),
    linear-gradient(135deg, #1a1d28, #0f1117);
}
.pmdb-cover-fallback-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-muted, #6B7490);
  opacity: 0.6;
}

.pmdb-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-primary, #EBECF0);
  background: rgba(12, 13, 19, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: 3px 8px;
  border-radius: 5px;
}
.pmdb-badge-set { position: absolute; top: 8px; left: 8px; color: var(--accent, #C8A951); }
.pmdb-badge-count { position: absolute; bottom: 8px; left: 8px; font-size: 10px; }

.pmdb-tile-info { padding: 11px 12px 13px; }
.pmdb-tile-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pmdb-tile-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pmdb-tile-sub {
  font-size: 11.5px;
  color: var(--text-muted, #6B7490);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* featured tiles a touch larger */
.pmdb-tile-featured .pmdb-tile-name { font-size: 15px; }
.pmdb-cover-lg { aspect-ratio: 16 / 10; }

/* star toggle */
.pmdb-star {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(12, 13, 19, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.pmdb-tile-wrap:hover .pmdb-star,
.pmdb-star:focus-visible,
.pmdb-star-on { opacity: 1; transform: scale(1); }
.pmdb-star svg path { fill: none; transition: fill 0.15s ease; }
.pmdb-star:hover { border-color: var(--accent, #C8A951); }
.pmdb-star-on { color: var(--accent, #C8A951); border-color: var(--accent, #C8A951); }
.pmdb-star-on svg path { fill: var(--accent, #C8A951); }

/* ---- color pips --------------------------------------------------- */
.pmdb-pips { display: inline-flex; gap: 3px; align-items: center; }
.pmdb-pip {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12);
  flex: none;
}
.pmdb-pip-W { background: var(--pmdb-W); }
.pmdb-pip-U { background: var(--pmdb-U); }
.pmdb-pip-B { background: var(--pmdb-B); }
.pmdb-pip-R { background: var(--pmdb-R); }
.pmdb-pip-G { background: var(--pmdb-G); }
.pmdb-pip-C { background: var(--pmdb-C); }

/* color distribution bar (detail) */
.pmdb-colorbar {
  display: flex;
  width: 100%;
  max-width: 260px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.pmdb-colorbar-seg { flex: 1 1 0; height: 100%; }
.pmdb-bg-W { background: var(--pmdb-W); }
.pmdb-bg-U { background: var(--pmdb-U); }
.pmdb-bg-B { background: var(--pmdb-B); }
.pmdb-bg-R { background: var(--pmdb-R); }
.pmdb-bg-G { background: var(--pmdb-G); }
.pmdb-bg-C { background: var(--pmdb-C); }

/* ---- skeletons ---------------------------------------------------- */
.pmdb-skel-tile {
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
  padding: 0 0 13px;
  overflow: hidden;
}
.pmdb-skel {
  position: relative;
  overflow: hidden;
  background: var(--bg-input, #1C2030);
}
.pmdb-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: pmdb-shimmer 1.3s infinite;
}
.pmdb-skel-cover { aspect-ratio: 626 / 457; width: 100%; }
.pmdb-skel-line { height: 12px; border-radius: 5px; margin: 12px 12px 0; }
.pmdb-skel-line-sm { width: 55%; }
.pmdb-skel-line-lg { height: 22px; }

.pmdb-detail-skel { display: flex; gap: 24px; flex-wrap: wrap; }
.pmdb-skel-detailcover { width: 320px; max-width: 100%; aspect-ratio: 626 / 457; border-radius: var(--radius-md, 8px); }
.pmdb-detail-skel-meta { flex: 1 1 280px; display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.pmdb-detail-skel-meta .pmdb-skel-line { margin: 0; }

/* ---- empty / error ------------------------------------------------ */
.pmdb-empty, .pmdb-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--text-secondary, #8B92A8);
}
.pmdb-empty .pmdb-ico, .pmdb-error .pmdb-ico { color: var(--text-muted, #6B7490); }
.pmdb-error .pmdb-ico { color: var(--warning, #FBBF24); }
.pmdb-empty-title { font-size: 16px; font-weight: 700; color: var(--text-primary, #EBECF0); margin: 4px 0 0; }
.pmdb-empty-sub, .pmdb-error-msg { font-size: 13.5px; margin: 0; }
.pmdb-empty .pmdb-btn, .pmdb-error .pmdb-btn { margin-top: 8px; }

/* ---- buttons ------------------------------------------------------ */
.pmdb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 11px 20px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid transparent;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.pmdb-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-btn-primary {
  color: #14110a;
  background: linear-gradient(180deg, var(--accent-hover, #DFBF68), var(--accent, #C8A951));
  box-shadow: 0 6px 18px -8px rgba(200, 169, 81, 0.6);
}
.pmdb-btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.pmdb-btn-secondary {
  color: var(--text-primary, #EBECF0);
  background: var(--bg-hover, #232840);
  border-color: var(--border, #272D42);
}
.pmdb-btn-secondary:hover { border-color: var(--accent, #C8A951); }
.pmdb-btn-ghost {
  color: var(--text-secondary, #8B92A8);
  background: transparent;
  border-color: var(--border, #272D42);
}
.pmdb-btn-ghost:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); }
.pmdb-loadmore { display: flex; margin: 22px auto 0; }

/* ---- detail ------------------------------------------------------- */
.pmdb-detail { max-width: 940px; margin: 0 auto; }
.pmdb-detail-hero {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.pmdb-cover-detail {
  width: 340px;
  max-width: 100%;
  aspect-ratio: 626 / 457;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border, #272D42);
  flex: none;
}
.pmdb-detail-meta { flex: 1 1 300px; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.pmdb-detail-name { font-size: clamp(22px, 3vw, 30px); font-weight: 800; margin: 0; letter-spacing: -0.4px; line-height: 1.15; }
.pmdb-detail-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.pmdb-detail-badges .pmdb-badge { position: static; }
.pmdb-badge-type { color: var(--text-secondary, #8B92A8); }
.pmdb-badge-fmt { color: var(--accent, #C8A951); border-color: rgba(200, 169, 81, 0.3); }

.pmdb-detail-idrow { display: flex; align-items: center; gap: 12px; }
.pmdb-detail-idrow .pmdb-pip { width: 17px; height: 17px; }
.pmdb-detail-count { font-size: 13px; color: var(--text-secondary, #8B92A8); font-weight: 600; }

.pmdb-detail-commander {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px;
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  border: 1px solid rgba(200, 169, 81, 0.22);
  border-radius: var(--radius-md, 8px);
}
.pmdb-detail-commander-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--accent, #C8A951); }
.pmdb-detail-commander-name { font-size: 16px; font-weight: 700; }

.pmdb-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.pmdb-detail-fav .pmdb-ico svg path { fill: none; }
.pmdb-detail-fav.pmdb-star-on { color: var(--accent, #C8A951); border-color: var(--accent, #C8A951); }
.pmdb-detail-fav.pmdb-star-on .pmdb-ico svg path { fill: var(--accent, #C8A951); }

/* card lists */
.pmdb-detail-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}
.pmdb-cardsec {
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
  padding: 14px 16px;
}
.pmdb-cardsec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #C8A951);
  margin: 0 0 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border-light, #1E2336);
}
.pmdb-cardsec-count {
  font-size: 11px;
  color: var(--text-muted, #6B7490);
  background: var(--bg-input, #1C2030);
  border-radius: 999px;
  padding: 1px 8px;
  letter-spacing: 0;
}
.pmdb-cardlist { list-style: none; margin: 0; padding: 0; }
.pmdb-card {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(39, 45, 66, 0.4);
}
.pmdb-card:last-child { border-bottom: 0; }
.pmdb-card-qty { color: var(--accent, #C8A951); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 26px; }
.pmdb-card-name { flex: 1 1 auto; color: var(--text-primary, #EBECF0); }
.pmdb-card-set { color: var(--text-muted, #6B7490); font-size: 11.5px; white-space: nowrap; }

/* ---- import dialog ------------------------------------------------ */
.pmdb-dialog-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.pmdb-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 11, 0.66);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: pmdb-fade 0.16s ease;
}
.pmdb-dialog {
  position: relative;
  width: min(440px, 100%);
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.85);
  padding: 24px;
  animation: pmdb-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.pmdb-dialog-title { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.pmdb-dialog-sub { font-size: 13.5px; color: var(--text-secondary, #8B92A8); margin: 0 0 20px; line-height: 1.5; }
.pmdb-dialog-btns { display: flex; flex-direction: column; gap: 10px; }
.pmdb-dialog-btns .pmdb-btn { width: 100%; }

/* ---- toast -------------------------------------------------------- */
.pmdb-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  z-index: 10000;
  max-width: 90vw;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-section, #181B24);
  border: 1px solid var(--accent, #C8A951);
  border-radius: var(--radius-md, 8px);
  padding: 12px 20px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.pmdb-toast-show { opacity: 1; transform: translate(-50%, 0); }

/* ---- scrollbars --------------------------------------------------- */
.pmdb-content, .pmdb-top5-row {
  scrollbar-width: thin;
  scrollbar-color: var(--border, #272D42) transparent;
}
.pmdb-content::-webkit-scrollbar, .pmdb-top5-row::-webkit-scrollbar { width: 10px; height: 10px; }
.pmdb-content::-webkit-scrollbar-track, .pmdb-top5-row::-webkit-scrollbar-track { background: transparent; }
.pmdb-content::-webkit-scrollbar-thumb, .pmdb-top5-row::-webkit-scrollbar-thumb {
  background: var(--border, #272D42);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.pmdb-content::-webkit-scrollbar-thumb:hover, .pmdb-top5-row::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted, #6B7490);
  background-clip: padding-box;
}

/* ---- animations --------------------------------------------------- */
@keyframes pmdb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pmdb-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pmdb-shimmer { 100% { transform: translateX(100%); } }

/* ---- responsive --------------------------------------------------- */
@media (max-width: 720px) {
  .pmdb-overlay { padding: 0; }
  .pmdb-panel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; border: 0; }
  .pmdb-choose-cards { grid-template-columns: 1fr; }
  .pmdb-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .pmdb-top5-row { grid-auto-columns: minmax(160px, 78%); }
  .pmdb-toolbar { gap: 8px; }
  .pmdb-search-wrap { flex: 1 1 100%; order: -1; }
  .pmdb-select { max-width: none; flex: 1 1 auto; }
  .pmdb-brand-text { display: none; }
  .pmdb-topbar-center { flex: 1 1 auto; }
  .pmdb-toggle-btn { padding: 7px 14px; }
  .pmdb-detail-hero { gap: 18px; }
  .pmdb-cover-detail { width: 100%; }
  .pmdb-detail-actions .pmdb-btn { flex: 1 1 auto; }
}

@media (max-width: 420px) {
  .pmdb-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pmdb-colorfilter { flex-wrap: wrap; }
}

/* ---- reduced motion ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .pmdb-overlay *,
  .pmdb-backdrop,
  .pmdb-panel,
  .pmdb-dialog,
  .pmdb-dialog-backdrop,
  .pmdb-toast { animation: none !important; transition: none !important; }
  .pmdb-tile:hover { transform: none; }
  .pmdb-tile:hover .pmdb-cover-img { transform: none; }
  .pmdb-hero:hover { transform: none; }
  .pmdb-skel::after { animation: none; }
}

/* =====================================================================
   PHASE 2 - Deck Intelligence (stats + mana curve)
   ===================================================================== */
.pmdb-stats { margin-top: 30px; }
.pmdb-stats-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 14px;
}
.pmdb-stats-body { display: block; }
.pmdb-stats-note { font-size: 13px; color: var(--text-muted, #6B7490); margin: 6px 0; }

/* summary chips */
.pmdb-statchips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.pmdb-statchip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-statchip-num { font-size: 20px; font-weight: 800; color: var(--text-primary, #EBECF0); font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.pmdb-statchip-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted, #6B7490); }

/* chart grids + cards */
.pmdb-stats-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.pmdb-chartcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
  min-width: 0;
}
.pmdb-chart-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #C8A951);
  margin: 0;
}
.pmdb-chart-sub { font-size: 11.5px; color: var(--text-muted, #6B7490); margin: 0; line-height: 1.45; }

/* inline-SVG charts */
.pmdb-svgchart { display: block; width: 100%; height: auto; overflow: visible; }
.pmdb-axis { stroke: var(--border, #272D42); stroke-width: 1; }
.pmdb-bar { fill: var(--accent, #C8A951); }
.pmdb-bar-track { fill: var(--bg-input, #1C2030); }
.pmdb-bar-num { fill: var(--text-secondary, #8B92A8); font-size: 11px; font-weight: 700; font-family: inherit; }
.pmdb-bar-lbl { fill: var(--text-muted, #6B7490); font-size: 11px; font-family: inherit; }
.pmdb-type-lbl { fill: var(--text-secondary, #8B92A8); font-size: 11px; font-family: inherit; }
.pmdb-fill-W { fill: var(--pmdb-W); }
.pmdb-fill-U { fill: var(--pmdb-U); }
.pmdb-fill-B { fill: var(--pmdb-B); }
.pmdb-fill-R { fill: var(--pmdb-R); }
.pmdb-fill-G { fill: var(--pmdb-G); }

.pmdb-color-wrap { display: flex; flex-direction: column; gap: 8px; }
.pmdb-color-cap { display: flex; flex-direction: column; gap: 5px; }
.pmdb-color-idrow { display: flex; align-items: center; gap: 7px; }

/* rarity */
.pmdb-rarity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.pmdb-rarity-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pmdb-rarity-dot { width: 11px; height: 11px; border-radius: 999px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4); }
.pmdb-rarity-name { flex: 1 1 auto; color: var(--text-secondary, #8B92A8); }
.pmdb-rarity-num { color: var(--text-primary, #EBECF0); font-weight: 700; font-variant-numeric: tabular-nums; }
.pmdb-rar-common { background: #6b7280; }
.pmdb-rar-uncommon { background: #9fb3c8; }
.pmdb-rar-rare { background: var(--accent, #C8A951); }
.pmdb-rar-mythic { background: #e8703a; }
.pmdb-rar-special { background: #b07cd6; }
.pmdb-rar-bonus { background: #d6b07c; }
.pmdb-rar-unknown { background: var(--text-muted, #6B7490); }

/* budget */
.pmdb-budget { display: flex; flex-direction: column; gap: 10px; }
.pmdb-budget-total { display: flex; flex-direction: column; gap: 2px; }
.pmdb-budget-total-num { font-size: 20px; font-weight: 800; color: var(--accent, #C8A951); font-variant-numeric: tabular-nums; }
.pmdb-budget-total-lbl { font-size: 11px; color: var(--text-muted, #6B7490); text-transform: uppercase; letter-spacing: 0.6px; }
.pmdb-budget-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.pmdb-budget-row { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.pmdb-budget-name { flex: 1 1 auto; color: var(--text-secondary, #8B92A8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmdb-budget-eur { color: var(--text-primary, #EBECF0); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* legality */
.pmdb-legal { display: flex; flex-direction: column; gap: 8px; }
.pmdb-legal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pmdb-legal-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  border: 1px solid rgba(200, 169, 81, 0.28);
  border-radius: 5px;
  padding: 3px 8px;
}
.pmdb-legal-ok { font-size: 12px; color: var(--success, #4ade80); margin: 0; font-weight: 600; }
.pmdb-flag {
  font-size: 12px;
  color: var(--warning, #FBBF24);
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius-md, 8px);
  padding: 7px 10px;
}
.pmdb-flag-sum { cursor: pointer; font-weight: 700; list-style: revert; }
.pmdb-flaglist { list-style: disc; margin: 7px 0 0; padding: 0 0 0 20px; color: var(--text-secondary, #8B92A8); }
.pmdb-flaglist li { margin: 2px 0; font-size: 12px; }

/* unresolved warning */
.pmdb-stats-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 16px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius-md, 8px);
}
.pmdb-stats-warn .pmdb-ico { color: var(--warning, #FBBF24); flex: none; }
.pmdb-stats-warn .pmdb-ico svg { width: 22px; height: 22px; }
.pmdb-stats-warn-txt { min-width: 0; }
.pmdb-stats-warn-title { font-size: 13px; font-weight: 600; color: var(--text-primary, #EBECF0); margin: 0 0 3px; }
.pmdb-stats-warn-list { font-size: 11.5px; color: var(--text-muted, #6B7490); margin: 0; line-height: 1.45; }

/* stats skeleton + error */
.pmdb-stats-skel { display: flex; flex-direction: column; gap: 16px; }
.pmdb-stats-skel .pmdb-skel-line { margin: 0; }
.pmdb-skel-chart { height: 130px; border-radius: var(--radius-md, 8px); }
.pmdb-stats-errbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 18px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-stats-errbox .pmdb-ico { color: var(--warning, #FBBF24); }
.pmdb-statbtn { margin-top: 4px; }

@media (max-width: 720px) {
  .pmdb-stats-charts { grid-template-columns: 1fr; }
  .pmdb-statchips { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   PHASE 5.1 - Token detection & "print the tokens too"
   ===================================================================== */
.pmdb-tokens { margin-top: 30px; }
.pmdb-tokens-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 14px;
}
.pmdb-tokens-body { display: block; }
.pmdb-tokens-note { font-size: 13px; color: var(--text-muted, #6B7490); margin: 6px 0; }

/* controls: include-toggle + add-now */
.pmdb-tokens-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.pmdb-tokens-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #8B92A8);
  cursor: pointer;
  user-select: none;
}
.pmdb-tokens-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #C8A951);
  cursor: pointer;
  flex: none;
}
.pmdb-tokens-add { padding: 8px 14px; font-size: 13px; }

/* token thumbnail grid */
.pmdb-tokens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 14px;
}
.pmdb-token { display: flex; flex-direction: column; gap: 7px; margin: 0; min-width: 0; }
.pmdb-token-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 7px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1d28, #0f1117);
  border: 1px solid var(--border-light, #1E2336);
}
.pmdb-token-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pmdb-token-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.pmdb-token-fallback {
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted, #6B7490);
  line-height: 1.3;
}
.pmdb-token-cap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pmdb-token-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary, #EBECF0);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pmdb-token-sub {
  font-size: 11px;
  color: var(--text-muted, #6B7490);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmdb-token-unprintable .pmdb-token-frame { opacity: 0.55; }
.pmdb-token-unprintable .pmdb-token-sub { color: var(--warning, #FBBF24); }

/* token skeleton */
.pmdb-tokens-skel .pmdb-token-frame { border: 0; }
.pmdb-tokens-skel .pmdb-skel-line { margin: 0; }

/* import dialog token note */
.pmdb-dialog-tokennote {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  border: 1px solid rgba(200, 169, 81, 0.28);
  border-radius: var(--radius-md, 8px);
  padding: 8px 11px;
  margin: 0 0 18px;
}

@media (max-width: 720px) {
  .pmdb-tokens-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
}

/* =====================================================================
   PHASE 5.2 - EDHREC recommendations & "Upgrade your precon"
   ===================================================================== */
.pmdb-recs { margin-top: 30px; }
.pmdb-recs-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 14px;
}
.pmdb-recs-body { display: block; }
.pmdb-recs-note { font-size: 13px; color: var(--text-muted, #6B7490); margin: 6px 0; line-height: 1.5; }

/* sub-section headers */
.pmdb-recs-subhead { margin: 4px 0 12px; }
.pmdb-recs-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #C8A951);
  margin: 0 0 3px;
}
.pmdb-recs-subsub { font-size: 12px; color: var(--text-muted, #6B7490); margin: 0; line-height: 1.45; }

/* recommendation card grid */
.pmdb-recs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.pmdb-rec { display: flex; flex-direction: column; gap: 7px; margin: 0; min-width: 0; }
.pmdb-rec-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 488 / 680; /* Scryfall card ratio */
  border-radius: 7px;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1d28, #0f1117);
  border: 1px solid var(--border-light, #1E2336);
}
.pmdb-rec-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pmdb-rec-broken { display: flex; align-items: center; justify-content: center; padding: 8px; }
.pmdb-rec-fallback {
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted, #6B7490);
  line-height: 1.3;
}
.pmdb-rec-cap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pmdb-rec-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary, #EBECF0);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pmdb-rec-sub {
  font-size: 11px;
  color: var(--text-muted, #6B7490);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmdb-rec-add { width: 100%; padding: 6px 10px; font-size: 12.5px; }
.pmdb-rec-added {
  color: var(--success, #4ade80);
  border-color: rgba(74, 222, 128, 0.4);
  cursor: default;
  opacity: 0.85;
}
.pmdb-rec-added:hover { color: var(--success, #4ade80); border-color: rgba(74, 222, 128, 0.4); }

/* upgrade sub-section header row (title + add-all) */
.pmdb-upgrade-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 12px;
}
.pmdb-upgrade-h {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary, #EBECF0);
  margin: 0;
}
.pmdb-recs-addall { padding: 7px 13px; font-size: 12.5px; }

/* possible cuts */
.pmdb-cuts { margin-top: 6px; }
.pmdb-cuts-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pmdb-cut-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 11px;
  font-size: 13px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-cut-name { flex: 1 1 auto; color: var(--text-secondary, #8B92A8); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmdb-cut-pct {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--warning, #FBBF24);
  font-variant-numeric: tabular-nums;
}
.pmdb-cuts-more { margin-top: 10px; }

/* attribution */
.pmdb-recs-attrib {
  font-size: 11.5px;
  color: var(--text-muted, #6B7490);
  letter-spacing: 0.2px;
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-light, #1E2336);
}

/* recs skeleton */
.pmdb-recs-skel .pmdb-rec-frame { border: 0; }
.pmdb-recs-skel .pmdb-skel-line { margin: 0 0 14px; }

@media (max-width: 720px) {
  .pmdb-recs-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
}

/* =====================================================================
   PHASE 3 - STAGE 1: Two-layer persistence (My Decks workshop + profile)
   ===================================================================== */

/* topbar "My Decks" / "Browse precons" pill */
.pmdb-mydecks-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: 999px;
  padding: 8px 15px;
  margin-right: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pmdb-mydecks-btn:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); background: var(--bg-hover, #232840); }
.pmdb-mydecks-btn:focus-visible { outline: none; border-color: var(--accent, #C8A951); box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-mydecks-btn .pmdb-ico { display: inline-flex; color: var(--accent, #C8A951); }
.pmdb-mydecks-btn .pmdb-ico svg { width: 16px; height: 16px; }

/* choose-screen "My Decks" entry card */
.pmdb-choose-mydecks {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  margin-top: 22px;
  padding: 18px 22px;
  cursor: pointer;
  font: inherit;
  color: var(--text-primary, #EBECF0);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(200, 169, 81, 0.08), transparent 55%),
    var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.pmdb-choose-mydecks:hover {
  transform: translateY(-3px);
  border-color: var(--accent, #C8A951);
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.8);
}
.pmdb-choose-mydecks .pmdb-ico {
  display: inline-flex;
  flex: none;
  color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  padding: 12px;
  border-radius: var(--radius-md, 8px);
}
.pmdb-choose-mydecks .pmdb-ico svg { width: 28px; height: 28px; }
.pmdb-choose-mydecks-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pmdb-choose-mydecks-title { font-size: 17px; font-weight: 700; }
.pmdb-choose-mydecks-sub { font-size: 13px; color: var(--text-secondary, #8B92A8); line-height: 1.4; }

/* profile screen */
.pmdb-profile { max-width: 940px; margin: 0 auto; }
.pmdb-profile-head { margin-bottom: 16px; }
.pmdb-profile-title { font-size: clamp(22px, 3vw, 30px); font-weight: 800; margin: 0 0 6px; letter-spacing: -0.4px; }
.pmdb-profile-sub { font-size: 14px; color: var(--text-secondary, #8B92A8); margin: 0; line-height: 1.5; max-width: 760px; }

/* persistence status surface */
.pmdb-pstatus {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin: 16px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-pstatus-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--text-muted, #6B7490);
  box-shadow: 0 0 0 3px rgba(107, 116, 144, 0.18);
}
.pmdb-pstatus-msg { flex: 1 1 auto; min-width: 0; }
.pmdb-pstatus-action { flex: none; padding: 5px 12px; font-size: 12px; }

.pmdb-pstatus-connected { border-color: rgba(74, 222, 128, 0.32); }
.pmdb-pstatus-connected .pmdb-pstatus-dot { background: var(--success, #4ADE80); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18); }
.pmdb-pstatus-connected .pmdb-pstatus-msg { color: var(--text-primary, #EBECF0); }

.pmdb-pstatus-saved { border-color: rgba(74, 222, 128, 0.32); }
.pmdb-pstatus-saved .pmdb-pstatus-dot { background: var(--success, #4ADE80); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18); }

.pmdb-pstatus-saving .pmdb-pstatus-dot { background: var(--accent, #C8A951); box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12)); animation: pmdb-pulse 1s ease-in-out infinite; }

.pmdb-pstatus-error { border-color: rgba(251, 191, 36, 0.32); }
.pmdb-pstatus-error .pmdb-pstatus-dot { background: var(--warning, #FBBF24); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }
.pmdb-pstatus-error .pmdb-pstatus-msg { color: var(--text-primary, #EBECF0); }

.pmdb-pstatus-reconnect { border-color: rgba(251, 191, 36, 0.32); background: rgba(251, 191, 36, 0.06); }
.pmdb-pstatus-reconnect .pmdb-pstatus-dot { background: var(--warning, #FBBF24); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }
.pmdb-pstatus-reconnect .pmdb-pstatus-msg { color: var(--text-primary, #EBECF0); }

@keyframes pmdb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pmdb-pstatus-saving .pmdb-pstatus-dot { animation: none; } }

/* Layer B toolbar */
.pmdb-profile-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.pmdb-profile-toolbar .pmdb-btn { padding: 10px 16px; font-size: 13px; }

/* deck list */
.pmdb-decklist { display: flex; flex-direction: column; gap: 10px; }
.pmdb-deckrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
  transition: border-color 0.15s ease;
}
.pmdb-deckrow:hover { border-color: var(--border, #272D42); }
.pmdb-deckrow-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.pmdb-deck-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #EBECF0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmdb-deck-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.pmdb-deck-meta .pmdb-badge { position: static; }
.pmdb-deck-src { color: var(--text-secondary, #8B92A8); }
.pmdb-deck-count { font-size: 12px; color: var(--text-muted, #6B7490); font-weight: 600; }
.pmdb-deck-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pmdb-deck-tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
  border: 1px solid rgba(200, 169, 81, 0.28);
  border-radius: 5px;
  padding: 2px 7px;
}
.pmdb-deckrow-actions { flex: none; display: flex; gap: 8px; }
.pmdb-deck-del { padding: 7px 13px; font-size: 12.5px; }

/* empty state */
.pmdb-profile-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 52px 20px;
  color: var(--text-secondary, #8B92A8);
}
.pmdb-profile-empty .pmdb-ico { color: var(--text-muted, #6B7490); }
.pmdb-profile-empty-title { font-size: 16px; font-weight: 700; color: var(--text-primary, #EBECF0); margin: 4px 0 0; }
.pmdb-profile-empty-sub { font-size: 13.5px; margin: 0; max-width: 420px; line-height: 1.5; }

@media (max-width: 720px) {
  .pmdb-deckrow { flex-wrap: wrap; }
  .pmdb-deckrow-actions { width: 100%; }
  .pmdb-deck-del { flex: 1 1 auto; }
  .pmdb-profile-toolbar .pmdb-btn { flex: 1 1 auto; }
}

/* =====================================================================
   PHASE 3 - STAGE 2: My-Decks workshop UI, CRUD, bridges & print
   ===================================================================== */

/* profile-file controls group */
.pmdb-profile-files { align-items: center; }
.pmdb-profile-grouplabel {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted, #6B7490);
  margin-right: 2px;
}

/* deck row: reorder column + clickable name + compact actions */
.pmdb-deckrow-reorder { flex: none; display: flex; flex-direction: column; gap: 3px; }
.pmdb-reorder-btn {
  width: 26px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.pmdb-reorder-btn:hover:not(:disabled) { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); }
.pmdb-reorder-btn:focus-visible { outline: none; border-color: var(--accent, #C8A951); box-shadow: 0 0 0 2px var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-reorder-btn:disabled { opacity: 0.3; cursor: default; }

.pmdb-deck-namebtn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  color: var(--text-primary, #EBECF0);
  background: transparent;
  border: 0;
  padding: 0;
  max-width: 100%;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}
.pmdb-deck-namebtn:hover { color: var(--accent, #C8A951); }
.pmdb-deck-namebtn:focus-visible { outline: none; color: var(--accent, #C8A951); text-decoration: underline; }

.pmdb-deck-updated { font-size: 11px; color: var(--text-muted, #6B7490); }

.pmdb-deckrow-actions { flex-wrap: wrap; justify-content: flex-end; }
.pmdb-deckrow-actions .pmdb-btn { padding: 7px 11px; font-size: 12px; }

/* dialog form fields (rename / tags / notes / save-from-decklist) */
.pmdb-dialog-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted, #6B7490);
  margin: 0 0 6px;
}
.pmdb-dialog-input,
.pmdb-dialog-textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 10px 12px;
  margin: 0 0 16px;
}
.pmdb-dialog-textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.pmdb-dialog-input::placeholder,
.pmdb-dialog-textarea::placeholder { color: var(--text-muted, #6B7490); }
.pmdb-dialog-input:focus,
.pmdb-dialog-textarea:focus {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12));
}
.pmdb-dialog-hint { font-size: 11.5px; color: var(--text-muted, #6B7490); margin: -8px 0 16px; line-height: 1.45; }
.pmdb-dialog-toggle { margin: 0 0 18px; }

/* saved-deck workshop view */
.pmdb-savedeck-head { margin-bottom: 22px; }
.pmdb-savedeck .pmdb-detail-meta { gap: 12px; }
.pmdb-savedeck-notes {
  margin: 0 0 24px;
  padding: 14px 16px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-savedeck-notes-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #C8A951);
  margin: 0 0 8px;
}
.pmdb-savedeck-notes-body {
  font-size: 13.5px;
  color: var(--text-secondary, #8B92A8);
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}
.pmdb-savedeck-emptycards {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 44px 20px;
  color: var(--text-secondary, #8B92A8);
}
.pmdb-savedeck-emptycards .pmdb-ico { color: var(--text-muted, #6B7490); }

@media (max-width: 720px) {
  .pmdb-deckrow-actions { justify-content: flex-start; }
  .pmdb-deckrow-actions .pmdb-btn { flex: 1 1 auto; }
}

/* =====================================================================
   PHASE 3 - STAGE 3: Custom builder (Scryfall search + live stats)
   ===================================================================== */
.pmdb-builder { display: flex; flex-direction: column; gap: 18px; }

.pmdb-builder-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pmdb-builder-name {
  flex: 1 1 260px;
  min-width: 200px;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 10px 14px;
}
.pmdb-builder-name::placeholder { color: var(--text-muted, #6B7490); }
.pmdb-builder-name:focus {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12));
}

.pmdb-builder-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 24px;
  align-items: start;
}
.pmdb-builder-left { min-width: 0; }
.pmdb-builder-right { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
/* F17 - explicit min-width:0 so these grid/flex children can shrink instead of
   forcing horizontal overflow (referenced by JS; previously had no rule). */
.pmdb-search-panel { min-width: 0; }
.pmdb-builder-lists { min-width: 0; }

.pmdb-builder-subtitle {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 12px;
}

/* search panel */
.pmdb-search-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.pmdb-search-filters .pmdb-select { max-width: none; }
.pmdb-mv-filter { display: inline-flex; gap: 6px; align-items: center; }
.pmdb-mv-op { max-width: 96px; }
.pmdb-mv-val {
  width: 68px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 9px 10px;
}
.pmdb-mv-val:focus { outline: none; border-color: var(--accent, #C8A951); }

.pmdb-addtarget { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.pmdb-addtarget-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted, #6B7490);
}

.pmdb-search-results { min-height: 70px; }
.pmdb-search-hint { font-size: 13px; color: var(--text-muted, #6B7490); margin: 8px 0; line-height: 1.5; }
.pmdb-sresults-head { font-size: 11.5px; color: var(--text-muted, #6B7490); margin: 0 0 10px; }
.pmdb-sresults-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 10px;
}
.pmdb-sresult {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text-primary, #EBECF0);
}
.pmdb-sresult-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 488 / 680;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.pmdb-sresult:hover .pmdb-sresult-frame { border-color: var(--accent, #C8A951); transform: translateY(-2px); }
.pmdb-sresult:focus-visible { outline: none; }
.pmdb-sresult:focus-visible .pmdb-sresult-frame {
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(200, 169, 81, 0.12));
}
.pmdb-sresult-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pmdb-sresult-broken { display: flex; align-items: center; justify-content: center; padding: 6px; }
.pmdb-sresult-fallback { font-size: 10.5px; text-align: center; line-height: 1.3; color: var(--text-secondary, #8B92A8); }
.pmdb-sresult-cap { display: flex; flex-direction: column; gap: 1px; }
.pmdb-sresult-name {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pmdb-sresult-set { font-size: 10px; color: var(--text-muted, #6B7490); }

/* editable deck lists */
.pmdb-builder-total { margin-bottom: 2px; }
.pmdb-builder-total-num { font-size: 13px; font-weight: 700; color: var(--text-secondary, #8B92A8); }
.pmdb-bgroup { margin-bottom: 18px; }
.pmdb-bgroup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #C8A951);
  margin: 0 0 8px;
}
.pmdb-bgroup-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #6B7490);
  background: var(--bg-input, #1C2030);
  border-radius: 999px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.pmdb-bgroup-empty { font-size: 12.5px; color: var(--text-muted, #6B7490); margin: 0; line-height: 1.5; }
.pmdb-bcardlist { display: flex; flex-direction: column; gap: 6px; }
.pmdb-bcard {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
}
.pmdb-bcard-qty { display: inline-flex; align-items: center; flex: none; }
.pmdb-qbtn {
  width: 26px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
}
.pmdb-qbtn:first-child { border-radius: 6px 0 0 6px; }
.pmdb-qbtn:last-child { border-radius: 0 6px 6px 0; }
.pmdb-qbtn:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); }
.pmdb-qbtn:focus-visible { outline: none; border-color: var(--accent, #C8A951); position: relative; z-index: 1; }
.pmdb-qinput {
  width: 42px;
  height: 28px;
  text-align: center;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-left: 0;
  border-right: 0;
  -moz-appearance: textfield;
}
.pmdb-qinput::-webkit-outer-spin-button,
.pmdb-qinput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pmdb-qinput:focus { outline: none; border-color: var(--accent, #C8A951); position: relative; z-index: 1; }
.pmdb-bcard-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pmdb-bcard-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #EBECF0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pmdb-bcard-set { font-size: 10.5px; color: var(--text-muted, #6B7490); }
.pmdb-bcard-actions { flex: none; display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.pmdb-bcard-move, .pmdb-bcard-rm { padding: 5px 9px; font-size: 11px; }
.pmdb-bcard-rm { color: var(--text-muted, #6B7490); }
.pmdb-bcard-rm:hover { color: var(--warning, #FBBF24); border-color: var(--warning, #FBBF24); }

.pmdb-builder-statspanel { margin-top: 0; }

@media (max-width: 860px) {
  .pmdb-builder-body { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .pmdb-builder-name { flex: 1 1 100%; }
  .pmdb-bcard { flex-wrap: wrap; }
  .pmdb-bcard-actions { width: 100%; justify-content: flex-start; }
}

/* ================================================================== *
 * Compact mini-card tiles + slim detail layout (shared)
 * ================================================================== */
.pmdb-tilegrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}
/* F3 - scope the mini-card tile under .pmdb-tilegrid so it no longer collides with
   (and overrides) the browse precon cover tile's bare .pmdb-tile (see ~357). */
.pmdb-tilegrid .pmdb-tile { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pmdb-tile-thumb {
  position: relative;
  aspect-ratio: 5 / 7;
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border-light, #1E2336);
}
.pmdb-tile-img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .2s ease; }
.pmdb-tile-thumb.pmdb-tile-ready .pmdb-tile-img { opacity: 1; }
.pmdb-tile-fallback {
  position: absolute; inset: 0; padding: 6px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 10px; line-height: 1.25;
  color: var(--text-muted, #6B7490); overflow: hidden;
}
.pmdb-tile-thumb.pmdb-tile-ready .pmdb-tile-fallback { display: none; }
.pmdb-tile-thumb.pmdb-tile-broken .pmdb-tile-img { display: none; }
.pmdb-tile-qty {
  position: absolute; top: 4px; left: 4px;
  background: rgba(12, 13, 19, 0.85); color: var(--accent, #C8A951);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 999px; border: 1px solid rgba(200, 169, 81, 0.4);
}
/* F3 - scope the mini-card tile name under .pmdb-tilegrid so it no longer collides
   with (and overrides) the browse precon tile name's bare .pmdb-tile-name (see ~435). */
.pmdb-tilegrid .pmdb-tile-name {
  font-size: 11px; line-height: 1.25; color: var(--text-secondary, #8B92A8);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* editable (builder) tiles */
.pmdb-tile-edit .pmdb-tile-name { color: var(--text-primary, #EBECF0); font-weight: 600; }
.pmdb-tile-qty-edit { display: flex; }
.pmdb-tile-qty-edit .pmdb-qbtn { width: 24px; height: 24px; font-size: 14px; }
.pmdb-tile-qty-edit .pmdb-qinput { width: 34px; height: 24px; font-size: 12px; }
.pmdb-tile-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.pmdb-tilebtn { padding: 3px 7px; font-size: 10.5px; line-height: 1.2; }
.pmdb-tile-rm { color: var(--text-muted, #6B7490); }
.pmdb-tile-rm:hover { color: var(--warning, #FBBF24); border-color: var(--warning, #FBBF24); }

/* precon/saved detail: small commander aside + wide mainboard */
.pmdb-detail-cols {
  display: grid;
  grid-template-columns: minmax(190px, 232px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.pmdb-detail-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pmdb-detail-main, .pmdb-detail-single { min-width: 0; }
.pmdb-detail-aside .pmdb-tilegrid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.pmdb-ministats {
  background: var(--bg-section, #181B24);
  border: 1px solid var(--border-light, #1E2336);
  border-radius: var(--radius-md, 8px);
  padding: 12px 14px;
}
.pmdb-ministats-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent, #C8A951); margin: 0 0 10px;
}
.pmdb-ministats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pmdb-ministat { background: var(--bg-input, #1C2030); border-radius: 6px; padding: 7px 9px; }
.pmdb-ministat-num { display: block; font-size: 16px; font-weight: 700; color: var(--text-primary, #EBECF0); font-variant-numeric: tabular-nums; }
.pmdb-ministat-lbl { display: block; font-size: 10px; color: var(--text-muted, #6B7490); text-transform: uppercase; letter-spacing: 0.5px; }

@media (max-width: 720px) {
  .pmdb-detail-cols { grid-template-columns: 1fr; }
  .pmdb-tilegrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}

/* =====================================================================
   REUSABLE CARD ZOOM / LIGHTBOX (with DFC flip)
   A .pmdb-zoom layer is appended to .pmdb-overlay above the panel; it shows
   one large, readable card image with an optional Flip control for DFCs.
   (Reduced-motion is already handled by the global ".pmdb-overlay *" rule.)
   ===================================================================== */
.pmdb-zoom {
  position: absolute;
  inset: 0;
  z-index: 40; /* above .pmdb-panel / .pmdb-content and the import dialog (5) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
}
.pmdb-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 11, 0.82);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  backdrop-filter: blur(6px) saturate(120%);
  animation: pmdb-fade 0.18s ease;
}
.pmdb-zoom-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 100%;
  max-height: 100%;
  /* No overflow here: the close button is intentionally nudged outside the stage
     (right/top:-6px) and sits within .pmdb-zoom's padding - overflow:auto would
     turn that nudge into a stray scrollbar. The image max-height keeps it in view. */
  animation: pmdb-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.pmdb-zoom-close {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary, #EBECF0);
  background: rgba(12, 13, 19, 0.85);
  border: 1px solid var(--border, #272D42);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.pmdb-zoom-close:hover { color: #fff; border-color: var(--accent, #C8A951); background: var(--bg-hover, #232840); }
.pmdb-zoom-close:focus-visible {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.22));
}

.pmdb-zoom-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
}
.pmdb-zoom-fig {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
}
.pmdb-zoom-img {
  display: block;
  max-width: min(700px, 94vw);
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 4.75% / 3.5%; /* MTG card corner radius */
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
  background: #0f1117;
}
/* F6 - flippable cards also render a Flip button below the image; trim the image
   height a little so the button stays on-screen alongside it (with .pmdb-zoom-stage
   overflow:auto as the safety net on very short viewports). */
.pmdb-zoom-img-flip { cursor: pointer; max-height: 80vh; }

/* loading + error states */
.pmdb-zoom-loading,
.pmdb-zoom-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(360px, 80vw);
  min-height: 240px;
  text-align: center;
  color: var(--text-secondary, #8B92A8);
}
.pmdb-zoom-error .pmdb-ico { color: var(--warning, #FBBF24); }
.pmdb-zoom-error-txt { font-size: 14px; font-weight: 600; margin: 0; color: var(--text-primary, #EBECF0); }
.pmdb-zoom-loading-txt { font-size: 13px; }
.pmdb-zoom-spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid var(--border, #272D42);
  border-top-color: var(--accent, #C8A951);
  animation: pmdb-zoom-spin 0.8s linear infinite;
}

/* flip control */
.pmdb-zoom-flip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  color: #14110a;
  background: linear-gradient(180deg, var(--accent-hover, #DFBF68), var(--accent, #C8A951));
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 18px;
  box-shadow: 0 8px 22px -10px rgba(200, 169, 81, 0.7);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.pmdb-zoom-flip:hover { filter: brightness(1.06); transform: translateY(-1px); }
.pmdb-zoom-flip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.25)); }
.pmdb-zoom-flip-ico { font-size: 15px; line-height: 1; }

/* the shared mini-card thumb is now an interactive zoom trigger */
.pmdb-tile-thumb-zoom { cursor: zoom-in; }
.pmdb-tile-thumb-zoom:focus-visible {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.2));
}

@keyframes pmdb-zoom-spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .pmdb-zoom-img { max-width: 94vw; max-height: 74vh; }
  .pmdb-zoom-close { top: 2px; right: 2px; }
}

/* =====================================================================
   GLOBAL BOARD CONTROLS - mini-cards on/off + sort by type
   Two obsidian + gold topbar pills (.pmdb-boardctl-btn) and the shared
   board body they drive: per-type subheaders (.pmdb-typehead) and a clean
   clickable text list (.pmdb-textlist) that reuses the card zoom.
   ===================================================================== */

/* topbar pill toggles */
.pmdb-boardctl { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
.pmdb-boardctl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary, #8B92A8);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.pmdb-boardctl-btn:hover { color: var(--text-primary, #EBECF0); border-color: var(--accent, #C8A951); }
.pmdb-boardctl-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12)); }
.pmdb-boardctl-on {
  color: var(--accent, #C8A951);
  border-color: var(--accent, #C8A951);
  background: var(--accent-dim, rgba(200, 169, 81, 0.12));
}

/* board body + per-type subheaders */
.pmdb-board { display: block; }
.pmdb-board > .pmdb-typehead { margin-top: 0; }
.pmdb-board > * + .pmdb-typehead { margin-top: 14px; }
.pmdb-typehead {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary, #8B92A8);
  margin: 0 0 8px;
}
.pmdb-typehead-count {
  font-size: 10.5px;
  color: var(--text-muted, #6B7490);
  background: var(--bg-input, #1C2030);
  border-radius: 999px;
  padding: 1px 7px;
  letter-spacing: 0;
}

/* clean clickable text list (read-only) */
.pmdb-textlist { list-style: none; margin: 0; padding: 0; }
.pmdb-textrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(39, 45, 66, 0.4);
}
.pmdb-textrow:last-child { border-bottom: 0; }
.pmdb-textqty {
  flex: none;
  min-width: 30px;
  color: var(--accent, #C8A951);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.pmdb-textname {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary, #EBECF0);
  background: transparent;
  border: 0;
  margin: 0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: zoom-in;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.14s ease, color 0.14s ease;
}
.pmdb-textname:hover { background: var(--bg-hover, #232840); color: var(--accent, #C8A951); }
.pmdb-textname:focus-visible {
  outline: none;
  color: var(--accent, #C8A951);
  box-shadow: 0 0 0 2px var(--accent-dim, rgba(200, 169, 81, 0.25));
}

/* editable slim rows (builder, text mode) */
.pmdb-textrow-edit { gap: 10px; padding: 4px 0; }
.pmdb-textrow-edit .pmdb-tile-qty-edit { flex: none; }
.pmdb-textrow-actions { flex: none; display: flex; flex-wrap: wrap; gap: 4px; }

@media (max-width: 720px) {
  .pmdb-boardctl { margin-right: 6px; gap: 4px; }
  .pmdb-boardctl-btn { padding: 7px 10px; font-size: 12px; }
}

/* =====================================================================
   PHASE 4.1 - Import a deck from a URL
   ===================================================================== */

/* primary banner on the My-Decks screen */
.pmdb-import-section {
  margin: 4px 0 18px;
  padding: 16px 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(200, 169, 81, 0.10), transparent 55%),
    var(--bg-section, #181B24);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-lg, 12px);
}
.pmdb-import-section-head { margin-bottom: 12px; }
.pmdb-import-section-title { font-size: 16px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.2px; }
.pmdb-import-section-sub { font-size: 13px; color: var(--text-secondary, #8B92A8); margin: 0; line-height: 1.5; }

/* shared control (input + button + hint + message) */
.pmdb-import-url { display: flex; flex-direction: column; gap: 7px; }
.pmdb-import-url-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.pmdb-import-url-input {
  flex: 1 1 280px;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary, #EBECF0);
  background: var(--bg-input, #1C2030);
  border: 1px solid var(--border, #272D42);
  border-radius: var(--radius-md, 8px);
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pmdb-import-url-input::placeholder { color: var(--text-muted, #6B7490); }
.pmdb-import-url-input:focus {
  outline: none;
  border-color: var(--accent, #C8A951);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(200, 169, 81, 0.12));
}
.pmdb-import-url-input:disabled { opacity: 0.6; cursor: not-allowed; }
.pmdb-import-url-btn { flex: none; }
.pmdb-import-url-btn:disabled { opacity: 0.7; cursor: progress; }

.pmdb-import-url-hint { font-size: 11.5px; color: var(--text-muted, #6B7490); margin: 0; line-height: 1.45; }
.pmdb-import-url-mock {
  font-weight: 700;
  color: var(--warning, #FBBF24);
}

/* inline status / error line (default hidden until it has text) */
.pmdb-import-url-msg { font-size: 12.5px; margin: 0; min-height: 0; line-height: 1.45; }
.pmdb-import-url-msg:empty { display: none; }
.pmdb-import-hasinfo .pmdb-import-url-msg { color: var(--accent, #C8A951); }
.pmdb-import-haserr .pmdb-import-url-msg { color: var(--warning, #FBBF24); }
.pmdb-import-busy .pmdb-import-url-input { cursor: progress; }

/* compact variant in the builder head */
.pmdb-import-url-builder { margin: -4px 0 14px; }
.pmdb-import-url-builder .pmdb-import-url-input { flex: 1 1 220px; font-size: 13px; padding: 8px 11px; }
.pmdb-import-url-builder .pmdb-import-url-btn { padding: 8px 16px; font-size: 13px; }
.pmdb-import-url-builder .pmdb-import-url-hint { font-size: 11px; }

/* per-deck attribution line (deck rows + saved-deck header) */
.pmdb-import-attrib { margin-top: 6px; font-size: 11.5px; line-height: 1.4; }
.pmdb-import-attrib-link,
.pmdb-import-attrib-txt { color: var(--text-muted, #6B7490); }
.pmdb-import-attrib-link {
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted, #6B7490);
  transition: color 0.14s ease, border-color 0.14s ease;
}
.pmdb-import-attrib-link:hover {
  color: var(--accent, #C8A951);
  border-bottom-color: var(--accent, #C8A951);
}

@media (max-width: 720px) {
  .pmdb-import-url-btn { flex: 1 1 auto; }
}

/* =====================================================================
   PHASE 4.3 - Tournament decks browse  +  PHASE 4.4 - global disclaimer
   ===================================================================== */

/* choose-screen entry tile (reuses .pmdb-choose-mydecks; mirrored gradient) */
.pmdb-choose-tourney {
  margin-top: 14px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(200, 169, 81, 0.08), transparent 55%),
    var(--bg-section, #181B24);
}

/* tournament browse header (mirrors the profile head) */
.pmdb-tourney-head { max-width: 1180px; margin: 0 auto 14px; }
.pmdb-tourney-title { font-size: clamp(22px, 3vw, 30px); font-weight: 800; margin: 0 0 6px; letter-spacing: -0.4px; }
.pmdb-tourney-sub { color: var(--text-secondary, #8B92A8); font-size: 14px; margin: 0; line-height: 1.5; max-width: 760px; }

/* placement badge - absolute (top-right) on a cover tile, inline in the
   detail badge row. Scope the absolute positioning to the cover so the
   detail-row badge stays in normal flow. */
.pmdb-badge-place { color: var(--accent, #C8A951); }
.pmdb-cover .pmdb-badge-place {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #14151B;
  background: rgba(200, 169, 81, 0.9);
  border-color: rgba(0, 0, 0, 0.15);
}
.pmdb-detail-badges .pmdb-badge-place { border-color: rgba(200, 169, 81, 0.3); }

/* tournament attribution line (reuses the import-attrib look) */
.pmdb-tourney-attrib { margin-top: 8px; }

/* global fan-project disclaimer */
.pmdb-footer-disclaimer { display: block; margin-top: 3px; opacity: 0.85; }
.pmdb-choose-disclaimer {
  margin: 26px auto 0;
  max-width: 640px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted, #6B7490);
}

/* Defensive styling for two visible edge states (broken cover / search skeleton). */
.pmdb-cover-broken {
  background: linear-gradient(135deg, var(--bg-section, #181B24), var(--bg-input, #1C2030)) !important;
}
.pmdb-sresult-skel {
  position: relative;
  overflow: hidden;
  min-height: 56px;
  background: var(--bg-input, #1C2030);
  border-color: var(--border-light, #1E2336);
  pointer-events: none;
}
.pmdb-sresult-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: pmdb-shimmer 1.3s infinite;
}

/* ================================================================== *
 * "Popular commanders" grouped view (Tournament Decks)
 * ================================================================== */
.pmdb-cmdlist { display: flex; flex-direction: column; gap: 8px; }
.pmdb-cmdgroup { border: 1px solid var(--border-light, #1E2336); border-radius: var(--radius-md, 8px); background: var(--bg-section, #181B24); overflow: hidden; }
.pmdb-cmdgroup-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; background: none; border: 0; cursor: pointer; color: inherit; font: inherit; text-align: left; }
.pmdb-cmdgroup-head:hover { background: var(--bg-hover, #232840); }
.pmdb-cmdgroup-head:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent, #C8A951); }
.pmdb-cmdgroup-thumb { width: 48px; height: 35px; flex: none; border-radius: 5px; overflow: hidden; background: var(--bg-input, #1C2030); border: 1px solid var(--border-light, #1E2336); }
.pmdb-cmdgroup-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pmdb-cmdgroup-thumb-broken .pmdb-cmdgroup-img { display: none; }
.pmdb-cmdgroup-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pmdb-cmdgroup-name { font-size: 15px; font-weight: 700; color: var(--text-primary, #EBECF0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmdb-cmdgroup-sub { display: flex; align-items: center; gap: 10px; }
.pmdb-cmdgroup-count { font-size: 12px; color: var(--accent, #C8A951); font-weight: 600; }
.pmdb-cmdgroup-chev { flex: none; font-size: 20px; line-height: 1; color: var(--text-muted, #6B7490); transition: transform 0.15s ease; }
.pmdb-cmdgroup-open .pmdb-cmdgroup-chev { transform: rotate(90deg); }
.pmdb-cmdgroup-decks { display: none; flex-direction: column; border-top: 1px solid var(--border-light, #1E2336); }
.pmdb-cmdgroup-open .pmdb-cmdgroup-decks { display: flex; }
.pmdb-cmddeck { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 14px 8px 22px; background: none; border: 0; border-top: 1px solid rgba(39, 45, 66, 0.4); cursor: pointer; color: inherit; font: inherit; text-align: left; }
.pmdb-cmddeck:first-child { border-top: 0; }
.pmdb-cmddeck:hover { background: var(--bg-hover, #232840); }
.pmdb-cmddeck:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent, #C8A951); }
.pmdb-cmddeck-wins { flex: none; min-width: 70px; font-size: 12.5px; font-weight: 700; color: var(--accent, #C8A951); font-variant-numeric: tabular-nums; }
.pmdb-cmddeck-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pmdb-cmddeck-event { font-size: 13px; color: var(--text-primary, #EBECF0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pmdb-cmddeck-date { font-size: 11px; color: var(--text-muted, #6B7490); }
.pmdb-cmddeck-open { flex: none; font-size: 12px; font-weight: 600; color: var(--accent2, #60A5FA); }

/* ═══════════════════════════════════════════════════════════════════ */
/* MOBILE REFINEMENTS (added 2026-06-27).                                */
/* Every rule below lives inside a max-width media query, so desktop      */
/* (>720px) never matches and is provably unchanged. Covers the deck      */
/* builder shell, browse, detail, My Decks and dialogs on phones.         */
/* ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 720px) {
  /* SHELL: the topbar cannot wrap and the panel clips overflow, so the
     close (X) used to fall off the right edge. Let it wrap: the centered
     format toggle drops to its own full-width line, the right cluster keeps
     the close button reachable. */
  .pmdb-topbar { flex-wrap: wrap; row-gap: 8px; }
  .pmdb-topbar-center { flex: 1 1 100%; order: 3; justify-content: flex-start; }
  .pmdb-topbar-center:empty { display: none; }
  .pmdb-topbar-right { flex-wrap: wrap; row-gap: 8px; justify-content: flex-end; }

  /* BROWSE: touch has no :hover, so always show the favourite star with a
     larger tap target, and let the tile sub line ellipsize instead of clip. */
  .pmdb-tile-wrap .pmdb-star { opacity: 1; transform: scale(1); width: 36px; height: 36px; }
  .pmdb-tile-meta .pmdb-tile-sub { min-width: 0; flex: 1 1 auto; }

  /* iOS Safari auto-zooms focused inputs under 16px -> keep them at 16px. */
  .pmdb-search,
  .pmdb-profile-controls .pmdb-search,
  .pmdb-profile-controls .pmdb-select { font-size: 16px; }

  /* Wrap long unbroken titles/names instead of clipping them. */
  .pmdb-card-name,
  .pmdb-hero-title,
  .pmdb-detail-name,
  .pmdb-deck-name,
  .pmdb-deck-namebtn { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }

  /* DETAIL: enlarge the small per-card action buttons for touch. */
  .pmdb-rec-add,
  .pmdb-recs-addall,
  .pmdb-tokens-add { min-height: 40px; }

  /* MY DECKS: bigger reorder + colour-pip targets; let the search fill the row. */
  .pmdb-deckrow-reorder { gap: 6px; }
  .pmdb-reorder-btn { width: 40px; height: 30px; font-size: 14px; }
  .pmdb-pipbtn { width: 40px; height: 40px; }
  .pmdb-pipbtn .pmdb-pip { width: 18px; height: 18px; }
  .pmdb-profile-search { max-width: none; }

  /* DIALOGS: cap height + scroll so the title and action buttons stay reachable
     on short screens / when the on-screen keyboard is open. */
  .pmdb-dialog {
    max-height: calc(100vh - 36px);
    max-height: calc(100dvh - 36px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 420px) {
  /* Popular-commander grouped rows: reclaim width for the event title. */
  .pmdb-cmdgroup-head { gap: 8px; padding: 10px 12px; }
  .pmdb-cmddeck { gap: 8px; padding: 8px 12px 8px 16px; }
  .pmdb-cmddeck-wins { min-width: 0; }
}

@media (max-width: 400px) {
  /* Detail on ultra-narrow phones: drop fixed min-widths so nothing clips. */
  .pmdb-detail-meta { min-width: 0; }
  .pmdb-detail-lists { grid-template-columns: 1fr; }
}
