/* ========================================
   BINDER ORGANIZER STYLES
   ======================================== */

/* Binder List View */
/* Layout handled by .content-view shared class */
.binder-list-view {
  animation: fadeIn 0.3s ease-in;
  padding-top: var(--space-xl, 20px);
  padding-bottom: var(--space-xl, 20px);
}

.binder-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3xl, 32px);
  padding-bottom: 15px;
}

.binder-list-header h2 {
  margin: 0;
  color: var(--color-primary);
  font-size: var(--text-3xl, 24px);
}

.binder-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl, 20px);
  align-items: stretch;
}

.binder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated, white);
  border-radius: var(--radius-lg, 12px);
  padding: 18px 20px 16px;
  border: 1px solid var(--border-color, #e5e7eb);
  /* Slightly thicker accent stripe + per-card variable so the stripe color
     follows the binder's chosen accent without inline style overrides. */
  border-left: 5px solid var(--binder-accent, var(--color-primary));
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
  min-height: 280px;
  overflow: hidden;
}

/* Subtle accent halo at the very top, tinted by the binder color, so each
   card feels uniquely identified at a glance. */
.binder-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--binder-accent, var(--color-primary));
  opacity: 0.4;
  border-top-left-radius: var(--radius-lg, 12px);
  border-top-right-radius: var(--radius-lg, 12px);
}

.binder-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.10),
    0 0 0 2px color-mix(in srgb, var(--binder-accent, #6c5ce7) 35%, transparent);
}

body.dark-mode .binder-card:hover {
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 0 2px color-mix(in srgb, var(--binder-accent, #6c5ce7) 50%, transparent);
}

.binder-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.binder-icon {
  font-size: 32px;
  margin-right: 12px;
}

.binder-card-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #333);
  line-height: 1.3;
  flex: 1;
  /* Keep the title to two lines max so adding a long binder name doesn't
     break the row layout; ellipsis kicks in past that. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Kebab "more" menu — collapses Modifier + Supprimer so the action row
   below stays compact (was overflowing the card with 4 inline buttons). */
.binder-card-menu {
  position: relative;
  flex-shrink: 0;
}

.binder-card-menu-toggle {
  background: transparent;
  border: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-tertiary, #999);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.binder-card-menu-toggle:hover {
  background: rgba(108, 92, 231, 0.10);
  color: var(--color-primary);
}

.binder-card-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  /* Layered shadow so the popover reads as elevated above the card it
     pivots from. Single weak shadow before made it look unstyled. */
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.16),
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(108, 92, 231, 0.06);
  z-index: 50;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: kebabMenuIn 0.12s ease-out;
}
.binder-card-menu-list[hidden] { display: none; }

@keyframes kebabMenuIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.binder-card-menu-list button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-primary, #333);
  transition: background 0.12s ease, color 0.12s ease;
}
.binder-card-menu-list button:hover,
.binder-card-menu-list button:focus-visible {
  background: rgba(108, 92, 231, 0.10);
  color: var(--color-primary);
}
.binder-card-menu-list button.danger { color: var(--ion-color-danger, #ef4444); }
.binder-card-menu-list button.danger:hover,
.binder-card-menu-list button.danger:focus-visible {
  background: rgba(239, 68, 68, 0.12);
  color: var(--ion-color-danger, #ef4444);
}

.binder-card-menu-icon {
  flex-shrink: 0;
  opacity: 0.75;
}
.binder-card-menu-list button:hover .binder-card-menu-icon { opacity: 1; }

.binder-card-menu-sep {
  height: 1px;
  background: var(--border-color);
  margin: 4px 6px;
}

body.dark-mode .binder-card-menu-list {
  background: #161b22;
  border-color: rgba(162, 155, 254, 0.18);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(162, 155, 254, 0.08);
}
body.dark-mode .binder-card-menu-list button { color: #e6edf3; }
body.dark-mode .binder-card-menu-sep {
  background: rgba(162, 155, 254, 0.18);
}

.binder-card-description {
  font-size: 13px;
  color: var(--text-secondary, #666);
  margin: 0 0 12px;
  line-height: 1.4;
  /* Cap the description at 2 lines so cards in the same row stay aligned. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.binder-card-location {
  font-size: 12px;
  color: #888;
  margin-bottom: 10px;
}

.binder-card-thumbs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 78px;
  align-items: center;
}

.binder-card-thumb {
  width: 56px;
  height: 78px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #f3f4f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.binder-card-thumbs--empty {
  justify-content: center;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  background: rgba(108, 92, 231, 0.04);
}

.binder-card-thumbs-empty-msg {
  font-size: 12px;
  color: var(--text-tertiary, #999);
  font-style: italic;
}

.binder-card-progress-block {
  /* Pin the progress + actions to the bottom of the card via flex auto-margin
     so cards in the same grid row align even when descriptions differ. */
  margin-top: auto;
  margin-bottom: 12px;
}

.binder-card-stats {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-tertiary, #999);
  margin-bottom: 6px;
}

.binder-card-stats-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #333);
}

.binder-card-stats-meta { flex: 1; }

.binder-card-stats-pct {
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
}

.binder-progress-track {
  height: 8px;
  background: rgba(108, 92, 231, 0.10);
  border-radius: 4px;
  overflow: hidden;
}

.binder-progress-track .progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.binder-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.binder-card-actions .btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}

.binder-card-view-btn {
  /* The primary action gets the binder accent so each card visually closes
     the loop "this card → click here to enter it". The text colour is
     auto-picked per-binder by JS via --binder-accent-text — light accents
     (yellow, light green, light pink) get dark text to clear WCAG AA;
     dark accents stay with white text. */
  background: var(--binder-accent, var(--color-primary)) !important;
  border-color: var(--binder-accent, var(--color-primary)) !important;
  color: var(--binder-accent-text, #fff) !important;
}
.binder-card-view-btn:hover {
  filter: brightness(1.08);
}

/* Create-binder tile — same grid cell shape, dashed treatment, big + */
.binder-card--create {
  background: rgba(108, 92, 231, 0.04);
  border: 2px dashed rgba(108, 92, 231, 0.35);
  border-left-width: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  min-height: 280px;
  padding: 20px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.binder-card--create::before { display: none; }
.binder-card--create:hover {
  background: rgba(108, 92, 231, 0.10);
  border-color: rgba(108, 92, 231, 0.6);
  transform: translateY(-2px);
}
.binder-card-create-icon {
  font-size: 42px;
  font-weight: 300;
  line-height: 1;
}
.binder-card-create-label {
  font-size: 14px;
}

body.dark-mode .binder-card--create {
  background: rgba(162, 155, 254, 0.05);
  border-color: rgba(162, 155, 254, 0.35);
  color: #a29bfe;
}
body.dark-mode .binder-card--create:hover {
  background: rgba(162, 155, 254, 0.12);
  border-color: rgba(162, 155, 254, 0.6);
}

body.dark-mode .binder-card-thumbs--empty {
  background: rgba(162, 155, 254, 0.05);
}
body.dark-mode .binder-card-menu-list {
  background: #161b22;
}
body.dark-mode .binder-card-menu-list button {
  color: #e6edf3;
}
body.dark-mode .binder-progress-track {
  background: rgba(162, 155, 254, 0.10);
}

/* Empty state */
.binder-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.binder-empty-state h3 {
  font-size: 24px;
  margin-bottom: 15px;
  color: #666;
}

.binder-empty-state p {
  font-size: 16px;
  margin-bottom: 30px;
}

/* Binder Detail View */
.binder-detail-view {
  animation: fadeIn 0.3s ease-in;
}

.binder-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
  color: white;
}

.binder-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.binder-header-top h2 {
  margin: 0;
  font-size: 28px;
  flex: 1;
  text-align: center;
}

.binder-header-top .btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.binder-header-top .btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.binder-stats-bar {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 16px;
}

.binder-stats-bar .progress-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.binder-stats-bar .progress-fill {
  height: 100%;
  background: #43e97b;
  transition: width 0.3s ease;
}

.binder-actions {
  display: flex;
  gap: 10px;
}

/* Documents dropdown */
.binder-export-dropdown {
  position: relative;
}

.binder-documents-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary, #fff);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  min-width: 200px;
  overflow: hidden;
}

.binder-documents-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-primary, #333);
  cursor: pointer;
  transition: background 0.15s;
}

.binder-documents-menu button:hover {
  background: var(--bg-hover, #f0f0f0);
}

.binder-documents-menu button + button {
  border-top: 1px solid var(--border-color, #eee);
}

/* Page Navigator */
.page-navigator {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.page-navigator::-webkit-scrollbar {
  display: none;
}

.page-numbers {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  justify-content: center;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.page-numbers::-webkit-scrollbar {
  display: none;
}

.page-number-btn {
  min-width: 32px;
  height: 30px;
  padding: 4px 8px;
  background: white;
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  flex-shrink: 0;
  font-weight: 600;
  color: #666;
}

.page-number-btn:hover {
  border-color: rgba(102, 126, 234, 0.5);
  color: var(--color-primary);
}

.page-number-btn.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
  color: white;
  border-color: var(--color-primary);
}

.page-nav-btn {
  padding: 4px 8px !important;
  font-size: 14px !important;
  min-width: 28px !important;
  height: 30px !important;
  flex-shrink: 0;
  line-height: 1;
}

.page-action-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  font-size: 11px !important;
  padding: 4px 10px !important;
  white-space: nowrap;
  flex-shrink: 0;
  height: 28px !important;
}

.page-clear-btn {
  color: #999 !important;
}
.page-clear-btn:hover {
  color: #ef4444 !important;
  border-color: #ef4444 !important;
}

.page-number-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-number-btn[draggable='true'] {
  cursor: move;
}

.page-drop-target {
  border: 2px dashed #ccc !important;
  background: #f9f9f9 !important;
}

.page-drag-over {
  border: 2px solid #43e97b !important;
  background: #f0fff4 !important;
  transform: scale(1.1);
}

/* Page Grid */
.page-grid {
  display: grid;
  gap: 15px;
  margin-bottom: 30px;
  overflow: visible;
}

/* Spread View */
.page-spread-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  margin-bottom: 30px;
  align-items: start;
}

.page-spine {
  width: 4px;
  background: linear-gradient(180deg, #999 0%, #666 50%, #999 100%);
  border-radius: 2px;
  min-height: 400px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  position: relative;
}

.page-spine::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 60px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2), transparent);
}

.page-spread-grid .page-grid {
  margin-bottom: 0;
}

.page-spread-half {
  position: relative;
  min-width: 0;
}

.page-grid.pockets-layout-1 {
  grid-template-columns: 1fr;
}

.page-grid.pockets-layout-4 {
  grid-template-columns: repeat(2, 1fr);
}

.page-grid.pockets-layout-6 {
  grid-template-columns: repeat(3, 1fr);
}

.page-grid.pockets-layout-9 {
  grid-template-columns: repeat(3, 1fr);
}

.page-grid.pockets-layout-12 {
  grid-template-columns: repeat(4, 1fr);
}

.page-grid.pockets-layout-16 {
  grid-template-columns: repeat(4, 1fr);
}

/* Pocket */
.pocket {
  aspect-ratio: 3/4;
  background: white;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.pocket:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.pocket--empty {
  border: 2px dashed var(--border-color);
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--border-color);
}

.pocket--empty:hover {
  border-color: var(--color-primary);
  background: #f0f0ff;
  color: var(--color-primary);
}

.pocket--filled {
  border: 2px solid #4caf50;
}

.pocket--selected {
  border: 3px solid var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.pocket--drag-over {
  border: 3px solid #43e97b;
  background: #f0fff4;
}

.pocket-card-image {
  width: 100%;
  height: auto;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 8px;
}

.pocket--not-owned .pocket-card-image {
  filter: grayscale(0.7);
}


.pocket-detail-not-owned-banner {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

#cardSearchResults .card.not-owned .card-image img {
  filter: grayscale(0.7);
}

.pocket-card-info {
  text-align: center;
  font-size: 12px;
}

.pocket-card-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.pocket-card-name .flag-icon {
  width: 14px;
  height: auto;
  flex-shrink: 0;
}

.pocket-card-number {
  color: #999;
  font-size: 11px;
}

.pocket-position {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Pocket Overlay */
.pocket-overlay {
  position: absolute;
  z-index: 50;
  background: var(--bg-elevated, white);
  border-radius: 12px;
  padding: 14px 16px 12px;
  /* Stronger elevation + ringed accent border so the overlay reads as
     "popped above the page" rather than blending into the spread it sits on.
     The earlier flat panel was easy to mistake for a reflowed spread. */
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.12),
    0 0 0 4px rgba(108, 92, 231, 0.18);
  border: 1px solid rgba(108, 92, 231, 0.40);
  width: 300px;
  pointer-events: auto;
  animation: pocketOverlayIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pointer arrow connecting the overlay to its source pocket (rendered above
   or below depending on space — JS positions). Default is "below" pose. */
.pocket-overlay::after {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--bg-elevated, white);
  border-left: 1px solid rgba(108, 92, 231, 0.40);
  border-top: 1px solid rgba(108, 92, 231, 0.40);
  pointer-events: none;
}
.pocket-overlay--below::after { /* default */ }
.pocket-overlay--above::after {
  top: auto;
  bottom: -7px;
  border-left: 0;
  border-top: 0;
  border-right: 1px solid rgba(108, 92, 231, 0.40);
  border-bottom: 1px solid rgba(108, 92, 231, 0.40);
}

body.dark-mode .pocket-overlay {
  background: #161b22;
  border-color: rgba(162, 155, 254, 0.5);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.6),
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 0 0 4px rgba(162, 155, 254, 0.22);
}
body.dark-mode .pocket-overlay::after {
  background: #161b22;
  border-color: rgba(162, 155, 254, 0.5);
}

@keyframes pocketOverlayIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.pocket-overlay-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 2px 4px;
}

.pocket-overlay-close:hover {
  color: #333;
}

.pocket-overlay-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-right: 20px;
}

.pocket-overlay-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
}

.pocket-overlay-header .btn-sm {
  padding: 5px 10px;
}

.pocket-overlay .pocket-detail-not-owned-banner {
  margin-bottom: 0;
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pocket-assign-btn {
  font-size: 10px !important;
  padding: 2px 8px !important;
  white-space: nowrap;
}

.pocket-overlay-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pocket-overlay-actions .btn-sm {
  font-size: 11px;
  padding: 4px 10px;
}

.pocket-overlay-remove {
  margin-left: auto;
}

.pocket-detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-size: 12px;
  line-height: 1.5;
}

.pocket-detail-grid .detail-label {
  color: var(--text-secondary, #666);
  white-space: nowrap;
}

.pocket-detail-grid .detail-value {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Color Picker */
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  cursor: pointer;
  position: relative;
}

.color-option input[type='radio'] {
  position: absolute;
  opacity: 0;
}

.color-option span {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.color-option:hover span {
  transform: scale(1.1);
}

.color-option input[type='radio']:checked + span {
  border-color: #333;
  box-shadow:
    0 0 0 2px white,
    0 0 0 4px #333;
}

/* Binder Modals */
.binder-settings-modal .modal-content {
  animation: slideUp 0.3s ease-out;
}

/* Card Search Modal */
.card-search-modal {
  max-width: 1200px;
  max-height: 95vh;
  width: 95%;
}

.cs-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(95vh - 60px);
}

.cs-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.cs-search-row .search-box {
  flex: 1;
  margin-bottom: 0;
}

.cs-quick-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.cs-quick-row .filter-section {
  min-width: 0;
}

.cs-quick-row .ownership-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.cs-quick-row .ownership-btn {
  padding: 3px 8px;
  font-size: 12px;
}

.cs-quick-row .language-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Lang filter buttons (mirrors .lang-filter-btn) */
.cs-lang-btn {
  padding: 5px 8px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.cs-lang-btn .flag-icon {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
}

.cs-lang-btn:hover {
  border-color: var(--color-primary);
  background: #f0f4ff;
}

.cs-lang-btn[data-state='include'] {
  background: #e0e7ff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.cs-lang-btn[data-state='exclude'] {
  background: #fee2e2;
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
  opacity: 0.7;
}

.cs-lang-exclusive-btn {
  padding: 5px 10px;
  border: 2px solid var(--border-color);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cs-lang-exclusive-btn:hover {
  border-color: var(--color-primary);
  background: #f0f4ff;
}

.cs-lang-exclusive-btn:hover .exclusive-dot {
  background: #aaa;
}

.cs-lang-exclusive-btn[data-state='include'] {
  background: #fef3c7;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.cs-lang-exclusive-btn[data-state='include'] .exclusive-dot {
  background: #f59e0b;
}

.cs-lang-exclusive-btn[data-state='include'] .exclusive-label {
  color: #b45309;
}

.cs-lang-exclusive-btn[data-state='exclude'] {
  background: #fee2e2;
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
  opacity: 0.7;
}

.cs-lang-exclusive-btn[data-state='exclude'] .exclusive-dot {
  background: #ef4444;
}

.cs-lang-exclusive-btn[data-state='exclude'] .exclusive-label {
  color: #b91c1c;
}

.cs-sort-control {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cs-sort-control .sort-select {
  font-size: 12px;
  padding: 4px 8px;
}

.cs-sort-control .sort-order-toggle-inline {
  padding: 4px 6px;
  font-size: 12px;
}

.cs-advanced-toggle {
  font-size: 12px;
  padding: 4px 12px;
  flex-shrink: 0;
}

.cs-advanced-filters {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-subtle, #fafafa);
}

.cs-advanced-filters .filter-row {
  margin-bottom: 8px;
}

.cs-advanced-filters .filter-group label {
  font-size: 10px;
}

.cs-advanced-filters .filter-group select {
  font-size: 12px;
  padding: 5px 6px;
}

.cs-advanced-filters .filter-section-header {
  margin: 2px 0 8px;
  font-size: 9px;
}

.cs-advanced-filters .pokemon-filter-search,
.cs-advanced-filters .illustrator-filter-search {
  font-size: 11px;
  padding: 4px 6px;
}

/* Card Search Results */
.cs-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 8px;
  flex: 1;
  min-height: 0;
}

#cardSearchResults .card {
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  height: 250px;
}

#cardSearchResults .card .card-image {
  width: 100%;
  aspect-ratio: 3/4;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}

#cardSearchResults .card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #f5f5f5;
}

#cardSearchResults .card:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

#cardSearchResults .card.in-binder {
  opacity: 0.6;
  position: relative;
}

#cardSearchResults .card.in-binder::after {
  content: '📍';
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 20px;
}

/* Page Label Display */
.binder-pages-wrapper {
  position: relative;
}

.page-label-display {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  text-align: center;
  pointer-events: none;
}

.page-label-spread {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
}

.page-label-same-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  user-select: none;
}

.page-label-same-toggle input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.page-label-shared {
  margin-bottom: 4px;
}

.page-label-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 4px;
}

.page-label-field .form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 6px;
  display: block;
}

@media (max-width: 480px) {
  .page-label-dual {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.page-label-pick {
  display: inline-block;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  margin-right: 6px;
  transition: all 0.15s;
}

.page-label-pick:hover {
  border-color: rgba(102, 126, 234, 0.4);
  background: rgba(102, 126, 234, 0.05);
}

.page-label-pick.active {
  background: rgba(102, 126, 234, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

.page-label-merged {
  left: auto;
  right: -20px;
  transform: translateX(50%);
}

.page-label-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 3px 14px;
  display: inline-block;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  box-shadow: 0 1px 4px rgba(102, 126, 234, 0.12);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive Design */
@media (max-width: 768px) {
  .binder-cards-container {
    grid-template-columns: 1fr;
  }

  .page-grid.pockets-layout-4,
  .page-grid.pockets-layout-6,
  .page-grid.pockets-layout-9,
  .page-grid.pockets-layout-12,
  .page-grid.pockets-layout-16 {
    grid-template-columns: repeat(2, 1fr);
  }

  .binder-header-top {
    flex-direction: column;
    gap: 15px;
  }

  .binder-header-top h2 {
    font-size: 22px;
  }

  .view-toggle {
    flex-direction: column;
  }

  .view-toggle button {
    width: 100%;
  }

  /* Spread view stacks vertically on mobile */
  .page-spread-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .page-spine {
    width: 100%;
    height: 4px;
    min-height: 4px;
  }
}

@media (max-width: 480px) {
  .page-grid.pockets-layout-4,
  .page-grid.pockets-layout-6,
  .page-grid.pockets-layout-9,
  .page-grid.pockets-layout-12,
  .page-grid.pockets-layout-16 {
    grid-template-columns: 1fr;
  }

  .pocket-card-image {
    height: 60%;
  }
}

/* Compact Header - Mobile Responsive */
@media (max-width: 768px) {
  .compact-header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }

  .compact-header .header-left h1 {
    font-size: 1.5em;
    text-align: center;
  }

  .compact-header .header-controls {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .compact-header .control-group {
    width: 100%;
    justify-content: space-between;
  }

  .data-source-group {
    flex: 1;
    min-width: 0;
  }

  .ds-local-pill,
  .ds-remote-pill {
    flex: 1;
    min-width: 0;
  }

  .ds-local-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #dataSourceSelect {
    max-width: none;
    flex: 1;
    min-width: 0;
  }

  .compact-header .btn-compact {
    width: 100%;
    justify-content: center;
  }

  .compact-progress-bar {
    flex-direction: column;
    gap: 10px;
  }

  .compact-progress-bar .progress-info {
    width: 100%;
    text-align: center;
  }

  .compact-progress-bar .btn-expand-stats {
    width: 100%;
  }

  /* Mobile header - wrap buttons properly */
  .header-right {
    width: 100%;
  }

  /* Hide long labels on mobile, show icons */
  .ds-empty-label {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
  }

  /* Language switch stays compact on mobile */
  .lang-switch {
    flex-shrink: 0;
  }

  /* Theme switch stays compact on mobile */
  .theme-switch {
    margin-left: auto;
  }

  /* Buttons in a row on mobile */
  .compact-header .header-controls > .btn-compact {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Make Orders button auto-sized */
  .compact-header .header-controls {
    flex-wrap: wrap;
  }

  #ordersBtn {
    flex: 0 0 auto;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .compact-header {
    padding: 12px;
    gap: 12px;
  }

  .brand-name {
    font-size: 1.4em;
  }

  .brand-tagline {
    font-size: 0.65em;
  }

  .brand-mascot {
    width: 50px;
    height: 50px;
  }

  /* Stack data source pills vertically on very small screens */
  .data-source-group {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .ds-local-pill,
  .ds-remote-pill {
    width: 100% !important;
  }

  .ds-empty-label {
    max-width: 100%;
    text-align: center;
  }

  /* Language switch and buttons row */
  .lang-switch {
    order: -1;
    justify-content: center;
    margin-bottom: 8px;
  }

  #ordersBtn {
    flex: 1;
    font-size: 12px;
    padding: 10px 8px;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════
   Page Manager Modal
   ═══════════════════════════════════════════════════════════ */

.page-manager-modal-content {
  /* Was 580px — too narrow on desktop, only ~3 rows visible at once with the
     binder-strip + action bar above the list. Bumped so a typical 13"
     laptop sees 6+ rows while still leaving generous side margins. */
  max-width: 760px;
  width: 90vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.page-manager-modal-content .modal-scrollable-content {
  /* Let the rows fill the available vertical space instead of maxing at the
     legacy modal default — visible row count was the bottleneck. */
  flex: 1;
  min-height: 0;
}

.page-manager-list {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.pm-row:hover {
  background: #f0f4ff;
  border-color: rgba(102, 126, 234, 0.3);
}

.pm-row[draggable='true'] {
  cursor: grab;
}

.pm-row-dragging {
  opacity: 0.4;
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
}

.pm-row-over {
  border: 2px solid var(--color-primary);
  background: #eef2ff;
  padding: 15px 11px;
}

.pm-drag-handle {
  font-size: 16px;
  color: #bbb;
  cursor: grab;
  flex-shrink: 0;
  line-height: 1;
}

.pm-page-num {
  min-width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.pm-label {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: #666;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-count {
  font-size: 11.5px;
  color: #999;
  flex-shrink: 0;
  white-space: nowrap;
}

.pm-thumbs {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.pm-thumb {
  width: 48px;
  height: 66px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #eee;
}

.pm-thumb-missing {
  width: 48px;
  height: 66px;
  border-radius: 4px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.pm-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.pm-btn-move,
.pm-btn-move-binder,
.pm-btn-delete {
  min-width: 28px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.2;
}

.pm-btn-move:disabled {
  opacity: 0.25;
  cursor: default;
}

.pm-btn-move-binder {
  font-size: 14px;
  font-weight: 700;
}

.page-manager-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.page-manager-footer .btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 600px) {
  .pm-drag-handle { display: none; }
  .pm-thumbs { display: none; }
  .pm-row { gap: 6px; padding: 14px 8px; }
  .page-manager-modal-content { max-width: 100%; }
}

/* ─── Transfer Tray ──────────────────────────────────────────
   Floating bottom-right panel that materialises when the user
   drags a card out of a binder pocket onto it. Hidden when empty. */

.transfer-tray {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 950;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: none;
  font-size: 13px;
  overflow: hidden;
}

.transfer-tray.transfer-tray--has-items { display: block; }

/* Toggle-on state for header buttons (used by the remember-last-page
 * pin in the binder-header-top). Visually fills the icon to signal
 * "active" without changing the layout. */
.btn-toggle-on {
  background: var(--color-primary, #6c5ce7);
  color: #fff;
  border-color: var(--color-primary, #6c5ce7);
}
.btn-toggle-on:hover {
  background: var(--color-primary-hover, #5a4ed4);
  border-color: var(--color-primary-hover, #5a4ed4);
}
body.dark-mode .btn-toggle-on {
  background: #a29bfe;
  color: #1e293b;
  border-color: #a29bfe;
}

/* Scope: the tray is only useful while the user is inside the
 * /binders route — outside it (cards / orders / stats / etc.) it's
 * just an irrelevant floating chip. Body is tagged with data-view by
 * the router. */
body:not([data-view="binders"]) .transfer-tray { display: none !important; }

.transfer-tray--drag-over {
  border-color: #6c5ce7;
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.25),
              0 8px 24px rgba(0, 0, 0, 0.2);
}

.transfer-tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: #fff;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.transfer-tray-icon { font-size: 16px; }
.transfer-tray-title { flex: 1; }
.transfer-tray-count {
  background: rgba(255, 255, 255, 0.25);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.transfer-tray-toggle { font-size: 14px; opacity: 0.85; }

.transfer-tray-body {
  display: none;
  padding: 10px;
}
.transfer-tray.transfer-tray--expanded .transfer-tray-body { display: block; }

.transfer-tray-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  /* No fixed max-height — let the parent .transfer-tray-body scroll
     the whole grid. The legacy 280px clip stopped the docked rail
     tray from filling its section. */
  align-content: start;
}

.tray-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  background: rgba(108, 92, 231, 0.06);
  border: 1px solid rgba(108, 92, 231, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tray-item:active { cursor: grabbing; }
.tray-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.tray-item--dragging { opacity: 0.4; }

.tray-item-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  object-fit: cover;
}

.tray-item-restore {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tray-item:hover .tray-item-restore { opacity: 1; }

.tray-item-discard {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--neg, #cc3333) 80%, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.tray-item:hover .tray-item-discard { opacity: 1; }
.tray-item-discard:hover { transform: scale(1.08); }

.tray-item-source {
  display: block;
  font-size: 9px;
  color: #6b7280;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transfer-tray-footer {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

body.dark-mode .transfer-tray {
  background: #161b22;
  border-color: #30363d;
}
body.dark-mode .tray-item {
  background: rgba(162, 155, 254, 0.08);
  border-color: rgba(162, 155, 254, 0.25);
}
body.dark-mode .tray-item-source { color: #989aa2; }

@media (max-width: 640px) {
  .transfer-tray { width: calc(100vw - 32px); bottom: 12px; right: 12px; }
}

/* ─── Page Manager: section grouping ──────────────────────────
   Pages with the same label render under a small section header,
   plus a coloured left border so the run is visually scannable. */

.pm-section-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--pm-section-color, #6c5ce7);
  padding: 14px 4px 4px;
  border-left: 3px solid var(--pm-section-color, #6c5ce7);
  margin-left: 2px;
  padding-left: 10px;
}
.pm-section-header:first-child { padding-top: 4px; }

.pm-row--in-section {
  border-left: 3px solid var(--pm-section-color, transparent);
  padding-left: 9px; /* compensate for the 3px border so content stays aligned */
}

/* ─── Page Manager: multi-select ────────────────────────────── */

.pm-row { cursor: pointer; }

.pm-row--selected {
  background: rgba(108, 92, 231, 0.10);
  outline: 2px solid rgba(108, 92, 231, 0.55);
  outline-offset: -2px;
}
body.dark-mode .pm-row--selected {
  background: rgba(162, 155, 254, 0.18);
  outline-color: rgba(162, 155, 254, 0.6);
}

/* Floating action bar above the page list. Sits inside the modal-scrollable
   region so it scrolls naturally with the content; sticky positioning so it
   stays visible at the top while the user scrolls a long list. */
.pm-action-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.pm-action-bar-count {
  font-weight: 700;
  margin-right: 4px;
}

.pm-action-bar .btn {
  font-size: 12px;
  padding: 6px 10px;
}

.pm-action-bar-deselect {
  margin-left: auto;
}

/* ─── Page Manager: binder strip (drop-on-tile) ────────────── */

.pm-binder-strip {
  /* Stick to the top of .modal-scrollable-content so users can drag a
   * page row from the bottom of the list onto a target binder without
   * having to drag-scroll all the way back up. The strip itself is a
   * sibling of #pageManagerList inside the scrolling viewport, so a
   * plain sticky/top: 0 anchors it correctly. */
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 12px;
  padding: 8px 12px;
  /* Layered background: an opaque base so scrolling rows don't bleed
   * through, plus the original purple tint as an overlay so the visual
   * identity stays the same. */
  background:
    linear-gradient(rgba(108, 92, 231, 0.10), rgba(108, 92, 231, 0.10)),
    #ffffff;
  border: 1px dashed rgba(108, 92, 231, 0.35);
  border-radius: 10px;
}

.pm-binder-strip-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-primary);
  margin-bottom: 6px;
}

.pm-binder-strip-tiles {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.pm-binder-tile {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-elevated, #fff);
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  cursor: copy;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
  min-width: 120px;
}

.pm-binder-tile:hover {
  border-color: rgba(108, 92, 231, 0.45);
}

.pm-binder-tile-icon { font-size: 16px; }

.pm-binder-tile-name {
  font-weight: 600;
  color: var(--text-primary, #333);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-binder-tile-meta {
  font-size: 10px;
  color: var(--text-tertiary, #999);
}

.pm-binder-tile--drag-over {
  border-color: var(--color-primary);
  background: rgba(108, 92, 231, 0.12);
  transform: scale(1.04);
}

.pm-binder-tile--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

body.dark-mode .pm-binder-strip {
  background:
    linear-gradient(rgba(162, 155, 254, 0.10), rgba(162, 155, 254, 0.10)),
    #0d1117;
  border-color: rgba(162, 155, 254, 0.3);
}
body.dark-mode .pm-binder-tile {
  background: #161b22;
  border-color: transparent;
}
body.dark-mode .pm-binder-tile-name { color: #e6edf3; }
body.dark-mode .pm-binder-tile-meta { color: #8b949e; }

/* ─── Page Manager: spread-level actions ────────────────────── */

.pm-action-bar--compact {
  background: transparent;
  box-shadow: none;
  padding: 4px 0 8px;
  justify-content: flex-end;
}
.pm-action-bar--compact .pm-view-toggle {
  /* Lift back to plain neutral when bar is in compact mode (no selection). */
  background: rgba(108, 92, 231, 0.10);
  color: var(--color-primary);
  border: 1px solid rgba(108, 92, 231, 0.3);
}
body.dark-mode .pm-action-bar--compact .pm-view-toggle {
  background: rgba(162, 155, 254, 0.12);
  color: #a29bfe;
  border-color: rgba(162, 155, 254, 0.35);
}

.pm-spread-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 4px 0 12px;
  background: rgba(108, 92, 231, 0.06);
  border-left: 3px solid rgba(108, 92, 231, 0.45);
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}

.pm-spread-actions-label {
  flex: 1;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
}

.pm-spread-actions .btn {
  font-size: 11px;
  padding: 4px 10px;
}

body.dark-mode .pm-spread-actions {
  background: rgba(162, 155, 254, 0.08);
  border-left-color: rgba(162, 155, 254, 0.5);
}
body.dark-mode .pm-spread-actions-label { color: #a29bfe; }

/* ─── Binder header: tray pill ────────────────────────────── */

.binder-tray-pill {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 6px 10px !important;
  position: relative;
  transition: background 0.15s ease;
}

.binder-tray-pill-icon { font-size: 14px; }

.binder-tray-pill-count {
  font-size: 11px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
}

.binder-tray-pill--has-items {
  background: rgba(108, 92, 231, 0.85) !important;
  color: #fff !important;
  animation: trayPulse 1.4s ease-in-out 1;
}
.binder-tray-pill--has-items .binder-tray-pill-count {
  background: rgba(255, 255, 255, 0.32);
}

@keyframes trayPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Tray empty-state — visible only when user opens the empty tray manually
   from the header pill, so the message has context. */
.transfer-tray--empty .transfer-tray-empty-hint {
  margin: 0;
  padding: 14px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary, #888);
  line-height: 1.5;
}

/* ─── Focus-visible polish ───────────────────────────────────
   Keyboard-only focus indicators for the binder surfaces. We use
   :focus-visible so mouse clicks don't draw rings, but Tab traversal
   does — addressing the a11y audit's missing-focus-indicator issue. */

.binder-card:focus-visible,
.binder-card-menu-toggle:focus-visible,
.binder-card-menu-list button:focus-visible,
.binder-card-actions .btn:focus-visible,
.binder-card--create:focus-visible,
.pm-row:focus-visible,
.pm-actions .btn:focus-visible,
.pm-thumb-draggable:focus-visible,
.pm-binder-tile:focus-visible,
.binder-tray-pill:focus-visible,
.tray-item:focus-visible,
.tray-item-restore:focus-visible {
  outline: 2px solid var(--color-primary, #6c5ce7);
  outline-offset: 2px;
  z-index: 1;
}

body.dark-mode .binder-card:focus-visible,
body.dark-mode .binder-card-menu-toggle:focus-visible,
body.dark-mode .binder-card--create:focus-visible,
body.dark-mode .pm-row:focus-visible,
body.dark-mode .pm-binder-tile:focus-visible,
body.dark-mode .binder-tray-pill:focus-visible {
  outline-color: #a29bfe;
}

/* Honour reduced-motion preferences for the entire binder UI. Cuts the
   hover lifts, the trayPulse animation, and the modal slide-ins. */
@media (prefers-reduced-motion: reduce) {
  .binder-card,
  .binder-card--create,
  .binder-card-menu-toggle,
  .binder-card-menu-list button,
  .binder-card-actions .btn,
  .pm-row,
  .pm-binder-tile,
  .pm-thumb-draggable,
  .tray-item,
  .binder-tray-pill,
  .binder-tray-pill--has-items,
  .transfer-tray,
  .transfer-tray-header {
    transition: none !important;
    animation: none !important;
  }
  .binder-card:hover,
  .binder-card--create:hover,
  .pm-binder-tile--drag-over,
  .tray-item:hover {
    transform: none !important;
  }
}
