/* ══════════════════════════════════════════════════════
   MARKETPLACE MODAL (mp-*) — V2 F95-style dark layout
   ══════════════════════════════════════════════════════ */

/* ── Full-screen modal override ── */
.mp-v2 {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
}

/* ── Top bar ── */
.mp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 20px 0;
  height: calc(52px + env(safe-area-inset-top));
  min-height: calc(52px + env(safe-area-inset-top));
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.mp-topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.mp-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--text-1);
  white-space: nowrap;
}

.mp-nav {
  display: flex;
  gap: 0;
}

.mp-nav-btn {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}

.mp-nav-btn:hover {
  color: var(--text-1);
}

.mp-nav-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.mp-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-topbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  min-width: 120px;
  max-width: 250px;
  flex: 1 1 auto;
}

.mp-topbar-search:focus-within {
  border-color: var(--accent);
}

.mp-topbar-search .mp-search-input {
  border: none;
  background: transparent;
  color: var(--text-1);
  outline: none;
  font-size: 13px;
  width: 100%;
  padding: 0;
}

.mp-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.mp-icon-btn:hover {
  color: var(--text-1);
  background: var(--bg-3);
  border-color: var(--accent);
}

.mp-icon-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Pagination bar ── */
.mp-pagination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}

.mp-page-btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}

.mp-page-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mp-page-btn:disabled {
  opacity: .4;
  cursor: default;
}

.mp-page-info {
  font-size: 12px;
  color: var(--text-2);
}

.mp-page-info strong {
  color: var(--text-1);
}

/* ── Layout: main + sidebar ── */
.mp-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.mp-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Sidebar ── */
.mp-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
  transition: width .2s, min-width .2s, padding .2s, opacity .2s;
}

.mp-sidebar.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  border-left: none;
}

.mp-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.mp-sidebar-header span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-sidebar-actions {
  display: flex;
  gap: 4px;
}

.mp-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* Sidebar category tabs */
.mp-sidebar-tabs {
  display: flex;
  gap: 4px;
}

.mp-sidebar-tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.mp-sidebar-tab:hover {
  color: var(--text-1);
  border-color: var(--accent);
}

.mp-sidebar-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Sidebar genre chips */
.mp-sidebar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mp-chip {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.mp-chip:hover {
  color: var(--text-1);
  border-color: var(--accent);
}

.mp-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Sidebar sort buttons */
.mp-sidebar-sort-btns {
  display: flex;
  gap: 6px;
}

.mp-sort-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.mp-sort-btn:hover {
  color: var(--text-1);
  border-color: var(--accent);
}

.mp-sort-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Sidebar search input */
.mp-sidebar-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-1);
  outline: none;
}

.mp-sidebar-search::placeholder {
  color: var(--text-3);
}

.mp-sidebar-search:focus {
  border-color: var(--accent);
}

/* Search mode toggle buttons */
.mp-search-mode-btns {
  display: flex;
  gap: 4px;
}

.mp-search-mode-btn {
  flex: 1;
  padding: 6px 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}

.mp-search-mode-btn:hover {
  color: var(--text-1);
  border-color: var(--accent);
}

.mp-search-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Date limit slider */
.mp-date-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mp-date-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-3);
  outline: none;
  cursor: pointer;
}

.mp-date-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-1);
  box-shadow: 0 0 4px rgba(124, 92, 252, .4);
}

.mp-date-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-1);
}

.mp-date-slider-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  text-align: center;
}

.mp-date-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-3);
  padding: 0 2px;
}

/* Tags section label with mode toggle */
.mp-sidebar-tags-section .mp-sidebar-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mp-tags-count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
}

.mp-tags-mode-toggle {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.mp-tags-mode-btn {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s;
}

.mp-tags-mode-btn:hover {
  color: var(--text-1);
  border-color: var(--accent);
}

.mp-tags-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Tags / Exclude tags input wrapper */
.mp-tags-input-wrap,
.mp-excl-input-wrap {
  position: relative;
}

.mp-tags-input,
.mp-excl-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-1);
  outline: none;
}

.mp-tags-input::placeholder,
.mp-excl-input::placeholder {
  color: var(--text-3);
}

.mp-tags-input:focus,
.mp-excl-input:focus {
  border-color: var(--accent);
}

/* Autocomplete dropdown */
.mp-tags-autocomplete,
.mp-excl-autocomplete,
.mp-pub-tags-ac {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

/* ── Tag picker (pub form step 2, module pub) ── */
.mp-pub-tags-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mp-pub-tags-sel-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 32px;
  margin-bottom: 10px;
}

.mp-pub-tags-sel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

.mp-pub-tags-grid,
.mp-modpub-tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}

.mp-pub-tags-grid .tag-chip,
.mp-modpub-tags-grid .tag-chip {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
}

.mp-pub-custom-tag,
.mp-custom-tag {
  border-style: dashed !important;
  color: var(--accent) !important;
}

.mp-tags-show-all {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.mp-tags-show-all:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.mp-ac-item {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .1s;
}

.mp-ac-item:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

/* Tag pills */
.mp-tags-pills,
.mp-excl-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mp-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border-radius: var(--radius-full);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.mp-excl-pills .mp-tag-pill {
  background: color-mix(in srgb, #ef4444 15%, transparent);
  color: #ef4444;
  border-color: color-mix(in srgb, #ef4444 30%, transparent);
}

.mp-tag-pill-x {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}

.mp-tag-pill-x:hover {
  opacity: 1;
}

/* ── Tags: Popular chips ── */
.mp-tags-popular {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  min-height: 0;
}

.mp-tags-popular-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  font-weight: 600;
  flex-shrink: 0;
}

.mp-tags-popular-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1.6;
}

.mp-tags-popular-chip:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* ── Tag count badge ── */
.mp-tag-cnt {
  font-size: 10px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  line-height: 1.5;
}

/* In autocomplete dropdown */
.mp-ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mp-tag-cnt-ac {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text-3);
  flex-shrink: 0;
}

/* ── Section containers ── */
.mp-section {
  min-height: 200px;
}

/* ── Grid — F95-style 3-column ── */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-items: flex-start;
}

/* ── Cards ── */
.mp-card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, border-color .15s;
}

.mp-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  border-color: var(--accent);
  overflow: visible;
  z-index: 50;
}

.mp-card:has(.mp-card-tags-dropdown):hover {
  border-bottom-color: var(--bg-1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* ── Book/Module Card Cover ── */
.mp-card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-3);
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}

.mp-card-cover img.mp-carousel-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .4s ease;
}

.mp-card-cover img.mp-carousel-img.active {
  opacity: 1;
}

.mp-card-cover img:not(.mp-carousel-img) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.mp-card:hover .mp-card-cover img:not(.mp-carousel-img) {
  transform: scale(1.05);
}

/* Carousel dots */
.mp-carousel-dots {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
  opacity: 0;
  transition: opacity .2s;
}

.mp-card:hover .mp-carousel-dots {
  opacity: 1;
}

.mp-carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .4);
  transition: background .2s;
}

.mp-carousel-dot.active {
  background: #fff;
}

.mp-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-4) 100%);
}

/* Module card cover variant */
.mp-mod-cover {
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-5) 100%);
}

.mp-mod-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Overlay badges on cover */
.mp-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 1;
}

.mp-card-badge {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.mp-badge-genre {
  background: rgba(124, 92, 252, .85);
  color: #fff;
}

.mp-badge-date {
  background: rgba(0, 0, 0, .6);
  color: #ccc;
  font-weight: 500;
  text-transform: none;
}

.mp-badge-version {
  background: rgba(0, 0, 0, .6);
  color: #ddd;
  font-weight: 500;
  text-transform: none;
}

/* Stats bar at bottom of cover */
.mp-card-stats-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 10px;
  display: flex;
  gap: 14px;
  align-items: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  font-size: 11px;
  color: rgba(255, 255, 255, .8);
  z-index: 1;
}

.mp-card-stats-bar span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mp-card-stats-bar i {
  opacity: .7;
}

/* Card body (below cover) */
.mp-card-body {
  padding: 10px 12px 12px;
}

.mp-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-1);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-card-author {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mp-card-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Price badge on card */
.mp-card-price {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}

.mp-card-price.mp-free {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
}

/* Token Shop */
.mp-shop-pack {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  transition: border-color .15s;
}

.mp-shop-pack:hover {
  border-color: var(--accent);
}

.mp-shop-pack-icon {
  flex-shrink: 0;
}

.mp-shop-pack-info {
  flex: 1;
}

.mp-shop-pack-name {
  font-size: 14px;
  font-weight: 600;
}

.mp-shop-pack-price {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tag dropdown on hover */
.mp-card-tags-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: -1px;
  right: -1px;
  background: var(--bg-1);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, .3);
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  max-height: 120px;
  overflow-y: auto;
  z-index: 50;
}

.mp-card:hover .mp-card-tags-dropdown {
  display: flex;
}

.mp-card-tags-dropdown .mp-tag {
  font-size: 10px;
  padding: 1px 7px;
}

/* ── Older card classes (kept for compat) ── */
.mp-card-meta {
  padding: 10px 12px;
}

.mp-card-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.mp-card-genre {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 10px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border-radius: var(--radius-xs);
}

/* ── Module Card (legacy compat) ── */
.mp-mod-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mp-mod-cat-tag {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg-3);
  border-radius: var(--radius-xs);
  color: var(--text-2);
}

.mp-mod-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0;
}

.mp-mod-desc {
  font-size: 12px;
  color: var(--text-2);
  margin: 0;
  line-height: 1.4;
}

.mp-mod-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.mp-mod-author {
  font-size: 11px;
  color: var(--text-2);
}

.mp-mod-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Empty state ── */
.mp-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-2);
  grid-column: 1 / -1;
}

/* ── Load more button ── */
.mp-load-more {
  text-align: center;
  padding: 20px;
}

/* ── Detail View ── */
.mp-detail {
  overflow-y: auto;
  max-height: calc(100vh - 140px);
}

.mp-back-btn {
  margin-bottom: 12px;
}

.mp-detail-header {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.mp-detail-cover {
  flex-shrink: 0;
}

.mp-detail-cover img {
  width: 220px;
  height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
}

.mp-detail-info h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text-1);
}

.mp-detail-author {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.mp-detail-author:hover {
  text-decoration: underline;
}

.mp-detail-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.mp-detail-genre-badge {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(124, 92, 252, .85);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.mp-detail-version-badge {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-2);
}

.mp-detail-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.mp-stars-row {
  color: #f59e0b;
  font-size: 14px;
}

.mp-star {
  color: var(--text-muted);
  font-size: 14px;
}

.mp-star.filled {
  color: #f59e0b;
}

.mp-rating-val {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-1);
}

.mp-detail-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.mp-detail-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mp-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.mp-detail-description {
  margin-bottom: 20px;
}

.mp-detail-description h3 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-1);
}

.mp-detail-description p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
}

.mp-detail-contents {
  margin-bottom: 20px;
}

.mp-detail-contents h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-1);
}

.mp-contents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.mp-content-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
}

.mp-content-item i {
  color: var(--accent);
  flex-shrink: 0;
}

.mp-content-count {
  margin-left: auto;
  font-weight: 700;
  color: var(--text-1);
}

.mp-tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  background: var(--bg-3);
  border-radius: var(--radius-xs);
  color: var(--text-2);
}

.mp-detail-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin: 10px 0;
}

.mp-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.mp-detail-actions .active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Gallery ── */
.mp-detail-gallery {
  margin-bottom: 20px;
}

.mp-detail-gallery h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-1);
}

.mp-gallery-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.mp-gallery-img {
  width: 180px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform .15s;
}

.mp-gallery-img:hover {
  transform: scale(1.05);
}

/* ── Reviews ── */
.mp-detail-reviews {
  margin-top: 20px;
}

.mp-detail-reviews h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-1);
}

.mp-review-form {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.mp-review-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
}

.mp-star-pick {
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: color .1s;
}

.mp-star-pick.active,
.mp-star-pick:hover {
  color: #f59e0b;
}

.mp-review-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  color: var(--text-1);
  font-size: 12px;
  resize: vertical;
  margin-bottom: 8px;
}

.mp-review-textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.mp-review-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}

.mp-review-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.mp-review-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.mp-review-author-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-review-author-info strong {
  font-size: 12px;
  color: var(--text-1);
}

.mp-review-stars {
  margin-left: auto;
  color: #f59e0b;
  font-size: 13px;
}

.mp-review-text {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  margin: 0 0 8px;
}

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

.mp-review-actions .btn {
  font-size: 11px;
}

.mp-reviews-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Profile ── */
.mp-profile {
  padding: 8px 0;
}

.mp-profile-header {
  text-align: center;
  margin-bottom: 24px;
}

.mp-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 28px;
  margin-bottom: 10px;
  overflow: hidden;
}

.mp-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-profile h3 {
  font-size: 14px;
  margin: 16px 0 10px;
  color: var(--text-1);
}

/* ── Detail Overlay V3 ── */
.mp-dt-overlay {
  backdrop-filter: blur(4px);
  overflow: hidden;
}

.mp-dt-modal {
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  background: var(--bg-1);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
}

.mp-dt-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.mp-dt-topbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.mp-dt-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.mp-dt-main {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.mp-dt-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-2);
}

.mp-dt-sidebar-inner {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Hero */
.mp-dt-hero {
  position: relative;
  min-height: 160px;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.mp-dt-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .2), rgba(0, 0, 0, .7));
}

.mp-dt-hero-inner {
  position: relative;
  z-index: 1;
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-end;
  min-height: 160px;
}

.mp-dt-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mp-dt-badge-type {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(139, 92, 246, .85);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.mp-dt-badge-genre {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  backdrop-filter: blur(4px);
}

.mp-dt-badge-ver {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .8);
}

.mp-dt-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* Tags */
.mp-dt-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
}

.mp-dt-tag {
  padding: 3px 12px;
  background: var(--bg-3);
  color: var(--text-2);
  border-radius: 20px;
  font-size: 11px;
}

/* Sections */
.mp-dt-section {
  padding: 20px 28px;
}

.mp-dt-section+.mp-dt-section {
  border-top: 1px solid var(--border);
}

.mp-dt-section-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-dt-description {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Contents tree */
.mp-dt-contents {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Book detail hero */
.mp-dt-book-hero {
  display: flex;
  gap: 24px;
  padding: 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.mp-dt-bh-cover {
  flex-shrink: 0;
  width: 160px;
  height: 230px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  background: var(--bg-3);
}

.mp-dt-bh-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-dt-bh-cover-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-dt-bh-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.mp-dt-bh-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.3;
}

.mp-dt-bh-author {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
}

.mp-dt-bh-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-3);
}

.mp-dt-bh-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mp-dt-bh-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* Book layout: full-width main, no sidebar */
.mp-dt-body--book {
  display: block !important;
}

.mp-dt-body--book .mp-dt-main {
  max-width: 780px;
  margin: 0 auto;
}

/* Chapters list */
.mp-dt-chapters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-dt-chapter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.15s;
}

.mp-dt-chapter-row:hover {
  background: var(--bg-3);
}

.mp-dt-ch-num {
  min-width: 50px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.mp-dt-ch-title {
  flex: 1;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-dt-ch-free {
  font-size: 11px;
  color: #22c55e;
  white-space: nowrap;
}

.mp-dt-ch-price {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

.mp-dt-domain {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border-left: 3px solid var(--domain-color);
}

.mp-dt-domain-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.mp-dt-domain-count {
  margin-left: auto;
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-2);
}

.mp-dt-domain-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mp-dt-item-badge {
  padding: 4px 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.mp-dt-item-more {
  padding: 4px 10px;
  background: var(--bg-3);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
}

/* Gallery — horizontal scroll */
.mp-dt-gallery {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.mp-dt-gallery::-webkit-scrollbar {
  height: 6px;
}

.mp-dt-gallery::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 3px;
}

.mp-dt-gallery-img {
  flex-shrink: 0;
  width: 240px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  scroll-snap-align: start;
  transition: transform .15s, box-shadow .15s;
}

.mp-dt-gallery-img:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}

/* Sidebar */
.mp-dt-cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mp-dt-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-dt-author {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}

.mp-dt-author:hover {
  background: var(--bg-3);
}

.mp-dt-author-ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.mp-dt-author-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-dt-author-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.mp-dt-author-sub {
  font-size: 11px;
  color: var(--text-3);
}

.mp-dt-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mp-dt-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.mp-dt-stat span {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
}

.mp-dt-stat small {
  font-size: 10px;
  color: var(--text-3);
}

.mp-dt-import-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
}

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

.mp-dt-actions .btn {
  flex: 1;
  justify-content: center;
}

.mp-dt-actions .active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mp-dt-meta-row {
  text-align: center;
  color: var(--text-3);
}

.mp-dt-meta-row small {
  font-size: 11px;
}

/* Rating inline (replacement for *****) */
.mp-rating-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #f59e0b;
}

/* Review clickable elements */
.mp-review-avatar-link,
.mp-review-author-link {
  cursor: pointer;
  transition: opacity .15s;
}

.mp-review-avatar-link:hover,
.mp-review-author-link:hover {
  opacity: .75;
}

.mp-react-btn.active {
  color: var(--accent);
}

/* ── Public Profile Overlay V2 ── */
.mp-pub-profile-overlay {
  backdrop-filter: blur(4px);
}

.mp-pub-profile-modal {
  width: 100%;
  max-width: 800px;
  max-height: 92vh;
  background: var(--bg-1);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
}

.mp-pp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.mp-pp-scroll {
  flex: 1;
  overflow-y: auto;
}

.mp-pp-banner {
  height: 160px;
  background-size: cover;
  background-position: center;
  border-radius: 0;
}

.mp-pp-header {
  padding: 0 28px 20px;
  margin-top: -40px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-pp-avatar-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--bg-1);
  overflow: hidden;
  flex-shrink: 0;
}

.mp-pp-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-pp-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  font-weight: 700;
}

.mp-pp-name-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.mp-pp-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.mp-pp-username {
  font-size: 13px;
  color: var(--text-3);
}

.mp-pp-bio {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
}

.mp-pp-socials {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.mp-pp-social {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: color-mix(in srgb, var(--social-color) 12%, transparent);
  color: var(--social-color);
  text-decoration: none;
  transition: background .15s, transform .1s;
}

.mp-pp-social:hover {
  background: color-mix(in srgb, var(--social-color) 22%, transparent);
  transform: translateY(-1px);
}

.mp-pp-section {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
}

.mp-pp-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .mp-dt-modal {
    max-width: 100vw;
    width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }

  /* Body becomes the single scroll container */
  .mp-dt-body {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /*
   * Dissolve .mp-dt-main into body's flex context —
   * lets us control child order precisely with `order`
   * without duplicating any HTML.
   */
  .mp-dt-main {
    display: contents;
    overflow: visible;
  }

  /* ── Reorder: hero → tags → sidebar strip → content ── */
  .mp-dt-hero        { order: 1; flex-shrink: 0; }
  .mp-dt-tags        { order: 2; }
  .mp-dt-sidebar     { order: 3; }
  .mp-dt-section     { order: 4; }

  /* ── Hero ── */
  .mp-dt-hero {
    min-height: 180px;
    background-size: cover;
    background-position: center;
  }

  .mp-dt-hero-inner {
    min-height: 180px;
    padding: 20px 16px 16px;
    justify-content: flex-end;
  }

  .mp-dt-title {
    font-size: 20px;
  }

  /* ── Tags strip ── */
  .mp-dt-tags {
    padding: 8px 14px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mp-dt-tags::-webkit-scrollbar { display: none; }

  /* ── Sidebar strip ── */
  .mp-dt-sidebar {
    width: 100%;
    border-left: none;
    border-top: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    background: var(--bg-2);
    flex-shrink: 0;
  }

  .mp-dt-sidebar-inner {
    padding: 12px 14px;
    gap: 10px;
  }

  /* Hide the tall portrait cover — hero already shows the image */
  .mp-dt-cover {
    display: none;
  }

  /* Author row: more compact */
  .mp-dt-author {
    padding: 4px 0;
  }

  /* Stats: 4 columns in a single tight row */
  .mp-dt-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .mp-dt-stat {
    padding: 7px 4px;
  }

  .mp-dt-stat span {
    font-size: 13px;
  }

  .mp-dt-stat small {
    font-size: 10px;
  }

  /* Action buttons row */
  .mp-dt-actions {
    gap: 6px;
  }

  /* ── Content sections ── */
  .mp-dt-section {
    padding: 14px 16px;
  }

  .mp-pub-profile-modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
/* ── Publish form ── */
.mp-pub-cover-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-pub-images-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.mp-mod-content-wrap {
  margin-bottom: 16px;
}

.mp-mod-content {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.mp-packs-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ── Lightbox ── */
.mp-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  cursor: pointer;
}

.mp-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
}

.mp-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 32px;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
}

/* ── Old toolbar / select compat ── */
.mp-select {
  padding: 7px 12px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  color: var(--text-1);
  cursor: pointer;
  width: 100%;
}

.mp-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* ── Detail V2 ── */
.mp-detail-v2 {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 85vh;
  overflow-y: auto;
}

.mp-detail-hero {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

.mp-detail-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.35);
  transform: scale(1.2);
}

.mp-detail-hero-content {
  position: relative;
  display: flex;
  gap: 24px;
  padding: 32px 28px;
  z-index: 1;
}

.mp-detail-hero-cover {
  width: 160px;
  height: 220px;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  flex-shrink: 0;
}

.mp-detail-hero-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #fff;
  min-width: 0;
  flex: 1;
}

.mp-detail-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mp-detail-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mp-detail-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: #fff;
}

.mp-detail-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-detail-author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.mp-detail-author-row span {
  font-size: 13px;
  opacity: .85;
}

.mp-detail-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.mp-detail-rating-row .stars {
  color: #fbbf24;
  display: flex;
  gap: 2px;
}

.mp-detail-stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
}

.mp-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, .1);
  border-radius: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, .8);
  backdrop-filter: blur(4px);
}

.mp-detail-action-bar {
  display: flex;
  gap: 10px;
  padding: 14px 28px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.mp-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.mp-import-btn:hover {
  opacity: .85;
}

.mp-detail-tags-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.mp-detail-tag {
  padding: 3px 10px;
  background: var(--bg-3);
  color: var(--text-2);
  border-radius: 20px;
  font-size: 11px;
}

.mp-detail-block {
  padding: 20px 28px;
}

.mp-detail-block+.mp-detail-block {
  border-top: 1px solid var(--border);
}

.mp-detail-block-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-detail-block-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
}

.mp-detail-contents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.mp-detail-content-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.mp-detail-content-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-detail-content-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.mp-detail-content-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
}

.mp-detail-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.mp-detail-gallery-grid img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .15s;
}

.mp-detail-gallery-grid img:hover {
  transform: scale(1.03);
}

/* ── Publish V2 ── */
/* Section visibility: class-controlled so CSS always wins */
.mp-pub-section-book,
.mp-pub-section-module,
.mp-pub-section-project {
  display: none;
}

.mp-pub-section-book.mp-pub-active,
.mp-pub-section-module.mp-pub-active,
.mp-pub-section-project.mp-pub-active {
  display: block;
}

.mp-publish-modal {
  max-width: 720px;
  width: 100%;
}

.mp-publish-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.mp-publish-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.mp-publish-body {
  padding: 20px;
  max-height: 65vh;
  overflow-y: auto;
}

.mp-publish-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.mp-publish-step,
.mp-proj-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--bg-1);
  border: 1px solid var(--border);
  transition: all .2s;
  white-space: nowrap;
}

.mp-publish-step span,
.mp-proj-step span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.mp-publish-step.active,
.mp-proj-step.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-1));
}

.mp-publish-step.active span,
.mp-proj-step.active span {
  background: var(--accent);
  color: #fff;
}

.mp-publish-step.done,
.mp-proj-step.done {
  color: #10b981;
  border-color: #10b981;
}

.mp-publish-step.done span,
.mp-proj-step.done span {
  background: #10b981;
  color: #fff;
}

.mp-publish-page {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.mp-publish-page.active {
  display: flex;
}

.mp-publish-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.mp-pub-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mp-pub-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mp-pub-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mp-pub-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all .2s;
  background: var(--bg-1);
}

.mp-pub-type-card:hover {
  border-color: var(--accent);
}

.mp-pub-type-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-1));
}

.mp-pub-type-card strong {
  font-size: 13px;
  color: var(--text-1);
}

.mp-pub-type-card span {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.3;
}

.mp-pub-type-card i {
  color: var(--accent);
}

/* Cover dropzone */
.mp-pub-cover-zone {
  position: relative;
}

.mp-pub-cover-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-3);
  font-size: 13px;
  transition: border-color .2s;
}

.mp-pub-cover-dropzone:hover {
  border-color: var(--accent);
}

/* Rules checkbox */
.mp-pub-rules-check {
  padding: 12px 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.mp-pub-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.mp-pub-checkbox-label input[type="checkbox"] {
  margin-top: 2px;
}

/* ── Publish grid helpers (replaces inline styles) ── */
.mp-pub-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mp-pub-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ══════════════════════════════════════════════════════════
   PUBLISH MODAL – MOBILE  (max-width: 600px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* Full-width, near-full-height sheet */
  .mp-publish-modal {
    max-width: 98vw !important;
    max-height: 94vh !important;
    border-radius: 16px !important;
    width: 98vw !important;
  }

  /* Header: compact */
  .mp-publish-header {
    padding: 10px 14px;
    gap: 10px;
  }
  .mp-publish-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
  }
  .mp-publish-header h2 {
    font-size: 15px;
    margin: 0;
  }

  /* Type selector tabs: equal columns, compact text */
  .mp-pub-type-selector {
    padding: 0 8px !important;
  }
  .mp-pub-type-tab {
    padding: 9px 4px !important;
    font-size: 11px !important;
    gap: 4px !important;
  }

  /* Step bar: horizontally scrollable, compact pills */
  .mp-publish-steps {
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 4px;
    padding-bottom: 2px;
    margin-bottom: 14px;
  }
  .mp-publish-steps::-webkit-scrollbar { display: none; }

  .mp-publish-step,
  .mp-proj-step {
    padding: 6px 8px;
    font-size: 10px;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Body: full remaining height with scrolling */
  .mp-publish-body {
    padding: 14px;
    max-height: 52vh;
  }

  /* Grid layouts: responsive */
  .mp-pub-grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .mp-pub-grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Cover drop zone: smaller */
  .mp-pub-cover-dropzone {
    padding: 18px 12px;
  }

  /* Preview card: vertical stack */
  .mp-pub-preview-card {
    flex-direction: column;
    gap: 12px;
  }
  .mp-pub-pv-cover {
    width: 100% !important;
    min-height: 140px !important;
    max-height: 160px;
  }
  .mp-proj-preview-card {
    flex-direction: column;
    gap: 12px;
  }
  .mp-proj-pv-cover {
    width: 100% !important;
    min-height: 120px !important;
  }

  /* Footer: keep on one row, shrink if needed */
  .mp-publish-footer {
    padding: 10px 14px;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .mp-pub-close-btn {
    flex-shrink: 0;
  }

  /* Module section body */
  .mp-pub-section-module > div {
    padding: 14px !important;
    max-height: 60vh !important;
    box-sizing: border-box;
  }
}

/* ── Extra small publish (< 400px) ── */
@media (max-width: 400px) {
  .mp-publish-step,
  .mp-proj-step {
    font-size: 9px;
    padding: 5px 6px;
  }
  .mp-pub-grid-3 { grid-template-columns: 1fr; }
  .mp-publish-footer {
      flex-wrap: nowrap;
      padding: 8px 12px;
  }
  .mp-pub-close-btn {
      padding: 6px 10px;
  }
}

.mp-ac-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-2);
}

.mp-ac-item:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

/* Tag pills */
.mp-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.mp-tag-pill-x {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: .7;
}

.mp-tag-pill-x:hover {
  opacity: 1;
}

/* Preview card */
.mp-pub-preview-card img {
  border-radius: var(--radius-sm);
}

/* ── Import Dialog ── */
.mp-import-modal {
  max-width: 440px;
  width: 100%;
}

.mp-import-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.mp-import-warning {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: color-mix(in srgb, #f59e0b 10%, var(--bg-1));
  border: 1px solid color-mix(in srgb, #f59e0b 30%, var(--border));
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
}

.mp-import-warning i {
  color: #f59e0b;
}

/* ── My Works — Author Dashboard ── */

/* Summary cards row */
.mp-author-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 20px 20px 0;
}

.mp-summary-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mp-summary-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mp-summary-card .mp-summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
}

.mp-summary-card .mp-summary-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Toolbar */
.mp-dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

.mp-dashboard-search {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
  position: relative;
}

.mp-dashboard-search input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  outline: none;
  transition: border-color .2s;
}

.mp-dashboard-search input:focus {
  border-color: var(--accent);
}

.mp-dashboard-search i,
.mp-dashboard-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.mp-dashboard-sort {
  padding: 7px 10px;
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  cursor: pointer;
}

.mp-dashboard-view-btns {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.mp-dashboard-view-btns button {
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.mp-dashboard-view-btns button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.mp-dashboard-view-btns button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.mp-dashboard-view-btns button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Grid cards */
.mp-myworks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: flex-start;
  padding: 0 20px 20px;
}

.mp-mywork-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  position: relative;
}

.mp-mywork-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
}

.mp-mywork-cover {
  height: 140px;
  background-size: cover;
  background-position: center;
}
/* ══════════════════════════════════════════════════════
   Edit Publication — Full redesign
══════════════════════════════════════════════════════ */
.mp-edit-fullmodal {
  background: var(--bg-1);
  border-radius: 20px;
  width: min(860px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,.45);
  border: 1px solid var(--border);
}

/* Header */
.mp-edit-fm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-1));
  flex-shrink: 0;
}
.mp-edit-fm-header-left { display: flex; align-items: center; gap: 14px; }
.mp-edit-fm-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mp-edit-fm-title { font-size: 17px; font-weight: 700; color: var(--text-1); }
.mp-edit-fm-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.mp-edit-fm-close {
  margin-left: auto;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.mp-edit-fm-close:hover { background: var(--bg-3); color: var(--text-1); }

/* Body */
.mp-edit-fm-body {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* Cover column */
.mp-edit-fm-cover-col {
  width: 200px;
  flex-shrink: 0;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
}
.mp-edit-fm-cover-wrap {
  position: relative;
  width: 160px; height: 220px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-3);
  border: 2px dashed var(--border);
}
.mp-edit-fm-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-edit-fm-cover-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--text-3); font-size: 12px;
}
.mp-edit-fm-cover-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  opacity: 0; transition: opacity .2s;
}
.mp-edit-fm-cover-wrap:hover .mp-edit-fm-cover-overlay { opacity: 1; }
.mp-edit-fm-cover-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.mp-edit-fm-cover-remove {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 8px;
  background: rgba(239,68,68,.85); color: #fff;
  font-size: 12px; cursor: pointer; border: none;
}
.mp-edit-fm-cover-remove.hidden { display: none; }
.mp-edit-fm-cover-hint { font-size: 11px; color: var(--text-3); text-align: center; }

.mp-edit-fm-status-preview {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center;
  margin-top: 4px;
}
.mp-edit-fm-status-badge {
  padding: 3px 10px; border-radius: 6px;
  background: var(--bg-3); color: var(--text-1);
  font-size: 12px; font-weight: 700; border: 1px solid var(--border);
}
.mp-edit-fm-cr-badge {
  padding: 3px 10px; border-radius: 6px;
  color: #fff; font-size: 12px; font-weight: 700;
}

/* Fields column */
.mp-edit-fm-fields {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.mp-edit-fm-field { display: flex; flex-direction: column; gap: 6px; }
.mp-edit-fm-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-2); letter-spacing: .3px;
  display: flex; align-items: center; gap: 5px;
}
.mp-edit-fm-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px; color: var(--text-1);
  outline: none; transition: border-color .15s;
  font-family: inherit;
  width: 100%; box-sizing: border-box;
}
.mp-edit-fm-input:focus { border-color: var(--accent); }
.mp-edit-fm-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.mp-edit-fm-row { display: flex; gap: 12px; flex-wrap: wrap; }
.mp-edit-fm-row .mp-edit-fm-field { min-width: 100px; }

/* Pills */
.mp-edit-fm-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.mp-edit-fm-pill {
  padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg-2); color: var(--text-2);
  cursor: pointer; transition: all .15s;
}
.mp-edit-fm-pill:hover { border-color: var(--accent); color: var(--accent); }
.mp-edit-ar-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mp-edit-cr-pill.active { background: var(--pill-c, var(--accent)); color: #fff; border-color: var(--pill-c, var(--accent)); }

/* Sync note */
.mp-edit-fm-sync-note {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 10px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  font-size: 12px; color: var(--text-2); line-height: 1.5;
}

/* Footer */
.mp-edit-fm-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
}
.mp-edit-fm-btn-cancel {
  padding: 9px 20px; border-radius: 10px; font-size: 14px; font-weight: 500;
  background: var(--bg-2); color: var(--text-2);
  border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 6px;
  line-height: normal;
  transition: background .15s;
}
.mp-edit-fm-btn-cancel:hover { background: var(--bg-3); }

.mp-edit-fm-btn-sync {
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); cursor: pointer;
  display: flex; align-items: center; gap: 6px; line-height: normal;
  transition: all .15s;
}
.mp-edit-fm-btn-sync:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent); border-color: var(--accent);
}
.mp-edit-fm-btn-sync:disabled {
  opacity: 0.5; cursor: not-allowed;
}

.mp-edit-fm-btn-save {
  padding: 9px 22px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: opacity .15s;
}
.mp-edit-fm-btn-save:hover { opacity: .88; }
.mp-edit-fm-btn-save:disabled { opacity: .5; cursor: not-allowed; }

/* ── Sync Modal v2 ── */
.mp-sync-modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 620px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.45);
}
.mp-sync-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mp-sync-header-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.mp-sync-title { font-size: 15px; font-weight: 700; color: var(--text-1); }
.mp-sync-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.mp-sync-close {
  margin-left: auto; flex-shrink: 0;
  width: 28px; height: 28px; padding: 0;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-3); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.mp-sync-close:hover { background: var(--bg-3); }

.mp-sync-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Project block */
.mp-sync-proj-block { display: flex; flex-direction: column; gap: 7px; }
.mp-sync-proj-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.mp-sync-proj-selector {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  transition: border-color .15s;
}
.mp-sync-proj-selector:focus-within { border-color: var(--accent); }
.mp-sync-proj-select {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 14px; font-weight: 500; color: var(--text-1);
  cursor: pointer;
}
.mp-sync-proj-select option {
  background: #1e1e2e;
  color: #e2e2f0;
}

/* Stats bar */
.mp-sync-stats-bar {
  display: flex; align-items: center; gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.mp-sync-stat {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 8px; gap: 2px;
}
.mp-sync-stat-num { font-size: 18px; font-weight: 700; color: var(--text-1); line-height: 1; }
.mp-sync-stat-lbl { font-size: 11px; color: var(--text-3); }
.mp-sync-stat-divider { width: 1px; background: var(--border); align-self: stretch; }

/* Table header */
.mp-sync-tbl-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

/* Module list */
.mp-sync-module-list { display: flex; flex-direction: column; gap: 3px; }
.mp-sync-module-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 9px;
  border: 1px solid transparent;
  transition: background .12s;
}
.mp-sync-module-row:hover { background: var(--bg-2); }
.mp-sync-module-row-only-pub { border-color: color-mix(in srgb, var(--danger,#e05) 18%, transparent); }
.mp-sync-module-row-new { border-color: color-mix(in srgb, #3b82f6 18%, transparent); }
.mp-sync-module-row-updated { border-color: color-mix(in srgb, #f59e0b 18%, transparent); }
.mp-sync-module-name {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-1); min-width: 0;
}
.mp-sync-col-cnt {
  width: 72px; text-align: center;
  font-size: 12px; font-weight: 500; color: var(--text-2);
}
.mp-sync-cnt-empty { color: var(--text-3); }
.mp-sync-col-status { width: 100px; display: flex; justify-content: center; }
.mp-sync-col-chk { width: 54px; display: flex; justify-content: center; }
.mp-sync-col-chk input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

/* Status badges */
.mp-sync-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px;
  white-space: nowrap;
}
.mp-sync-badge-same { background: var(--bg-3); color: var(--text-3); }
.mp-sync-badge-updated { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #f59e0b; }
.mp-sync-badge-new { background: color-mix(in srgb, #3b82f6 14%, transparent); color: #60a5fa; }
.mp-sync-badge-only-pub { background: color-mix(in srgb, var(--danger,#e05) 12%, transparent); color: var(--danger,#e05); }

/* Select all row */
.mp-sync-chkall-row {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.mp-sync-chkall-row label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2); cursor: pointer;
}

/* Footer */
.mp-sync-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
}
.mp-sync-btn-cancel {
  padding: 8px 18px; border-radius: 9px; font-size: 13px; font-weight: 500;
  background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); cursor: pointer;
  transition: background .15s;
}
.mp-sync-btn-cancel:hover { background: var(--bg-3); }
.mp-sync-btn-confirm {
  padding: 8px 20px; border-radius: 9px; font-size: 13px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: opacity .15s;
}
.mp-sync-btn-confirm:hover { opacity: .88; }
.mp-sync-btn-confirm:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 660px) {
  .mp-sync-modal { width: 97vw; }
  .mp-sync-tbl-head .mp-sync-col-cnt:first-of-type { display: none; }
  .mp-sync-module-row .mp-sync-col-cnt:first-of-type { display: none; }
}

@media (max-width: 600px) {
  .mp-edit-fm-body { flex-direction: column; }
  .mp-edit-fm-cover-col { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; gap: 16px; padding: 16px; }
  .mp-edit-fm-cover-wrap { width: 90px; height: 124px; flex-shrink: 0; }
}

/* ── My Library sub-tabs ── */
.mp-lib-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.mp-lib-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mp-lib-tab:hover {
  color: var(--text-1);
}

.mp-lib-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.mp-lib-tab-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-3);
  color: var(--text-2);
  min-width: 18px;
  text-align: center;
}

/* ── Age Gate (18+) ─────────────────────────────────────────── */
.adult-restricted .mp-card-cover img,
.adult-restricted .mp-card-cover .mp-cover-placeholder,
.adult-restricted .mp-card-cover .mp-mod-icon-wrap {
  filter: blur(14px) brightness(0.65);
  transition: filter 0.3s;
}
.adult-restricted .mp-card-title,
.adult-restricted .mp-card-author,
.adult-restricted .mp-card-date {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}
.mp-card.adult-restricted {
  cursor: pointer;
}
/* overlay injected by JS */
.mp-adult-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  z-index: 4;
  border-radius: var(--card-radius, 10px) var(--card-radius, 10px) 0 0;
  pointer-events: none;
}
.mp-adult-overlay-badge {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  background: rgba(220, 38, 38, 0.9);
  padding: 5px 14px;
  border-radius: 8px;
  letter-spacing: 1px;
  backdrop-filter: blur(4px);
}

/* ── Mobile-injected elements (always rendered via JS on mobile) ── */
.mp-mobile-tabstrip {
  display: flex;
  height: 38px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-0);
  padding: 0 4px;
  gap: 0;
  flex-shrink: 0;
}
.mp-mobile-tabstrip::-webkit-scrollbar { display: none; }
.mp-mobile-tabstrip .mp-nav-btn {
  padding: 8px 14px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  height: 100%;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
  font-weight: 500;
}
.mp-mobile-tabstrip .mp-nav-btn.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}
.mp-mobile-search {
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  flex-shrink: 0;
}
.mp-mobile-search input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  box-sizing: border-box;
}
.mp-mobile-search input:focus {
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE OVERRIDES  (max-width: 768px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Topbar: compact header + unified tab strip below ── */
  .mp-topbar {
    height: calc(44px + env(safe-area-inset-top));
    min-height: calc(44px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    flex-wrap: nowrap;
    gap: 0;
    position: relative;
    padding-left: 0;
    padding-right: 0;
  }

  /* Logo side */
  .mp-topbar-left {
    height: 44px;
    padding: 0 0 0 12px;
    gap: 4px;
    flex-shrink: 0;
    flex: 1;
    min-width: 0;
  }

  .mp-logo {
    font-size: 14px;
    gap: 4px;
    flex: 1;
  }

  .mp-logo strong {
    font-size: 13px;
  }

  /* Primary nav from topbar-left hidden on mobile (moved to tabstrip) */
  .mp-topbar-left > .mp-nav {
    display: none;
  }

  /* Action buttons side */
  .mp-topbar-right {
    height: 44px;
    padding: 0 8px;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
    flex-shrink: 0;
    overflow: visible;
  }

  /* Separators hidden */
  .mp-topbar-sep {
    display: none !important;
  }

  /* Icon buttons */
  .mp-topbar-right > .mp-icon-btn {
    width: 32px;
    height: 32px;
    align-self: center;
    flex-shrink: 0;
  }

  /* Token balance btn */
  .mp-topbar-right > .mp-token-balance-btn {
    height: 28px;
    padding: 4px 8px !important;
    font-size: 12px;
    align-self: center;
    flex-shrink: 0;
    border-radius: 20px !important;
  }

  /* Secondary nav in topbar-right hidden (moved to tabstrip)
     !important needed to override inline style="display:flex" set in HTML */
  .mp-topbar-right > .mp-secondary-nav {
    display: none !important;
  }

  /* Search in topbar-right hidden (uses mobile search bar)
     !important needed to override inline style on the element */
  .mp-topbar-right > .mp-topbar-search {
    display: none !important;
  }

  /* ── Sidebar: bottom sheet, starts hidden, slides up on toggle ── */
  .mp-sidebar {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: 78vh !important;
    height: auto !important;
    border-left: none !important;
    border-top: 2px solid var(--border) !important;
    border-radius: 16px 16px 0 0 !important;
    z-index: 10000 !important;
    transform: translateY(0) !important;
    transition: transform .3s cubic-bezier(.32,.72,0,1), opacity .3s !important;
    overflow-y: auto !important;
    padding: 16px 16px 24px !important;
    background: var(--bg-1) !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,.35) !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .mp-sidebar.collapsed {
    transform: translateY(110%) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Drag handle hint */
  .mp-sidebar-header::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin: -4px auto 12px;
  }

  /* Sidebar backdrop — inside the overlay stacking context, below the sidebar */
  .mp-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 9999;
    backdrop-filter: blur(2px);
  }

  .mp-sidebar-backdrop.visible {
    display: block;
  }

  /* Sort buttons: all same width — show label too on mobile */
  .mp-sidebar-sort-btns {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .mp-sort-btn {
    width: auto;
    flex-direction: column;
    font-size: 10px;
    gap: 2px;
    padding: 6px 4px;
    height: auto;
  }

  /* ── Main content area ── */
  .mp-main {
    padding: 10px;
  }

  /* ── Grid: 1 column on mobile (readable list) ── */
  .mp-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Card: full-width vertical (like My Works) */
  .mp-card {
    height: auto;
  }

  .mp-card-cover {
    height: 160px;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  /* ── Cards ── */
  .mp-card-title {
    font-size: 12px;
  }

  .mp-card-author,
  .mp-card-date {
    font-size: 10px;
  }

  .mp-card-body {
    padding: 8px 8px 10px;
  }

  /* Tags dropdown: hidden on mobile (no hover), show nothing */
  .mp-card-tags-dropdown {
    display: none !important;
  }

  /* Card hover: no transform on mobile (lag) */
  .mp-card:hover {
    transform: none;
  }

  /* ── Pagination ── */
  .mp-pagination-bar {
    padding: 6px 12px;
    justify-content: center;
    gap: 10px;
  }

  .mp-page-btn {
    padding: 6px 14px;
    font-size: 12px;
  }

  /* ── Stats bar ── */
  .mp-card-stats-bar {
    font-size: 10px;
    gap: 6px;
    padding: 4px 6px;
  }

  /* ── Badge ── */
  .mp-card-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* ── Section min-height ── */
  .mp-section {
    min-height: 100px;
  }

  /* ── Library tabs ── */
  .mp-lib-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .mp-lib-tabs::-webkit-scrollbar {
    display: none;
  }

  .mp-lib-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── Publish Modal: full-screen on mobile ── */
  .mp-publish-modal {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex;
    flex-direction: column;
  }

  .mp-publish-header {
    padding: 12px 14px;
    flex-shrink: 0;
    gap: 8px;
  }

  .mp-publish-header-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .mp-publish-header h2 {
    font-size: 16px;
    margin: 0;
  }

  /* Type selector tabs */
  .mp-pub-type-selector {
    padding: 0 !important;
    flex-shrink: 0;
  }

  .mp-pub-type-tab {
    font-size: 12px !important;
    padding: 9px 0 !important;
  }

  /* Steps strip: compact pills — numbers only */
  .mp-publish-steps {
    gap: 3px;
    margin-bottom: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .mp-publish-steps::-webkit-scrollbar { display: none; }

  .mp-publish-step,
  .mp-proj-step {
    flex-shrink: 0;
    flex: 0 0 auto;
    padding: 6px 8px;
    font-size: 10px;
    gap: 4px;
    white-space: nowrap;
    min-width: 0;
  }

  /* Body: fill remaining height, scroll inset */
  .mp-publish-body {
    flex: 1;
    max-height: none !important;
    overflow-y: auto;
    padding: 14px;
  }

  /* 2-column grids → 1 column */
  .mp-publish-page > div[style*="grid-template-columns:1fr 1fr"],
  .mp-publish-page > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* 3-column grids → 1 column */
  .mp-publish-page > div[style*="grid-template-columns:1fr 1fr 1fr"],
  .mp-publish-page > div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Preview card: stack vertically */
  .mp-pub-preview-card {
    flex-direction: column !important;
    gap: 12px !important;
    padding: 14px !important;
  }

  .mp-pub-pv-cover {
    width: 100% !important;
    min-height: 140px !important;
    max-height: 180px !important;
  }

  /* Sections: only active section shows, fills remaining height as flex column */
  .mp-pub-section-book,
  .mp-pub-section-module,
  .mp-pub-section-project {
    display: none;
  }

  .mp-pub-section-book.mp-pub-active,
  .mp-pub-section-module.mp-pub-active,
  .mp-pub-section-project.mp-pub-active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Footer: stick to bottom */
  .mp-publish-footer {
    flex-shrink: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
  }
}

/* ── Extra small (phones < 400px) ── */
@media (max-width: 400px) {
  .mp-grid {
    gap: 8px;
  }

  .mp-card-title {
    font-size: 11px;
  }

  .mp-topbar-left .mp-nav-btn {
    padding: 10px 8px;
    font-size: 11px;
  }
}
