/* ══════════════════════════════════════════════════════════════════
   CODEX BINDER VIEWS (redesign step 8)
   See design_handoff_codex_redesign/README.md §Per-view specs · Binders.

   CSS-only restyle of:
     - Binder list view (#binderListView): grid of binder cards with
       mini-mosaic preview + progress bar.
     - Binder detail view (#binderDetailView): header (back / name /
       tools) + stats bar + spread + available-cards tray.

   Deferred (DEFERRED.md):
     - Strip the binder list rail in detail view (it already doesn't
       exist in the live markup, so no-op).
     - Pocket layout selector currently lives in the spread header
       toolbar. Codex spec wants it moved to the Edit Binder modal —
       JS restructure deferred.
   ══════════════════════════════════════════════════════════════════ */

/* ── Binder list view header ──────────────────────────────────────── */
#binderListView .binder-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 20px;
  margin: 0;
}
#binderListView .binder-list-header h2 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0;
}
#binderListView .binder-list-header .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  background-image: none;
  box-shadow: none;
}
#binderListView .binder-list-header .btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 90%, white);
}

/* Grid of binder cards. */
#binderListView .binder-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Individual binder card. */
#binderListView .binder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
  background-image: none;
  box-shadow: none;
  color: var(--text);
}
#binderListView .binder-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  box-shadow: var(--shadow-tile-hover);
}

#binderListView .binder-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
#binderListView .binder-card-title {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#binderListView .binder-card-menu-toggle {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
}
#binderListView .binder-card-menu-toggle:hover {
  background: var(--surface2);
  color: var(--text);
}

#binderListView .binder-card-thumbs {
  display: grid;
  /* Drop from 6 to 4 columns → each thumb ~50% wider; combined with
     reduced gaps it lands near the user's "~75% bigger" ask. */
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
  background: var(--surface2);
  border-radius: var(--radius-md);
  padding: 8px;
  min-height: 80px;
  align-items: center;
  /* Center the thumb row inside the container — fewer columns means
     the thumbs sometimes don't fill a row (e.g. binders with only
     1-3 cards). */
  justify-content: center;
  justify-items: center;
}
#binderListView .binder-card-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1.39;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
#binderListView .binder-card-thumbs--empty {
  display: flex;
  align-items: center;
  justify-content: center;
}
#binderListView .binder-card-thumbs-empty-msg {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-mute);
}

#binderListView .binder-card-location {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* Binder card progress bar. */
#binderListView .binder-card .binder-progress-track,
#binderListView .binder-card .progress-bar {
  background: var(--surface3);
  border-radius: 2px;
  height: 4px;
  overflow: hidden;
}
#binderListView .binder-card .binder-progress-fill,
#binderListView .binder-card .progress-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Binder detail view — Codex header ────────────────────────────── */
#binderDetailView .binder-header {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 0 14px;
  margin-bottom: 14px;
}

#binderDetailView .binder-header-row {
  /* 3-column grid so the spread-title can sit in the middle column,
     truly centred between the info pills on the left and the tools
     cluster on the right. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

#binderDetailView .binder-header-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

/* "‹ Tous les classeurs" — back-to-list affordance. Was a near-
   invisible flat text button; now a proper pill so the user has an
   obvious navigation handle out of the binder detail view. */
#binderDetailView .binder-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#binderDetailView .binder-back-link:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--accent);
}

#binderDetailView .binder-id-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#binderDetailView .binder-id-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
#binderDetailView .binder-id-sep {
  color: var(--text-mute);
}
#binderDetailView #binderName {
  color: var(--text);
}

#binderDetailView .binder-spread-title {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0;
  justify-self: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#binderDetailView .binder-spread-sub {
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  margin-left: 4px;
}

/* Tools cluster (right). */
#binderDetailView .binder-header-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
#binderDetailView .binder-tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 3px;
}

/* Spread/Single segmented toggle. */
#binderDetailView .binder-view-toggle {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
#binderDetailView .binder-view-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
#binderDetailView .binder-view-btn:hover {
  color: var(--text);
}
#binderDetailView .binder-view-btn.active {
  background: var(--surface3);
  color: var(--text);
}

#binderDetailView .binder-tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  background-image: none;
  box-shadow: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#binderDetailView .binder-tool-icon:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border-hi);
}
#binderDetailView .binder-tool-icon[aria-pressed='true'] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

#binderDetailView .binder-page-indicator {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 0 8px;
  white-space: nowrap;
}

#binderDetailView .binder-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background-image: none;
  box-shadow: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
#binderDetailView .binder-tool-btn:hover {
  background: var(--surface2);
  border-color: var(--border-hi);
}

#binderDetailView .binder-tray-pill {
  width: auto !important;
  height: 30px;
  padding: 0 8px !important;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
#binderDetailView .binder-tray-pill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

/* Thin fill progress line under the header. */
#binderDetailView .binder-progress-line {
  height: 3px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
}
#binderDetailView .binder-progress-line .progress-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Per-page header (p.NN + label + actions) ─────────────────────── */
#binderDetailView .binder-page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 8px;
}
#binderDetailView .binder-page-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}
#binderDetailView .binder-page-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
/* .binder-page-label-tag removed — only the .page-label-text label
   itself is rendered now. */
#binderDetailView .binder-page-label-wrap .page-label-text {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#binderDetailView .binder-page-label-add {
  color: var(--text-mute) !important;
  font-weight: 400 !important;
  cursor: pointer;
}
#binderDetailView .binder-page-label-add:hover {
  color: var(--accent) !important;
}
#binderDetailView .binder-page-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
#binderDetailView .binder-page-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--text-mute);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
#binderDetailView .binder-page-action:hover {
  background: var(--surface2);
  color: var(--text);
}
#binderDetailView .binder-page-clear:hover {
  color: var(--neg);
}

/* Single-page mode: collapse the spread grid to one centered page. */
#binderDetailView .page-spread-grid--single {
  grid-template-columns: minmax(0, 720px) !important;
  justify-content: center;
}
#binderDetailView .page-spread-grid--single .page-spine,
#binderDetailView .page-spread-grid--single .page-spread-half:last-child {
  display: none;
}

/* Page navigator ellipsis token. */
#binderDetailView .page-nav-ellipsis {
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 6px;
  align-self: center;
}

/* Codex step 8: page navigator strip. The mono spread groupings
   ([1] [2-3] [4-5] ... [last]) are produced by binderView.js
   updateNavigator; this is the chrome. */
#binderDetailView .page-navigator {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

#binderDetailView .page-navigator::-webkit-scrollbar {
  height: 4px;
}
#binderDetailView .page-navigator::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

#binderDetailView .page-number-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
#binderDetailView .page-number-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
#binderDetailView .page-number-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}
#binderDetailView .page-navigator span {
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Binder spread / pages container. */
#binderDetailView .binder-spread,
#binderDetailView .page-grid,
#binderDetailView .binder-page-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

#binderDetailView .pocket {
  background: var(--surface2);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-md);
}

/* Override the dark-mode hardcoded backgrounds for binder elements. */
body.dark-mode #binderListView .binder-card,
body.dark-mode #binderDetailView .binder-header {
  background: var(--surface);
  border-color: var(--border);
}
body.dark-mode #binderDetailView .binder-header {
  border-top-color: var(--accent);
}
body.dark-mode #binderDetailView .binder-spread,
body.dark-mode #binderDetailView .page-grid,
body.dark-mode #binderDetailView .binder-page-block {
  background: var(--surface);
  border-color: var(--border);
}
body.dark-mode #binderDetailView .pocket {
  background: var(--surface2);
  border-color: var(--border-hi);
}

/* ── Codex right rail (Available cards + transfer tray) — step 8 ──── */
/* The right rail lives inside #binderDetailView .binder-spread-layout
   as a true flex sibling of the binder spread, NOT a floating
   overlay. Markup in index.html — this file styles the chrome. */

#binderDetailView .binder-spread-layout {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 0;
}
#binderDetailView .binder-spread-main {
  flex: 1;
  min-width: 0;
  /* Cap the spread width based on the available viewport height so
     the cards grow as tall as possible while keeping every pocket
     in-viewport. Width = (vh − chrome) × spread aspect ratio, where
     the spread aspect ratio depends on the pockets-per-page layout:
       layout-4  (2×2): spread 4×2 → 6:4 = 1.5
       layout-9  (3×3): spread 6×3 → 9:9 = 1.0  → but each card is 3:4
                                                  so practical ratio
                                                  ≈ (6×3)/(3×4) = 1.5
       layout-16 (4×4): same 3:2 family
       layout-12 (4×3): spread 8×3 → wider, allow 2.0
       layout-6  (3×2): spread 6×2 → wider still, allow 2.25
       layout-1  (1×1): very narrow → 0.75 keeps a single card sane
     Falls back to the 1.5 default — covers 4/9/16, the most common
     layouts. Each per-layout override below specialises. */
  max-width: calc((100vh - 220px) * 1.5);
  margin: 0 auto;
}
#binderDetailView .binder-spread-main:has(.pockets-layout-12) {
  max-width: calc((100vh - 220px) * 2);
}
#binderDetailView .binder-spread-main:has(.pockets-layout-6) {
  max-width: calc((100vh - 220px) * 2.25);
}
#binderDetailView .binder-spread-main:has(.pockets-layout-1) {
  max-width: calc((100vh - 220px) * 0.75);
}
/* Single-page mode shows one page instead of two — halve the
   horizontal multiplier so the page itself fills the right amount of
   width without leaving the cards squished vertically. */
#binderDetailView .binder-spread-main:has(.page-spread-grid--single) {
  max-width: calc((100vh - 220px) * 0.75);
}
#binderDetailView .binder-spread-main:has(.page-spread-grid--single):has(.pockets-layout-12) {
  max-width: calc((100vh - 220px) * 1);
}
#binderDetailView .binder-spread-main:has(.page-spread-grid--single):has(.pockets-layout-6) {
  max-width: calc((100vh - 220px) * 1.125);
}
#binderDetailView .binder-spread-main .binder-pages-wrapper {
  margin: 0;
}

#binderDetailView .binder-rail {
  flex: 0 0 300px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-sans);
  overflow: hidden;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 120px);
}

#binderDetailView .binder-rail.binder-rail--collapsed {
  flex-basis: 36px;
  align-items: center;
}
#binderDetailView .binder-rail.binder-rail--collapsed > *:not(.binder-rail-header) {
  display: none;
}
#binderDetailView .binder-rail.binder-rail--collapsed .binder-rail-header {
  writing-mode: vertical-rl;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 16px 8px;
  background: transparent;
  border: 0;
  text-align: center;
}
#binderDetailView .binder-rail.binder-rail--collapsed .binder-rail-collapse {
  transform: rotate(180deg);
}

#binderDetailView .binder-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
#binderDetailView .binder-rail-header:hover {
  color: var(--text);
}
#binderDetailView .binder-rail-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#binderDetailView .binder-rail-sep {
  color: var(--text-mute);
}
#binderDetailView .binder-rail-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0;
}
#binderDetailView .binder-rail-collapse {
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: transform 0.2s ease;
}

#binderDetailView .binder-rail-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
#binderDetailView .binder-rail-search-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text-dim);
}
#binderDetailView .binder-rail-search-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 5px 9px;
  outline: none;
}
#binderDetailView .binder-rail-search-input:focus {
  border-color: var(--accent);
}

/* .binder-rail-highlight removed — rail-card status borders are now
   always on (no per-user toggle). */

#binderDetailView .binder-rail-available {
  flex: 1;
  min-height: 80px;
  /* No fixed max-height — the section body controls vertical extent
     via flex now; the grid scrolls inside whatever room is left. */
  overflow-y: auto;
  padding: 8px 0 0;
  display: grid;
  /* 2 columns so each thumb is big enough to read the card design
     even at modest counts. Explicit grid-auto-rows keeps each row at
     its natural max-content height — combined with align-content:start
     in a flex parent the implicit rows were collapsing to ~2.5px. */
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  gap: 6px;
}
#binderDetailView .binder-rail-empty {
  grid-column: 1 / -1;
  padding: 24px 12px;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
#binderDetailView .binder-rail-overflow {
  grid-column: 1 / -1;
  padding: 8px 4px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
}

#binderDetailView .binder-rail-card {
  position: relative;
  aspect-ratio: 1 / 1.39;
  cursor: grab;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid transparent;
  background: var(--surface2);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
#binderDetailView .binder-rail-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-hi);
}
#binderDetailView .binder-rail-card--highlight {
  outline: 1.5px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -1px;
}
/* Status borders in the "Ajouter" area: blue tint when the card is
   already placed in another binder, neutral when it's free to drop.
   The "in this binder" area uses a green tint. */
#binderDetailView .binder-rail-card--in-other {
  border-color: color-mix(in srgb, var(--cool) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cool) 25%, transparent);
}
#binderDetailView .binder-rail-card--in-other:hover {
  border-color: var(--cool);
}
#binderDetailView .binder-rail-card--in-this {
  cursor: pointer;
  border-color: color-mix(in srgb, var(--pos) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--pos) 25%, transparent);
}
#binderDetailView .binder-rail-card--in-this:hover {
  border-color: var(--pos);
}
/* Pin banner — shows above the "Ajouter" grid when the user has
   picked cards in the cardSearchModal. */
#binderDetailView .binder-rail-pin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--accent);
}
#binderDetailView .binder-rail-pin-banner[hidden] {
  display: none;
}
#binderDetailView .binder-rail-pin-banner strong {
  color: var(--text);
  font-weight: 600;
}
#binderDetailView .binder-rail-pin-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
#binderDetailView .binder-rail-pin-clear:hover {
  background: var(--surface3);
  color: var(--text);
}

/* --not-owned: card we don't own yet but plan to file here. Subdued
   warm border so it reads as "planning" without competing with the
   owned/in-another statuses. */
#binderDetailView .binder-rail-card--not-owned {
  border-color: color-mix(in srgb, var(--warm) 35%, var(--border));
  opacity: 0.7;
}
#binderDetailView .binder-rail-card--not-owned:hover {
  border-color: var(--warm);
  opacity: 1;
}
#binderDetailView .binder-rail-card-page {
  position: absolute;
  top: 3px;
  left: 3px;
  padding: 1px 5px;
  background: color-mix(in srgb, var(--pos) 70%, rgba(0, 0, 0, 0.55));
  color: #fff;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}

/* ── Rail section structure (collapsable) ───────────────────────── */
/* The rail aside is already display: flex; flex-direction: column
   (see #binderDetailView .binder-rail above). Sections share the
   available vertical space — expanded ones grow, collapsed ones
   shrink to title height. */
#binderDetailView .binder-rail-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
#binderDetailView .binder-rail-section:last-of-type {
  border-bottom: 0;
}
/* Uncollapsed sections share the available vertical evenly; collapsed
   sections shrink to their title row only. */
#binderDetailView .binder-rail-section:not(.binder-rail-section--collapsed) {
  flex: 1 1 0;
}
#binderDetailView .binder-rail-section--collapsed {
  flex: 0 0 auto;
}
#binderDetailView .binder-rail-section-title {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 10px 12px;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
#binderDetailView .binder-rail-section-title:hover {
  color: var(--text);
  background: var(--surface2);
}
#binderDetailView .binder-rail-section-title .binder-rail-sep {
  color: var(--text-mute);
}
#binderDetailView .binder-rail-section-title .binder-rail-count {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-mute);
}

/* Missing-pockets filter chip — sits in the "In this binder" section
   title to the right of the count, toggles a filter that surfaces only
   cards whose pocket is still waiting for an owned-instance link. */
#binderDetailView .binder-rail-missing-chip {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px 1px 5px;
  border-radius: var(--radius-full);
  border: 1px solid var(--binder-chip-border, rgba(217, 119, 6, 0.45));
  background: var(--binder-chip-bg, rgba(217, 119, 6, 0.1));
  color: var(--binder-chip-fg, #b45309);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, transform 0.15s;
}
#binderDetailView .binder-rail-missing-chip:hover:not(:disabled) {
  background: var(--binder-chip-bg-hover, rgba(217, 119, 6, 0.2));
  transform: translateY(-1px);
}
#binderDetailView .binder-rail-missing-chip.is-active {
  background: var(--binder-chip-bg-active, #d97706);
  border-color: var(--binder-chip-bg-active, #d97706);
  color: #fff;
  box-shadow: 0 1px 4px rgba(217, 119, 6, 0.35);
}
#binderDetailView .binder-rail-missing-chip:disabled {
  opacity: 0.45;
  cursor: default;
}
#binderDetailView .binder-rail-missing-chip .binder-rail-missing-icon {
  font-size: 10px;
  line-height: 1;
  opacity: 0.85;
}

/* Lang flag overlay on rail thumbs — only shown when the missing
   filter is on, so (cardId, lang) variants are distinguishable. */
#binderDetailView .binder-rail-card-lang-flag {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 12px;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}

#binderDetailView .binder-rail-section-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#binderDetailView .binder-rail-section-title-row > .binder-rail-section-title {
  flex: 1 1 auto;
  min-width: 0;
}

#binderDetailView .binder-rail-section-chevron {
  display: inline-flex;
  width: 12px;
  font-size: 11px;
  color: var(--text-mute);
  transition: transform 0.15s ease;
}
#binderDetailView .binder-rail-section--collapsed .binder-rail-section-chevron {
  transform: rotate(-90deg);
}
#binderDetailView .binder-rail-section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 10px;
  /* Let the body fill the remaining section height so the inner
     .binder-rail-available scroll-grid uses the available space. */
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#binderDetailView .binder-rail-section--collapsed .binder-rail-section-body {
  display: none;
}

/* Inline ✕ clear button inside the rail search rows. Hidden until
   the input has text (toggled by JS). */
#binderDetailView .binder-rail-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 2px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: var(--text-mute);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
#binderDetailView .binder-rail-clear-btn:hover {
  background: var(--surface3);
  color: var(--text);
}
#binderDetailView .binder-rail-clear-btn[hidden] {
  display: none;
}

/* Inline advanced-search trigger in the add-cards row. */
#binderDetailView .binder-rail-adv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#binderDetailView .binder-rail-adv-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border-hi);
}
#binderDetailView .binder-rail-card--dragging {
  opacity: 0.4;
}
#binderDetailView .binder-rail-card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface2);
}
#binderDetailView .binder-rail-card-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 4px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

#binderDetailView .binder-rail-tray {
  border-top: 1px solid var(--border);
  /* Reset legacy fixed-positioning rules when the tray lives inside the rail. */
  position: static !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: auto !important;
  max-height: none !important;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  flex: 0 0 auto;
  overflow: visible;
  visibility: visible !important;
  opacity: 1 !important;
  display: none;
}
#binderDetailView .binder-rail-tray.transfer-tray--has-items,
#binderDetailView .binder-rail-tray.transfer-tray--empty {
  display: flex !important;
  flex-direction: column;
}

#binderDetailView .binder-rail-hint {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mute);
  line-height: 1.4;
  letter-spacing: 0;
}

.transfer-tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
}
.transfer-tray-icon {
  font-size: 14px;
}
.transfer-tray-title {
  flex: 1;
}
.transfer-tray-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0;
}
.transfer-tray-toggle {
  color: var(--text-dim);
  transition: transform 0.2s ease;
}
.transfer-tray--expanded .transfer-tray-toggle {
  transform: rotate(180deg);
}

.transfer-tray-body {
  display: block !important;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.transfer-tray-empty-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  padding: 18px 14px;
  text-align: center;
  line-height: 1.5;
}

.transfer-tray-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.transfer-tray-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* Drop-over hover state — accent glow. */
.transfer-tray--drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), var(--shadow-modal);
}

/* The legacy header pill (#binderTrayPill) becomes redundant when the
   rail is visible — hide it on wide screens. */
@media (min-width: 1281px) {
  body.binder-detail-active #binderTrayPill {
    display: none;
  }
}

/* On narrower screens, fall back to a stacked layout: rail drops below
   the spread instead of taking horizontal width. */
@media (max-width: 1280px) {
  #binderDetailView .binder-spread-layout {
    flex-direction: column;
  }
  #binderDetailView .binder-rail {
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
    position: static;
  }
  #binderDetailView .binder-rail-available {
    max-height: 280px;
  }
}

/* ── Binder Settings + Page Manager modals: Codex chrome ──────────── */
/* Both modals were dark-themed already but the chrome (modal frame,
   color picker, action buttons, form fields) still reads as legacy.
   The overrides below align them with the Codex modal aesthetic
   used by #cardModal and #orderDetailModal. */

body.dark-mode #binderSettingsModal .modal-content,
body.dark-mode #pageManagerModal .modal-content {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
}
body.dark-mode #binderSettingsModal .modal-header,
body.dark-mode #pageManagerModal .modal-header {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
body.dark-mode #binderSettingsModal .modal-header h2,
body.dark-mode #pageManagerModal .modal-header h2 {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
body.dark-mode #binderSettingsModal .modal-close,
body.dark-mode #pageManagerModal .modal-close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 20px;
}
body.dark-mode #binderSettingsModal .modal-close:hover,
body.dark-mode #pageManagerModal .modal-close:hover {
  color: var(--text);
}

/* Form labels + inputs */
body.dark-mode #binderSettingsModal .form-label,
body.dark-mode #binderSettingsModal legend.form-label {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
body.dark-mode #binderSettingsModal .form-control {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
}
body.dark-mode #binderSettingsModal .form-control:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Color picker: replace legacy bright palette with Codex tones. The
   radio values stay as-is in markup (hex literals stored in binder
   state), but the swatch chrome adopts the Codex check-style ring on
   the selected option. */
body.dark-mode #binderSettingsModal .color-option span {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  box-shadow: none;
}
body.dark-mode #binderSettingsModal .color-option input[type='radio']:checked + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--bg), 0 0 0 2px var(--accent);
}
body.dark-mode #binderSettingsModal .color-option:hover span {
  transform: none;
  border-color: var(--accent);
}

/* Pocket layout radios: Codex tone */
body.dark-mode #binderSettingsModal input[type='radio'] {
  accent-color: var(--accent);
}

/* Action buttons */
body.dark-mode #binderSettingsModal .btn-primary,
body.dark-mode #pageManagerModal .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background-image: none;
  box-shadow: none;
  font-family: var(--font-sans);
  font-weight: 600;
}
body.dark-mode #binderSettingsModal .btn-primary:hover,
body.dark-mode #pageManagerModal .btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, white);
}
body.dark-mode #binderSettingsModal .btn-secondary,
body.dark-mode #pageManagerModal .btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-image: none;
  box-shadow: none;
}
body.dark-mode #binderSettingsModal .btn-secondary:hover,
body.dark-mode #pageManagerModal .btn-secondary:hover {
  background: var(--surface3);
  border-color: var(--border-hi);
}

/* Page Manager: row chrome + danger actions */
body.dark-mode #pageManagerModal .page-manager-row,
body.dark-mode #pageManagerModal .page-manager-list > * {
  background: var(--surface);
  border-color: var(--border);
}
/* "Première cartes" / "DOUBLE-PAGE 2-3" group headers — neutralise the
   legacy purple/red bar background; use a subtle border-left accent
   instead so the divider role stays clear without competing. */
body.dark-mode #pageManagerModal .page-manager-section-header,
body.dark-mode #pageManagerModal .page-manager-double-header,
body.dark-mode #pageManagerModal [class*='page-header'],
body.dark-mode #pageManagerModal .double-page-bar {
  background: var(--surface2) !important;
  background-image: none !important;
  border-left: 2px solid var(--accent);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 5px;
}

/* Destructive page actions (Supprimer la page, Supprimer la double-page)
   were styled as red-gradient buttons. Codex danger: surface bg + neg
   text + dashed neg border on hover. */
body.dark-mode #pageManagerModal .btn-danger,
body.dark-mode #pageManagerModal button[class*='supprimer'],
body.dark-mode #pageManagerModal .page-manager-row .btn[class*='danger'] {
  background: var(--surface2) !important;
  background-image: none !important;
  color: var(--neg) !important;
  border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent) !important;
  border-radius: var(--radius-md);
  box-shadow: none !important;
  font-family: var(--font-sans);
  font-weight: 500;
}
body.dark-mode #pageManagerModal .btn-danger:hover {
  background: color-mix(in srgb, var(--neg) 10%, var(--surface2)) !important;
  border-color: var(--neg) !important;
}

/* Page Manager footer (Ajouter une page) */
body.dark-mode #pageManagerModal .page-manager-footer {
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
}

/* ── Instance selection modal (choose an owned copy) ──────────────── */
#instanceSelectionModal .instance-section-label {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 12px 0 6px;
}
#instanceSelectionModal .instance-section-label--placeholder {
  margin-top: 18px;
}
#instanceSelectionModal .instance-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
#instanceSelectionModal .instance-picker-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
#instanceSelectionModal .instance-picker-row:hover {
  background: var(--surface2);
  border-color: var(--accent);
}
#instanceSelectionModal .instance-picker-row:active {
  transform: translateY(1px);
}
#instanceSelectionModal .instance-picker-row--locked {
  opacity: 0.45;
  cursor: not-allowed;
}
#instanceSelectionModal .instance-picker-row--locked:hover {
  background: var(--surface);
  border-color: var(--border);
}
#instanceSelectionModal .instance-picker-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
#instanceSelectionModal .instance-picker-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
}
#instanceSelectionModal .instance-picker-lang .flag-icon,
#instanceSelectionModal .instance-picker-lang img {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  display: inline-block;
}
#instanceSelectionModal .instance-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#instanceSelectionModal .instance-picker-chip {
  display: inline-block;
  padding: 2px 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text);
}
#instanceSelectionModal .instance-picker-chip--muted {
  color: var(--text-dim);
  font-family: var(--font-sans);
  text-transform: none;
}
#instanceSelectionModal .instance-picker-notes {
  font-style: italic;
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 2px;
}
#instanceSelectionModal .instance-picker-locked {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neg);
}

/* Placeholder (not-owned) language grid. */
#instanceSelectionModal .instance-picker-lang-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#instanceSelectionModal .instance-picker-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
#instanceSelectionModal .instance-picker-lang-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}
#instanceSelectionModal .instance-picker-lang-flag img,
#instanceSelectionModal .instance-picker-lang-flag .flag-icon {
  width: 20px;
  height: 14px;
  border-radius: 2px;
  display: block;
}

/* ── Pocket overlay lang picker (Codex flag chips) ────────────────── */
#binderDetailView .pocket-overlay .pocket-lang-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
#binderDetailView .pocket-overlay .pocket-lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 24px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
#binderDetailView .pocket-overlay .pocket-lang-btn:hover {
  opacity: 0.9;
  border-color: var(--border-hi);
}
#binderDetailView .pocket-overlay .pocket-lang-btn.active {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-dim);
}
#binderDetailView .pocket-overlay .pocket-lang-btn .flag-icon,
#binderDetailView .pocket-overlay .pocket-lang-btn img {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  display: block;
}

/* ── Pocket overlay (click a placed card) — Codex chrome ──────────── */
/* Always-on Codex skin (not gated to dark mode) — the legacy overlay
   styling in binders.css uses indigo + thick ringed accent that
   never fit. Light theme inherits codex tokens via codex-light-theme. */
#binderDetailView .pocket-overlay,
.pocket-overlay {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 12px;
  box-shadow: var(--shadow-modal);
  width: 320px;
}
#binderDetailView .pocket-overlay::after,
.pocket-overlay::after {
  background: var(--surface);
  border-color: var(--border);
}
/* Status pill at the top of the header. */
.pocket-overlay-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pocket-overlay-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.pocket-overlay-status--owned {
  background: color-mix(in srgb, var(--pos) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--pos) 45%, transparent);
  color: var(--pos);
}
.pocket-overlay-status--owned .pocket-overlay-status-dot {
  background: var(--pos);
}
.pocket-overlay-status--placeholder {
  background: color-mix(in srgb, var(--warm) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--warm) 45%, transparent);
  color: var(--warm);
}
.pocket-overlay-status--placeholder .pocket-overlay-status-dot {
  background: var(--warm);
}
/* Header: status pill stacked above title, "Détails" link on the right. */
#binderDetailView .pocket-overlay .pocket-overlay-header,
.pocket-overlay .pocket-overlay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-right: 22px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pocket-overlay-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.pocket-overlay-details {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pocket-overlay-details:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}
/* Section labels (e.g. "Langue") inside the overlay. */
.pocket-overlay-section {
  margin-top: 10px;
}
.pocket-overlay-section-label {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 6px;
}
/* Actions: primary full-width on top, secondary row below. */
#binderDetailView .pocket-overlay-actions,
.pocket-overlay .pocket-overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.pocket-overlay-primary {
  width: 100%;
  justify-content: center;
}
.pocket-overlay-secondary-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pocket-overlay-secondary-row .btn-sm {
  flex: 1;
  white-space: nowrap;
}

body.dark-mode #binderDetailView .pocket-overlay,
body.dark-mode .pocket-overlay {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
}
body.dark-mode #binderDetailView .pocket-overlay::after,
body.dark-mode .pocket-overlay::after {
  background: var(--surface);
  border-color: var(--border-hi);
}
body.dark-mode .pocket-overlay-title {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
body.dark-mode .pocket-overlay-close {
  color: var(--text-dim);
}
body.dark-mode .pocket-overlay-close:hover {
  color: var(--text);
}
body.dark-mode .pocket-overlay .pocket-detail-grid .detail-label {
  color: var(--text-mute);
  font-family: var(--font-sans);
  font-size: 11px;
}
body.dark-mode .pocket-overlay .pocket-detail-grid .detail-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
body.dark-mode .pocket-overlay .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  background-image: none;
  box-shadow: none;
}
body.dark-mode .pocket-overlay .btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  background-image: none;
  box-shadow: none;
}
body.dark-mode .pocket-overlay .btn-secondary:hover {
  background: var(--surface3);
}
body.dark-mode .pocket-overlay .btn-danger {
  background: var(--surface2);
  color: var(--neg);
  border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent);
  background-image: none;
  box-shadow: none;
}
body.dark-mode .pocket-overlay .btn-danger:hover {
  background: color-mix(in srgb, var(--neg) 10%, var(--surface2));
  border-color: var(--neg);
}

/* ── In-binder search / filter panel — Codex chrome ───────────────── */
body.dark-mode #binderDetailView .binder-search-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
body.dark-mode #binderDetailView .binder-search-filter .search-box,
body.dark-mode #binderDetailView .binder-search-filter .form-control-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 12px;
}
body.dark-mode #binderDetailView .binder-search-filter .search-box:focus,
body.dark-mode #binderDetailView .binder-search-filter .form-control-sm:focus {
  border-color: var(--accent);
  outline: none;
}
body.dark-mode #binderDetailView .binder-search-filter .btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  background-image: none;
  box-shadow: none;
}
body.dark-mode #binderDetailView .binder-search-filter .btn-secondary:hover {
  background: var(--surface3);
  border-color: var(--border-hi);
}
body.dark-mode #binderDetailView .binder-filter-label {
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
body.dark-mode #binderDetailView .binder-search-filter #binderSearchResults {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Binder export dropdown */
#binderDetailView .binder-documents-menu {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 4px;
}
#binderDetailView .binder-documents-menu button {
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
}
#binderDetailView .binder-documents-menu button:hover {
  background: var(--surface2);
}
