/* The settings preview follows the selected theme without changing the binder
   behind an unsaved form. Shared controls keep the same structure in all three. */
.binder-settings-modal {
  --settings-bg: #171e2c; --settings-field: #101621; --settings-line: #364152;
  --settings-text: #f4f5f7; --settings-muted: #aab4c3; --settings-accent: #e8b54a;
  --settings-font: 'Archivo', ui-sans-serif, system-ui, sans-serif;
  --settings-radius: 12px; --settings-shadow: 0 24px 70px rgba(0,0,0,.45);
  --settings-button-text: var(--settings-field);
}

#modalRoot .modal.binder-settings-modal {
  width: min(760px, 100%); padding: 24px;
  background: var(--settings-bg) !important; color: var(--settings-text) !important;
  border: 1px solid var(--settings-line) !important; border-image: none !important;
  border-radius: var(--settings-radius) !important; box-shadow: var(--settings-shadow) !important;
  font-family: var(--settings-font);
}
#modalRoot .binder-settings-modal h3 { color: var(--settings-text) !important; padding-right: 40px; margin-bottom: 24px; }

.binder-settings-layout { display: grid; grid-template-columns: minmax(0,1fr) 180px; gap: 24px; }
.binder-settings-fields { grid-template-columns: minmax(0,1fr); gap: 14px; min-width: 0; }
#modalRoot .binder-settings-modal .field label { color: var(--settings-muted) !important; font-size: 12px; font-weight: 700; }
#modalRoot .binder-settings-modal .field :is(input:not([type="checkbox"]), textarea, select),
#modalRoot .binder-settings-modal :is(.custom-select-trigger,.custom-select-menu,.custom-select-option) {
  background: var(--settings-field) !important; color: var(--settings-text) !important;
  border-color: var(--settings-line) !important; border-radius: var(--settings-radius) !important;
  font-family: var(--settings-font); font-size: 13px;
}
#modalRoot .binder-settings-modal .field :is(input,textarea) { padding: 11px 12px; }
#modalRoot .binder-settings-modal .field textarea { min-height: 72px; resize: vertical; }
#modalRoot .binder-settings-modal textarea::placeholder { color: var(--settings-muted); opacity: .75; }
#modalRoot .binder-settings-modal .custom-select-trigger { min-height: 44px; box-shadow: none !important; }
#modalRoot .binder-settings-modal .custom-select-option:hover,
#modalRoot .binder-settings-modal .custom-select-option.selected { background: color-mix(in srgb,var(--settings-accent) 16%,var(--settings-field)) !important; }
.binder-settings-modal .binder-size-presets { gap: 8px; }
#modalRoot .binder-settings-modal .binder-size-preset {
  min-width: 0; padding: 9px 5px; background: var(--settings-field) !important;
  color: var(--settings-text) !important; border: 1px solid var(--settings-line) !important;
  border-radius: var(--settings-radius) !important; box-shadow: none !important;
}
#modalRoot .binder-settings-modal .binder-size-preset.selected { border-color: var(--settings-accent) !important; background: color-mix(in srgb,var(--settings-accent) 12%,var(--settings-field)) !important; }
#modalRoot .binder-settings-modal .binder-size-copy small { color: var(--settings-muted) !important; }
#modalRoot .binder-settings-modal .binder-size-pocket-preview i { background: var(--settings-line); border-color: var(--settings-line); }
/* Daytime previews use the same cream paper and crisp ink as the pixel menu,
   rather than inheriting the classic/night preview's dark binder frame. */

.binder-settings-modal .check-row { padding-top: 0; align-items: stretch; }
#modalRoot .binder-settings-modal .binder-auto-prices { min-height: 44px; display: flex; align-items: center; gap: 12px; color: var(--settings-text) !important; cursor: pointer; }
.binder-auto-prices input {
  appearance: none; position: relative; width: 24px; height: 24px; flex: none; margin: 0;
  border: 2px solid var(--settings-line); border-radius: var(--settings-radius);
  background: var(--settings-field); cursor: pointer;
}
.binder-auto-prices input:checked { background: var(--settings-accent); border-color: var(--settings-accent); }
#modalRoot .binder-settings-modal .binder-auto-prices input { width: 24px; height: 24px; min-width: 24px; min-height: 24px; padding: 0 !important; box-sizing: border-box; background: var(--settings-field) !important; border-color: var(--settings-line) !important; }
#modalRoot .binder-settings-modal .binder-auto-prices input:checked { background: var(--settings-accent) !important; border-color: var(--settings-accent) !important; }
.binder-auto-prices input:checked::after { content: ''; position: absolute; left: 50%; top: 43%; width: 7px; height: 12px; border: solid var(--settings-button-text); border-width: 0 3px 3px 0; transform: translate(-50%,-50%) rotate(45deg); }
.binder-price-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.binder-wishlist-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.binder-price-help { position: relative; }
.binder-price-info { position: relative; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--settings-muted); font-size: 12px; font-weight: 800; }
.binder-price-info::before { content: ''; position: absolute; width: 22px; height: 22px; border: 1px solid var(--settings-line); border-radius: 50%; }
.binder-price-tooltip {
  position: absolute; right: 0; bottom: calc(100% + 6px); width: min(280px,70vw); padding: 12px;
  border: 1px solid var(--settings-line); border-radius: var(--settings-radius); background: var(--settings-field);
  color: var(--settings-text); font-size: 12px; line-height: 1.6; box-shadow: var(--settings-shadow); z-index: 8;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .12s ease,transform .12s ease,visibility .12s;
}
.binder-price-help:is(:hover,:focus-within,.show-help) .binder-price-tooltip { opacity: 1; visibility: visible; transform: none; }
#modalRoot .binder-settings-modal .binder-cover-drop { aspect-ratio: 7/10; min-height: 0; background: var(--settings-field); border-color: var(--settings-line); border-radius: var(--settings-radius); color: var(--settings-text); }
#modalRoot .binder-settings-modal .binder-cover-drop img { height: 100%; position: absolute; inset: 0; }
#modalRoot .binder-settings-modal .binder-cover-drop small { color: var(--settings-muted); }
.binder-settings-modal .binder-cover-drop > div { padding: 14px; }
#modalRoot .binder-settings-modal .modal-close { color: var(--settings-muted); background: var(--settings-field); border-color: var(--settings-line); border-radius: var(--settings-radius); }
#modalRoot .binder-settings-modal .modal-close:hover { color: var(--danger); background: color-mix(in srgb,var(--danger) 12%,var(--settings-field)); }
#modalRoot .binder-settings-modal .modal-actions :is(.primary,.ghost) { min-height: 44px; border-radius: var(--settings-radius); font-family: var(--settings-font); box-shadow: none; }
#modalRoot .binder-settings-modal .modal-actions .primary { background: var(--settings-accent); color: var(--settings-button-text); border-color: var(--settings-accent); }

#modalRoot .binder-settings-modal .modal-actions .ghost { background: var(--settings-field); color: var(--settings-text); border-color: var(--settings-line); }
#modalRoot .binder-settings-modal :is(button,input,textarea):focus-visible { outline: 2px solid var(--settings-accent); outline-offset: 3px; }

/* A closed cover is artwork, with collection details beside it, not on top. */
.binder-nav-dock[hidden] { display: none !important; }
html body .binder-nav-dock :is(#prevBtn,#nextBtn) { display: inline-flex; align-items: center; justify-content: center; padding: 0 !important; }
html body .binder-nav-dock :is(#prevBtn,#nextBtn)::before { content: none; display: none; }
html body .binder-nav-dock :is(#prevBtn,#nextBtn) .btn-ico { width: 22px; height: 22px; display: block; flex: none; margin: 0; }
button.binder-cover { padding: 0; font: inherit; color: inherit; }
button.binder-cover:focus-visible { outline: 3px solid var(--accent); outline-offset: 6px; }
/* A locked binder never draws an unused second page. The single-page board
   scales to the same available stage height, including room for navigation. */
html body #spread.locked-single-page:not(.cover-mode) {
  --single-page-ar: calc(var(--binder-cols,3) * .72 / var(--binder-rows,3));
  min-height: 0 !important; max-height: none !important; height: auto !important;
  aspect-ratio: var(--single-page-ar) !important; padding: 12px !important;
  grid-template-columns: minmax(0,1fr) !important; grid-template-rows: minmax(0,1fr) !important;
}
html body #spread.locked-single-page:not(.cover-mode) > :is(.spine,.page-wrap:last-child) { display: none !important; }
html body #spread.locked-single-page:not(.cover-mode) > .page-wrap:first-child {
  display: block !important; grid-area: 1/1 !important; width: 100% !important;
  height: 100% !important; aspect-ratio: auto !important; position: relative;
}
html body #spread.locked-single-page:not(.cover-mode) .binder-page {
  position: relative !important; inset: auto !important; width: 100% !important;
  height: 100% !important; min-height: 0 !important; margin: 0 !important; padding: 8px !important;
  grid-template-columns: repeat(var(--binder-cols,3),minmax(0,1fr)) !important;
  grid-template-rows: repeat(var(--binder-rows,3),minmax(0,1fr)) !important;
}
html body #spread.locked-single-page:not(.cover-mode) .slot { min-width: 0; min-height: 0; aspect-ratio: auto !important; }
html body #spread.locked-single-page:not(.cover-mode)::after { display: none !important; }
html body #spread.locked-single-page:not(.cover-mode)::before { inset: 4px !important; }

html body #spread.locked-single-page .binder-empty-page { display: flex !important; align-items: center; justify-content: center; text-align: center; }
html body #spread.locked-single-page.has-inside-cover > .page-wrap:first-child,
html body #spread.locked-single-page.has-inside-cover .inside-cover-container { min-height: 0 !important; }
html body #spread.cover-mode {
  display: grid !important; grid-template-columns: minmax(0,1fr) minmax(0,.8fr) !important;
  width: min(100%,900px) !important; max-width: 900px !important; min-height: 0 !important;
  max-height: none !important; aspect-ratio: auto !important; padding: 18px !important; gap: 32px !important;
  align-items: center; background: none !important; border: 0 !important; box-shadow: none !important;
}
/* A closed binder still hides when a profile replaces it (the rule above outweighs .hidden). */
html body #spread.cover-mode.hidden { display: none !important; }
html body #spread.cover-mode > .page-wrap { width: 100% !important; height: auto !important; min-width: 0; grid-area: auto !important; }
html body #spread.cover-mode .binder-cover { width: 100% !important; height: auto !important; aspect-ratio: 7/10; }
html body #spread.cover-mode > .page-wrap:last-child { display: block !important; }
html body #spread.cover-mode > .page-wrap:first-child { max-width: calc((100cqh - 120px) * .7); justify-self: end; }
html body #spread.cover-mode :is(.cover-page,.binder-overview-page) { display: block !important; width: 100% !important; min-height: 0 !important; height: auto !important; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; }
.binder-overview { --overview-muted: var(--muted); width: 100%; max-height: calc(100cqh - 120px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--box); color: var(--text); }
.binder-overview h2 { margin: 10px 0 14px; font-size: clamp(20px,2.1vw,30px); line-height: 1.2; overflow-wrap: anywhere; }
.binder-overview-description { margin: 0 0 20px; font-size: 13px; line-height: 1.6; color: var(--overview-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.binder-overview-stats { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin: 0; }
.binder-overview-stats dt { color: var(--overview-muted); font-size: 11px; }
.binder-overview-stats dd { margin: 5px 0 0; font-size: 22px; font-weight: 800; }
.binder-overview-value { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.binder-overview-value span { font-size: 11px; color: var(--overview-muted); }
.binder-overview-value strong { font-size: 24px; color: var(--accent); }
.binder-overview-layout { margin: 14px 0 0; font-size: 11px; color: var(--overview-muted); }

@media (max-width: 700px) {
  #modalRoot .modal.binder-settings-modal { padding: 18px; }
  .binder-settings-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
  /* The cover keeps its small centred size. */
  .binder-settings-cover { width: 100%; }
  .binder-settings-cover :is(.binder-cover-drop, .cover-remove) { width: 100%; max-width: 180px; align-self: center; }
  .binder-settings-modal .modal-actions { flex-wrap: wrap; }
  .binder-settings-modal .modal-actions .danger-link { width: 100%; margin: 0; }
}
@container (max-width: 620px) {
  html body #spread.cover-mode { grid-template-columns: minmax(0,1fr) !important; gap: 14px !important; padding: 6px 16px !important; }
  html body #spread.cover-mode > .page-wrap:first-child { max-width: calc((100cqh - 300px) * .7); justify-self: center; }
  html body #spread.cover-mode > .page-wrap:last-child { max-width: 380px; justify-self: center; }
  .binder-overview { max-height: 200px; padding: 14px 16px; }
  .binder-overview .eyebrow { display: none; }
  .binder-overview h2 { margin: 0 0 10px; font-size: 18px; }
  
  .binder-overview-description { margin-bottom: 12px; font-size: 12px; }
  .binder-overview-stats { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
  .binder-overview-stats dt { font-size: 10px; }
  .binder-overview-stats dd { font-size: 18px; }
  .binder-overview-value { flex-direction: row; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 10px; }
  .binder-overview-value strong { font-size: 18px; }
  .binder-overview-layout { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .binder-price-tooltip { transition: none; } }
