:root {
  --accent: #97566d;
  --accent-dark: #784256;
  --ink: #392c2e;
  --muted: #796a6c;
  --line: #e8dcd5;
  --bg: #f8f1e9;
  --surface: #fffaf4;
  --accent-soft: #f4e7eb;
  --topbar-h: 44px;
  --bottombar-h: 68px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { display: flex; flex-direction: column; height: 100dvh; touch-action: manipulation; overflow: hidden; padding-bottom: 0; }
button { font: inherit; cursor: pointer; color: inherit; line-height: 1.25; -webkit-appearance: none; appearance: none; }
.editor-icon { display: block; width: 22px; height: 22px; flex: 0 0 auto; pointer-events: none; }
.hidden { display: none !important; }

/* top bar */
.topbar { min-height: var(--topbar-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.model-badge { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 44px; border: 0; background: transparent; padding: 4px 0; text-align: left; }
.phone-color-dot { width: 14px; height: 14px; border: 1px solid #0002; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 1px 2px #fff7; }
.model-label { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: 2px; }
.model-color-name { font-size: 10px; color: var(--muted); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.model-name { font-weight: 600; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.model-change { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--accent); white-space: nowrap; }
.model-change .editor-icon { width: 14px; height: 14px; }
.material-select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 20px 8px 8px; background-color: var(--surface); color: var(--ink); font: inherit; font-size: 11px; width: 96px; min-width: 0; min-height: 40px; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23796a6c' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 5px center; background-size: 14px; }
@media (max-width: 400px) { .phone-color-dot { display: none; } .model-name { max-width: 118px; } }
.topbar-actions { display: flex; gap: 4px; align-items: center; margin-left: auto; flex: 0 0 auto; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: 0; background: transparent; padding: 0; }
.icon-btn:not(:disabled):active { background: var(--accent-soft); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.primary-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 600; white-space: nowrap; }
.primary-btn:disabled { background: #d5c8c8; cursor: default; }
.primary-btn:not(:disabled):active { background: var(--accent-dark); }
.ghost-btn { min-height: 44px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }

/* stage */
.stage-area { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 16px; position: relative; overflow: hidden; }
.stage-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.stage { position: relative; overflow: visible; border-radius: 6px; user-select: none; -webkit-user-select: none; touch-action: none; transform-origin: center center; }
.stage-artwork { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.checker { position: absolute; inset: 0; background-color: #fff; background-image: linear-gradient(45deg, #d9d9de 25%, transparent 25%), linear-gradient(-45deg, #d9d9de 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d9de 75%), linear-gradient(-45deg, transparent 75%, #d9d9de 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.bottom-color { position: absolute; inset: 0; }
.supplier-stack { position: absolute; inset: 0; pointer-events: none; }
.supplier-stack img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.layers { position: absolute; inset: 0; z-index: 100; }
.stage.supplier-active .checker { background: transparent !important; background-image: none !important; }
.stage.supplier-active .bottom-color { display: none; }
.layer { position: absolute; transform-origin: center center; will-change: transform; }
.layer img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 500; }
.hint { margin: 8px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); text-align: center; max-width: 340px; min-height: 2.6em; flex: 0 0 auto; }
.hint.warn { color: #c0392b; }
.zoom-btn { position: absolute; right: 14px; bottom: 54px; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px #392c2e0a; z-index: 650; }
.zoom-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* photo slots (frames) */
.layer.slot { overflow: visible; }
.layer.slot .slot-border { position: absolute; inset: 0; background: #fff; }
.layer.slot.empty .slot-border { background: rgba(255,255,255,.7); }
.layer.slot .slot-inner { position: absolute; overflow: hidden; background: rgba(255,255,255,.55); }
.layer.slot.empty .slot-inner { background: rgba(0,0,0,.1); }
.layer.slot .slot-img { position: absolute; display: block; pointer-events: none; -webkit-user-drag: none; max-width: none; }
.layer.slot .slot-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 42px; color: rgba(0,0,0,.35); font-weight: 300; }

/* selection box + handles */
.selection { position: absolute; transform-origin: center center; border: 1.5px dashed var(--accent); z-index: 600; pointer-events: none; box-sizing: border-box; }
.selection.adjust { border-style: solid; border-color: var(--accent-dark); }
.handle { position: absolute; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--accent); padding: 0; pointer-events: auto; touch-action: none; transform-origin: center center; }
.handle::before { content: ""; position: absolute; inset: 6px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); box-shadow: 0 1px 5px #392c2e14; }
.handle .editor-icon { width: 17px; height: 17px; position: relative; }
.handle-delete { left: -22px; bottom: -22px; color: #9a4c58; }
.handle-rotate { right: -22px; top: -22px; }
.handle-scale { right: -22px; bottom: -22px; cursor: nwse-resize; }
.handle-edit { left: -22px; top: -22px; }
.field-row[hidden], .note[hidden] { display: none; }

/* bottom bar */
.bottombar { height: var(--bottombar-h); background: var(--surface); border-top: 1px solid var(--line); flex: 0 0 auto; display: flex; align-items: stretch; }
.tab-row { display: flex; width: 100%; min-width: 0; padding-inline: 6px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.tab-row::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 68px; min-height: 44px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 8px 4px; }
.tab:active { background: var(--bg); }
.tab-icon { display: grid; place-items: center; width: 24px; height: 24px; color: var(--ink); }
#layerRow .tab { flex: 0 0 68px; }
#layerRow [data-action="delete"] { color: #9a4c58; }
#layerRow [data-action="delete"] .tab-icon { color: inherit; }
#layerRow [data-action="deselect"] { position: sticky; right: -6px; margin-left: auto; background: var(--surface); border-left: 1px solid var(--line); }

/* sheets */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 32px #392c2e12; z-index: 900; max-height: 46vh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet.tall { max-height: 78vh; height: 78vh; }
.sheet-head { display: flex; align-items: center; justify-content: center; min-height: 56px; position: relative; padding: 14px 60px; font-weight: 600; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.sheet-close { position: absolute; right: 8px; top: 6px; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 0; background: transparent; color: var(--muted); }
.sheet-close:active { background: var(--accent-soft); }
.cat-row { display: flex; gap: 8px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.cat-row::-webkit-scrollbar { display: none; }
.cat-row button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.cat-row button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px; overflow-y: auto; }
.tpl { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tpl.blank { background: var(--bg); }
.tpl-thumb { width: 100%; aspect-ratio: 1 / 1.9; border-radius: 8px; background: #f7f7f9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tpl-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.blank-thumb .editor-icon, .slot-ph .editor-icon { width: 36px; height: 36px; }
.blank-thumb { font-size: 40px; color: var(--muted); border: 2px dashed var(--line); background: #fff; }
.tpl-name { font-size: 12px; color: var(--ink); }
.tpl-sub { font-size: 11px; color: var(--muted); }
.spinner.small { width: 22px; height: 22px; border-width: 3px; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px; overflow-y: auto; }
.sticker-grid button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; }
.sticker-grid img { width: 100%; height: 100%; object-fit: contain; }
.model-search { padding: 10px 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.model-search input { width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font: inherit; background: var(--bg); }
.model-body { display: flex; flex: 1 1 auto; min-height: 0; }
.brand-list { width: 88px; flex: 0 0 auto; border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg); }
.brand-list button { display: block; width: 100%; border: 0; background: transparent; padding: 14px 8px; text-align: center; font-size: 14px; color: var(--muted); border-left: 3px solid transparent; }
.brand-list button.active { background: #fff; color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.model-list { flex: 1 1 auto; overflow-y: auto; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.model-list button { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 13px; min-height: 40px; }
.model-list button.active { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }
.model-list .empty { color: var(--muted); font-size: 13px; padding: 12px; }
#modelSheet { max-width: 720px; margin: 0 auto; }
#modelSheet .model-body { min-height: 90px; }
#modelSheet .brand-list { width: 62px; }
.phone-finish-section { display: flex; gap: 18px; padding: 18px; border-top: 1px solid var(--line); background: var(--bg); flex: 0 0 auto; }
.phone-hardware-preview { width: 110px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.phone-hardware-preview img { width: 110px; height: 116px; object-fit: cover; object-position: left top; border-radius: 18px; box-shadow: 0 2px 8px #0000000d; }
.phone-hardware-preview span { font-size: 10px; color: var(--muted); }
.phone-finish-options { flex: 1; min-width: 0; }
.phone-finish-eyebrow { font-size: 10px; color: var(--muted); letter-spacing: .05em; }
.phone-finish-options h3 { font-size: 15px; margin: 5px 0 12px; }
.phone-colors { display: flex; gap: 10px 8px; flex-wrap: wrap; }
.phone-colors button { width: 48px; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; font-size: 10px; color: var(--muted); line-height: 1.3; }
.phone-colors .swatch { display: block; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #00000020; box-shadow: inset 0 1px 2px #ffffff50; position: relative; }
.phone-colors button[aria-pressed=true] { color: var(--ink); font-weight: 600; }
.phone-colors button[aria-pressed=true] .swatch::after { content: ''; position: absolute; inset: -5px; border: 1.5px solid var(--accent); border-radius: 50%; }
.phone-picker-footer { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.phone-picker-footer p { margin: 0; flex: 1; color: var(--muted); font-size: 11px; line-height: 1.6; }
@media (max-height: 650px) { .phone-finish-section { padding: 12px; } .phone-hardware-preview img { height: 90px; } .phone-finish-options h3 { margin-bottom: 8px; } .phone-colors { gap: 8px; } }

/* modals */
.modal { position: fixed; inset: 0; background: #392c2e52; display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-box { background: var(--surface); border-radius: 16px; padding: 18px; width: 100%; max-width: 380px; max-height: 92vh; overflow: auto; }
.modal-box.wide { max-width: 820px; }
.modal-box h3 { margin: 0 0 12px; font-size: 17px; }
.modal-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; resize: vertical; }
.field-row { display: flex; gap: 14px; align-items: center; margin-top: 12px; font-size: 14px; flex-wrap: wrap; }
.field-row label { display: flex; align-items: center; gap: 6px; }
.field-row select, .field-row input[type=range] { max-width: 150px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.export-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.export-grid figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.export-grid img { width: 100%; max-height: 300px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.export-grid img.checker-bg { background-image: linear-gradient(45deg, #eee 25%, transparent 25%), linear-gradient(-45deg, #eee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eee 75%), linear-gradient(-45deg, transparent 75%, #eee 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
details { margin-top: 12px; font-size: 12px; }
pre { background: var(--bg); padding: 8px; border-radius: 8px; overflow: auto; max-height: 180px; }

/* busy + toast */
.busy { position: fixed; inset: 0; background: #fffaf4e8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 1100; font-weight: 600; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--bottombar-h) + 24px); transform: translateX(-50%); background: rgba(0,0,0,.78); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 1200; max-width: 86vw; }

@media (max-width: 480px) {
  .export-grid { grid-template-columns: 1fr; }
  .export-grid img { max-height: 220px; }
}
@media (min-width: 720px) {
  .hint { max-width: 520px; }
  .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 520px; }
}

/* Ready-made pet collages: photos are replaceable; stickers stay editable. */
.fixed-panel { flex: 0 0 auto; width: 100%; background: var(--surface); padding: 12px 18px 9px; border-top: 1px solid var(--line); }
.fixed-heading, .fixed-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fixed-eyebrow { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .1em; }
.fixed-heading h2 { font-size: 17px; line-height: 1.25; margin: 3px 0 0; letter-spacing: -.4px; }
.fixed-change { min-height: 40px; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 7px 11px; font-size: 11px; white-space: nowrap; }
.fixed-meta { font-size: 11px; color: var(--muted); margin: 12px 0 8px; }
#fixedProgress { color: var(--accent); font-variant-numeric: tabular-nums; }
.photo-slots { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.photo-slot-card { position: relative; min-width: 0; height: 76px; background: var(--bg); border: 1px dashed #d5bfc7; border-radius: 11px; padding: 3px 3px 18px; overflow: hidden; }
.photo-slot-card img { height: 100%; width: 100%; object-fit: contain; opacity: .66; }
.photo-slot-card.filled { border-style: solid; }
.photo-slot-card.filled img { opacity: 1; }
.photo-slot-card.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.photo-slot-label { position: absolute; bottom: 4px; left: 0; right: 0; font-size: 9px; color: #806b63; }
.photo-slot-plus { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 20px; height: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 50%; color: var(--accent); }
.photo-slot-plus .editor-icon { width: 13px; height: 13px; }
.cutout-toggle { min-height: 44px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin: 12px 0 4px; }
.cutout-toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.cutout-hint { font-size: 10px; line-height: 1.5; color: #8b817c; margin: 0; }
.cutout-retry { display: block; min-height: 44px; margin-top: 2px; padding: 6px 0; border: 0; background: transparent; color: var(--accent-dark); font-size: 11px; text-decoration: underline; }
.cutout-retry[hidden] { display: none; }
.layer.slot.contain-slot { background: transparent; }
.slot-canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.slot-sample-label { position: absolute; right: 4px; bottom: 5px; padding: 2px 6px; font-size: 9px; border-radius: 20px; background: rgba(255,255,255,.9); color: #80685b; pointer-events: none; white-space: nowrap; }
.slot-sample-label:empty { display: none; }
.contain-slot.empty::after { content: ''; position: absolute; inset: 3px; border: 1px dashed rgba(116,91,80,.36); border-radius: 18px; pointer-events: none; }
.fixed-badge { color: var(--muted); font-size: 9px; }
.fixed-mode .checker { background-color: #fff; background-image: none; }
@media (min-width: 900px) {
  .fixed-mode .stage-area { padding-right: 310px; padding-left: 70px; }
  .fixed-panel { position: absolute; right: 26px; top: 94px; width: 270px; border: 1px solid #e8e0db; border-radius: 20px; padding: 22px 18px; box-shadow: 0 12px 40px #37231b07; }
  .fixed-heading { align-items: flex-start; }
  .fixed-heading h2 { font-size: 20px; margin-top: 7px; }
  .fixed-meta { margin-top: 24px; }
  .photo-slots { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .photo-slot-card { height: 108px; }
  .photo-slot-label { font-size: 10px; }
  .cutout-toggle { margin-top: 24px; }
  .cutout-hint { margin-top: 7px; }
  .fixed-mode .zoom-btn { right: 325px; }
  .fixed-mode .stage-wrap { width: 100%; }
}
@media (max-width: 899px) {
  .fixed-panel { padding-top: 8px; }
  .fixed-heading h2 { font-size: 14px; display: inline; margin-left: 7px; }
  .fixed-eyebrow { font-size: 9px; }
  .fixed-meta { margin: 6px 0; }
  .photo-slot-card { height: 62px; }
  .cutout-toggle { display: inline-flex; gap: 9px; margin: 8px 0 0; }
  .cutout-hint { display: inline; font-size: 9px; margin-left: 8px; }
  .fixed-mode .hint { font-size: 10px; min-height: 1.8em; }
}

/* Storefront customers confirm the design; production controls stay in the standalone editor. */
body[data-embed="storefront"] #exportModal .export-grid { grid-template-columns: 1fr; }
body[data-embed="storefront"] #exportModal .export-grid figure:nth-child(2),
body[data-embed="storefront"] #exportModal #proofFigure,
body[data-embed="storefront"] #exportModal details,
body[data-embed="storefront"] #exportModal .dl { display: none; }

/* A clear, visible choice of a complete style comes before editing. */
.design-steps { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; background: var(--surface); border-bottom: 1px solid var(--line); }
.design-steps button { display: flex; align-items: center; min-height: 44px; gap: 6px; border: 0; background: none; color: #a39c96; font-size: 11px; padding: 8px 0; }
.design-steps button > span:first-child { border: 1px solid #e6dfd9; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-size: 9px; }
.design-steps button.active { color: var(--accent-dark); font-weight: 600; }
.design-steps button.active > span:first-child { border-color: var(--accent); background: var(--accent-soft); }
.design-steps i { color: #cbbcb5; font-style: normal; }
.design-steps i .editor-icon { width: 12px; height: 12px; }
#templateSheet { background: var(--surface); height: 92dvh; max-height: 92dvh; border-radius: 24px 24px 0 0; }
#templateSheet .sheet-head { font-size: 12px; color: #85776f; border-color: #ebe4de; }
.catalog-intro { flex: 0 0 auto; padding: 22px 20px 10px; }
.catalog-eyebrow { font-size: 9px; letter-spacing: .15em; color: var(--accent); font-weight: 600; }
.catalog-intro h1 { font-size: 23px; line-height: 1.45; letter-spacing: -.7px; margin: 7px 0 9px; }
.catalog-intro p { font-size: 11px; color: #92847a; line-height: 1.7; margin: 0; max-width: 390px; }
#templateCats { padding: 10px 20px 14px; }
#templateCats button { font-size: 11px; border-color: #e4dcd3; background: transparent; padding: 7px 12px; }
#templateCats button.active { background: #332c28; color: #fff; border-color: #332c28; }
#templateGrid { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 0 18px 24px; gap: 14px; }
#templateGrid .tpl { border-radius: 16px; padding: 8px 8px 12px; border-color: #e7ded5; background: #fff; gap: 6px; }
#templateGrid .tpl-thumb { aspect-ratio: 1 / 1.45; border-radius: 10px; background: #f5f0e9; }
#templateGrid .tpl-name { font-size: 13px; font-weight: 600; letter-spacing: -.2px; }
#templateGrid .tpl-choose { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 10px; color: var(--accent-dark); border-top: 1px solid #eee6df; width: 100%; padding-top: 8px; margin-top: 3px; }
#templateGrid .tpl-choose .editor-icon { width: 13px; height: 13px; }
#templateGrid .tpl:nth-child(4n+2) .tpl-thumb { background: #ececee; }
#templateGrid .tpl:nth-child(4n+3) .tpl-thumb { background: #ece7f5; }
#templateGrid .tpl:nth-child(4n+4) .tpl-thumb { background: #f1ead3; }
@media (min-width: 720px) {
  #templateSheet { width: 720px; }
  .catalog-intro { padding: 26px 28px 12px; }
  .catalog-intro h1 { font-size: 30px; }
  #templateGrid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; padding: 0 24px 24px; }
  #templateCats { padding-left: 28px; }
  #templateGrid .tpl-thumb { aspect-ratio: 1 / 1.8; }
}

/* Persistent photo recovery and visible keyboard controls. */
.photo-error { margin: 10px 0 0; padding: 10px 12px; border: 1px solid #e7b8a7; border-radius: 10px; background: #fff2e9; color: #913b28; font-size: 12px; line-height: 1.5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.fixed-mode #doneBtn { min-width: 80px; padding-inline: 12px; }

/* A single aligned header and readable controls down to 320px wide. */
@media (max-width: 560px) {
  .topbar { padding-inline: 6px; gap: 4px; }
  .model-badge { flex: 1 1 auto; gap: 3px; }
  .model-label { flex: 1 1 auto; }
  .model-name, .model-color-name { max-width: 100%; }
  .model-change > span { display: none; }
  .material-select { flex: 0 1 74px; width: 74px; font-size: 10px; }
  .topbar-actions { gap: 2px; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .topbar .primary-btn { min-height: 40px; padding-inline: 10px; font-size: 12px; }
  .fixed-heading > div { min-width: 0; }
  .fixed-heading h2 { display: block; margin: 3px 0 0; font-size: 14px; line-height: 1.25; }
  .fixed-heading { gap: 8px; }
  .fixed-eyebrow { display: none; }
  .fixed-meta { flex-wrap: wrap; gap: 4px; }
  .cutout-toggle { margin-top: 2px; }
  .cutout-hint { display: block; margin: 0; line-height: 1.5; }
  .design-steps { gap: 6px; padding-inline: 6px; }
  .design-steps button { gap: 4px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
}

#layerRow [data-action="next-photo"] { color: var(--accent-dark); background: #f5e9ed; border-radius: 12px; margin: 5px 3px; }

/* Supplier layers already contain transparency and the case shadow. */
.stage-area { background: var(--bg); }
.stage.supplier-active { background: transparent; border: 0; box-shadow: none; }

.stage.supplier-active .overlay { display: none; }


/* Preview-first editor: two quiet header rows and a real-height tool drawer. */
.editor-header { flex: 0 0 auto; background: var(--surface); padding-top: env(safe-area-inset-top); }
.titlebar { display: grid; grid-template-columns: minmax(88px,1fr) auto minmax(88px,1fr); align-items: center; min-height: 52px; padding-inline: 10px; border-bottom: 1px solid var(--line); }
.editor-title { margin: 0; color: var(--ink); font-family: Georgia, "Times New Roman", "Songti SC", serif; font-size: 19px; font-weight: 500; line-height: 1.2; letter-spacing: -.35px; }
.editor-close { justify-self: start; color: var(--ink); }
.titlebar #doneBtn { justify-self: end; min-width: 84px; min-height: 36px; padding: 7px 13px; font-size: 12px; font-weight: 600; }
.editor-header .topbar { min-height: 48px; gap: 8px; padding: 2px 14px; }
.editor-header .model-badge { flex: 1 1 auto; min-height: 44px; gap: 6px; }
.editor-header .model-name { max-width: 190px; font-size: 13px; }
.editor-header .model-color-name { max-width: 190px; font-size: 10px; }
.editor-header .model-change > span { display: none; }
.editor-header .material-select { flex: 0 1 94px; width: 94px; min-height: 34px; border-color: transparent; background-color: transparent; padding-left: 5px; }
.editor-header .topbar-actions { margin-left: 0; gap: 2px; }
.editor-header .icon-btn { width: 40px; height: 40px; }
.editor-header .editor-close { width: 44px; height: 44px; }
.editor-header .topbar-actions .editor-icon { width: 21px; height: 21px; }
.zoom-btn { width: 46px; height: 54px; bottom: 14px; right: 14px; display: flex; flex-direction: column; justify-content: center; gap: 4px; border-radius: 20px; border-color: #e8dcd580; box-shadow: 0 3px 12px #392c2e0d; }
.zoom-btn .editor-icon { width: 18px; height: 18px; }
.zoom-btn > span { font-size: 9px; line-height: 1; }
.tool-dock { flex: 0 0 auto; min-width: 0; display: flex; flex-direction: column; position: relative; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -3px 22px #392c2e08; z-index: 700; touch-action: manipulation; }
.tool-toggle-row { height: 24px; flex: 0 0 24px; position: relative; }
.tool-toggle { display: grid; place-items: center; position: absolute; width: 76px; height: 44px; top: 50%; left: 50%; transform: translate(-50%,-50%); padding: 0; background: transparent; border: 0; border-radius: 16px; color: #9a7f88; z-index: 2; touch-action: none; }
.tool-toggle-icon { display: block; width: 34px; height: 7px; pointer-events: none; transition: transform 180ms ease; }
.tool-dock[data-expanded="true"] .tool-toggle-icon { transform: rotate(180deg); }
.tool-dock .bottombar { height: var(--bottombar-h); min-height: var(--bottombar-h); flex: 0 0 var(--bottombar-h); border-top-color: #e8dcd580; background: transparent; }
#addRow, #addRow.hidden { display: grid !important; grid-template-columns: repeat(4,minmax(0,1fr)); overflow: visible; padding: 0 8px; }
#addRow .tab { min-width: 0; min-height: 44px; padding: 8px 4px; gap: 5px; border-radius: 17px; font-size: 11px; }
#addRow .tab-icon { position: relative; width: 22px; height: 22px; }
#addRow .tab-icon .editor-icon { width: 21px; height: 21px; }
#addRow .tab[aria-pressed="true"], .tool-dock[data-expanded="true"] #uploadBtn { color: var(--accent-dark); background: var(--accent-soft); }
#addRow .tab[aria-pressed="true"] .tab-icon, .tool-dock[data-expanded="true"] #uploadBtn .tab-icon { color: var(--accent-dark); }
.photo-count-badge { position: absolute; top: -10px; right: -18px; min-width: 26px; height: 16px; display: inline-flex; align-items: center; justify-content: center; padding: 1px 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 9px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--surface); }
#layerRow.context-tools { flex: 0 0 58px; min-height: 58px; width: 100%; border-top: 1px solid var(--line); background: var(--surface); touch-action: pan-x; }
#layerRow.context-tools .tab { font-size: 10px; gap: 4px; }
#layerRow.context-tools .tab-icon, #layerRow.context-tools .editor-icon { width: 20px; height: 20px; }
#layerRow.context-tools [data-action="deselect"] { z-index: 1; }
.sheet, .modal { touch-action: pan-y; }

@media (max-width: 899px) {
  .design-steps { display: none; }
  .stage-area { padding: 5px 10px; }
  .stage-wrap { min-height: 0; }
  .fixed-mode .hint, .hint { display: none; }
  .fixed-mode .hint.warn, .hint.warn { display: block; position: absolute; bottom: 8px; left: 14px; right: 72px; margin: 0; max-width: none; min-height: 0; padding: 7px 10px; color: #964b4b; background: #fffaf4ee; border: 1px solid #ead3cc; border-radius: 10px; font-size: 10px; line-height: 1.5; pointer-events: none; z-index: 660; }
  .tool-dock[data-expanded="false"] > .fixed-panel, .tool-dock[data-expanded="false"] > #layerRow { display: none !important; }
  .tool-dock[data-expanded="true"] { max-height: min(380px,48dvh); }
  .tool-dock > .fixed-panel { position: relative; top: auto; right: auto; flex: 0 1 auto; min-height: 0; max-height: 220px; margin: 0; width: 100%; border: 0; border-radius: 0; box-shadow: none; padding: 2px 16px 10px; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; }
  .tool-dock .fixed-heading { min-height: 32px; gap: 10px; align-items: center; }
  .tool-dock .fixed-heading h2 { display: block; margin: 0; font-size: 14px; line-height: 1.3; letter-spacing: -.2px; }
  .tool-dock .fixed-eyebrow { display: none; }
  .tool-dock .fixed-change { min-height: 32px; padding: 6px 9px; font-size: 10px; }
  .tool-dock .fixed-meta { gap: 8px; margin: 6px 0 8px; font-size: 11px; }
  .tool-dock .photo-slots { gap: 8px; padding: 2px; }
  .tool-dock .photo-slot-card { height: 72px; border-radius: 10px; }
  .tool-dock .photo-slot-card.active { outline-offset: 0; }
  .tool-dock .photo-slot-label { bottom: 5px; font-size: 9px; }
  .tool-dock .cutout-toggle { display: flex; justify-content: space-between; min-height: 40px; margin: 4px 0 0; gap: 10px; font-size: 11px; }
  .tool-dock .cutout-hint { display: block; margin: 0; font-size: 10px; line-height: 1.45; }
  .tool-dock .photo-error { margin: 7px 0 0; padding: 8px 10px; font-size: 11px; }
  .tool-dock .cutout-retry { min-height: 40px; }
}
@media (max-width: 359px) {
  .titlebar { grid-template-columns: minmax(76px,1fr) auto minmax(76px,1fr); padding-inline: 6px; }
  .editor-title { font-size: 18px; }
  .titlebar #doneBtn { min-width: 76px; padding-inline: 10px; }
  .editor-header .topbar { padding-inline: 10px; gap: 4px; }
  .editor-header .model-name, .editor-header .model-color-name { max-width: 138px; }
  .editor-header .material-select { flex-basis: 74px; width: 74px; font-size: 10px; }
  .editor-header .topbar-actions { gap: 0; }
}
@media (max-width: 899px) and (max-height: 640px) {
  .titlebar { min-height: 48px; }
  .editor-header .topbar { min-height: 44px; padding-block: 0; }
  .tool-dock[data-expanded="true"] { max-height: 46dvh; }
  .tool-dock .photo-slot-card { height: 62px; }
  .tool-dock .fixed-meta { margin-block: 4px; }
}
@media (min-width: 900px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .tool-dock { display: contents; }
  .tool-toggle-row { display: none; }
  .fixed-panel { top: 160px; max-height: calc(100dvh - 260px); overflow-y: auto; touch-action: pan-y; }
  #layerRow.context-tools { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tool-toggle-icon { transition: none; }
}
@keyframes tool-handle-glow {
  0%, 100% { opacity: .62; filter: drop-shadow(0 0 0 transparent); }
  50% { opacity: 1; filter: drop-shadow(0 0 3px #b46d89aa); }
}
@media (max-width: 899px) and (prefers-reduced-motion: no-preference) {
  .tool-dock[data-expanded="false"] .tool-toggle-icon { color: var(--accent); animation: tool-handle-glow 2.8s ease-in-out infinite; }
}

/* Photo actions keep a clear text hierarchy without another banner or pill. */
.fixed-style-name { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.3; }
.fixed-next-photo { min-height: 44px; display: inline-flex; align-items: center; justify-content: flex-start; padding: 0 3px; border: 0; border-radius: 6px; background: transparent; color: var(--accent-dark); font-size: 11px; font-weight: 600; text-align: left; }
.fixed-next-photo[hidden] { display: none; }
.fixed-next-photo:active { background: var(--accent-soft); }
.fixed-meta #fixedProgress { margin-left: auto; }
@media (max-width: 899px) {
  .tool-dock .fixed-heading > div { min-width: 0; }
  .tool-dock .fixed-heading h2 { font-size: 15px; font-weight: 600; }
  .tool-dock .fixed-style-name { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; margin-top: 2px; }
  .tool-dock .fixed-meta { margin-block: 2px; }
}

/* Keep the standalone title balanced without exposing an inert close action. */
.editor-close[hidden] { display: inline-flex; visibility: hidden; pointer-events: none; }
.photo-count-badge[hidden] { display: none; }
@media (max-width: 899px) {
  .titlebar { min-height: 48px; padding-block: 2px; }
  .editor-header .topbar { min-height: 44px; padding-block: 0; }
}

.photo-guide, .template-guide { margin: 8px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.template-guide { padding: 0 16px; }

/* Blank designs keep printed background color separate from phone hardware. */
.design-background-btn { position: absolute; left: 14px; bottom: 14px; z-index: 650; display: inline-flex; align-items: center; gap: 7px; min-height: 44px; max-width: calc(100% - 90px); border: 1px solid #e8dcd580; border-radius: 999px; background: var(--surface); padding: 7px 11px; color: var(--ink); box-shadow: 0 3px 12px #392c2e0d; font-size: 10px; font-weight: 500; }
.design-background-btn[hidden] { display: none; }
.design-background-btn .editor-icon { width: 12px; height: 12px; }
.design-background-swatch, .background-color-chip { display: block; width: 23px; height: 23px; border: 1px solid #b9a8a855; border-radius: 50%; flex: 0 0 auto; }
.is-transparent { background-color: #fff; background-image: linear-gradient(45deg,#d7d0ca 25%,transparent 25%),linear-gradient(-45deg,#d7d0ca 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d7d0ca 75%),linear-gradient(-45deg,transparent 75%,#d7d0ca 75%); background-size: 10px 10px; background-position: 0 0,0 5px,5px -5px,-5px 0; }
#backgroundSheet { max-height: min(460px,80dvh); overflow-y: auto; padding-bottom: max(16px,env(safe-area-inset-bottom)); }
.background-guide { margin: 12px 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.background-color-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; padding: 4px 18px 16px; }
.background-color-option { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 68px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 9px; }
.background-color-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.background-color-chip { width: 30px; height: 30px; }
.background-custom { display: grid; grid-template-columns: 34px minmax(75px,1fr) auto; align-items: center; gap: 9px; padding: 12px 18px 0; border-top: 1px solid var(--line); }
.background-custom label { grid-column: 1/-1; color: var(--ink); font-size: 12px; }
#backgroundColorInput { width: 34px; height: 44px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#backgroundHexInput { width: 100%; min-width: 0; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 12px; text-transform: uppercase; }
.background-custom .primary-btn { padding-inline: 11px; font-size: 11px; }
.blank-mode .fixed-panel .photo-guide { display: none; }
.blank-mode .fixed-panel .photo-slots { display: none; }
.blank-mode .fixed-meta { margin-top: 8px; }
.blank-mode .fixed-next-photo { width: 100%; justify-content: center; border: 1px solid var(--line); border-radius: 999px; }
.blank-mode .hint.warn { bottom: 65px; }
@media (min-width:900px) { .design-background-btn { bottom: 40px; } }
