/* Another view — paper, halftone, foil. One stylesheet for the full mobile flow. */
:root {
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei", sans-serif;

  color: #202344;

  background: #f5f3f7;

  --ink: #202344;

  --muted: #666780;

  --blue: #3049a6;

  --pink: #aa286f;

  --paper: #f8f6fa;

  --line: #d5d4e3;

  --green: var(--blue);

  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;

  min-width: min(320px, 100%);

  background:
    radial-gradient(ellipse at 90% 0%, #dbe8f5aa, transparent 40%), var(--paper);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  color: var(--ink);

  background: #fbfaff;

  border: 1px solid var(--line);

  border-radius: 3px;

  padding: 10px 14px;

  min-height: 44px;

  font-size: 14px;

  cursor: pointer;

  transition:
    background 0.16s,
    border-color 0.16s,
    transform 0.16s;
}

button:hover:enabled {
  border-color: var(--blue);

  background: #edf0fa;
}

button:active:enabled {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.4;

  cursor: default;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible,
summary:focus-visible,
.appearance-panel:focus-visible {
  outline: 2px solid var(--pink);

  outline-offset: 4px;
}

input[type="range"]:disabled {
  opacity: 0.4;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2,
h3 {
  font-size: 16px;

  font-weight: 650;
}

section {
  min-width: 0;
}

main:not(.flow) {
  display: none;
}

.skip-link {
  position: fixed;

  left: 12px;

  top: -80px;

  z-index: 50;

  padding: 12px;

  background: var(--ink);

  color: white;
}

.skip-link:focus {
  top: 8px;
}

header {
  height: 68px;

  border-bottom: 1px solid var(--line);

  display: flex;

  align-items: center;

  gap: 16px;

  padding: 0 28px;

  background: #f8f6faf5;
}

.brand {
  display: flex;

  align-items: center;

  gap: 10px;

  font-size: 21px;

  letter-spacing: -1px;

  font-weight: 750;

  white-space: nowrap;
}

.brand-symbol {
  font-size: 29px;

  color: var(--blue);
}

.brand-en {
  font-family: Georgia, "Times New Roman", serif;

  font-size: 23px;

  font-weight: 400;

  font-style: italic;

  letter-spacing: -1px;

  border-left: 1px solid var(--line);

  padding-left: 16px;

  margin-left: 6px;
}

.header-edition {
  margin-left: auto;

  font-size: 10px;

  letter-spacing: 2px;

  color: var(--muted);
}

header #flowBack {
  border: 0;

  border-right: 1px solid var(--line);

  border-radius: 0;

  background: transparent;

  min-width: 62px;

  padding: 8px 16px 8px 0;

  font-size: 14px;
}

.local {
  display: none;
}

.flow {
  width: 100%;

  max-width: 820px;

  margin: 0 auto;

  padding: 32px 28px 112px;

  display: block;

  height: auto;

  min-height: 0;
}

.flow-progress {
  display: flex;

  align-items: center;

  justify-content: space-between;

  font:
    11px Consolas,
    monospace;

  letter-spacing: 1px;

  color: var(--muted);
}

#flowMode {
  font-family: inherit;

  letter-spacing: 0;
}

.flow-track {
  height: 3px;

  margin: 12px 0 28px;

  background: #dedde9;
}

.flow-track i {
  display: block;

  height: 100%;

  background: var(--blue);
}

.flow-heading {
  margin-bottom: 24px;
}

.flow-heading h1 {
  font-size: clamp(27px, 4vw, 38px);

  font-weight: 750;

  letter-spacing: -1.6px;

  line-height: 1.25;

  outline: none;
}

.flow-heading p {
  color: var(--muted);

  font-size: 13px;
}

#flowNotice {
  color: #962956;

  font-size: 13px;

  line-height: 1.7;

  margin-top: 14px;

  overflow-wrap: anywhere;
}

#flowNotice:empty {
  display: none;
}

.flow-nav {
  position: fixed;

  bottom: 0;

  left: 0;

  right: 0;

  display: flex;

  gap: 12px;

  z-index: 20;

  padding: 14px max(28px, calc((100vw - 764px) / 2))
    calc(14px + env(safe-area-inset-bottom));

  background: #f8f6faf5;

  border-top: 1px solid var(--line);

  backdrop-filter: blur(12px);
}

.flow-nav button {
  min-height: 50px;

  flex: 1;
}

.primary,
.flow-nav .primary {
  background: var(--blue);

  color: #fff;

  border: 1px solid var(--blue);

  font-weight: 600;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 16px;
}

.primary:hover:enabled,
.flow-nav .primary:hover:enabled {
  background: #243680;

  color: white;

  border-color: #243680;
}

.flow-nav .primary::after {
  content: "↗";

  font-size: 21px;

  font-weight: 400;
}

.flow-nav #batchUpload {
  flex: 0 1 36%;

  background: transparent;
}

body[data-step="depth"] .flow-nav .primary::after {
  content: "→";
}

/* Choice page: two original, person-free foil prints. */
body[data-step="mode"] .flow {
  max-width: 940px;

  padding-top: 28px;
}

body[data-step="mode"] .flow-heading {
  position: relative;

  margin-bottom: 28px;
}

body[data-step="mode"] .flow-heading::before {
  content: "Another view.";

  display: block;

  font:
    italic clamp(48px, 7vw, 72px) / 1 Georgia,
    "Times New Roman",
    serif;

  letter-spacing: -5px;

  color: var(--blue);

  margin: 0 0 20px -4px;
}

body[data-step="mode"] .flow-heading h1 {
  font-size: 19px;

  font-weight: 500;

  letter-spacing: 0;
}

.mode-choice {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 24px;
}

.mode-card {
  display: flex;

  flex-direction: column;

  align-items: stretch;

  text-align: left;

  padding: 0 0 18px;

  border: 0;

  border-bottom: 1px solid var(--ink);

  border-radius: 0;

  min-width: 0;

  background: transparent;

  overflow: visible;
}

.mode-card:hover:enabled {
  background: transparent;

  border-color: var(--pink);
}

.mode-art {
  background: #eceef6;
  position: relative;

  display: block;

  overflow: hidden;

  aspect-ratio: 540/350;

  border: 6px solid #fff;

  box-shadow: 0 1px 0 #cecede;

  margin-bottom: 20px;
}

.mode-art img {
  display: block;

  width: 100%;

  height: 100%;

  object-fit: cover;

  transition: transform 0.25s;
}

.mode-card:hover .mode-art img {
  transform: scale(1.035);
}

.art-tag {
  position: absolute;

  right: 10px;

  top: 10px;

  background: #f8f6fa;

  color: #26377e;

  padding: 6px 8px;

  font:
    10px Consolas,
    monospace;

  letter-spacing: 1px;

  box-shadow: 2px 2px 0 #26377e;
}

.mode-caption {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 10px;

  padding: 0 2px;

  margin-bottom: 8px;
}

.mode-caption strong {
  font-size: 24px;

  font-weight: 700;

  letter-spacing: -0.7px;
}

.mode-arrow {
  color: var(--blue);

  font-size: 28px;
}

.mode-card > span:last-child {
  font-size: 13px;

  color: var(--muted);

  padding: 0 2px;
}

.mode-card[aria-pressed="true"] .mode-art {
  outline: 2px solid var(--blue);

  outline-offset: 2px;
}

/* Shared forms. */
.heading,
.edit-panel-heading {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 12px;
}

.heading > span,
output {
  font-size: 12px;

  color: var(--muted);
}

output {
  font-family: Consolas, monospace;

  font-variant-numeric: tabular-nums;
}

.field,
.color-field {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 16px;

  font-size: 14px;

  margin: 18px 0;
}

.color-field[hidden] {
  display: none;
}

.field select {
  width: 52%;

  min-width: 140px;

  max-width: 240px;
}

.range-label {
  display: grid;

  grid-template-columns: 1fr auto;

  gap: 10px;

  font-size: 14px;

  margin: 22px 0;
}

.range-label input {
  grid-column: 1/-1;

  width: 100%;

  margin: 0;
}

select {
  min-height: 44px;

  padding: 8px 12px;

  background: #fff;

  border: 1px solid var(--line);

  border-radius: 3px;

  color: var(--ink);

  font-size: 14px;
}

input[type="range"] {
  appearance: none;

  -webkit-appearance: none;

  background: transparent;

  height: 28px;

  cursor: pointer;

  accent-color: var(--blue);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;

  background: #d7d7e6;

  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;

  width: 20px;

  height: 20px;

  border-radius: 50%;

  margin-top: -8.5px;

  border: 3px solid #fff;

  background: var(--blue);

  box-shadow: 0 0 0 1px #7c89c0;
}

input[type="range"]::-moz-range-track {
  height: 3px;

  background: #d7d7e6;
}

input[type="range"]::-moz-range-thumb {
  width: 15px;

  height: 15px;

  border: 3px solid #fff;

  background: var(--blue);

  border-radius: 50%;
}

input[type="color"] {
  width: 48px;

  height: 36px;

  padding: 3px;

  background: #fff;

  border: 1px solid var(--line);

  border-radius: 3px;

  cursor: pointer;
}

.hint {
  font-size: 12px;

  color: var(--muted);

  line-height: 1.6;
}

.detail button,
.heading button {
  border-color: transparent;

  background: transparent;

  padding: 6px 8px;

  font-size: 12px;
}

.heading button:hover:enabled {
  background: #e7eaf5;
}

.intro {
  display: none;
}

/* Sequence + crop share one stable workspace. */
.combined-editor {
  display: flex;

  flex-direction: column;

  gap: 12px;
}

.flow-sequence > .heading {
  min-height: 36px;
}

.flow-sequence > .heading h2 {
  font-size: 12px;

  font-weight: 500;

  color: var(--muted);

  letter-spacing: 1px;
}

.thumbnails {
  position: relative;
  display: flex;

  align-items: center;

  gap: 9px;

  overflow-x: auto;

  min-height: 92px;

  padding: 8px 3px 10px;

  scrollbar-width: thin;

  scrollbar-color: #b4bbd6 transparent;
}

.thumb,
.motion-removed {
  position: relative;

  flex: 0 0 72px;

  width: 72px;

  height: 78px;

  padding: 3px;

  min-height: 0;

  border: 1px solid transparent;

  background: #fff;

  border-radius: 3px;
}

.thumb img,
.motion-removed img {
  display: block;

  width: 64px;

  height: 52px;

  object-fit: cover;

  background: #e7e8f1;
}

.thumb span,
.motion-removed span {
  display: block;

  text-align: center;

  margin-top: 3px;

  font:
    10px Consolas,
    monospace;
}

.thumb.active {
  border: 2px solid var(--blue);

  padding: 2px;

  background: #edf0fc;
}

.thumb.drag-target {
  outline: 2px dashed var(--pink);
}

.thumb.draft {
  flex: 0 0 72px;

  width: 72px;

  height: 72px;

  padding: 0;

  display: grid;

  place-items: center;

  font-size: 28px;

  line-height: 1;

  font-weight: 300;

  border: 1px dashed #9a9dbb;

  background: #eceef8;

  color: var(--blue);
}

.thumb.draft.active {
  border: 2px solid var(--blue);
}

.sequence-actions {
  display: flex;

  gap: 6px;

  padding-top: 4px;
}

.sequence-actions button {
  flex: 1;

  min-height: 36px;

  font-size: 12px;

  padding: 6px 8px;

  background: transparent;
}

.sequence-actions #delete {
  color: #a02d68;
}

.combined-editor > .field {
  margin: 4px 0 8px;
}

.combined-editor > section {
  border: 1px solid #d5d8e8;

  background: #f1f2fa;

  padding: 16px;

  border-radius: 4px;
}

.edit-panel-heading {
  font-size: 14px;

  min-height: 40px;
}

.edit-panel-heading #selectedLabel {
  font-weight: 650;
}

.edit-panel-heading button {
  border: 0;

  background: transparent;

  font-size: 12px;

  min-height: 40px;
}

.editor-shell {
  position: relative;

  display: flex;

  align-items: center;

  justify-content: center;

  overflow: hidden;

  height: clamp(240px, 38dvh, 400px);

  margin: 12px 0;

  background:
    radial-gradient(#8893bf40 0.8px, transparent 0.8px) 0 0/6px 6px,
    #e4e7f2;

  border-radius: 2px;
}

#editor {
  max-width: 100%;

  max-height: 100%;

  object-fit: contain;

  touch-action: none;

  cursor: grab;

  box-shadow: 0 4px 18px #1f286a14;
}

#editor:active {
  cursor: grabbing;
}

.upload {
  position: absolute;

  inset: 0;

  display: flex;

  align-items: center;

  justify-content: center;

  border: 1px dashed #9299bc;

  background: #e8eafa;

  cursor: pointer;
}

.upload::before {
  content: "✦";

  position: absolute;

  font-size: 100px;

  font-family: Georgia, serif;

  line-height: 1;

  color: #7185c0;

  opacity: 0.28;

  transform: translate(78px, -50px) rotate(12deg);
}

.upload strong {
  position: relative;

  z-index: 1;

  font-size: 17px;

  color: var(--blue);

  font-weight: 550;

  border-bottom: 1px solid #929bbf;

  padding: 12px 6px;
}

.upload input {
  position: absolute;

  inset: 0;

  width: 100%;

  height: 100%;

  opacity: 0;

  cursor: pointer;

  z-index: 2;
}

.upload:focus-within,
.upload.dragover {
  outline: 2px solid var(--pink);

  outline-offset: -4px;
}

.detail {
  display: flex;

  justify-content: flex-end;
}

.combined-editor:not(.has-photo) .detail,
.combined-editor:not(.has-photo) .range-label,
.combined-editor:not(.has-photo) .field:has(#reference) {
  display: none;
}

.combined-editor .range-label {
  margin: 14px 0;
}

.combined-editor #message {
  color: #9a2869;

  font-size: 12px;

  line-height: 1.7;
}

.combined-editor #message:empty {
  display: none;
}

body[data-creation-mode="depth"] .field:has(#reference),
body[data-creation-mode="depth"] .range-label:has(#opacity) {
  display: none;
}

/* Depth generation: quiet controls around a framed print. */
.ai-panel > .heading {
  display: none;
}

.depth-canvas {
  height: clamp(230px, 38dvh, 390px);

  display: flex;

  align-items: center;

  justify-content: center;

  overflow: hidden;

  background:
    radial-gradient(#9a9ec450 0.7px, transparent 0.8px) 0 0/5px 5px,
    #e7e8f3;

  border: 1px solid var(--line);

  padding: 16px;

  position: relative;
}

.depth-placeholder {
  position: relative;

  height: 100%;

  max-width: 400px;

  width: 100%;

  display: grid;

  place-items: center;
}

.depth-placeholder span {
  color: var(--muted);
  font-size: 13px;
}

.ai-panel #aiMap {
  display: block;

  max-width: 100%;

  max-height: 100%;

  width: auto;

  height: auto;

  object-fit: contain;

  border: 6px solid #fff;
}

.ai-panel #aiMessage {
  min-height: 24px;

  font-size: 13px;

  color: var(--muted);

  margin: 14px 0;
}

.ai-panel[aria-busy="true"] #aiMessage::before {
  content: "";

  display: inline-block;

  width: 7px;

  height: 7px;

  background: var(--pink);

  margin-right: 8px;

  animation: pulse 1.2s ease-in-out infinite;
}

.ai-panel[aria-busy="true"] .depth-canvas::after {
  content: "";

  position: absolute;

  inset: 0;

  background: linear-gradient(transparent 46%, #8cadf45c 50%, transparent 54%);

  background-size: 100% 200%;

  animation: scan 2.5s ease-in-out infinite;

  pointer-events: none;
}

#aiCancel {
  display: none !important;
}

#aiSettings {
  min-width: 0;
  margin: 0;
  padding: 2px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

#aiSettings .field {
  margin-bottom: 0;
}

@keyframes scan {
  from {
    background-position: 0 100%;
  }

  to {
    background-position: 0 -100%;
  }
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* Preview stays fixed;
   only the material parameters scroll. */
.preview-heading {
  display: none;
}

body.preview-screen {
  height: 100dvh;

  overflow: hidden;
}

.preview-screen header {
  height: 52px;

  min-height: 52px;
}

.preview-screen .flow {
  height: calc(100dvh - 52px);

  max-width: 1100px;

  padding: 0 22px;

  overflow: hidden;
}

.preview-screen .flow-progress,
.preview-screen .flow-track,
.preview-screen .flow-heading,
.preview-screen #flowNotice {
  display: none;
}

.preview-screen #flowPages {
  height: 100%;

  min-height: 0;
}

.preview {
  display: flex;

  flex-direction: column;

  height: 100%;

  min-height: 0;

  overflow: hidden;
}

.preview-dock {
  display: flex;

  flex-direction: column;

  flex: 0 0 auto;

  min-height: 0;

  height: min(80dvh, calc(100dvh - 148px));

  padding-bottom: 8px;

  background: var(--paper);
}

.preview[data-size="small"] .preview-dock {
  height: 44dvh;

  min-height: 220px;
}

.preview-sizebar {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 12px;

  flex: 0 0 48px;
}

.preview-sizebar strong {
  font-size: 13px;

  font-weight: 600;
}

.preview-sizebar > div {
  display: flex;

  gap: 2px;

  background: #e7e9f3;

  padding: 3px;

  border-radius: 3px;
}

.preview-sizebar button {
  min-height: 30px;

  padding: 5px 14px;

  font-size: 12px;

  background: transparent;

  border-color: transparent;
}

.preview-sizebar button[aria-pressed="true"] {
  background: #fff;

  border-color: #c2c9e2;

  color: var(--blue);
}

.preview-sizebar #largePreview[aria-pressed="true"] {
  background: var(--blue);

  border-color: var(--blue);

  color: #fff;
}

.preview-dock:fullscreen,
body.large-preview-active .preview-dock {
  width: 100vw;

  height: 100dvh;

  min-height: 100dvh;

  padding: max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));

  background: var(--paper);
}

body.large-preview-active {
  overflow: hidden;
}

body.large-preview-active .preview-dock {
  position: fixed;

  inset: 0;

  z-index: 1000;
}

.preview-dock:fullscreen .preview-sizebar,
body.large-preview-active .preview-sizebar {
  flex-basis: 52px;
}

#stage {
  position: relative;

  min-height: 0;

  flex: 1;

  width: 100%;

  overflow: hidden;

  touch-action: none;

  cursor: grab;

  border: 1px solid #d1d5e7;

  border-radius: 3px;

  background: radial-gradient(
    ellipse at 45% 48%,
    #f7fafb 5%,
    #e3e9f4 55%,
    #dcd8ef 100%
  );
}

#stage::before {
  content: "";

  position: absolute;

  inset: 0;

  pointer-events: none;

  background: radial-gradient(#777ba51f 0.65px, transparent 0.8px) 0 0/5px 5px;
}

#stage::after {
  content: "✦";

  position: absolute;

  right: 14px;

  bottom: 6px;

  color: #868fba;

  font-size: 38px;

  pointer-events: none;
}

#stage:active {
  cursor: grabbing;
}

#stage > canvas {
  display: block;

  position: relative;

  width: 100%;

  height: 100%;
}

#previewEmpty {
  position: absolute;

  inset: 0;

  display: flex;

  align-items: center;

  justify-content: center;

  flex-direction: column;

  pointer-events: none;

  gap: 12px;
}

#previewEmpty h3 {
  font-size: 16px;

  font-weight: 500;
}

#previewEmpty p {
  font-size: 12px;

  color: var(--muted);
}

.card-outline {
  width: 100px;

  height: 140px;

  border: 1px solid #9da7ce;

  border-radius: 3px;

  transform: rotate(-9deg);

  box-shadow:
    8px 7px 0 #e7e9f3,
    9px 8px 0 #a7b1d0;

  margin-bottom: 12px;
}

.preview-controls {
  flex: 0 0 auto;

  width: 100%;

  margin-top: 8px;
}

.preview-controls .heading {
  min-height: 32px;
}

.preview-controls strong {
  font:
    12px Consolas,
    monospace;

  color: var(--blue);
}

.preview-controls button {
  font-size: 12px;

  min-height: 32px;

  padding: 5px 10px;

  background: transparent;

  border: 1px solid var(--line);
}

.angle-label {
  display: flex;

  align-items: center;

  gap: 10px;

  font:
    10px Consolas,
    monospace;

  color: var(--muted);

  margin: 0;
}

.angle-label input {
  flex: 1;

  min-width: 0;
}

#angleLabel {
  text-align: center;

  font-size: 11px;

  line-height: 16px;

  color: var(--muted);

  margin: 0;
}

.appearance-panel {
  flex: 1 1 0;

  min-height: 0;

  overflow-y: auto;

  overscroll-behavior: contain;

  touch-action: pan-y;

  margin: 0;

  padding: 8px 12px calc(24px + env(safe-area-inset-bottom));

  border-top: 1px solid #bfc4da;

  background: var(--paper);

  scrollbar-width: thin;

  scrollbar-color: #a9b0cc transparent;
}

.appearance-panel > .heading {
  position: sticky;

  top: -8px;

  z-index: 2;

  background: var(--paper);

  padding: 8px 0;
}

.appearance-panel > .heading h2 {
  font-size: 14px;
}

.appearance-panel small {
  font-size: 10px;

  color: var(--muted);

  font-weight: 400;

  margin-left: 6px;
}

.appearance-panel .heading button {
  font-size: 12px;

  min-height: 36px;
}

.appearance-sliders .range-label {
  margin: 14px 0;
}

.finish-details summary {
  font-size: 13px;

  padding: 12px 0;

  cursor: pointer;

  color: var(--muted);
}

.finish-grid {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 28px;
}

.finish-grid > div {
  border-top: 1px solid var(--line);

  padding-top: 8px;
}

.finish-grid h3 {
  font-size: 15px;
}

.finish-grid .range-label {
  margin: 18px 0;
}

.grain-field {
  font-size: 14px;

  margin: 20px 0;
}

.grain-options {
  display: flex;

  gap: 8px;

  margin-top: 12px;
}

.grain-options button {
  flex: 1;

  display: flex;

  align-items: center;

  justify-content: center;

  gap: 6px;

  min-height: 48px;

  background: transparent;

  font-size: 13px;
}

.grain-options button[aria-pressed="true"] {
  border-color: var(--blue);

  background: #e8ecfb;

  color: var(--blue);
}

.grain-options small {
  display: none;
}

.grain-dot {
  display: inline-block;

  border-radius: 50%;

  background: currentColor;
}

.grain-dot.coarse {
  width: 7px;

  height: 7px;

  box-shadow: 4px -4px 0 -2px currentColor;
}

.grain-dot.fine {
  width: 3px;

  height: 3px;

  box-shadow:
    4px -3px 0 currentColor,
    -4px 2px 0 currentColor;
}

.color-field {
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  header {
    padding: 0 18px;

    height: 60px;

    gap: 10px;
  }

  .brand {
    font-size: 19px;

    gap: 7px;
  }

  .brand-en {
    font-size: 21px;

    padding-left: 11px;

    margin-left: 4px;
  }

  .header-edition {
    display: none;
  }

  header:has(#flowBack:not([hidden])) .brand-en {
    font-size: 19px;
  }

  .flow {
    padding: 24px 18px 108px;
  }

  .flow-track {
    margin-bottom: 24px;
  }

  .flow-heading {
    margin-bottom: 20px;
  }

  .flow-nav {
    padding-left: 18px;

    padding-right: 18px;
  }

  .flow-nav button {
    font-size: 14px;
  }

  body[data-step="mode"] .flow {
    padding-top: 28px;
  }

  body[data-step="mode"] .flow-heading::before {
    font-size: 58px;

    letter-spacing: -3px;

    margin-bottom: 18px;
  }

  body[data-step="mode"] .flow-heading h1 {
    font-size: 17px;
  }

  .mode-choice {
    gap: 20px;

    grid-template-columns: 1fr;
  }

  .mode-card {
    display: grid;

    grid-template-columns: 116px 1fr;

    column-gap: 16px;

    row-gap: 4px;

    padding: 0 0 20px;
  }

  .mode-art {
    grid-row: 1/3;

    aspect-ratio: 1/1;

    margin: 0;

    border-width: 3px;
  }

  .mode-art img {
    object-fit: cover;
  }

  .art-tag {
    display: none;
  }

  .mode-caption {
    align-self: end;

    margin: 0;

    padding: 0;
  }

  .mode-caption strong {
    font-size: 20px;
  }

  .mode-card > span:last-child {
    align-self: start;

    font-size: 12px;

    line-height: 1.6;

    padding: 0;
  }

  .mode-arrow {
    font-size: 23px;
  }

  .combined-editor > section {
    padding: 12px;
  }

  .editor-shell {
    height: clamp(225px, 35dvh, 320px);
  }

  .sequence-actions button {
    font-size: 11px;
  }

  .preview-screen .flow {
    padding: 0 12px;
  }

  .finish-grid {
    grid-template-columns: 1fr;

    gap: 20px;
  }

  .appearance-panel {
    padding-left: 8px;

    padding-right: 8px;
  }

  .depth-canvas {
    height: 32dvh;

    min-height: 225px;
  }

  .preview-sizebar {
    padding: 0 3px;
  }
}

@media (max-width: 360px) {
  .brand-en {
    font-size: 19px;
  }

  .mode-card {
    grid-template-columns: 100px 1fr;

    column-gap: 12px;
  }

  .mode-caption strong {
    font-size: 18px;
  }

  .flow {
    padding-left: 14px;

    padding-right: 14px;
  }

  .field select {
    min-width: 130px;
  }
}

@media (max-height: 580px) {
  .preview-dock {
    height: calc(100dvh - 168px);
  }

  .preview[data-size="small"] .preview-dock {
    height: 48dvh;

    min-height: 150px;
  }

  .preview #angleLabel {
    display: none;
  }

  .flow {
    padding-top: 16px;
  }

  .flow-track {
    margin-bottom: 18px;
  }
}

/* Phone/tablet web layout. Keep system insets separate from the navigation row.
   Some embedded browsers report zero insets; the minimum top gap is deliberate. */
@media (max-width: 700px), (pointer: coarse) and (max-width: 1100px), (max-height: 500px) and (max-width: 1100px) {
  html {
    scroll-padding-top: calc(76px + max(32px, env(safe-area-inset-top, 0px)));
    scroll-padding-bottom: calc(96px + max(16px, env(safe-area-inset-bottom, 0px)));
  }
  body {
    --mobile-safe-top: max(32px, env(safe-area-inset-top, 0px));
    --mobile-safe-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    --mobile-safe-left: max(16px, env(safe-area-inset-left, 0px));
    --mobile-safe-right: max(16px, env(safe-area-inset-right, 0px));
    --mobile-nav-height: 64px;
  }

  header,
  .preview-screen header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: calc(var(--mobile-nav-height) + var(--mobile-safe-top));
    min-height: calc(var(--mobile-nav-height) + var(--mobile-safe-top));
    padding: calc(var(--mobile-safe-top) + 8px) var(--mobile-safe-right) 8px var(--mobile-safe-left);
    gap: 12px;
  }

  header #flowBack {
    min-width: 72px;
    min-height: 48px;
    padding: 10px 12px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    touch-action: manipulation;
  }

  .header-edition { display: none; }
  .brand { min-width: 0; }
  .brand-en { font-size: 19px; padding-left: 10px; margin-left: 0; }
  header:has(#flowBack:not([hidden])) .brand-en { font-size: 17px; }

  .flow {
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
    padding-bottom: calc(112px + var(--mobile-safe-bottom));
  }

  .flow-nav {
    padding: 12px var(--mobile-safe-right) calc(12px + var(--mobile-safe-bottom)) var(--mobile-safe-left);
    gap: 10px;
  }
  .flow-nav button { min-width: 0; min-height: 52px; }
  .flow-nav #batchUpload { flex-basis: 40%; }
  button { touch-action: manipulation; }
  select { font-size: 16px; min-height: 48px; max-width: 100%; }
  input[type="range"] { height: 44px; }
  input[type="color"] { width: 52px; height: 48px; }
  .sequence-actions button { font-size: 13px; min-height: 48px; }
  .field, .color-field { gap: 10px; }
  .field select { min-width: 0; }
  .thumbnails { touch-action: pan-x; }

  .preview-screen .flow {
    height: calc(100dvh - var(--mobile-nav-height) - var(--mobile-safe-top));
    padding: 0 var(--mobile-safe-right) 0 var(--mobile-safe-left);
  }
  .preview[data-size="small"] .preview-dock {
    height: clamp(270px, 48dvh, 480px);
    min-height: 0;
  }
  .preview-sizebar { flex-basis: 60px; padding: 0; }
  .preview-sizebar button { min-height: 48px; min-width: 56px; font-size: 14px; }
  .preview-controls button { min-height: 48px; font-size: 14px; }
  .appearance-panel {
    padding: 8px 4px calc(24px + var(--mobile-safe-bottom));
    scroll-padding-bottom: calc(24px + var(--mobile-safe-bottom));
  }
  .appearance-panel .heading button,
  .finish-grid .heading button { min-height: 48px; }

  .preview-dock:fullscreen,
  body.large-preview-active .preview-dock {
    padding: calc(var(--mobile-safe-top) + 8px) var(--mobile-safe-right)
      calc(var(--mobile-safe-bottom) + 8px) var(--mobile-safe-left);
  }
  .preview-dock:fullscreen .preview-sizebar,
  body.large-preview-active .preview-sizebar { flex-basis: 60px; }
}

@media (max-width: 380px) {
  header:has(#flowBack:not([hidden])) .brand-en { display: none; }
  .preview-sizebar { gap: 6px; }
}

@media (max-height: 500px) and (max-width: 1100px) and (min-width: 600px) {
  body { --mobile-safe-top: max(12px, env(safe-area-inset-top, 0px)); }
  .preview.finishing { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
  .preview[data-size="small"] .preview-dock { height: 100%; min-height: 0; }
  .appearance-panel { border-top: 0; border-left: 1px solid var(--line); padding-left: 12px; }
  .finish-grid { grid-template-columns: 1fr; }
  .preview-sizebar strong { display: none; }
  .preview-sizebar { justify-content: flex-end; }
  .preview-controls { margin-top: 4px; }
  .preview #angleLabel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;

    transition: none !important;
  }
}

/* Immersive phone preview: only the card and its two actions. */
body.large-preview-active header,
body.large-preview-active .appearance-panel,
body.large-preview-active .skip-link {
  visibility: hidden;
}
body.large-preview-active .preview-dock,
.preview-dock:fullscreen {
  display: grid;
  grid-template-rows: minmax(0, 1fr) max(64px, 18dvh);
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: #000;
  border: 0;
  border-radius: 0;
}
body.large-preview-active .preview-controls,
.preview-dock:fullscreen .preview-controls,
body.large-preview-active .preview-sizebar strong,
.preview-dock:fullscreen .preview-sizebar strong,
body.large-preview-active #largePreview,
.preview-dock:fullscreen #largePreview {
  display: none;
}
body.large-preview-active #stage,
.preview-dock:fullscreen #stage {
  grid-row: 1;
  height: 100%;
  background: #000;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
body.large-preview-active #stage::before,
body.large-preview-active #stage::after,
.preview-dock:fullscreen #stage::before,
.preview-dock:fullscreen #stage::after {
  display: none;
}
body.large-preview-active .preview-sizebar,
.preview-dock:fullscreen .preview-sizebar {
  grid-row: 2;
  justify-content: center;
  padding: 0;
}
body.large-preview-active .preview-sizebar > div,
.preview-dock:fullscreen .preview-sizebar > div {
  background: transparent;
  gap: 16px;
  padding: 0;
}
body.large-preview-active .preview-sizebar button,
.preview-dock:fullscreen .preview-sizebar button {
  min-height: 48px;
  padding: 12px 20px;
  font-size: 14px;
  background: #171717;
  color: #fff;
  border: 1px solid #444;
  border-radius: 24px;
}
body.large-preview-active .preview-sizebar button:active,
.preview-dock:fullscreen .preview-sizebar button:active {
  background: #303030;
}
.export-panel {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid #dfe2ee;
  flex-wrap: wrap;
}
.export-panel .field { flex: 1 1 170px; margin: 0; }
.export-panel > button { flex: 1 1 190px; min-height: 44px; }
.export-panel > p { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--blue); }
.thumbnails.vertical-sequence {
  flex-direction: column;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 280px;
}
.thumbnails.vertical-sequence .thumb {
  flex: 0 0 68px;
  width: 100%;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.thumbnails.vertical-sequence .thumb img { width: 58px; height: 58px; }
.thumbnails.vertical-sequence .thumb span { margin: 0; }
.thumbnails.vertical-sequence .thumb.draft { justify-content: center; }
.sequence-order-hint {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
}
