/*
 * Reusable component styles: one entry per Jinja macro in
 * templates/_components/ (see CLAUDE.md), plus the client-templated upload
 * list below (an Alpine x-for block, not a Jinja macro — nothing for Jinja
 * to loop over at render time, so it lives inline in its one template).
 */
@layer components {
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-brand-strong);
    border-radius: var(--radius-md);
    background: var(--color-brand);
    color: var(--color-paper);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
  }

  .button:hover {
    background: var(--color-brand-strong);
  }

  .button[data-variant="secondary"] {
    background: var(--color-paper);
    color: var(--color-ink);
    border-color: var(--color-line);
    box-shadow: none;
  }

  .button[data-variant="secondary"]:hover {
    background: var(--color-paper-muted);
  }

  /* A destructive action next to the normal ones (crop sheet "Delete photo"): quiet like secondary, red so it isn't
     pressed by habit. */
  .button[data-variant="danger"] {
    background: var(--color-paper);
    color: var(--color-danger);
    border-color: var(--color-danger);
    box-shadow: none;
  }

  .button[data-variant="danger"]:hover {
    background: var(--color-paper-muted);
  }

  .dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-7) var(--space-5);
    border: 2px dashed var(--color-line);
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--color-ink-soft);
    transition: border-color var(--transition-base), background var(--transition-base);
  }

  /* Drag state comes from Alpine's :data-state binding, not a toggled class
     (D14) — and not x-show/:style either, since those write inline styles. */
  .dropzone[data-state="dragover"] {
    border-color: var(--color-brand);
    background: var(--color-paper-muted);
  }

  .dropzone[data-state="max"] {
    background: var(--color-paper-muted);
    opacity: 0.7;
  }

  .dropzone label:has(+ input:disabled) {
    cursor: not-allowed;
  }

  .thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-8) * 2), 1fr));
    gap: var(--space-3);
    list-style: none;
    padding: 0;
  }

  .thumb-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-paper-muted);
    box-shadow: var(--shadow-sm);
    cursor: grab;
  }

  .thumb-tile__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  /* The arrange step's drag-to-reorder grid (arrange.js). A touch drag starts with a long-press, and on iOS a
     long-press on a photo belongs to Safari: the "Save to Photos" callout, text selection, or lifting the <img> for
     a system drag into another app. Each of those cancels the pointer and kills Sortable's drag before it starts,
     so the page order could not be changed on an iPhone (owner report 2026-11-22). Taking those gestures away and
     letting the touch land on the tile, not the image, leaves the long-press to Sortable. */
  .thumb-grid--sortable .thumb-tile {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .thumb-grid--sortable .thumb-tile__img {
    -webkit-user-drag: none;
    pointer-events: none;
  }

  /* Sortable's own state classes: the tile lifts once the long-press has taken (so a touch user knows they can
     move it now), and the gap it leaves while dragging is marked out. */
  .thumb-grid--sortable .sortable-chosen {
    box-shadow: var(--shadow-md);
    outline: 2px solid var(--color-brand);
  }

  .thumb-grid--sortable .sortable-ghost {
    outline-style: dashed;
  }

  /* A tile with controls under the photo (lab "Use"/"Delete", admin "Remove"): the tile grows to fit them, the photo
     stays square. Without this the square tile clipped the controls away (owner report 2026-10-11). */
  .thumb-tile--with-actions {
    aspect-ratio: auto;
    cursor: default;
  }

  .thumb-tile--with-actions .thumb-tile__img {
    aspect-ratio: 1 / 1;
    height: auto;
    cursor: pointer;
  }

  .thumb-tile__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2);
    font-size: var(--font-size-sm);
  }

  .thumb-tile__actions label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    cursor: pointer;
  }

  /* A photo the browser can't decode (HEIC outside Safari) has nothing to show until the server's thumbnail arrives:
     its file name stands in rather than a broken image. Top-aligned so the error overlay at the bottom can't cover it. */
  .thumb-tile__name {
    display: none;
    position: absolute;
    inset: 0;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
    text-align: center;
    overflow-wrap: anywhere;
  }

  .thumb-tile[data-state="no-preview"] .thumb-tile__img {
    display: none;
  }

  .thumb-tile[data-state="no-preview"] .thumb-tile__name {
    display: flex;
  }

  .thumb-tile__overlay {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--color-overlay);
  }

  .thumb-tile[data-status="preparing"] .thumb-tile__overlay,
  .thumb-tile[data-status="uploading"] .thumb-tile__overlay,
  .thumb-tile[data-status="error"] .thumb-tile__overlay {
    display: flex;
  }

  /* Progress and error/retry visibility follow data-status, not x-show:
     Alpine's x-show toggles an inline style, which D14 rules out. */
  .thumb-tile__progress {
    display: none;
    width: 100%;
    height: var(--space-1);
    border: none;
    border-radius: var(--radius-full);
    accent-color: var(--color-brand);
  }

  .thumb-tile[data-status="preparing"] .thumb-tile__progress,
  .thumb-tile[data-status="uploading"] .thumb-tile__progress {
    display: block;
  }

  .thumb-tile__error {
    display: none;
    font-size: var(--font-size-sm);
    color: var(--color-paper);
  }

  .thumb-tile[data-status="error"] .thumb-tile__error {
    display: block;
  }

  .retry-button {
    display: none;
    border: none;
    background: none;
    color: var(--color-paper);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
  }

  .thumb-tile[data-status="error"] .retry-button {
    display: inline-flex;
  }

  .crop-sheet {
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
    max-width: min(90vw, var(--content-max-width));
  }

  .crop-sheet::backdrop {
    background: var(--color-overlay);
  }

  .crop-sheet__body {
    max-height: 60vh;
  }

  .crop-sheet__image {
    display: block;
    max-width: 100%;
    /* Cropper.js replaces this <img> with its own canvas-based UI on init;
       until then (and if the library ever fails to load) show the plain photo. */
    max-height: 60vh;
  }

  .crop-sheet__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-4);
  }

  /* "Delete photo": its own row under Cancel/Save, set apart by a rule, so it is never next to Save. */
  .crop-sheet__secondary {
    display: flex;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-line);
  }

  .crop-sheet__secondary .button:disabled {
    opacity: 0.6;
    cursor: progress;
  }

  .lang-switch {
    display: flex;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
  }

  .lang-switch a {
    color: var(--color-ink-soft);
    text-decoration: none;
  }

  .lang-switch a[data-state="active"] {
    color: var(--color-ink);
    font-weight: 700;
    text-decoration: underline;
  }

  .page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .account-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: baseline;
    font-size: var(--font-size-sm);
  }

  .account-nav a,
  .account-nav button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-ink-soft);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
  }

  .footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .footer-links a {
    color: inherit;
  }

  /* Legal documents (plan step 25): the lawyer's texts, one section per numbered paragraph, tables included. */
  .legal-doc section > * + * {
    margin-top: var(--space-3);
  }

  .legal-doc ul {
    padding-left: var(--space-5);
  }

  .legal-table-wrap {
    overflow-x: auto;
  }

  .legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
  }

  .legal-table th,
  .legal-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-line);
    text-align: left;
    vertical-align: top;
  }

  .legal-table th {
    color: var(--color-ink-soft);
    font-weight: 600;
  }

  .choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .choice-card {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
  }

  .choice-card:has(input:checked) {
    border-color: var(--color-brand);
    background: var(--color-paper-muted);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
  }

  .choice-card input {
    accent-color: var(--color-brand);
  }

  .hint {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .hint[data-status="success"] {
    color: var(--color-success);
    font-weight: 600;
  }

  .hint[data-tone="warning"] {
    color: var(--color-warning);
  }

  .form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .form-field label {
    font-size: var(--font-size-sm);
    font-weight: 600;
  }

  .form-field input,
  .form-field select,
  .form-field textarea {
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-paper);
    font-family: inherit;
  }

  .form-field textarea {
    resize: vertical;
  }

  .form-field[data-invalid="true"] input,
  .form-field[data-invalid="true"] select,
  .form-field[data-invalid="true"] textarea {
    border-color: var(--color-danger);
  }

  .form-field input[readonly] {
    background: var(--color-paper-muted);
    color: var(--color-ink-soft);
  }

  .form-field__hint {
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
  }

  .form-field__error {
    font-size: var(--font-size-sm);
    color: var(--color-danger);
  }

  /* Wizard details step: address line 2 as a disclosure instead of an
     always-visible field (plan D28), same marker-hiding treatment as the
     admin regenerate <details> below. */
  .address-extra-disclosure summary {
    list-style: none;
    color: var(--color-brand-strong);
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
  }

  .address-extra-disclosure summary::-webkit-details-marker {
    display: none;
  }

  .address-extra-disclosure[open] summary {
    margin-bottom: var(--space-2);
  }

  .check-field {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
  }

  .check-field input {
    flex-shrink: 0;
    margin-top: var(--space-1);
    accent-color: var(--color-brand);
  }

  .billing-address:has(input[name="bill_differs"]:not(:checked)) .billing-address__fields {
    display: none;
  }

  .consent-field {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
  }

  .consent-field input {
    flex-shrink: 0;
    margin-top: var(--space-1);
    accent-color: var(--color-brand);
  }

  /* Covers both OrderStatus and PageStatus values (see _components/badge.html);
     color comes only from data-status, per D14. */
  .status-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border: 1px solid currentColor;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: 600;
    white-space: nowrap;
  }

  /* Tabular-figure treatment for admin cost/token numbers (D18), an
     intentional contrast with the customer-facing serif (DESIGN.md). */
  .cost-figure {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }

  .status-badge[data-status="draft"],
  .status-badge[data-status="purged"],
  .status-badge[data-status="pending"],
  .status-badge[data-status="created"],
  .status-badge[data-status="expired"] {
    color: var(--color-status-pending);
  }

  .status-badge[data-status="submitted"] {
    color: var(--color-brand);
  }

  .status-badge[data-status="generating"],
  .status-badge[data-status="payment"],
  .status-badge[data-status="capture_pending"],
  .status-badge[data-status="sending"] {
    color: var(--color-status-generating);
  }

  .status-badge[data-status="review"],
  .status-badge[data-status="outdated"] {
    color: var(--color-status-outdated);
  }

  .status-badge[data-status="shipped"],
  .status-badge[data-status="done"],
  .status-badge[data-status="captured"],
  .status-badge[data-status="sent"] {
    color: var(--color-status-done);
  }

  .status-badge[data-status="cancelled"],
  .status-badge[data-status="failed"] {
    color: var(--color-status-failed);
  }

  .status-badge[data-status="refused"] {
    color: var(--color-status-refused);
  }

  .status-badge[data-status="excluded"],
  .status-badge[data-status="deleted"],
  .status-badge[data-status="partially_refunded"],
  .status-badge[data-status="refunded"] {
    color: var(--color-status-excluded);
  }

  .filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .filter-tabs a,
  .filter-tabs button {
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-full);
    color: var(--color-ink-soft);
    text-decoration: none;
    font-size: var(--font-size-sm);
  }

  /* The admin nav's logout is a POST form (CSRF), styled like a tab and pushed to the far end. */
  .filter-tabs button {
    background: none;
    font-family: inherit;
    cursor: pointer;
  }

  .filter-tabs form {
    margin-left: auto;
  }

  .filter-tabs a[data-state="active"] {
    border-color: var(--color-brand);
    background: var(--color-paper-muted);
    color: var(--color-ink);
    font-weight: 600;
  }

  .order-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    list-style: none;
    padding: 0;
  }

  .order-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    background: var(--color-paper);
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  }

  a.order-card:hover {
    border-color: var(--color-brand);
    box-shadow: var(--shadow-md);
  }

  .order-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .order-card__ref {
    font-weight: 700;
  }

  .order-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
  }

  /* Row of action buttons/forms at the bottom of a card (e.g. styles.html's edit/delete). */
  .card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .page-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
  }

  .page-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-paper);
  }

  .page-row__label {
    font-weight: 600;
  }

  .page-row__error {
    font-size: var(--font-size-sm);
    color: var(--color-danger);
  }

  .page-row__thumb,
  .page-row__output,
  .page-row__output-empty {
    width: calc(var(--space-8) * 1.5);
    height: calc(var(--space-8) * 1.5);
    border-radius: var(--radius-md);
    flex-shrink: 0;
  }

  .page-row__thumb,
  .page-row__output {
    border: 1px solid var(--color-line);
    background: var(--color-paper-muted);
    object-fit: cover;
    display: block;
  }

  .page-row__output-empty {
    border: 1px dashed var(--color-line);
  }

  .page-row__output-empty[data-status="generating"] {
    animation: page-output-pulse 1.4s ease-in-out infinite;
  }

  @keyframes page-output-pulse {
    0%, 100% { background: var(--color-paper-muted); }
    50% { background: var(--color-paper); }
  }

  /* flex-basis: 100% drops this onto its own line within the wrapping .page-row, regardless of
     how tall the regenerate form gets once opened. */
  .page-row__actions {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .page-row__regenerate summary {
    list-style: none;
  }

  .page-row__regenerate summary::-webkit-details-marker {
    display: none;
  }

  .page-row__regenerate[open] summary {
    margin-bottom: var(--space-2);
  }

  .page-row__regenerate form {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: min(100%, calc(var(--space-8) * 5));
  }

  .page-row__regenerate form label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--font-size-sm);
    font-weight: 600;
  }

  /* _components/media_frame.html — a confident product-shot frame for the
     hero and example gallery. `data-ratio` is a fixed enum, not a
     per-instance inline style (CLAUDE.md). */
  .media-frame {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: var(--color-paper-muted);
  }

  .media-frame[data-ratio="wide"] {
    aspect-ratio: 16 / 9;
  }

  .media-frame[data-ratio="square"] {
    aspect-ratio: 1 / 1;
  }

  .media-frame__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Progressive-enhancement video layer: hidden until main.js marks it
     ready (its `loadeddata` event), so the poster <img> never flashes
     behind a blank video frame; removed entirely under reduced motion. */
  .media-frame__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--transition-base);
  }

  .media-frame__video[data-state="ready"] {
    opacity: 1;
  }

  @media (prefers-reduced-motion: reduce) {
    .media-frame__video {
      display: none;
    }
  }

  /* _components/photo_frame.html — the instant-photo motif (Appendix B),
     reserved for personal-photo moments (title-star selection,
     order-complete) — never the hero/gallery, which use media_frame.
     `data-tilt` is a fixed enum, not a per-instance inline style. */
  .photo-frame {
    display: inline-block;
    max-width: 100%;
    padding: var(--space-2) var(--space-2) var(--space-5);
    background: var(--color-paper);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
  }

  .photo-frame[data-tilt="left"] {
    transform: rotate(-4deg);
  }

  .photo-frame[data-tilt="right"] {
    transform: rotate(3deg);
  }

  .photo-frame__img {
    display: block;
    width: min(100%, calc(var(--space-8) * 4));
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
  }

  /* _components/book_preview.html — click-through example-book gallery.
     Alpine only (no new vendored lib); page visibility via `data-state`,
     never x-show/:style (D14). */
  .book-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }

  /* width: 100% (not just max-width) matters here: every child is
     position:absolute (book-preview__page), so the frame has no in-flow
     content to size itself from — without an explicit width, a flex item's
     shrink-to-fit sizing collapses it to 0 instead of filling the
     (align-items: center) parent up to max-width. */
  .book-preview__frame {
    width: 100%;
    max-width: min(100%, calc(var(--space-8) * 6));
  }

  .book-preview__page {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--transition-base);
  }

  .book-preview__page[data-state="active"] {
    opacity: 1;
  }

  .book-preview__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
  }

  .book-preview__counter {
    min-width: calc(var(--space-8) * 1.5);
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
  }

  /* _components/peel_reveal.html — style-showcase card (plan step 27): the
     coloring page lies on top with its bottom-right corner folded back,
     showing a sliver of the original photo underneath; pressing and holding
     peels the whole page off diagonally, letting go lays it back. State via
     `data-state`, never x-show/:style (D14).

     The fold is a 45° line at distance --peel from the corner. The page is
     clipped along it, and the folded-back flap is the cut-off triangle
     mirrored across that line, so growing --peel to 200% moves the fold past
     the opposite corner: page and flap both leave the frame. --peel is
     unregistered, so it is not animated itself; the properties that use it
     carry the transition instead. */
  .peel {
    --peel: 22%;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
  }

  .peel[data-state="revealed"] {
    --peel: 200%;
  }

  @media (hover: hover) {
    .peel:hover {
      --peel: 28%;
    }

    .peel[data-state="revealed"]:hover {
      --peel: 200%;
    }
  }

  .peel__photo,
  .peel__sheet {
    position: absolute;
    inset: 0;
  }

  .peel__sheet {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--peel)), calc(100% - var(--peel)) 100%, 0 100%);
    transition: clip-path var(--transition-peel);
  }

  .peel__flap {
    position: absolute;
    right: 0;
    bottom: 0;
    width: var(--peel);
    height: var(--peel);
    filter: drop-shadow(var(--shadow-peel));
    pointer-events: none;
    transition: width var(--transition-peel), height var(--transition-peel);
  }

  /* The back of the paper: lightest at the tip, darkening into the fold. */
  .peel__flap::before {
    content: "";
    position: absolute;
    inset: 0;
    clip-path: polygon(0 0, 100% 0, 0 100%);
    background: linear-gradient(to bottom right, var(--color-paper-muted) 0%, var(--color-paper) 28%, var(--color-line) 50%);
  }

  /* One button over the whole card takes the press (mouse, touch, or Space
     and Enter held down): no image is the touch target, so a long press
     opens no "save image" menu. */
  .peel__handle {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: var(--space-3);
    border: none;
    background: none;
    cursor: pointer;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* The frame clips overflow, so the ring has to sit inside its edge. */
  .peel__handle:focus-visible {
    outline-offset: calc(-1 * var(--space-1));
    border-radius: var(--radius-lg);
  }

  .peel__hint {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target-min);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--color-overlay);
    color: var(--color-paper);
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: opacity var(--transition-base);
  }

  .peel[data-state="revealed"] .peel__hint {
    opacity: 0;
  }

  @media (prefers-reduced-motion: reduce) {
    .peel__sheet,
    .peel__flap {
      transition: none;
    }
  }

  /* Landing page: hero (plan D27) */
  .hero {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    text-align: center;
  }

  .hero__title {
    font-size: var(--font-size-display);
    line-height: var(--line-height-display);
    letter-spacing: var(--letter-spacing-tight);
  }

  .hero__lede {
    max-width: var(--content-max-width);
    margin-inline: auto;
    color: var(--color-ink-soft);
  }

  .hero__cta {
    margin-inline: auto;
  }

  /* Landing page: section headings shared by the example gallery and style
     showcase (plan D27) */
  .landing-section__title {
    text-align: center;
    font-size: var(--font-size-3xl);
  }

  .landing-section__subtitle {
    max-width: var(--content-max-width);
    margin-inline: auto;
    text-align: center;
    color: var(--color-ink-soft);
  }

  /* Landing page: per-style showcase grid (plan D27) */
  .showcase-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    list-style: none;
    padding: 0;
  }

  @media (min-width: 768px) {
    .showcase-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  .showcase-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .showcase-card__title {
    font-family: var(--font-serif);
    font-size: var(--font-size-lg);
  }

  .showcase-card__desc {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  /* Landing page: "How it's made" numbered steps (plan D28) */
  .how-it-works {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    list-style: none;
    padding: 0;
    max-width: var(--content-max-width);
    margin-inline: auto;
  }

  .how-it-works__item {
    display: flex;
    gap: var(--space-3);
  }

  .how-it-works__index {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--color-brand);
    padding-top: var(--space-1);
  }

  /* Wizard step shell (plan D28): shared chrome for the six step routes. */
  .wizard-step {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
  }

  .wizard-step__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .wizard-step__back {
    color: var(--color-ink-soft);
    text-decoration: none;
    font-size: var(--font-size-lg);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .wizard-step__count {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
  }

  .wizard-step__exit {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
    text-decoration: none;
  }

  .wizard-step__body h1 {
    font-size: var(--font-size-2xl);
    letter-spacing: var(--letter-spacing-tight);
  }

  /* _components/wizard_progress.html — six-segment progress bar. Segment
     state via data-state, not a class string built in Jinja (CLAUDE.md). */
  .wizard-progress {
    display: flex;
    gap: var(--space-1);
  }

  .wizard-progress__segment {
    flex: 1;
    height: var(--space-1);
    border-radius: var(--radius-full);
    background: var(--color-line);
  }

  .wizard-progress__segment[data-state="done"],
  .wizard-progress__segment[data-state="current"] {
    background: var(--color-brand);
  }

  /* Photo-count meter on the photos step: a native <progress> element, not
     an inline-styled fill bar (CLAUDE.md: no inline style attributes). */
  .wizard-meter {
    display: flex;
    align-items: center;
    gap: var(--space-3);
  }

  .wizard-meter__bar {
    flex: 1;
    height: var(--space-2);
    border: none;
    border-radius: var(--radius-full);
    accent-color: var(--color-brand);
  }

  .wizard-meter__count {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
    white-space: nowrap;
  }

  /* Sticky action bar: this codebase's first position: sticky element
     (DESIGN.md Layout) — replaces the legal-links footer on wizard steps
     (base.html's footer block), context line left, one action right. */
  .wizard-actionbar {
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--color-paper);
    border-top: 1px solid var(--color-line);
  }

  .wizard-actionbar[data-state="inline"] {
    position: static;
  }

  .wizard-actionbar__context {
    font-size: var(--font-size-sm);
    color: var(--color-ink-soft);
  }

  .button[data-state="disabled"] {
    background: var(--color-paper-muted);
    border-color: var(--color-line);
    color: var(--color-ink-soft);
    box-shadow: none;
    cursor: not-allowed;
  }

  /* Wide choice cards (audience step: sample-artwork thumbnail + text,
     stacked full-width rather than the pill-shaped .choice-card row). */
  .choice-group--stacked {
    flex-direction: column;
  }

  .choice-card--wide {
    width: 100%;
    border-radius: var(--radius-lg);
    align-items: center;
  }

  .choice-card--wide .media-frame {
    width: calc(var(--space-8) * 1.5);
    flex-shrink: 0;
  }

  /* Style step: a 2-column grid of style cards, each fadeable via
     data-state (CLAUDE.md), rather than the audience step's pill row. */
  .choice-group--grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .choice-card--style {
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius-lg);
  }

  .choice-card--style[data-state="unavailable"] {
    opacity: 0.55;
  }

  .choice-card--style[data-state="unavailable"] input {
    cursor: not-allowed;
  }

  /* Arrange step: cover-page badge on the title photo, replacing the old
     star-button toggle (plan D28). */
  .cover-badge {
    position: absolute;
    top: var(--space-1);
    left: var(--space-1);
    padding: 0 var(--space-2);
    border: none;
    border-radius: var(--radius-full);
    background: var(--color-overlay);
    color: var(--color-paper);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    cursor: pointer;
  }

  .thumb-tile[data-cover="true"] .cover-badge {
    background: var(--color-brand);
  }

  /* Confirm step: summary rows with a per-row Edit link (plan D28). */
  .summary-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  .summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .summary-row + .summary-row {
    border-top: 1px solid var(--color-line);
  }

  .summary-row__label {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .summary-row__value {
    text-align: right;
    font-weight: 600;
  }

  .summary-row__edit {
    margin-left: var(--space-2);
    color: var(--color-brand-strong);
    font-weight: 600;
    text-decoration: none;
  }

  /* ---- Staging: "test environment" banner on every page (plan step 27), _components/env_banner.html ---- */
  .env-banner {
    padding: var(--space-2) var(--space-4);
    border-bottom: 2px solid var(--color-warning);
    background: var(--color-paper-muted);
    color: var(--color-ink);
    font-size: var(--font-size-sm);
    text-align: center;
  }

  /* ---- Admin: generation paused banner (plan step 19), rendered by the nav macro ---- */
  .admin-alert {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    background: var(--color-paper-muted);
  }

  /* ---- Admin: prompts screen with revision history (plan D42) ---- */
  .prompt-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .prompt-style {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
  }

  .prompt-style legend {
    padding: 0 var(--space-2);
    font-weight: 600;
  }

  .prompt-history summary {
    cursor: pointer;
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .prompt-history__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-2);
    padding-left: 0;
    list-style: none;
  }

  .prompt-history__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding-left: var(--space-3);
    border-left: 2px solid var(--color-line);
  }

  .prompt-history__item[data-state="current"] {
    border-left-color: var(--color-success);
  }

  .prompt-history__text {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  /* Save stays reachable at the end of a long form of prompts. */
  .sticky-save {
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    padding: var(--space-3) 0;
    background: var(--color-paper);
    border-top: 1px solid var(--color-line);
  }

  /* ---- Admin: prompt lab (plan D42) ---- */
  .lab-upload {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
  }

  .lab-photo {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .lab-photo__pick {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-size-sm);
  }

  .lab-photo__delete .button {
    font-size: var(--font-size-sm);
  }

  .lab-styles {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
  }

  .lab-styles__option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .lab-run-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
  }

  .lab-run-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: 0;
    list-style: none;
  }

  .lab-run {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-paper);
  }

  .lab-run__images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }

  .lab-run__image,
  .lab-run__image-empty {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
  }

  .lab-run__image {
    border: 1px solid var(--color-line);
    background: var(--color-paper-muted);
    object-fit: contain;
  }

  .lab-run__image-empty {
    border: 1px dashed var(--color-line);
  }

  .lab-run__image-empty[data-status="generating"] {
    animation: page-output-pulse 1.4s ease-in-out infinite;
  }

  .lab-run__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }

  .lab-run__title {
    font-weight: 600;
  }

  .lab-run__prompt summary {
    cursor: pointer;
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .lab-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(calc(var(--space-8) * 2), 1fr));
    gap: var(--space-2);
    margin: 0;
  }

  .lab-metric dt {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .lab-metric dd {
    margin: 0;
    font-family: var(--font-mono);
    font-weight: 600;
  }

  .lab-metric[data-state="off-target"] dd {
    color: var(--color-warning);
  }

  .lab-metric__target {
    color: var(--color-ink-soft);
    font-weight: 400;
    font-size: var(--font-size-sm);
  }

  .lab-estimate {
    font-size: var(--font-size-lg);
  }

  .lab-changes__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 0;
    list-style: none;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
  }

  .lab-changes__line[data-state="added"] {
    color: var(--color-success);
  }

  .lab-changes__line[data-state="removed"] {
    color: var(--color-danger);
    text-decoration: line-through;
  }

  /* ---- Prices (plan step 20) ---- */
  .price-summary .summary-row__value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .summary-row[data-state="total"] {
    font-weight: 700;
    font-size: var(--font-size-lg);
  }

  .price-summary > .hint {
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--color-line);
  }

  .price-line {
    font-weight: 600;
  }

  .price-line:empty {
    display: none;
  }

  .hero__price a {
    color: var(--color-brand-strong);
  }

  /* ---- Admin pricing tables (plan step 20) ---- */
  .form-errors {
    margin: 0;
    padding: var(--space-3) var(--space-4) var(--space-3) var(--space-6);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    color: var(--color-danger);
  }

  .price-table {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
  }

  .price-table legend {
    padding: 0 var(--space-2);
    font-weight: 600;
  }

  .price-table__head,
  .price-table__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2);
  }

  .price-table__head {
    color: var(--color-ink-soft);
    font-size: var(--font-size-sm);
  }

  .price-table__row input {
    width: 100%;
    min-height: var(--touch-target-min);
    padding: var(--space-2);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-sm);
    background: var(--color-paper);
    font: inherit;
    font-variant-numeric: tabular-nums;
  }
}
