:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --paper: #ffffff;
  --panel: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #e2e8f0;
  --accent: #e56b2f;
  --teal: #0f9f8f;
  --green: #22c55e;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(15, 23, 42, .12);
  --radius: 16px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(145deg, rgba(15, 159, 143, .10) 0%, transparent 32%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 48%, #fff5ec 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  overflow-x: hidden;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .06);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 12px 8px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup img {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #fff;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 15px;
  line-height: 1.1;
}

.brand-lockup span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.icon-btn,
.tool-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: var(--ink);
  text-decoration: none;
  box-shadow: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

.icon-btn:hover,
.tool-btn:hover,
.tool-btn:focus-visible,
.icon-btn:focus-visible {
  border-color: rgba(15, 159, 143, .55);
  color: var(--teal);
  box-shadow: 0 10px 24px rgba(15, 159, 143, .16);
  outline: none;
}

.icon-btn svg,
.tool-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:active,
.tool-btn:active,
.mode-toggle:active,
.choice-card:active,
.pattern-card:active,
.primary-btn:active,
.secondary-btn:active,
.whatsapp-btn:active {
  transform: scale(.97);
}

main {
  display: grid;
  gap: 10px;
  padding: 8px 8px calc(18px + env(safe-area-inset-bottom));
}

.stage-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 0 0 20px 20px;
  background:
    linear-gradient(135deg, rgba(15, 159, 143, .14), rgba(37, 99, 235, .08) 52%, rgba(229, 107, 47, .12)),
    #eef7f6;
  box-shadow: var(--shadow);
}

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 6px;
}

.stage-head > div {
  min-width: 0;
}

.eyebrow {
  display: block;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

h1 {
  margin: 3px 0 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.stage-note {
  margin: 5px 0 0;
  max-width: 285px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.25;
}

.mode-toggle {
  flex: 0 0 auto;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(15, 159, 143, .22);
}

.canvas-viewport {
  position: relative;
  height: clamp(500px, 74svh, 760px);
  display: grid;
  place-items: center;
  padding: 6px 4px 44px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 12%, rgba(15, 159, 143, .10), transparent 30%),
    linear-gradient(90deg, rgba(17, 24, 39, .045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(17, 24, 39, .045) 1px, transparent 1px),
    #f9fbff;
  background-size: 26px 26px;
  touch-action: none;
  cursor: grab;
}

#designCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 58px rgba(17, 24, 39, .22);
  pointer-events: none;
  transition: transform .26s ease, box-shadow .26s ease;
}

#designCanvas.pop {
  animation: canvasPop .34s ease;
}

body.previewing #designCanvas {
  transform: none;
  box-shadow: 0 34px 78px rgba(17, 24, 39, .30);
}

.view-zoom-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 14;
  display: none;
  grid-template-columns: 40px 1fr 40px 86px 62px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(17, 24, 39, .1);
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 18px 42px rgba(17, 24, 39, .16);
  backdrop-filter: blur(12px);
}

body.previewing .view-zoom-panel {
  display: grid;
}

body.previewing.quick-editor-open .view-zoom-panel {
  display: none;
}

.view-tool-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 82px;
  z-index: 16;
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(17, 24, 39, .10);
  border-radius: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 18px 42px rgba(17, 24, 39, .16);
  backdrop-filter: blur(12px);
}

body.previewing .view-tool-dock {
  display: grid;
}

body.previewing.quick-editor-open .view-tool-dock {
  display: none;
}

.view-tool {
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 5px;
  padding: 8px 8px;
  font-size: 12px;
  font-weight: 900;
}

.view-tool svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view-tool.active {
  border-color: rgba(15, 159, 143, .24);
  background: linear-gradient(135deg, rgba(15, 159, 143, .16), rgba(37, 99, 235, .13));
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(15, 159, 143, .14);
}

.view-tool:active {
  transform: scale(.97);
}

.zoom-btn,
.zoom-reset-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: var(--ink);
  font-weight: 900;
}

.zoom-btn:active,
.zoom-reset-btn:active {
  transform: scale(.96);
}

.zoom-reset-btn {
  font-size: 12px;
}

#viewZoomRange {
  min-height: 38px;
  padding: 0;
}

#viewZoomValue {
  min-width: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.gesture-hint {
  position: absolute;
  left: 14px;
  right: auto;
  bottom: 10px;
  max-width: min(285px, calc(100% - 92px));
  padding: 7px 10px;
  border-radius: 13px;
  background: rgba(15, 23, 42, .82);
  color: #fff;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.floating-tools {
  position: absolute;
  right: 10px;
  top: 64px;
  z-index: 15;
  display: grid;
  gap: 7px;
  padding: 6px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 18px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 16px 34px rgba(15, 23, 42, .16);
  backdrop-filter: blur(12px);
}

body.quick-editor-open #quickTextBtn {
  border-color: rgba(229, 107, 47, .65);
  color: var(--accent);
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(229, 107, 47, .16);
}

.quick-editor {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 18;
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(15, 159, 143, .2);
  border-radius: 18px 18px 16px 16px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 20px 48px rgba(15, 23, 42, .2);
  backdrop-filter: blur(16px);
  animation: editorIn .18s ease;
  max-height: min(242px, calc(100% - 26px));
  overflow: auto;
}

.quick-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.quick-editor-head strong {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.editor-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

#quickTextInput {
  min-height: 42px;
  border-color: rgba(15, 159, 143, .28);
  font-weight: 900;
}

.quick-editor-grid {
  display: grid;
  grid-template-columns: minmax(128px, .9fr) 1fr;
  gap: 8px;
}

.quick-editor label,
.quick-rotation {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.quick-editor select,
.quick-editor input[type="range"] {
  margin-top: 5px;
  min-height: 36px;
}

.quick-color-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 1px 0 3px;
}

.quick-color {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: 1px solid rgba(15, 23, 42, .16);
  border-radius: 999px;
  background: var(--quick-color);
}

.quick-color.active {
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .2);
  border-color: var(--teal);
}

.workflow-card {
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, .08);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.step-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 8px;
  border-bottom: 1px solid rgba(17, 24, 39, .08);
  background: #f9faf7;
}

.step-tab {
  min-width: 0;
  min-height: 39px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.step-tab.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 159, 143, .18);
}

.step-panel {
  display: none;
  padding: 15px;
  animation: panelIn .2s ease;
}

.step-panel.active { display: block; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-card {
  min-width: 0;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: left;
  padding: 12px;
}

.choice-card strong,
.choice-card span {
  display: block;
}

.choice-card strong { font-size: 17px; }

.choice-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.choice-card.active {
  border-color: var(--teal);
  background: #e9fbf8;
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .14);
}

label {
  display: block;
  margin: 14px 0 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .15);
}

.hidden { display: none !important; }

.input-with-unit,
.range-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.input-with-unit span,
output {
  min-width: 52px;
  color: var(--accent);
  font-weight: 900;
  text-align: right;
}

input[type="range"] {
  accent-color: var(--teal);
}

.microcopy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.assist-card {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfe7c7;
  border-radius: 16px;
  background: #f0fff4;
}

.assist-card strong {
  color: #14532d;
  font-size: 13px;
}

.assist-card span {
  color: #315443;
  font-size: 12px;
  line-height: 1.35;
}

.quick-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 3px;
}

.preset-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 228px;
  overflow: auto;
  padding-right: 2px;
}

.preset-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  text-align: left;
}

.preset-btn strong,
.preset-btn span {
  display: block;
}

.preset-btn span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.preset-btn.active {
  border-color: var(--teal);
  background: #e9fbf8;
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .15);
}

.custom-size {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.custom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-grid select,
.custom-grid button {
  grid-column: span 2;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.file-chip,
.secondary-file,
.upload-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 14px;
  padding: 11px 12px;
  background: linear-gradient(180deg, #eef6ff 0%, #f7fbff 100%);
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.file-chip input,
.secondary-file input,
.upload-main input {
  display: none;
}

.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px -15px 10px;
  padding: 0 15px 6px;
  scrollbar-width: thin;
}

.category-chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.category-chip.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(15, 159, 143, .16);
}

.pattern-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 2px;
}

.pattern-card {
  position: relative;
  min-height: 106px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #e9eee5;
  padding: 0;
}

.pattern-card img {
  width: 100%;
  height: 100%;
  min-height: 106px;
  object-fit: cover;
  display: block;
}

.pattern-card span {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .88);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.pattern-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 143, .18);
}

.upload-panel,
.selected-card,
.export-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.upload-panel strong,
.selected-card strong,
.export-card strong {
  font-size: 17px;
}

.upload-panel span,
.selected-card span,
.export-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 12px;
}

.primary-btn,
.secondary-btn,
.whatsapp-btn,
.store-btn,
.whatsapp-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 159, 143, .18);
}

.secondary-btn {
  background: #eef6ff;
  color: var(--ink);
}

.secondary-btn.full,
.whatsapp-btn,
.store-btn.full {
  width: 100%;
  margin-top: 10px;
}

.whatsapp-btn {
  background: var(--green);
  color: #073b1d;
}

.whatsapp-mini {
  min-height: 44px;
  background: var(--green);
  color: #073b1d;
}

.store-btn {
  min-height: 44px;
  background: #eef6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

.swatch-row {
  display: flex;
  gap: 9px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.swatch {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--swatch);
}

.swatch.active {
  box-shadow: 0 0 0 3px rgba(15, 159, 143, .2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: min(440px, calc(100vw - 28px));
  padding: 12px 15px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px) scale(.98);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.done-layer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, .5);
  backdrop-filter: blur(10px);
}

.done-card {
  width: min(100%, 360px);
  overflow: hidden;
  border-radius: 22px;
  background: #fff;
  padding: 0 16px 16px;
  text-align: center;
  box-shadow: 0 26px 70px rgba(17, 24, 39, .28);
  animation: modalIn .25s ease;
}

.done-card canvas {
  display: block;
  width: 100%;
  height: 170px;
}

.done-card strong,
.done-card span {
  display: block;
}

.done-card strong {
  font-size: 24px;
}

.done-card span {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

body.previewing .workflow-card,
body.previewing .gesture-hint {
  opacity: 0;
  pointer-events: none;
}

body.quick-editor-open .gesture-hint {
  opacity: 0;
}

body.previewing .stage-head {
  display: none;
}

body.previewing .canvas-viewport {
  height: calc(100dvh - 104px);
  padding-bottom: 76px;
}

body.previewing .floating-tools {
  top: 18px;
  right: 10px;
}

body.previewing .quick-editor {
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-height: min(226px, calc(100% - 28px));
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes canvasPop {
  0% { transform: scale(.985); }
  65% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes editorIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 900px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .app-shell {
    min-height: min(900px, calc(100vh - 48px));
    border-radius: 28px;
    overflow: hidden;
  }
}

@media (max-width: 420px) {
  main {
    padding-inline: 8px;
  }

  .stage-head {
    gap: 8px;
    padding-inline: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .stage-note {
    max-width: 245px;
    font-size: 10px;
  }

  .mode-toggle {
    padding-inline: 10px;
    font-size: 13px;
  }

  .top-actions {
    gap: 4px;
  }

  .view-zoom-panel {
    grid-template-columns: 36px 1fr 36px 74px 56px;
    gap: 6px;
  }

  .step-tab {
    padding-inline: 2px;
    font-size: 11px;
  }

  .mode-grid {
    gap: 8px;
  }
}

@media (max-width: 380px) {
  .step-tabs {
    gap: 3px;
    padding: 6px;
  }

  .step-tab {
    font-size: 11px;
  }

  .floating-tools {
    right: 8px;
    gap: 5px;
  }
}

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

/* v5.0 mobile app shell */
body {
  background:
    linear-gradient(180deg, #eef8f6 0%, #f9fbff 38%, #fff7ef 100%);
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  background: rgba(255, 255, 255, .84);
}

.topbar {
  min-height: 62px;
}

main {
  min-height: calc(100dvh - 62px);
  display: block;
  padding: 0;
}

.stage-card {
  min-height: calc(100dvh - 62px);
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  box-shadow: none;
  background:
    linear-gradient(135deg, rgba(15, 159, 143, .16), rgba(37, 99, 235, .08) 55%, rgba(229, 107, 47, .12)),
    #eef8f6;
}

.stage-head {
  flex: 0 0 auto;
  padding: 9px 12px 7px;
}

.stage-note {
  max-width: min(310px, calc(100vw - 126px));
}

.mode-toggle {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.mode-toggle::after,
.primary-btn::after,
.view-tool.active::after,
.step-tab.active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, .24), transparent);
  transform: translateX(-120%);
  animation: sheen 3.8s ease-in-out infinite;
  pointer-events: none;
}

.canvas-viewport {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding: 6px 4px clamp(188px, 34dvh, 294px);
  background:
    linear-gradient(90deg, rgba(17, 24, 39, .045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(17, 24, 39, .045) 1px, transparent 1px),
    #fbfcff;
  background-size: 22px 22px;
}

#designCanvas {
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(17, 24, 39, .18);
}

.floating-tools {
  top: 116px;
  right: 8px;
  gap: 6px;
  border-radius: 20px;
}

.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.gesture-hint {
  bottom: clamp(196px, 35dvh, 304px);
  left: 12px;
  max-width: min(330px, calc(100% - 86px));
  opacity: .94;
}

.workflow-card {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 48;
  width: min(100%, 520px);
  max-height: min(48dvh, 430px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
  border: 1px solid rgba(15, 23, 42, .10);
  border-bottom: 0;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 -18px 54px rgba(15, 23, 42, .18);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
  transition: transform .24s ease, opacity .2s ease;
}

.sheet-grip {
  flex: 0 0 auto;
  width: 44px;
  height: 5px;
  margin: 8px auto 4px;
  border-radius: 999px;
  background: rgba(102, 112, 133, .28);
}

.step-tabs {
  flex: 0 0 auto;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 8px 8px;
  border-bottom: 1px solid rgba(15, 23, 42, .07);
  background: transparent;
}

.step-tab {
  position: relative;
  overflow: hidden;
  min-height: 42px;
  border-radius: 15px;
}

.step-panel {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;
}

.choice-card,
.assist-card,
.upload-panel,
.selected-card,
.export-card {
  border-radius: 14px;
}

.pattern-grid {
  max-height: min(30dvh, 300px);
}

.preset-list {
  max-height: min(30dvh, 260px);
}

.quick-editor {
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  border-radius: 22px;
  max-height: min(270px, calc(100% - 28px));
}

body.quick-editor-open .workflow-card {
  transform: translateX(-50%) translateY(calc(100% - 62px));
}

body.keyboard-open .workflow-card {
  opacity: 0;
  pointer-events: none;
}

body.keyboard-open .quick-editor {
  position: fixed;
  left: max(10px, calc((100vw - 520px) / 2 + 10px));
  right: max(10px, calc((100vw - 520px) / 2 + 10px));
  bottom: calc(var(--keyboard-offset, 0px) + 8px);
  max-height: 178px;
}

body.previewing .canvas-viewport {
  height: calc(100dvh - 62px);
  padding-bottom: 142px;
}

body.previewing .view-tool-dock {
  bottom: 86px;
}

body.previewing .view-zoom-panel {
  bottom: 14px;
}

body.previewing .floating-tools {
  top: 14px;
}

body.previewing .workflow-card {
  transform: translateX(-50%) translateY(100%);
  opacity: 0;
  pointer-events: none;
}

body.previewing .gesture-hint {
  opacity: 0;
  pointer-events: none;
}

@keyframes sheen {
  0%, 55% { transform: translateX(-120%); }
  75%, 100% { transform: translateX(120%); }
}

@media (max-width: 420px) {
  .canvas-viewport {
    padding-bottom: clamp(178px, 35dvh, 286px);
  }

  .workflow-card {
    max-height: min(50dvh, 420px);
  }

  .gesture-hint {
    bottom: clamp(190px, 36dvh, 296px);
  }

  .floating-tools {
    top: 112px;
  }

  .step-tabs {
    gap: 4px;
  }
}

@media (min-width: 900px) {
  .workflow-card {
    bottom: 24px;
    border-radius: 24px;
    border-bottom: 1px solid rgba(15, 23, 42, .10);
  }

  .canvas-viewport {
    padding-bottom: clamp(194px, 30dvh, 294px);
  }
}
