@layer reset, base, layout, components, pages, utilities;

/* Printed cookbooks: starting one, the four builder steps and the shelf. */
@layer pages {
  .book-form { display: flex; flex-direction: column; gap: 20px; max-width: 920px; }
  .book-form fieldset.field, .look-form fieldset.field, .builder fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }

  .choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 0; margin: 0; padding: 0; }
  .choice-grid--compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .choice { position: relative; display: flex; cursor: pointer; }
  .choice input { position: absolute; opacity: 0; pointer-events: none; }
  .choice__body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .choice:hover .choice__body { border-color: var(--ink-3); }
  .choice input:checked + .choice__body { border: 2px solid var(--accent); padding: 13px 15px; background: var(--accent-soft); }
  .choice input:focus-visible + .choice__body { outline: 2px solid var(--ink); outline-offset: 2px; }
  .choice--off { cursor: not-allowed; }
  .choice--off .choice__body { opacity: .55; }
  .choice--off:hover .choice__body { border-color: var(--border-strong); }
  .choice__title { font-weight: 600; font-size: 15px; }
  .choice__text { font-size: 13px; color: var(--muted); }

  .theme-sample { font-size: 22px; line-height: 1.1; color: var(--accent); }
  .theme-sample--classic { font-family: var(--serif); }
  .theme-sample--modern { font-family: var(--sans); font-weight: 600; letter-spacing: -0.01em; }

  /* Two tiny pages showing where the photo goes. */
  .mini-spread { display: flex; gap: 2px; align-self: flex-start; margin-bottom: 4px; }
  .mini-spread > span {
    width: 30px;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    background: repeating-linear-gradient(to bottom, transparent 0 16px, var(--rule) 16px 18px, transparent 18px 21px) var(--surface);
    background-size: 70% 100%;
    background-position: 50% 0;
    background-repeat: no-repeat;
  }
  .mini-spread--spread > span:first-child { background: #D9A873; }
  .mini-spread--top > span { background: linear-gradient(#D9A873, #D9A873) 50% 4px / 76% 13px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 21px, var(--rule) 21px 23px, transparent 23px 26px) 50% 0 / 70% 100% no-repeat, var(--surface); }

  .swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .swatch { position: relative; cursor: pointer; }
  .swatch input { position: absolute; opacity: 0; }
  .swatch span:not(.visually-hidden) { display: block; width: 36px; height: 36px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
  .swatch input:checked + span { outline: 2px solid var(--ink); outline-offset: 3px; }
  .swatch input:focus-visible + span { outline: 2px dashed var(--ink); outline-offset: 3px; }

  .recipe-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2px 16px;
    max-height: 60vh;
    overflow-y: auto;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .recipe-picker legend { padding: 0 4px; }
  .recipe-picker__item { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
  .recipe-picker__item .muted { margin-left: auto; font-size: 13px; }
  .recipe-picker__none { grid-column: 1 / -1; }
  .recipe-picker__tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
  .recipe-picker__search { flex: 1 1 220px; max-width: 360px; }

  .toggle-row { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; font-weight: 500; }

  .book-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
  .book-facts dt { font-size: 12px; color: var(--muted); }
  .book-facts dd { margin: 0; font-weight: 600; font-size: 14px; }
  .book-facts dd .muted { font-weight: 400; }

  .check-dot--lg { width: 44px; height: 44px; }
  .check-dot--lg .icon { width: 22px; height: 22px; }
  .check-dot--warn { background: var(--amber-soft); color: var(--amber-ink); }
  .check-dot--bad { background: var(--accent); }

  /* Builder frame ------------------------------------------------------ */

  .builder-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
  .builder-head__text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .builder-head__title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .book-stage { padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
  .book-stage--draft { background: var(--accent-soft); color: var(--accent-ink); }
  .book-stage--ordered { background: var(--green-soft); color: var(--green-ink); }
  .builder-nav { display: flex; gap: 8px; align-items: center; }
  .builder-nav__note { display: none; }
  .builder-nav--phone { display: none; }
  .builder-head .breadcrumb { margin: 0; }
  .builder-status { font-size: 14px; }
  .builder-status > span { display: inline-flex; align-items: center; gap: 6px; }
  .builder-status--ok { color: var(--green); }
  .builder-status--busy { color: var(--muted); }
  .builder-status--busy .icon { animation: spin 1s linear infinite; }
  .builder-status--bad { color: var(--accent-ink); }

  .builder-steps {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--sunken);
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
  }
  .builder-steps__item {
    flex: 1 1 150px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    color: var(--ink-3);
    text-decoration: none;
  }
  a.builder-steps__item:hover { background: var(--hover); color: var(--ink); }
  .builder-steps__item[aria-current] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
  .builder-steps__item[aria-disabled] { opacity: .5; }
  .builder-steps__number {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--dashed);
    display: grid;
    place-items: center;
    font-size: 13px;
  }
  .builder-steps__item[aria-current] .builder-steps__number { background: var(--accent); border-color: var(--accent); color: var(--surface); }

  .builder-alert { margin-bottom: 24px; border-color: var(--warn-border); background: var(--warn-soft); }

  .builder { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
  .builder__main { flex: 999 1 460px; }
  .builder__side { flex: 1 1 480px; }
  .builder-lede { margin-top: 4px; font-size: 14px; }

  /* Step 1: contents ---------------------------------------------------- */

  .book-matter { font-size: 14px; --row-gap: 8px; }
  .book-matter .chip { height: 32px; padding: 0 12px; font-size: 14px; border-radius: 999px; }
  .book-matter .chip--dashed { cursor: default; }
  .book-matter__note { margin-top: -6px; font-size: 13px; }

  /* Select several: a tick on each recipe, and a bar to take the ticked ones out. */
  .book-entry__pick { display: none; flex-shrink: 0; }
  .is-selecting .book-entry__pick { display: block; }
  .is-selecting .book-entry .drag-handle { display: none; }
  .book-select-bar { display: none; }
  .is-selecting .book-select-bar {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .book-select-bar__count { margin-right: auto; font-weight: 600; }

  .book-chapters { display: flex; flex-direction: column; gap: 12px; }
  .book-chapter { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
  .book-chapter__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 6px;
    background: var(--bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .book-chapter__name { flex: 1; min-width: 0; font: 500 20px var(--serif); }
  .book-chapter__meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
  .book-chapter .menu__items { min-width: 260px; }
  .menu__form { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
  .menu__items .menu__form .btn { width: auto; display: inline-flex; padding: 0 12px; border: 1px solid var(--border-strong); }
  .input--sm { min-height: 36px; font-size: 15px; }

  .drag-handle {
    width: 32px;
    height: 40px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--faint);
    cursor: grab;
    touch-action: none;
  }
  .drag-handle:hover { background: var(--sunken); color: var(--ink-3); }
  .drag-handle--sm { color: var(--dashed); }

  .book-entries { list-style: none; margin: 0; padding: 0; min-height: 12px; }
  .book-entries:empty { min-height: 44px; }
  .book-entry { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 6px; border-top: 1px solid var(--border); background: var(--surface); }
  .book-entry:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
  .book-entry .media { width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius-sm); }
  .book-entry .media__plate { width: 60%; border-width: 1px; box-shadow: none; }
  .book-entry__title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 2px 0;
    border: 0;
    background: none;
    text-align: left;
    font-size: 15px;
  }
  .book-entry__title b { font-weight: 600; }
  .book-entry__title .muted { font-size: 13px; }
  a.book-entry__title { color: var(--ink); text-decoration: none; }
  a.book-entry__title:hover b { text-decoration: underline; }
  .book-entry__page { min-height: 36px; padding: 0 6px; border: 0; border-radius: 8px; background: none; font-size: 13px; color: var(--muted); white-space: nowrap; }
  .book-entry__page:hover { background: var(--sunken); color: var(--ink); }
  .book-entry__two { padding: 2px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
  .book-entry__menu .menu__items { min-width: 220px; }
  .book-entry__where { display: none; font-size: 13px; color: var(--muted); }
  .menu__items hr { margin: 4px 6px; border: 0; border-top: 1px solid var(--rule); }
  .book-entry.is-previewing { background: var(--accent-soft); }
  .book-entry.is-previewing .book-entry__page { color: var(--accent-ink); font-weight: 600; }
  .is-ghost { opacity: .35; }
  .is-dragging { box-shadow: var(--shadow); }

  .new-chapter > summary { list-style: none; border: 1.5px dashed var(--dashed); background: transparent; color: var(--ink-3); border-radius: var(--radius-lg); min-height: 48px; }
  .new-chapter > summary::-webkit-details-marker { display: none; }
  .new-chapter[open] > summary { display: none; }

  /* Previews ------------------------------------------------------------ */

  .book-preview__note { font-size: 13px; }
  .book-preview__empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 20px; text-align: center; background: var(--sunken); border-radius: var(--radius-lg); }

  .flipbook { position: relative; display: flex; justify-content: center; padding: 28px 20px; background: var(--sunken); border-radius: var(--radius-lg); }
  .flipbook:focus-visible { outline-offset: -2px; }
  .flipbook__spread { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 560px; filter: drop-shadow(0 8px 16px rgba(35, 30, 25, .16)); }
  .flipbook__page { width: 100%; height: auto; aspect-ratio: var(--page-ratio); object-fit: cover; background: #FBF7F0; }
  .flipbook__page--left { border-right: 1px solid rgba(35, 30, 25, .12); }
  .flipbook__page.is-empty { visibility: hidden; }
  .flipbook__spread.is-single { grid-template-columns: 1fr; max-width: 340px; }
  .flipbook__spread.is-single .flipbook__page--left { display: none; }
  .flipbook__busy {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    color: var(--muted);
  }
  .flipbook__busy .icon { animation: spin 1s linear infinite; }
  .flipbook__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
  .flipbook__controls .btn { padding: 0 12px; }
  .flipbook__scrubber { --fill: 0%; flex: 1 1 100%; height: 24px; margin: 0; background: none; cursor: pointer; appearance: none; -webkit-appearance: none; }
  .flipbook__scrubber::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--fill), var(--sunken) var(--fill)); }
  .flipbook__scrubber::-moz-range-track { height: 6px; border-radius: 3px; background: var(--sunken); }
  .flipbook__scrubber::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
  .flipbook__scrubber::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -6px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: var(--shadow-sm); -webkit-appearance: none; appearance: none; }
  .flipbook__scrubber::-moz-range-thumb { width: 18px; height: 18px; box-sizing: border-box; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: var(--shadow-sm); }
  .flipbook__goto { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
  .flipbook__page-field { width: 64px; padding: 0 6px; text-align: center; -moz-appearance: textfield; appearance: textfield; }
  .flipbook__page-field::-webkit-inner-spin-button, .flipbook__page-field::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
  @media (pointer: coarse) {
    .flipbook__scrubber { height: 36px; }
    .flipbook__scrubber::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -10px; }
    .flipbook__scrubber::-moz-range-thumb { width: 26px; height: 26px; }
  }
  .flipbook__edits { display: flex; flex-wrap: wrap; gap: 8px; }
  .flipbook__edits:empty { display: none; }
  .flipbook-zoom { width: min(1400px, calc(100vw - 24px)); max-width: none; height: calc(100dvh - 24px); max-height: none; padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--sunken); }
  .flipbook-zoom::backdrop { background: rgba(35, 30, 25, .6); }
  .flipbook-zoom__bar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--rule); }
  .flipbook-zoom__pages { display: flex; justify-content: center; align-items: flex-start; gap: 2px; padding: 16px; }
  .flipbook-zoom__pages img { flex: 1 1 0; min-width: 0; max-width: 800px; height: auto; background: #fff; box-shadow: var(--shadow); }

  .page-meter { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--rule); }
  .page-meter__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
  .page-meter__head .muted { font-size: 13px; }
  .page-meter__bar { position: relative; height: 10px; border-radius: 5px; background: var(--sunken); }
  .page-meter__fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--green); }
  .page-meter__fill--bad { background: var(--accent); }
  .page-meter__mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--muted); }
  .page-meter__scale { position: relative; height: 16px; font-size: 12px; }
  .page-meter__scale span { position: absolute; white-space: nowrap; }
  .page-meter__note { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--green); }
  .page-meter__note--bad { color: var(--accent-ink); }

  /* Step 2: look and cover ---------------------------------------------- */

  .cover-preview { display: flex; flex-direction: column; gap: 12px; }
  .cover-preview__toggle { align-self: flex-start; }
  .cover-preview__sheet { position: relative; width: 100%; border-radius: 4px; overflow: hidden; box-shadow: 0 8px 24px rgba(35, 30, 25, .16); background: var(--sunken); }
  .cover-preview__image { width: 100%; height: 100%; }
  .cover-guides { display: none; position: absolute; inset: 0; }
  .cover-preview:has(input:checked) .cover-guides { display: block; }
  .cover-guides > span:not(.cover-guides__legend) { position: absolute; }
  .cover-guides__trim { outline: 1.5px dashed rgba(255, 253, 248, .95); }
  .cover-guides__safe { outline: 1.5px dotted #F3C969; }
  .cover-guides__spine { border-left: 1px dashed rgba(255, 253, 248, .7); border-right: 1px dashed rgba(255, 253, 248, .7); }
  .cover-guides__legend {
    position: absolute;
    left: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(35, 30, 25, .78);
    color: var(--surface);
    font-size: 12px;
  }
  .cover-guides__key { width: 16px; height: 0; border-top: 2px dashed var(--surface); }
  .cover-guides__key--safe { margin-left: 8px; border-top: 2px dotted #F3C969; }

  .cover-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--ink-2); }
  .cover-facts--ok { color: var(--green); }

  .look-form { display: flex; flex-direction: column; gap: 18px; }

  .option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
  .option-grid__option { position: relative; display: flex; cursor: pointer; }
  .option-grid__option input { position: absolute; opacity: 0; pointer-events: none; }
  .option-grid__option > span {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 44px;
    justify-content: center;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
  }
  .option-grid__option .muted { font-size: 13px; font-weight: 400; }
  .option-grid__option:hover > span { border-color: var(--ink-3); }
  .option-grid__option input:checked + span { border: 2px solid var(--accent); padding: 9px 11px; background: var(--accent-soft); }
  .option-grid__option input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
  .option-grid__delta { margin-top: 4px; font-size: 13px; color: var(--accent-ink); }

  .fit-toggle { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
  .fit-toggle .checkbox { margin-top: 2px; flex-shrink: 0; }
  .fit-toggle > span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
  .fit-toggle .muted { font-size: 13px; }

  .cover-styles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
  .cover-styles .option-grid__option > span { align-items: center; text-align: center; padding: 8px 6px; font-size: 13px; }
  .cover-styles .option-grid__option input:checked + span { padding: 7px 5px; }
  .cover-note { font-size: 14px; color: var(--ink-2); }
  .cover-front { display: none; flex-direction: column; align-items: center; gap: 10px; padding: 20px; border-radius: var(--radius-lg); background: var(--sunken); font-size: 14px; }
  .cover-front img { width: 70%; box-shadow: 0 8px 20px rgba(35, 30, 25, .2); }

  .cover-frame { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius); background: var(--sunken); cursor: grab; touch-action: none; }
  .cover-frame:active { cursor: grabbing; }
  .cover-frame img { width: 100%; height: 100%; object-fit: cover; user-select: none; pointer-events: none; }

  .cover-photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
  .cover-photo-wrap { position: relative; }
  .cover-photo { position: relative; display: block; width: 64px; height: 64px; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; cursor: pointer; background: var(--sunken); }
  .cover-photo img { width: 100%; height: 100%; object-fit: cover; }
  .cover-photo[aria-pressed=true] { outline: 3px solid var(--accent); outline-offset: 2px; }
  .cover-photo:focus-visible { outline: 2px dashed var(--ink); outline-offset: 2px; }
  .cover-photo__badge {
    position: absolute;
    top: 4px;
    left: 4px;
    min-width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--accent);
    color: var(--surface);
    font-size: 13px;
  }
  .cover-photo__remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-3);
  }
  .cover-more > summary { list-style: none; }
  .cover-more > summary::-webkit-details-marker { display: none; }
  .cover-more[open] > summary { display: none; }
  .cover-upload { position: relative; align-self: flex-start; cursor: pointer; }

  /* Step 3: format and price -------------------------------------------- */

  .bindings { display: flex; flex-direction: column; gap: 12px; border: 0; margin: 0; padding: 0; min-width: 0; }
  .bindings__others { margin-top: 6px; }
  .binding-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border: 0; margin: 0; padding: 0; }
  .binding-choice--main .choice__body { flex-direction: row; gap: 20px; align-items: center; padding: 20px; }
  .binding-choice--main input:checked + .choice__body { padding: 19px; }
  .binding-choice__text { display: flex; flex-direction: column; gap: 6px; }
  .binding-choice--main .choice__title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .binding-choice--main .choice__text { font-size: 15px; color: var(--ink-2); }
  .serif-title { font: 500 24px var(--serif); }
  .binding-choice__badge { padding: 2px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); font-size: 12px; font-weight: 700; }
  .binding-choice__art.binding-choice__art--lg { flex-shrink: 0; width: 76px; height: 98px; margin: 0; background-size: 6px 100%; }
  .lie-flat { display: flex; gap: 12px 16px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid var(--warn-border); color: var(--amber-ink); font-size: 14px; }
  .lie-flat > span { flex: 1 1 260px; }

  .sizes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .size-choice > span { flex-direction: row; align-items: flex-end; gap: 10px; }
  .size-choice__outline { flex-shrink: 0; border: 1.5px solid var(--ink-3); border-radius: 2px; background: var(--surface); }
  .size-choice input:checked + span .size-choice__outline { border-color: var(--accent); background: var(--accent-soft); }
  .size-choice__text { display: flex; flex-direction: column; gap: 2px; }

  .paper-compare { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 14px; border-radius: var(--radius); background: var(--sunken); font-size: 14px; }
  .paper-compare__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 16px; }
  .paper-compare__side { display: flex; flex-direction: column; gap: 4px; }
  .paper-compare__side .muted { font-size: 13px; }
  .paper-compare__photo { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
  .paper-compare__photo--plain { display: block; background: linear-gradient(135deg, #C7735A, #2E2620); }
  .paper-compare__photo--standard { filter: saturate(.78) contrast(.88) brightness(1.04); }
  .paper-compare__photo--premium { filter: saturate(1.12) contrast(1.06); }

  .book-summary { position: sticky; top: 20px; }
  .book-scale { --inch: 18px; display: flex; align-items: flex-end; justify-content: center; gap: 14px; padding: 24px 16px; border-radius: var(--radius-lg); background: var(--sunken); flex-wrap: wrap; }
  .book-scale__item { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
  .book-scale__cover { display: block; object-fit: cover; box-shadow: 3px 6px 14px rgba(35, 30, 25, .25); border-radius: 1px 3px 3px 1px; }
  .book-scale__outline { display: block; border: 1.5px dashed var(--dashed); border-radius: 2px; }
  .binding-choice__art { width: 40px; height: 52px; border-radius: 2px 4px 4px 2px; box-shadow: 3px 4px 8px rgba(35, 30, 25, .18); margin-bottom: 6px; }
  .binding-choice__art--paperback { background: #D9A873; }
  .binding-choice__art--hardcover { background: #B98A7A; border-left: 4px solid #8F5E4E; }
  .binding-choice__art--linen { background: #2B3A55; border-left: 4px solid #1D2840; }
  .binding-choice__art--coil { background: repeating-linear-gradient(to bottom, #6A5F55 0 2px, transparent 2px 6px) left / 4px 100% no-repeat, #8FA58A; }
  .binding-choice__price { margin-top: auto; padding-top: 6px; font-size: 14px; font-weight: 600; }

  .foil-sample { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--linen); }
  .foil-sample .field__label { color: rgba(255, 253, 248, .8); }
  .foil-sample .field__hint { color: rgba(255, 253, 248, .8); }
  .foil-sample__text { color: var(--foil); font: 600 15px var(--sans); letter-spacing: .14em; }

  .book-summary__price { display: flex; justify-content: space-between; align-items: baseline; padding-top: 16px; border-top: 1px solid var(--rule); }
  .book-summary__price b { font: 500 40px var(--serif); }

  .admin-strip { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px dashed var(--warn-border); border-radius: var(--radius); background: var(--warn-soft); color: var(--amber-ink); font-size: 13px; }
  .admin-strip__label { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
  .admin-strip code { font-size: 13px; color: var(--ink); }

  .mini-cover {
    position: relative;
    width: 40px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 3px solid color-mix(in srgb, var(--cover) 70%, black);
    background: var(--cover);
    box-shadow: 3px 4px 10px rgba(35, 30, 25, .2);
  }
  .mini-cover__photo { flex: 0 0 58%; background: #B98A7A; }
  .mini-cover__front { display: block; width: 100%; height: 100%; object-fit: cover; }
  .mini-cover--linen { align-items: center; justify-content: center; }
  .mini-cover__foil { color: var(--foil); font: 500 14px var(--serif); }

  /* Step 4: proof --------------------------------------------------------- */

  .proof-stage { position: relative; display: flex; flex-direction: column; gap: 16px; }
  .soft-badge {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    color: var(--amber-ink);
    font-size: 13px;
    font-weight: 600;
  }
  .soft-badge.is-previewing { display: inline-flex; }

  .spreads { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x proximity; }
  .spreads__item { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border: 0; border-radius: 6px; background: none; scroll-snap-align: start; }
  .spreads__pages { display: flex; box-shadow: 0 1px 3px rgba(35, 30, 25, .2); }
  .spreads__pages img, .spreads__blank { width: 30px; height: 39px; object-fit: cover; background: #FBF7F0; }
  .spreads__blank { visibility: hidden; }
  .spreads__item[aria-current] .spreads__pages { outline: 2px solid var(--accent); outline-offset: 2px; }
  .spreads__label { font-size: 12px; color: var(--muted); }
  .spreads__item[aria-current] .spreads__label { color: var(--accent-ink); font-weight: 600; }
  .spreads__warn { color: var(--amber-ink); }

  .check { align-items: flex-start; }
  .check__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .check__body .muted { font-size: 14px; }
  .check__body .button_to { margin-top: 8px; }
  .check__list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
  /* Each row: the recipe, then Replace and Leave out lined up in their own columns. */
  .checks .check__list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 12px; align-items: baseline; }
  .check__item { display: flex; flex-direction: column; min-width: 0; }
  .check__item small { font-size: 12px; }
  .check__list form, .check__body .check__list .button_to { margin: 0; }
  .check__list .check__action { min-height: 0; padding: 0; font: inherit; text-decoration: underline; }
  .check-problems { padding: 12px 14px; border-radius: var(--radius); background: var(--del-soft); color: var(--del-ink); font-size: 14px; }
  .check-problems ul { margin: 6px 0 0; padding-left: 18px; }

  .proof-turn { display: none; font-size: 13px; color: var(--muted); }
  .proof-copy { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--radius-lg); background: var(--sunken); }
  .proof-copy h3 { font: 500 20px var(--serif); }
  .proof-copy p { font-size: 14px; }

  /* Cookbooks ----------------------------------------------------------- */

  .cookbooks { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
  .cookbooks__main { flex: 999 1 560px; min-width: 0; }
  .cookbooks__side { flex: 1 1 340px; min-width: 0; }
  .shelf { display: flex; flex-direction: column; gap: 6px; }
  .shelf__item { display: flex; align-items: center; gap: 4px; }
  .shelf__book { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 6px; border-radius: var(--radius); color: var(--ink); text-decoration: none; }
  .shelf__book:hover { background: var(--bg); color: var(--ink); }
  .shelf__book .grow { display: flex; flex-direction: column; gap: 2px; }
  .shelf__book .muted { font-size: 13px; }

  /* Ordering ------------------------------------------------------------ */

  .btn--dark { background: var(--ink); border-color: var(--ink); color: var(--surface); }
  .btn--dark:hover { background: var(--ink-2); color: var(--surface); }

  .recipients { display: flex; flex-direction: column; gap: 12px; }
  .recipient { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
  .recipient--off { background: var(--bg); }
  .recipient__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .recipient__head .grow { display: flex; flex-direction: column; gap: 2px; flex-basis: 200px; }
  .recipient__head .muted { font-size: 14px; }
  .recipient__initial { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font: 500 18px var(--serif); }
  .recipient__error { padding: 10px 12px; border-radius: var(--radius); background: var(--del-soft); color: var(--del-ink); font-size: 14px; }
  .stepper-group { display: flex; align-items: center; gap: 8px; }
  .stepper-group .stepper { width: 40px; height: 40px; }
  .stepper-group__value { min-width: 64px; text-align: center; font-size: 14px; font-weight: 600; }

  .speeds { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; border: 0; margin: 0; padding: 0; }
  .speed { position: relative; display: flex; cursor: pointer; }
  .speed input { position: absolute; opacity: 0; pointer-events: none; }
  .speed > span { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); font-size: 14px; }
  .speed__top { display: flex; justify-content: space-between; gap: 8px; }
  .speed .muted { font-size: 13px; }
  .speed:hover > span { border-color: var(--ink-3); }
  .speed input:checked + span { border: 2px solid var(--accent); padding: 9px 11px; background: var(--accent-soft); }
  .speed input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

  .saved-recipients { font-size: 14px; --row-gap: 8px; }
  .saved-recipients .chip { height: 36px; cursor: pointer; }
  .address-form { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

  .checkout__book { display: flex; align-items: center; gap: 14px; }
  .checkout__book .grow { display: flex; flex-direction: column; gap: 2px; }
  .checkout__book .muted { font-size: 14px; }
  .totals { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 15px; }
  .totals > div { display: flex; justify-content: space-between; gap: 12px; }
  .totals dd { margin: 0; font-variant-numeric: tabular-nums; }
  .totals__total { padding-top: 8px; font-weight: 600; font-size: 18px; }
  .totals__credit { color: var(--green-ink); }
  .checkout__element { min-height: 120px; }
  .checkout__error { padding: 10px 12px; border-radius: var(--radius); background: var(--del-soft); color: var(--del-ink); font-size: 14px; }
  .checkout__notes { display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--ink-3); }
  .checkout__notes li { display: flex; gap: 10px; align-items: flex-start; }
  .checkout__notes .icon { margin-top: 2px; color: var(--muted); }

  .order-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
  .order-card__head .grow { display: flex; flex-direction: column; gap: 4px; flex-basis: 240px; }
  .order-card__head .muted { font-size: 14px; }
  .order-card__title { font: 500 26px var(--serif); }
  .order-card .mini-cover { width: 54px; height: 70px; }
  .shipment { display: flex; flex-direction: column; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
  .shipment__head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
  .shipment__head .grow { display: flex; flex-direction: column; gap: 2px; flex-basis: 220px; }
  .shipment__head .muted { font-size: 14px; }
  .shipment__head .chip { border-radius: 999px; font-size: 13px; padding: 0 12px; }
  .shipment__tracking { font-size: 14px; }
  .progress { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .progress__step { display: flex; flex-direction: column; gap: 6px; }
  .progress__bar { height: 6px; border-radius: 3px; background: var(--sunken); }
  .progress__step--done .progress__bar { background: var(--green); }
  .progress__step--current .progress__bar { background: var(--accent); }
  .progress__label { font-size: 13px; color: var(--muted); }
  .progress__step--done .progress__label { color: var(--ink); }
  .progress__step--current .progress__label { color: var(--ink); font-weight: 600; }
  .progress__when { font-size: 12px; color: var(--muted); min-height: 1em; }

  @media (max-width: 900px) {
    .progress__label { font-size: 11px; }
    .progress__when { display: none; }
  }

  @media (max-width: 900px) {
    .choice-grid, .binding-grid { grid-template-columns: minmax(0, 1fr); }
    .sizes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .book-summary { position: static; }
    .builder__main, .builder__side { flex-basis: 100%; }
    .book-chapter__meta { display: none; }
  }

  /* On a phone the steps scroll sideways, Next sits in a bar above the tab
     bar, and recipes move from their menu instead of by dragging. */
  @media (max-width: 640px) {
    .main--builder { padding-bottom: 24px; }
    .builder-head { margin-bottom: 12px; }
    .builder-head__download span { display: none; }
    .builder-steps { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)) 16px; border-radius: 0; scrollbar-width: none; }
    .builder-steps__item { flex: 0 0 auto; }
    .builder-head .builder-nav { display: none; }
    .builder-nav--phone {
      display: flex;
      padding: 10px var(--gutter);
      background: var(--surface);
      border-top: 1px solid var(--rule);
      box-shadow: 0 -4px 12px rgba(35, 30, 25, .06);
    }
    .builder-nav__note { display: flex; flex-direction: column; margin-right: auto; font-size: 13px; color: var(--muted); }
    .builder-nav__note b { font: 500 22px var(--serif); color: var(--ink); }
    .builder-nav__next { flex: 1; }
    .builder-nav__note + .btn, .builder-nav__note ~ .builder-nav__next { flex: 0 1 auto; }

    .book-entry .drag-handle, .book-chapter__head .drag-handle, .book-drag-hint { display: none; }
    .binding-choice--main .choice__body { flex-direction: column; align-items: flex-start; }
    .book-scale { --inch: 8.5px; gap: 8px; flex-wrap: nowrap; padding: 18px 10px; }
    .binding-grid .choice__body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
    .binding-grid .binding-choice__art { display: none; }
    .binding-grid .binding-choice__price { grid-column: 2; grid-row: 1 / span 2; margin: 0; padding: 0; text-align: right; }
    .builder-nav__note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .builder-nav .btn { padding: 0 14px; white-space: nowrap; }
    .cover-front { display: flex; }
    .cover-sheet { display: none; }
    .binding-choice__art.binding-choice__art--lg { width: 48px; height: 62px; }
    .flipbook { padding: 16px 12px; touch-action: pan-y; }
    .flipbook__controls .btn { min-width: 44px; min-height: 44px; }
    .proof-turn { display: block; }
    .book-entry { padding-left: 10px; }
    .book-entry__title .muted { display: none; }
    .book-entry__where { display: block; }
    .book-entry > .book-entry__two, .book-entry > .book-entry__page { display: none; }
  }
}
