/* ShelfPilot responsive layer — mobile-first components shared by the app, auth, storefront and marketing layouts.
   Loaded after app.css. Desktop (lg+) keeps the sidebar, tables and inline filters; phones get one-column flows,
   44px+ touch targets, a bottom quick nav and sticky primary actions. */

:root {
  --sp-space-1: .25rem;
  --sp-space-2: .5rem;
  --sp-space-3: .75rem;
  --sp-space-4: 1rem;
  --sp-space-5: 1.5rem;
  --sp-space-6: 2rem;
  --sp-radius-md: .75rem;
  --sp-radius-lg: 1rem;
  --sp-touch-min: 44px;
  --sp-content-max: 1440px;
  --sp-bottomnav-h: 64px;
  --sp-sticky-h: 72px;
  --sp-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- global safety: media never forces a sideways scroll (layout bugs are fixed at the source, not hidden) */
img, video, svg { max-width: 100%; }
img { height: auto; }
.sp-wrap, .sp-title-cell .t, .sp-mcard-title, .sf-meta .t, h1, h2 { overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }

/* ---------- phone + tablet: touch targets and readable type */
@media (max-width: 991.98px) {
  body { font-size: 1rem; }
  .btn { min-height: var(--sp-touch-min); display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 40px; padding-left: .75rem; padding-right: .75rem; }
  .btn-link { min-height: var(--sp-touch-min); }
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; min-height: var(--sp-touch-min); }
  textarea.form-control { min-height: 88px; }
  .form-check-input { width: 1.25em; height: 1.25em; }
  .form-switch .form-check-input { width: 2.4em; }
  .form-check { min-height: 32px; display: flex; align-items: center; gap: .5rem; }
  .form-check .form-check-input { margin-top: 0; float: none; flex: none; }
  .form-check-label { line-height: 1.35; }
  .dropdown-item { padding-top: .65rem; padding-bottom: .65rem; }
  .sp-flash .btn-close { width: 44px; height: 44px; margin: -.6rem -.6rem -.6rem auto; }
}
@media (max-width: 767.98px) {
  .sp-page-header { align-items: stretch; margin-bottom: 1rem; }
  .sp-page-header h1 { font-size: clamp(1.4rem, 6vw, 1.65rem); }
  .sp-page-header > div:first-child { width: 100%; }
  .sp-card-header { padding: .85rem 1rem; }
  .sp-card-body { padding: 1rem; }
  .sp-card-footer { padding: .85rem 1rem; }
}

/* ---------- page header actions: full-width stacked buttons on phone */
.sp-page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 767.98px) {
  .sp-page-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .sp-page-actions > .btn, .sp-page-actions > .dropdown > .btn { width: 100%; }
  .sp-page-actions > .sp-action-primary { grid-column: 1 / -1; }
  .sp-page-actions .dropdown { display: contents; }
}

/* ---------- bottom quick nav (phone/tablet, authenticated app) */
.sp-bottom-nav { display: none; }
@media (max-width: 991.98px) {
  .sp-bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
    height: calc(var(--sp-bottomnav-h) + var(--sp-safe-bottom)); padding: 0 env(safe-area-inset-right) var(--sp-safe-bottom) env(safe-area-inset-left);
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--sp-border); box-shadow: 0 -4px 18px rgba(31, 42, 60, .08);
    backdrop-filter: blur(8px);
  }
  .sp-bottom-nav a, .sp-bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; height: var(--sp-bottomnav-h);
    color: var(--sp-muted); text-decoration: none; font-size: .72rem; font-weight: 600; border: 0; background: none; padding: 0;
  }
  .sp-bottom-nav i { font-size: 1.3rem; line-height: 1; }
  .sp-bottom-nav .active { color: var(--sp-ink); }
  .sp-bottom-nav .active i { color: var(--sp-accent-600); }
  .sp-bottom-nav .sp-bn-scan { position: relative; }
  .sp-bottom-nav .sp-bn-scan span.sp-bn-fab {
    width: 58px; height: 58px; border-radius: 50%; background: var(--sp-accent); color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(197, 139, 43, .45); margin-top: -26px; border: 4px solid #fff;
  }
  .sp-bottom-nav .sp-bn-scan span.sp-bn-fab i { font-size: 1.5rem; color: #fff; }
  .sp-bottom-nav .sp-bn-scan { color: var(--sp-ink); }
  body.sp-app .sp-main { padding-bottom: calc(var(--sp-bottomnav-h) + var(--sp-safe-bottom) + 1.5rem); }
  body.sp-app.sp-has-sticky .sp-bottom-nav { display: none; }
  body.sp-app.sp-has-sticky .sp-main { padding-bottom: calc(var(--sp-sticky-h) + var(--sp-safe-bottom) + 1.5rem); }
}

/* ---------- sticky bottom actions (Save Book, Continue Import, Reserve, ...) */
.sp-sticky-actions { display: none; }
@media (max-width: 991.98px) {
  .sp-sticky-actions {
    display: flex; gap: .6rem; align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1036;
    padding: .7rem calc(1rem + env(safe-area-inset-right)) calc(.7rem + var(--sp-safe-bottom)) calc(1rem + env(safe-area-inset-left));
    background: rgba(255, 255, 255, .98); border-top: 1px solid var(--sp-border); box-shadow: 0 -6px 18px rgba(31, 42, 60, .1);
  }
  .sp-sticky-actions .btn { flex: 1 1 0; min-height: 48px; font-weight: 600; }
  .sp-sticky-actions .btn-primary, .sp-sticky-actions .btn-accent { flex-grow: 2; }
  .sp-sticky-actions .sp-sticky-note { flex: 1 1 100%; font-size: .82rem; color: var(--sp-muted); margin-bottom: -.2rem; }
  .sp-sticky-actions.wrap { flex-wrap: wrap; }
  .sp-desktop-actions { display: none !important; }
}

/* ---------- mobile card lists (desktop tables -> cards below lg) */
.sp-card-list { list-style: none; margin: 0; padding: 0; }
.sp-mcard { display: block; padding: .9rem 1rem; border-bottom: 1px solid var(--sp-border); color: inherit; text-decoration: none; }
.sp-mcard:last-child { border-bottom: 0; }
.sp-mcard-row { display: flex; gap: .85rem; align-items: flex-start; }
.sp-mcard-title { font-weight: 600; color: var(--sp-ink); line-height: 1.3; }
.sp-mcard-title a { color: inherit; text-decoration: none; }
.sp-mcard-sub { color: var(--sp-muted); font-size: .9rem; }
.sp-mcard-meta { display: flex; flex-wrap: wrap; gap: .25rem .6rem; font-size: .9rem; color: var(--sp-ink-2); margin-top: .35rem; }
.sp-mcard-meta .dot::before { content: "•"; margin-right: .6rem; color: var(--sp-border-strong); }
.sp-mcard-actions { display: flex; gap: .5rem; align-items: center; margin-top: .7rem; }
.sp-mcard-actions .btn, .sp-mcard-actions form { flex: 1 1 0; }
.sp-mcard-actions form .btn { width: 100%; }
.sp-mcard-actions .sp-icon-btn { flex: 0 0 44px; }
.sp-mcard .sp-thumb, .sp-mcard .sp-thumb-placeholder { width: 52px; height: 76px; }
.sp-icon-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- touchable rows (dashboard attention, settings landing) */
.sp-touch-list { list-style: none; margin: 0; padding: 0; }
.sp-touch-row {
  display: flex; align-items: center; gap: .85rem; min-height: 56px; padding: .7rem 1.1rem; border-bottom: 1px solid var(--sp-border);
  color: inherit; text-decoration: none;
}
.sp-touch-list li:last-child .sp-touch-row { border-bottom: 0; }
a.sp-touch-row:hover, a.sp-touch-row:focus-visible { background: var(--sp-surface-2); }
.sp-touch-row .n { font-family: var(--sp-font-display); font-weight: 600; font-size: 1.25rem; color: var(--sp-ink); min-width: 2.2rem; }
.sp-touch-row .lbl { flex: 1; min-width: 0; }
.sp-touch-row .lbl small { display: block; color: var(--sp-muted); }
.sp-touch-row .chev { color: var(--sp-muted); }
.sp-touch-row .ic { width: 38px; height: 38px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--sp-accent-soft); color: var(--sp-accent-600); font-size: 1.1rem; }

/* ---------- filter sheet (Bootstrap offcanvas-lg offcanvas-bottom: inline at lg+, bottom sheet on phone) */
@media (max-width: 991.98px) {
  .sp-filter-sheet.offcanvas-lg { height: auto !important; max-height: 88vh; max-height: 88dvh; border-radius: 18px 18px 0 0; }
  .sp-filter-sheet .offcanvas-body { display: grid; gap: .9rem; padding-bottom: 1rem; overflow-y: auto; }
  .sp-filter-sheet .offcanvas-body > *, .sp-filter-sheet .form-select { width: 100% !important; }
  .sp-filter-sheet .sp-filter-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 2fr; gap: .6rem; padding: .75rem 1rem calc(.75rem + var(--sp-safe-bottom)); background: #fff; border-top: 1px solid var(--sp-border); }
}
@media (min-width: 992px) {
  .sp-filter-sheet .offcanvas-header, .sp-filter-sheet .sp-filter-actions, .sp-filter-sheet .sp-filter-label { display: none !important; }
  .sp-filter-sheet .offcanvas-body { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 0; overflow: visible; }
}

/* ---------- toolbar: phone search row + [Filters] [Sort] */
@media (max-width: 991.98px) {
  .sp-toolbar { padding: .75rem; gap: .5rem; }
  .sp-toolbar .sp-search { flex: 1 1 100%; }
  .sp-toolbar-phone { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; }
  .sp-toolbar-phone .btn, .sp-toolbar-phone .form-select { width: 100%; }
}
@media (min-width: 992px) { .sp-toolbar-phone { display: none !important; } }

/* ---------- tabs scroll sideways instead of wrapping into a wall */
@media (max-width: 767.98px) {
  .sp-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: -1rem; margin-right: -1rem; padding: 0 1rem; }
  .sp-tabs::-webkit-scrollbar { display: none; }
  .sp-tabs a { white-space: nowrap; padding: .7rem .9rem; }
}


/* ---------- form sections */
.sp-form-section + .sp-form-section { margin-top: 1rem; }
.sp-form-section > summary { list-style: none; cursor: pointer; }
.sp-form-section > summary::-webkit-details-marker { display: none; }
.sp-form-section > summary h2::after { content: "\F282"; font-family: "bootstrap-icons"; font-size: .85rem; margin-left: .5rem; color: var(--sp-muted); }
.sp-form-section[open] > summary h2::after { content: "\F286"; }
@media (max-width: 991.98px) {
  .sp-form-grid > [class*="col-md-"], .sp-form-grid > [class*="col-sm-"] { flex: 0 0 100%; max-width: 100%; }
}

/* ---------- chooser (Add Book: Scan ISBN / Enter Manually) */
.sp-chooser { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.sp-chooser a, .sp-chooser button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; min-height: 110px; padding: 1rem;
  border: 1px solid var(--sp-border); border-radius: var(--sp-radius); background: var(--sp-surface); color: var(--sp-ink); font-weight: 600; text-decoration: none; text-align: center;
}
.sp-chooser a:hover, .sp-chooser button:hover { border-color: var(--sp-accent); }
.sp-chooser i { font-size: 1.8rem; color: var(--sp-accent-600); }
.sp-chooser small { color: var(--sp-muted); font-weight: 500; }
@media (max-width: 359.98px) { .sp-chooser { grid-template-columns: 1fr; } }

/* ---------- dashboard metrics: 2 columns on phones, 1 on very narrow */
@media (max-width: 767.98px) {
  .sp-metric { padding: .85rem .9rem; }
  .sp-metric .value { font-size: 1.55rem; }
  .sp-metric .label { font-size: .7rem; }
}
@media (max-width: 359.98px) {
  .sp-metric-grid > [class*="col-6"] { flex: 0 0 100%; max-width: 100%; }
}
.sp-quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.sp-quick-actions .sp-qa-primary { grid-column: 1 / -1; min-height: 56px; font-size: 1.05rem; font-weight: 700; }
.sp-quick-actions .btn { min-height: 48px; }
.sp-quick-actions form { grid-column: 1 / -1; }
@media (min-width: 992px) { .sp-quick-actions { display: none; } }

/* ---------- covers: consistent aspect ratio, never stretched */
.sp-cover-frame { aspect-ratio: 2 / 3; width: 120px; border-radius: 6px; overflow: hidden; background: var(--sp-bg-deep); box-shadow: var(--sp-shadow); flex: none; }
.sp-cover-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-cover-frame .sp-thumb-placeholder { width: 100%; height: 100%; font-size: 2rem; border-radius: 0; }

/* Drag an image onto the Book card to use it as the cover (books.js). */
section.is-dragover { position: relative; outline: 3px dashed var(--sp-accent); outline-offset: -3px; background: var(--sp-accent-soft); }
section.is-dragover::after {
  content: "Drop the image to use it as the cover"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 1rem; font-weight: 600; font-size: 1.05rem; color: var(--sp-ink); background: rgba(255, 255, 255, .86); border-radius: inherit; pointer-events: none; z-index: 5;
}
#bookPhotos.is-dragover::after { content: "Drop to add photos of this copy"; }

/* Photos of this copy (book-photos.js): drag to reorder, faded = saved but beyond the plan's allowance. */
.sp-photo-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.sp-photo-grid:empty { display: none; }
.sp-photo-tile { position: relative; width: 84px; height: 84px; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); overflow: hidden; background: var(--sp-bg-deep); cursor: grab; }
.sp-photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-photo-tile.dragging { opacity: .4; }
.sp-photo-tile.is-hidden-by-plan { opacity: .45; }
.sp-photo-tile .n { position: absolute; left: 3px; top: 3px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .68rem; padding: 0 .35rem; border-radius: .25rem; }
.sp-photo-tile .x { position: absolute; right: 2px; top: 2px; border: 0; background: rgba(0, 0, 0, .65); color: #fff; width: 26px; height: 26px; border-radius: 50%; line-height: 1; font-size: 1rem; }
@media (max-width: 575.98px) { .sp-photo-tile { width: 72px; height: 72px; } }
.sp-drop-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .sp-drop-hint { display: block; } }

/* ---------- missing-cover recovery + "Find Cover & Details" preview (full-screen modal on phones) */
.sp-nocover { border: 1px dashed var(--sp-border-strong); border-radius: var(--sp-radius-sm); padding: .85rem; background: var(--sp-surface-2); }
.sp-nocover-title { font-weight: 700; margin: 0 0 .5rem; }
.sp-nocover .btn { min-height: 44px; }
.sp-kv.sp-kv-compact { grid-template-columns: 128px 1fr; }
.sp-meta-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.sp-meta-cover { width: 96px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; box-shadow: var(--sp-shadow); flex: none; background: var(--sp-bg-deep); }
.sp-meta-cover-ph { display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--sp-muted); }
.sp-meta-title { font-size: 1.1rem; margin: 0 0 .15rem; }
.sp-meta-rows { border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); }
.sp-meta-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: .25rem 1rem; padding: .7rem .85rem; align-items: start; }
.sp-meta-row + .sp-meta-row { border-top: 1px solid var(--sp-border); }
.sp-meta-row.is-empty { color: var(--sp-muted); }
.sp-meta-check { display: flex; gap: .55rem; align-items: center; font-weight: 600; cursor: pointer; min-height: 32px; margin: 0; }
.sp-meta-check input { width: 1.25rem; height: 1.25rem; flex: none; margin: 0; }
.sp-meta-k { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sp-muted); font-weight: 600; margin-right: .4rem; }
.sp-meta-note { grid-column: 1 / -1; font-size: .8rem; color: var(--sp-muted); }
.sp-meta-nocover { border: 1px dashed var(--sp-border-strong); border-radius: var(--sp-radius-sm); padding: .85rem; margin-bottom: 1rem; }
.sp-meta-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.sp-meta-actions .btn { min-height: 44px; }
.sp-meta-cands { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.sp-meta-cand { display: flex; gap: .75rem; padding: .6rem; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); }
.sp-meta-cand img { width: 64px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; flex: none; background: var(--sp-bg-deep); }
.sp-meta-confirm { padding: .75rem .75rem .75rem 2.25rem; background: #fffaf0; border-radius: var(--sp-radius-sm); }
@media (max-width: 575.98px) {
  .sp-meta-row { grid-template-columns: 1fr; }
  .sp-meta-actions { display: grid; grid-template-columns: 1fr; }
  .sp-meta-cands { grid-template-columns: 1fr; }
  .sp-meta-cover { width: 80px; }
  #metaModal .modal-footer { display: grid; grid-template-columns: 1fr 1fr; }
  #metaModal .modal-footer .btn { min-height: 48px; margin: 0; }
}

/* ---------- import mapping cards (same markup as desktop rows) */
@media (max-width: 991.98px) {
  .sp-map-list { display: flex; flex-direction: column; }
  .sp-map-head { display: none; }
  .sp-map-row { grid-template-columns: 1fr; gap: .45rem; padding: 1rem; }
  .sp-map-row .arrow { display: none; }
  .sp-map-row .samples { white-space: normal; overflow: visible; }
  .sp-map-row .samples .ex { display: block; }
  .sp-map-row .sp-map-to { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sp-muted); font-weight: 600; display: block; margin-bottom: .2rem; }
  .sp-map-row.is-uncertain { order: -1; background: #fffaf0; }
  .sp-map-row .form-select { min-height: 48px; }
}
@media (min-width: 992px) {
  .sp-map-row .sp-map-to { display: none; }
  .sp-map-row .samples .ex + .ex::before { content: " · "; }
}
.sp-conf-text { font-size: .78rem; font-weight: 600; }

/* ---------- import dropzone: phones get a file-picker button, not drag language */
.sp-drag-only { display: none; }
@media (hover: hover) and (pointer: fine) { .sp-drag-only { display: inline; } .sp-touch-only { display: none; } }
@media (max-width: 767.98px) { .sp-dropzone { padding: 1.75rem 1rem; } .sp-dropzone h2 { font-size: 1.2rem; } }

/* ---------- radio cards (worksheet picker) */
.sp-radio-card { display: flex; gap: .75rem; align-items: center; min-height: 60px; padding: .85rem 1rem; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); margin-bottom: .5rem; cursor: pointer; background: var(--sp-surface); }
.sp-radio-card:has(input:checked) { border-color: var(--sp-accent); background: var(--sp-accent-soft); }
.sp-radio-card input { width: 1.25rem; height: 1.25rem; flex: none; }
.sp-radio-card.disabled { opacity: .5; cursor: not-allowed; }

/* ---------- import stat pills: 3 across even on phones */
@media (max-width: 575.98px) {
  .sp-stat-pills > div { flex: 0 0 33.333%; max-width: 33.333%; }
  .sp-stat-pill { padding: .7rem .6rem; text-align: center; }
  .sp-stat-pill .v { font-size: 1.35rem; }
  .sp-stat-pill .l { font-size: .74rem; }
  .sp-stat-pill .l .long { display: none; }
}
@media (max-width: 575.98px) { .sp-steps li { font-size: 0; gap: 0; } .sp-steps li .n { font-size: .78rem; } .sp-steps li.current { font-size: .85rem; gap: .4rem; } }

/* ---------- key/value lists stack on phone */
@media (max-width: 575.98px) {
  .sp-kv { grid-template-columns: 1fr; gap: .1rem; }
  .sp-kv dd { margin-bottom: .5rem; }
}

/* ---------- modals: bottom sheet / full screen on phone */
@media (max-width: 575.98px) {
  .modal-dialog.sp-modal-sheet { margin: 0; position: fixed; left: 0; right: 0; bottom: 0; max-width: none; }
  .modal-dialog.sp-modal-sheet .modal-content { border-radius: 18px 18px 0 0 !important; padding-bottom: var(--sp-safe-bottom); }
  .modal-dialog.sp-modal-sheet .modal-footer { display: grid; grid-template-columns: 1fr 1fr; }
}
.modal-fullscreen-sm-down .modal-content { border-radius: 0; }
@media (min-width: 576px) { .modal-fullscreen-sm-down .modal-content { border-radius: 16px; } }

/* ---------- offcanvas drawers (app menu, marketing, storefront) */
.offcanvas .sp-drawer-link { display: flex; align-items: center; gap: .75rem; min-height: 52px; padding: .5rem 1rem; color: inherit; text-decoration: none; font-weight: 500; border-radius: 10px; }
.offcanvas .sp-drawer-link:hover { background: var(--sp-surface-2); }
@media (max-width: 991.98px) {
  .offcanvas.sp-offcanvas .sp-sidebar .nav-link { min-height: 48px; font-size: 1rem; }
  .offcanvas.sp-offcanvas { padding-bottom: var(--sp-safe-bottom); overflow-y: auto; }
  .offcanvas.sp-offcanvas .sp-sidebar { height: auto; min-height: calc(100% - 56px); }
  .offcanvas.sp-offcanvas .sp-sidebar-footer .btn-link { min-height: 44px; font-size: 1rem; }
}

/* ---------- top bar on phone: [☰] ShelfPilot ... [User] */
@media (max-width: 991.98px) {
  .sp-topbar { padding: 0 calc(.75rem + env(safe-area-inset-right)) 0 calc(.75rem + env(safe-area-inset-left)); }
  .sp-topbar .btn { min-height: 44px; min-width: 44px; }
}

/* ---------- utility */
.sp-nowrap { white-space: nowrap; }
@media (max-width: 991.98px) { .sp-hide-touch { display: none !important; } }

/* ---------- book form: on phones the two desktop columns dissolve so sections follow the spec order
   (Book, Inventory & pricing, Details, Storefront, More details). */
@media (max-width: 991.98px) {
  .sp-book-form { display: flex; flex-direction: column; margin: 0; }
  .sp-book-form > .sp-col { display: contents; }
  .sp-book-form .sp-card { width: 100%; }
  .sp-o-1 { order: 1; } .sp-o-2 { order: 2; } .sp-o-3 { order: 3; } .sp-o-4 { order: 4; } .sp-o-5 { order: 5; } .sp-o-6 { order: 6; }
  .sp-book-form .input-group .btn { white-space: nowrap; }
}

/* ---------- Store Settings -> Branding (admin page; the store theme itself only renders inside the preview iframe) */
.sp-preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.sp-preset { position: relative; display: flex; flex-direction: column; gap: .45rem; padding: .7rem; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm); background: var(--sp-surface); cursor: pointer; min-height: 44px; }
.sp-preset input { position: absolute; opacity: 0; pointer-events: none; }
.sp-preset:has(input:checked) { border-color: var(--sp-accent); box-shadow: 0 0 0 2px var(--sp-accent-soft); }
.sp-preset:has(input:focus-visible) { outline: 3px solid rgba(197, 139, 43, .55); outline-offset: 2px; }
.sp-preset .sw { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid var(--sp-border); }
.sp-preset .sw i { flex: 1; }
.sp-preset .sw-custom { align-items: center; justify-content: center; color: var(--sp-muted); background: var(--sp-surface-2); }
.sp-preset .nm { font-size: .85rem; font-weight: 600; color: var(--sp-ink); }
fieldset:disabled .sp-preset, fieldset:disabled .sp-seg-opt { cursor: not-allowed; opacity: .6; }
.sp-color-input { display: flex; gap: .5rem; align-items: stretch; }
.sp-color-input .form-control-color { width: 52px; min-width: 52px; height: auto; min-height: 44px; padding: .25rem; flex: none; }
.sp-color-input input[type="text"] { text-transform: uppercase; }
.sp-seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.sp-seg-opt { margin: 0; cursor: pointer; }
.sp-seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sp-seg-opt span { display: inline-flex; align-items: center; min-height: 44px; padding: .45rem .9rem; border: 1px solid var(--sp-border-strong); border-radius: 999px; background: var(--sp-surface); font-size: .88rem; font-weight: 500; }
.sp-seg-opt input:checked + span { background: var(--sp-ink); border-color: var(--sp-ink); color: #fff; }
.sp-seg-opt input:focus-visible + span { outline: 3px solid rgba(197, 139, 43, .55); outline-offset: 2px; }
.sp-seg-sm { gap: .25rem; }
.sp-seg-btn { border: 1px solid var(--sp-border-strong); background: var(--sp-surface); border-radius: 8px; min-width: 44px; min-height: 40px; color: var(--sp-ink-2); }
.sp-seg-btn.active { background: var(--sp-ink); color: #fff; border-color: var(--sp-ink); }
.sp-asset-row { display: flex; gap: 1rem; align-items: flex-start; }
.sp-asset-thumb { flex: none; display: flex; align-items: center; justify-content: center; background: var(--sp-surface-2); border: 1px dashed var(--sp-border-strong); border-radius: var(--sp-radius-sm); overflow: hidden; }
.sp-asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.sp-asset-logo { width: 96px; height: 64px; padding: 4px; }
.sp-asset-hero { width: 140px; height: 64px; }
.sp-asset-hero img { width: 100%; height: 100%; object-fit: cover; }
.sp-asset-icon { width: 64px; height: 64px; padding: 10px; }
.sp-brand-preview { position: sticky; top: calc(var(--sp-topbar-h) + 1rem); overflow: hidden; }
.sp-brand-frame-wrap { background: var(--sp-bg-deep); display: flex; justify-content: center; }
.sp-brand-frame { display: block; width: 100%; height: 680px; border: 0; background: #fff; transition: width .2s ease; }
.sp-brand-preview.is-phone .sp-brand-frame { width: 390px; max-width: 100%; }
.sp-brand-upsell { border-color: var(--sp-accent); background: var(--sp-accent-soft); }
@media (max-width: 1199.98px) {
  .sp-brand-preview { position: static; }
  .sp-brand-frame { height: 560px; }
}
@media (max-width: 575.98px) {
  .sp-asset-row { flex-direction: column; gap: .6rem; }
  .sp-asset-hero { width: 100%; height: 96px; }
  .sp-preset-grid { grid-template-columns: 1fr 1fr; }
  .sp-seg-opt { flex: 1 1 auto; }
  .sp-seg-opt span { width: 100%; justify-content: center; }
}
