:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --surface-muted: #eef2f8;
  --text: #161b24;
  --text-soft: #465064;
  --muted: #7b8496;
  --line: #dfe4ed;
  --accent: #4e7ff8;
  --accent-rgb: 78,127,248;
  --accent-soft: rgba(var(--accent-rgb), .11);
  --success: #2aaa6b;
  --danger: #d55252;
  --warning: #d28b2c;
  --shadow: 0 18px 42px rgba(34, 44, 64, .09);
  --shadow-soft: 0 7px 20px rgba(34, 44, 64, .07);
  --shell: 760px;
  --top-safe: env(safe-area-inset-top, 0px);
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2,.8,.2,1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #141a24;
  --surface-soft: #171f2b;
  --surface-muted: #1d2634;
  --text: #f3f6fb;
  --text-soft: #c2c9d6;
  --muted: #8e98aa;
  --line: #293342;
  --accent: #6c95ff;
  --accent-rgb: 108,149,255;
  --accent-soft: rgba(var(--accent-rgb), .15);
  --shadow: 0 20px 50px rgba(0,0,0,.26);
  --shadow-soft: 0 8px 22px rgba(0,0,0,.2);
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  padding: calc(64px + var(--top-safe)) 0 calc(104px + var(--bottom-safe));
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .45); outline-offset: 2px; }
[hidden] { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.app-bg span { position: absolute; width: 380px; height: 380px; border-radius: 50%; filter: blur(80px); opacity: .12; background: var(--accent); }
.app-bg span:first-child { top: -220px; right: -170px; }
.app-bg span:last-child { bottom: -260px; left: -220px; opacity: .08; }

.topbar {
  position: fixed;
  z-index: 30;
  top: var(--top-safe);
  left: 50%;
  width: min(var(--shell), 100%);
  min-height: 64px;
  transform: translateX(-50%);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--bg) 72%, transparent);
}
.brand-button { border: 0; background: transparent; color: var(--text); font-weight: 930; font-size: 28px; letter-spacing: -.05em; cursor: pointer; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 15px; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-soft); cursor: pointer; }

.app-shell { width: min(var(--shell), 100%); margin: 0 auto; padding: 8px 16px 28px; }
.page { display: none; }
.page.page-active { display: block; animation: page-in .22s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.studio-form, .studio-stack { display: grid; gap: 10px; }
.notice { margin-bottom: 10px; padding: 12px 14px; border: 1px solid rgba(var(--accent-rgb), .25); border-radius: 16px; background: var(--accent-soft); color: var(--text-soft); font-size: 13px; line-height: 1.45; }
.notice.error { border-color: rgba(213,82,82,.32); background: rgba(213,82,82,.09); color: var(--danger); }
.notice.success { border-color: rgba(42,170,107,.28); background: rgba(42,170,107,.09); color: var(--success); }

.step-card, .detail-card, .profile-card, .wallet-card, .appearance-card, .profile-list {
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.step-card, .detail-card { padding: 15px; }
.step-card.required-step .step-number::after { content: ""; position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); }
.step-heading { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 10px; align-items: start; margin-bottom: 11px; }
.step-heading-actions { grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; }
.step-heading h2, .detail-heading h1 { margin: 0; font-size: 17px; line-height: 1.18; letter-spacing: -.026em; }
.step-heading p, .detail-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.step-number, .detail-heading-icon { position: relative; width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 850; font-size: 13px; }
.step-number .ui-icon { width: 18px; height: 18px; }
.info-button { min-height: 32px; border: 1px solid var(--line); border-radius: 11px; padding: 0 9px; display: inline-flex; align-items: center; gap: 5px; background: var(--surface-soft); color: var(--accent); font-size: 11px; font-weight: 780; cursor: pointer; }
.info-button .ui-icon { width: 16px; height: 16px; }

.segmented-control { min-height: 44px; padding: 4px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 4px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-muted); }
.segment { min-height: 36px; border: 0; border-radius: 11px; padding: 0 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 760; cursor: pointer; transition: background .17s ease, color .17s ease, box-shadow .17s ease, transform .17s ease; }
.segment:active { transform: scale(.985); }
.segment.active { background: var(--surface); color: var(--text); box-shadow: 0 3px 10px rgba(30,40,58,.09), inset 0 0 0 1px var(--line); }
.compact-segment { max-width: 340px; }

.field { display: block; margin-top: 10px; }
textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.45;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 62px; max-height: 320px; resize: none; overflow-y: hidden; }
textarea:focus, input[type="text"]:focus { border-color: rgba(var(--accent-rgb), .52); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .10); background: var(--surface); outline: none; }
textarea::placeholder, input::placeholder { color: var(--muted); }

.choice-grid { display: grid; gap: 7px; }
.aspect-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.choice { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 14px; padding: 9px 10px; background: var(--surface-soft); color: var(--text); text-align: left; cursor: pointer; transition: border-color .17s ease, background .17s ease, box-shadow .17s ease, transform .17s ease; }
.choice:active { transform: scale(.985); }
.choice strong, .choice small { display: block; }
.choice strong { font-size: 13px; font-weight: 850; }
.choice small { margin-top: 2px; color: var(--muted); font-size: 9.5px; line-height: 1.18; }
.choice.active { border-color: rgba(var(--accent-rgb), .45); background: var(--accent-soft); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .13); }
.compact-choice { min-height: 55px; }
.choice-grid-two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.choice[data-text-area] { display: grid; place-items: center; text-align: center; }
.generation-choice-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.generation-choice-grid .choice { min-height: 62px; text-align: center; }
.generation-choice-grid .choice strong { font-size: 20px; }
.generation-choice-grid em { display: inline-block; margin-top: 3px; color: var(--success); font-size: 9px; font-style: normal; font-weight: 800; }

.upload-slot-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.upload-slot { position: relative; aspect-ratio: 1; min-width: 0; border: 1.5px dashed rgba(var(--accent-rgb), .38); border-radius: 17px; display: grid; place-items: center; overflow: hidden; background: var(--accent-soft); color: var(--accent); cursor: pointer; transition: border-color .17s ease, transform .17s ease, background .17s ease; }
.upload-slot:active { transform: scale(.98); }
.upload-slot.drag-over { border-color: var(--accent); background: rgba(var(--accent-rgb), .2); }
.upload-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-slot .slot-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,15,24,.45); color: #fff; font-size: 11px; }
.upload-slot.has-image::after { content: "Заменить"; position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 4px; border-radius: 8px; background: rgba(9,13,20,.62); color: #fff; font-size: 9px; font-weight: 750; text-align: center; }
.subject-rows { display: grid; gap: 8px; }
.subject-row { position: relative; display: grid; grid-template-columns: 94px minmax(0,1fr); gap: 9px; padding: 9px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-soft); }
.subject-row .upload-slot { width: 100%; align-self: start; }
.subject-row textarea { margin: 0; min-height: 62px; }
.subject-remove { position: absolute; z-index: 3; top: 4px; right: 4px; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); cursor: pointer; }
.subject-remove .ui-icon { width: 15px; height: 15px; }
.add-row-button { width: 100%; min-height: 40px; margin-top: 8px; border: 1px dashed rgba(var(--accent-rgb), .42); border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: transparent; color: var(--accent); font-size: 12px; font-weight: 780; cursor: pointer; }
.add-row-button .ui-icon { width: 17px; height: 17px; }

.style-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
.chip, .font-choice { min-width: 0; min-height: 38px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; background: var(--surface-soft); color: var(--text-soft); font-size: 11.5px; font-weight: 760; text-align: center; cursor: pointer; transition: background .17s ease, border-color .17s ease, color .17s ease, transform .17s ease; }
.chip:active, .font-choice:active { transform: scale(.98); }
.chip.active, .font-choice.active { border-color: rgba(var(--accent-rgb), .44); background: var(--accent-soft); color: var(--accent); }
.conditional-stack { display: grid; gap: 9px; margin-top: 9px; }
.subsection { display: grid; gap: 6px; }
.subsection-label, .position-panel > span { color: var(--text-soft); font-size: 10.5px; font-weight: 780; }
.compact-subsection { padding-top: 2px; }
.chip-grid { display: grid; gap: 7px; }
.chip-grid-three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.position-panels { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.position-panel { padding: 9px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); transition: opacity .17s ease, filter .17s ease, border-color .17s ease; }
.position-panel.active { border-color: rgba(var(--accent-rgb), .36); }
.position-panel.disabled { opacity: .45; filter: grayscale(.45); pointer-events: none; }
.position-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; margin-top: 7px; }
.position-grid button, .half-position-grid button { min-height: 31px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; cursor: pointer; }
.position-grid button.active, .half-position-grid button.active { border-color: rgba(var(--accent-rgb), .45); background: var(--accent); color: #fff; }
.half-position-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; margin-top: 7px; }
.font-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.font-choice { min-height: 40px; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }


/* Text region editor */
.text-region-editor { display: grid; gap: 9px; }
.text-region-intro { display: grid; gap: 2px; }
.text-region-intro strong { color: var(--text); font-size: 12px; font-weight: 850; }
.text-region-intro p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.text-region-canvas-shell { min-height: 180px; display: grid; place-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-muted); overflow: hidden; }
.text-region-canvas {
  position: relative;
  width: 100%;
  min-width: 150px;
  min-height: 150px;
  overflow: hidden;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(130,145,170,.08) 25%, transparent 25%, transparent 75%, rgba(130,145,170,.08) 75%),
    linear-gradient(45deg, rgba(130,145,170,.08) 25%, transparent 25%, transparent 75%, rgba(130,145,170,.08) 75%),
    var(--surface);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.text-region-canvas.drawing { touch-action: none; cursor: crosshair; box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .32); }
.text-region-canvas-grid { position: absolute; inset: 0; pointer-events: none; opacity: .32; background-image: linear-gradient(rgba(var(--accent-rgb), .14) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--accent-rgb), .14) 1px, transparent 1px); background-size: 25% 25%; }
.text-region-aspect-badge { position: absolute; z-index: 1; top: 7px; left: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--muted); font-size: 9px; font-weight: 820; line-height: 1; pointer-events: none; }
.text-region-layer { position: absolute; inset: 0; }
.text-region-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 4px; padding: 20px; text-align: center; color: var(--muted); pointer-events: none; }
.text-region-empty strong { color: var(--text-soft); font-size: 13px; }
.text-region-empty span { font-size: 10px; }
.text-region-box {
  position: absolute;
  z-index: 2;
  min-width: 46px;
  min-height: 34px;
  border: 2px dashed var(--region-color);
  border-radius: 10px;
  background: color-mix(in srgb, var(--region-color) 10%, var(--surface));
  color: var(--text);
  touch-action: pan-y;
  box-shadow: 0 5px 18px color-mix(in srgb, var(--region-color) 18%, transparent);
}
.text-region-box.active { touch-action: none; border-style: solid; box-shadow: 0 0 0 3px color-mix(in srgb, var(--region-color) 17%, transparent), 0 8px 24px rgba(0,0,0,.14); }
.text-region-inline-input {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 9px 9px 7px;
  overflow: hidden;
  resize: none;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  caret-color: var(--region-color);
  font-weight: 900;
  line-height: 1.02;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px var(--surface);
  outline: none;
  touch-action: pan-y;
  pointer-events: none;
  user-select: text;
  -webkit-user-select: text;
}
.text-region-box.active .text-region-inline-input { pointer-events: auto; touch-action: manipulation; }
.text-region-inline-input:focus { background: color-mix(in srgb, var(--surface) 72%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--region-color) 38%, transparent); }
.text-region-inline-input::placeholder { color: color-mix(in srgb, var(--text-soft) 72%, transparent); font-weight: 720; text-shadow: none; }
.text-region-inline-input.overflowing { box-shadow: inset 0 0 0 2px rgba(213,82,82,.5); }
.text-region-drag-handle,
.text-region-inline-delete {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--region-color) 42%, var(--line));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--region-color);
  box-shadow: 0 2px 8px rgba(0,0,0,.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.text-region-box.active .text-region-drag-handle,
.text-region-box.active .text-region-inline-delete { opacity: 1; pointer-events: auto; }
.text-region-drag-handle {
  top: auto;
  bottom: -13px;
  left: 50%;
  min-width: 32px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 999px;
  cursor: move;
  touch-action: none;
  font-size: 14px;
  line-height: 1;
}
.text-region-inline-delete {
  top: -14px;
  left: 50%;
  right: auto;
  width: 28px;
  height: 28px;
  transform: translateX(-50%);
  border-color: rgba(213,82,82,.38);
  border-radius: 50%;
  color: var(--danger);
  cursor: pointer;
}
.text-region-inline-delete .ui-icon { width: 13px; height: 13px; }
.text-region-handle {
  position: absolute;
  z-index: 8;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.text-region-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--region-color);
  box-shadow: 0 2px 7px rgba(0,0,0,.22);
}
.text-region-box.active .text-region-handle { opacity: 1; pointer-events: auto; }
.text-region-handle[data-region-handle="nw"] { left: -19px; top: -19px; cursor: nwse-resize; }
.text-region-handle[data-region-handle="ne"] { right: -19px; top: -19px; cursor: nesw-resize; }
.text-region-handle[data-region-handle="sw"] { left: -19px; bottom: -19px; cursor: nesw-resize; }
.text-region-handle[data-region-handle="se"] { right: -19px; bottom: -19px; cursor: nwse-resize; }
.text-region-draw-preview { position: absolute; z-index: 5; border: 2px dashed var(--accent); border-radius: 10px; background: rgba(var(--accent-rgb), .13); pointer-events: none; }
.text-region-toolbar { display: flex; gap: 7px; align-items: stretch; }
.text-region-add, .text-region-clear { min-height: 39px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 11.5px; font-weight: 800; cursor: pointer; }
.text-region-add { flex: 1 1 auto; min-width: 0; width: 100%; border: 1px dashed rgba(var(--accent-rgb), .5); padding: 0 14px; background: var(--accent-soft); color: var(--accent); }
.text-region-add.active { border-style: solid; background: var(--accent); color: #fff; }
.text-region-add:disabled { opacity: .48; cursor: default; }
.text-region-clear { flex: 0 0 auto; min-width: 88px; border: 1px solid rgba(213,82,82,.25); padding: 0 10px; background: rgba(213,82,82,.08); color: var(--danger); }
.text-region-add .ui-icon, .text-region-clear .ui-icon { width: 16px; height: 16px; }
.text-region-note { margin: -1px 0 0; color: var(--muted); font-size: 9.5px; line-height: 1.35; text-align: center; }

@media (max-width: 420px) {
  .text-region-canvas-shell { padding: 6px; }
  .text-region-clear { min-width: 78px; padding: 0 8px; }
  .text-region-add { min-width: 0; padding: 0 10px; }
  .text-region-inline-input { padding: 8px 7px 6px; }
  .text-region-inline-delete { top: -15px; left: 50%; right: auto; }
  .text-region-drag-handle { bottom: -15px; }
  .text-region-handle { width: 48px; height: 48px; }
  .text-region-handle::after { width: 20px; height: 20px; }
  .text-region-handle[data-region-handle="nw"] { left: -24px; top: -24px; }
  .text-region-handle[data-region-handle="ne"] { right: -24px; top: -24px; }
  .text-region-handle[data-region-handle="sw"] { left: -24px; bottom: -24px; }
  .text-region-handle[data-region-handle="se"] { right: -24px; bottom: -24px; }
}

.secondary-button, .checkout-pay-button, .payment-method-button { width: 100%; border-radius: 15px; cursor: pointer; }
.secondary-button { min-height: 42px; border: 1px solid var(--line); background: var(--surface-soft); color: var(--text); font-size: 12px; font-weight: 780; }
.prompt-preview { max-height: 320px; margin-top: 8px; padding: 11px; overflow: auto; white-space: pre-wrap; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-muted); color: var(--text-soft); font-size: 11.5px; line-height: 1.45; }
.checkout-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 9px; }
.checkout-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.checkout-summary span, .checkout-summary strong { display: block; }
.checkout-summary span { color: var(--muted); font-size: 10px; }
.checkout-summary strong { margin-top: 3px; font-size: 16px; }
.checkout-pay-button { min-height: 44px; border: 1px solid rgba(var(--accent-rgb), .36); background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 850; transition: transform .17s ease, background .17s ease; }
.checkout-pay-button:active { transform: scale(.987); }
.checkout-pay-button:disabled { opacity: .55; cursor: default; }

.profile-main { padding: 14px; display: grid; grid-template-columns: 50px minmax(0,1fr) auto; gap: 11px; align-items: center; }
.profile-avatar { width: 50px; height: 50px; border-radius: 17px; display: grid; place-items: center; background: linear-gradient(145deg,var(--accent),#315fd6); color: #fff; font-size: 20px; font-weight: 900; }
.profile-copy h1 { margin: 0; font-size: 17px; }
.profile-copy p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.admin-badge { padding: 5px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 800; }
.wallet-card, .appearance-card { margin-top: 10px; padding: 14px; }
.wallet-card-top { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 10px; align-items: center; }
.wallet-card-icon, .appearance-icon, .profile-row-icon { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.wallet-card-icon { width: 48px; height: 48px; border-radius: 16px; }
.wallet-card-copy small, .wallet-card-copy strong { display: block; }
.wallet-card-copy small { color: var(--muted); font-size: 11px; }
.wallet-card-copy strong { margin-top: 2px; font-size: 28px; letter-spacing: -.04em; }
.wallet-topup-button { width: 100%; min-height: 58px; margin-top: 10px; border: 0; border-radius: 17px; padding: 8px 12px 8px 9px; display: grid; grid-template-columns: 40px minmax(0,1fr) 18px; gap: 9px; align-items: center; background: linear-gradient(135deg,#3378ff,#2457ca); color: #fff; text-align: left; cursor: pointer; }
.wallet-topup-plus { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: rgba(255,255,255,.17); }
.wallet-topup-button strong, .wallet-topup-button small { display: block; }
.wallet-topup-button strong { font-size: 13px; }
.wallet-topup-button small { margin-top: 2px; color: rgba(255,255,255,.72); font-size: 10px; }
.appearance-heading { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 10px; align-items: center; }
.appearance-icon { width: 42px; height: 42px; border-radius: 14px; }
.appearance-heading strong, .appearance-heading small { display: block; }
.appearance-heading strong { font-size: 14px; }
.appearance-heading small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.theme-segment { margin-top: 10px; padding: 4px; display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-muted); }
.theme-segment-button { min-height: 38px; border: 0; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 760; cursor: pointer; }
.theme-segment-button.active { background: var(--surface); color: var(--text); box-shadow: 0 3px 10px rgba(30,40,58,.09); }
.theme-segment-button .ui-icon { width: 17px; height: 17px; }
.profile-list { margin-top: 10px; padding: 4px 8px; }
.profile-row { width: 100%; min-height: 60px; border: 0; border-bottom: 1px solid var(--line); padding: 7px 4px; display: grid; grid-template-columns: 40px minmax(0,1fr) 18px; gap: 9px; align-items: center; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.profile-row:last-child { border-bottom: 0; }
.profile-row-icon { width: 40px; height: 40px; border-radius: 13px; }
.profile-row-copy strong, .profile-row-copy small { display: block; }
.profile-row-copy strong { font-size: 13px; }
.profile-row-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.row-chevron { width: 17px; height: 17px; color: var(--muted); }

.detail-card { min-height: 180px; }
.detail-heading { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 11px; align-items: center; margin-bottom: 14px; }
.detail-heading-icon { width: 42px; height: 42px; border-radius: 14px; }
.payment-page-card { display: grid; gap: 10px; }
.payment-job-context, .payment-calculation { display: grid; gap: 6px; padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.payment-job-context { grid-template-columns: repeat(3,minmax(0,1fr)); }
.payment-job-context small, .payment-calculation span { display: block; color: var(--muted); font-size: 9.5px; }
.payment-job-context strong, .payment-calculation strong { display: block; margin-top: 2px; font-size: 13px; }
.payment-amount-block { display: grid; gap: 5px; }
.payment-amount-control { height: 56px; border: 1px solid var(--line); border-radius: 15px; display: grid; grid-template-columns: 1fr auto; align-items: center; background: var(--surface-soft); }
.payment-amount-control input { height: 100%; border: 0; background: transparent; font-size: 24px; font-weight: 850; }
.payment-amount-control span { padding-right: 14px; color: var(--text-soft); font-size: 18px; font-weight: 800; }
.payment-field-hint, .payment-field-error { margin: 0 2px; font-size: 10px; }
.payment-field-hint { color: var(--muted); }
.payment-field-error { color: var(--danger); }
.payment-presets { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.payment-preset { min-height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); color: var(--text); font-size: 11px; font-weight: 780; cursor: pointer; }
.payment-preset.active { border-color: rgba(var(--accent-rgb), .42); background: var(--accent-soft); color: var(--accent); }
.payment-calculation > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.payment-total-row { padding-top: 6px; border-top: 1px solid var(--line); }
.payment-method-button { min-height: 58px; border: 1px solid var(--line); padding: 8px 12px 8px 9px; display: grid; grid-template-columns: 40px minmax(0,1fr) 18px; gap: 9px; align-items: center; background: var(--surface-soft); color: var(--text); text-align: left; }
.payment-method-button[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.payment-method-icon { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.order-status { padding: 10px 12px; border-radius: 12px; background: var(--surface-muted); color: var(--text-soft); font-size: 11px; }
.order-status.paid { background: rgba(42,170,107,.1); color: var(--success); }

.orders-list, .reviews-list { display: grid; gap: 9px; }
.order-card, .review-card { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.order-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.order-card strong, .order-card small { display: block; }
.order-card small { margin-top: 3px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.order-status-chip { min-height: 27px; padding: 0 9px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--surface-muted); color: var(--muted); font-size: 9px; font-weight: 780; text-align: center; }
.order-status-chip.paid { background: rgba(42,170,107,.1); color: var(--success); }
.order-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.order-action { min-height: 32px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; display: inline-flex; align-items: center; gap: 5px; background: var(--surface); color: var(--text-soft); font-size: 10px; font-weight: 760; cursor: pointer; }
.order-action .ui-icon { width: 14px; height: 14px; }
.order-prompt { margin-top: 8px; padding: 9px; border-radius: 11px; background: var(--surface-muted); white-space: pre-wrap; color: var(--text-soft); font-size: 10.5px; line-height: 1.4; }
.review-stars { color: #f0a62d; letter-spacing: 2px; }
.review-card p { margin: 7px 0; color: var(--text-soft); font-size: 12px; line-height: 1.45; }
.review-card small { color: var(--muted); font-size: 10px; }
.empty-state { padding: 24px 12px; color: var(--muted); text-align: center; font-size: 12px; }

.ratio-examples { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.ratio-examples article { padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.ratio-examples strong { display: block; margin-top: 7px; font-size: 11px; line-height: 1.3; }
.ratio-visual { width: 100%; max-height: 175px; margin: 0 auto; border-radius: 12px; display: grid; place-items: end start; overflow: hidden; background: linear-gradient(140deg,#2b62d8,#7d43d9 55%,#f0954f); box-shadow: inset 0 -55px 50px rgba(0,0,0,.25); }
.ratio-visual::before { content: ""; width: 58%; height: 52%; align-self: center; justify-self: center; border-radius: 50% 50% 42% 42%; background: rgba(255,255,255,.3); box-shadow: 42px 12px 0 -18px rgba(255,255,255,.28); }
.ratio-visual span { position: absolute; margin: 9px; padding: 4px 7px; border-radius: 8px; background: rgba(8,12,20,.58); color: #fff; font-size: 10px; font-weight: 850; }
.ratio-visual { position: relative; }
.ratio-9-16 { aspect-ratio: 9/16; width: 44%; }
.ratio-16-9 { aspect-ratio: 16/9; }
.ratio-1-1 { aspect-ratio: 1; width: 68%; }
.ratio-2-3 { aspect-ratio: 2/3; width: 56%; }
.ratio-3-2 { aspect-ratio: 3/2; }
.ratio-3-4 { aspect-ratio: 3/4; width: 58%; }
.ratio-4-3 { aspect-ratio: 4/3; }
.info-copy { color: var(--text-soft); font-size: 13px; line-height: 1.55; }
.info-copy h2 { color: var(--text); font-size: 15px; }
.info-copy p { margin: 8px 0; }

/* Legal documents */
.legal-copy, .legal-document { color: var(--text-soft); font-size: 12px; line-height: 1.58; }
.legal-copy h2, .legal-document h2 { margin: 18px 0 6px; color: var(--text); font-size: 15px; }
.legal-copy h3, .legal-document h3 { margin: 14px 0 5px; color: var(--text); font-size: 13px; }
.legal-copy p, .legal-document p { margin: 7px 0; }
.legal-copy ul, .legal-document ul { margin: 7px 0; padding-left: 20px; }
.legal-copy li, .legal-document li { margin: 4px 0; }

.bottom-nav {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(9px, var(--bottom-safe));
  width: min(calc(var(--shell) - 32px), calc(100% - 24px));
  min-height: 74px;
  padding: 6px 8px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 18px 42px rgba(31,39,54,.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.bottom-btn { min-width: 0; min-height: 60px; border: 0; border-radius: 17px; padding: 3px; display: grid; place-items: center; align-content: center; gap: 3px; background: transparent; color: var(--muted); cursor: pointer; }
.bottom-btn .bottom-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.bottom-btn .bottom-icon .ui-icon { width: 20px; height: 20px; }
.bottom-btn b { font-size: 10px; line-height: 1; font-weight: 760; }
.bottom-btn.active { color: var(--accent); }
.bottom-btn.active .bottom-icon { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(var(--accent-rgb), .30); }
#backBtn .bottom-icon { border: 1px solid var(--line); background: transparent; }
#backBtn.disabled { opacity: .55; }
#backBtn.disabled b { visibility: visible; }
body.keyboard-open .bottom-nav { opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, calc(100% + 26px)); }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 640px) {
  body { padding-top: calc(58px + var(--top-safe)); }
  .topbar { min-height: 58px; padding: 8px 14px; }
  .brand-button { font-size: 24px; }
  .app-shell { padding: 6px 10px 24px; }
  .step-card, .detail-card { padding: 12px; border-radius: 19px; }
  .step-heading { margin-bottom: 9px; }
  .aspect-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .style-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .subject-row { grid-template-columns: 82px minmax(0,1fr); }
  .subject-row textarea { min-height: 62px; }
  .font-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .position-panels { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .payment-job-context { grid-template-columns: 1fr; }
  .ratio-examples { grid-template-columns: 1fr 1fr; }
  .bottom-nav { width: calc(100% - 18px); }
}
@media (max-width: 390px) {
  .style-grid { gap: 5px; }
  .chip, .font-choice { padding-inline: 4px; font-size: 10.5px; }
  .position-panels { grid-template-columns: 1fr; }
  .payment-presets { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

.upload-slot .slot-clear {
  position: absolute;
  z-index: 5;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(8, 13, 22, .68);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  font-weight: 500;
  opacity: .92;
}
.upload-slot:not(.has-image) .slot-clear { display: none; }
.upload-slot.has-image::after { display: none; }

/* Compact overlays, validation, progress and refined choice controls */
.instruction-button {
  min-height: 32px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 11px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.info-button {
  width: 31px;
  height: 31px;
  min-height: 31px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  gap: 0;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
}
.aspect-grid { grid-template-columns: repeat(4, minmax(0,1fr)) !important; gap: 6px; }
.aspect-grid .choice {
  min-height: 42px;
  padding: 6px 3px;
  display: grid;
  place-items: center;
  text-align: center;
}
.aspect-grid .choice strong { font-size: 12px; line-height: 1; }
.aspect-grid .choice small { display: none; }
.generation-choice-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.generation-choice-grid .choice { min-height: 58px; padding: 7px 5px; }

.font-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}
.font-choice {
  width: 100%;
  min-height: 50px;
  padding: 7px 11px;
  display: grid;
  align-items: center;
  justify-items: start;
  overflow: hidden;
  text-align: left;
}
.font-preview-text {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: pre-line;
  text-overflow: ellipsis;
  font-size: clamp(17px, 4.8vw, 22px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: .015em;
}

.ratio-visual::before { display: none !important; content: none !important; }
.ratio-visual {
  background:
    linear-gradient(145deg, rgba(255,255,255,.12), transparent 46%),
    linear-gradient(135deg, #245bd3, #7245d9 56%, #ec8b4e);
  box-shadow: inset 0 -38px 42px rgba(0,0,0,.20);
}
.ratio-examples article:nth-child(2n) .ratio-visual {
  background: linear-gradient(135deg, #0f8e9b, #2f69d7 55%, #7556d8);
}
.ratio-examples article:nth-child(3n) .ratio-visual {
  background: linear-gradient(135deg, #de6d55, #ba4da1 52%, #545cc9);
}

.step-card.has-error {
  border-color: rgba(213,82,82,.54);
  box-shadow: 0 0 0 2px rgba(213,82,82,.08), var(--shadow-soft);
}

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: calc(max(9px, var(--bottom-safe)) + 83px);
  width: min(520px, calc(100% - 30px));
  transform: translateX(-50%);
  padding: 11px 14px;
  border: 1px solid rgba(var(--accent-rgb), .28);
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  color: var(--text);
  box-shadow: 0 15px 38px rgba(22,29,42,.20);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  white-space: pre-line;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  animation: toast-in .18s var(--ease);
}
.toast.error { border-color: rgba(213,82,82,.42); color: var(--danger); }
.toast.success { border-color: rgba(42,170,107,.38); color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
body.keyboard-open .toast { bottom: max(12px, var(--bottom-safe)); }

html.overlay-open,
body.overlay-open,
html.studio-tour-open,
body.studio-tour-open { overflow: hidden; }
.overlay-modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: calc(16px + var(--top-safe)) 12px calc(20px + var(--bottom-safe));
  display: grid;
  place-items: center;
  background: rgba(5,9,16,.64);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.overlay-backdrop { position: absolute; inset: 0; }
.overlay-panel {
  position: relative;
  z-index: 1;
  width: min(650px, 100%);
  max-height: min(84vh, 820px);
  border: 1px solid var(--line);
  border-radius: 23px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0,0,0,.34);
}
.overlay-panel-head {
  min-height: 58px;
  padding: 11px 13px 10px 17px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.overlay-panel-head h2 { margin: 0; font-size: 18px; }
.overlay-close {
  width: 35px;
  height: 35px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}
.overlay-close .ui-icon { width: 17px; height: 17px; }
.overlay-panel-body { overflow: auto; padding: 14px; overscroll-behavior: contain; }
.overlay-panel-body .ratio-examples { grid-template-columns: repeat(2,minmax(0,1fr)); }

.studio-tour {
  position: fixed;
  z-index: 130;
  inset: 0;
  background: rgba(4,8,15,.68);
  pointer-events: auto;
}
.studio-tour-spotlight {
  position: fixed;
  border: 2px solid rgba(255,255,255,.88);
  border-radius: 22px;
  box-shadow: 0 0 0 9999px rgba(4,8,15,.70), 0 0 24px rgba(var(--accent-rgb),.45);
  transition: left .22s var(--ease), top .22s var(--ease), width .22s var(--ease), height .22s var(--ease);
  pointer-events: none;
}
.studio-tour-card {
  position: fixed;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 22px 60px rgba(0,0,0,.32);
}
.studio-tour-card-top { color: var(--muted); font-size: 10px; font-weight: 800; }
.studio-tour-card h3 { margin: 7px 0 5px; font-size: 17px; }
.studio-tour-card p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.48; }
.studio-tour-actions { margin-top: 13px; display: grid; grid-template-columns: 1fr 38px 1fr; gap: 8px; }
.studio-tour-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}
.studio-tour-actions button:last-child { background: var(--accent); border-color: var(--accent); color: #fff; }
.studio-tour-close { display: grid; place-items: center; }
.studio-tour-close .ui-icon { width: 16px; height: 16px; }

.processing-card { display: grid; gap: 14px; }
.processing-progress-wrap {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-soft);
}
.processing-progress-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.processing-progress-head strong { font-size: 14px; }
.processing-progress-head span { color: var(--accent); font-size: 17px; font-weight: 900; }
.processing-progress-track {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-muted);
}
.processing-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8f6fff);
  transition: width .42s var(--ease);
}
.processing-message { margin: 9px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.processing-error { padding: 11px 13px; border-radius: 14px; background: rgba(213,82,82,.1); color: var(--danger); font-size: 12px; line-height: 1.45; }
.processing-results { display: grid; gap: 10px; }
.processing-results h2 { margin: 0; font-size: 18px; }
.processing-results > p { margin: -5px 0 0; color: var(--muted); font-size: 11px; }
.processing-result-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.processing-result-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-soft); }
.processing-result-card img { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.processing-result-placeholder { min-height: 130px; display: grid; place-items: center; padding: 16px; color: var(--muted); font-size: 11px; text-align: center; }
.processing-result-placeholder.error { color: var(--danger); }

@media (max-width: 640px) {
  .aspect-grid { grid-template-columns: repeat(4,minmax(0,1fr)) !important; }
  .overlay-panel-body .ratio-examples { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .processing-result-grid { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .aspect-grid { gap: 4px; }
  .aspect-grid .choice strong { font-size: 11px; }
}
.ratio-visual span { display: none; }
.processing-heading {
  display: grid;
  grid-template-columns: 46px minmax(0,1fr);
  gap: 11px;
  align-items: center;
}
.processing-heading-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.processing-heading h1 { margin: 0; font-size: 18px; }
.processing-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.processing-progress {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface-soft);
}
.processing-progress .processing-progress-track { margin-top: 0; }
.processing-progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8f6fff);
  transition: width .42s var(--ease);
}
.processing-progress > strong { min-width: 43px; color: var(--accent); font-size: 16px; text-align: right; }
.processing-result-heading h2 { margin: 0; font-size: 18px; }
.processing-result-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.processing-result-card img {
  width: 100%;
  height: auto;
  max-height: 72vh;
  aspect-ratio: auto;
  object-fit: contain;
  background: var(--surface-muted);
}

/* Compact info panels, isolated controls and refined previews */
.info-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
  text-transform: lowercase;
}

/* Information opens above the page while the three main navigation buttons remain available. */
.overlay-modal {
  z-index: 35;
  padding: calc(12px + var(--top-safe)) 10px calc(98px + var(--bottom-safe));
}
.overlay-backdrop { pointer-events: auto; cursor: pointer; }
.overlay-close { display: grid !important; flex: 0 0 auto; }
.overlay-panel {
  max-height: min(calc(100dvh - 124px - var(--top-safe) - var(--bottom-safe)), 760px);
  border-radius: 20px;
}
.overlay-panel-head {
  min-height: 48px;
  padding: 8px 13px;
}
.overlay-panel-head h2 { font-size: 16px; }
.overlay-panel-body { padding: 10px 12px 12px; }
.overlay-panel-body [data-info-content] > :first-child { margin-top: 0; }
.overlay-lead { margin: 0 0 7px; line-height: 1.4; }
.info-copy { font-size: 12px; line-height: 1.45; }
.info-copy h3 { margin: 0 0 6px; font-size: 13px; }
.info-copy p { margin: 4px 0; }
.ratio-examples { gap: 8px; }
.ratio-examples article { gap: 4px; }
.ratio-examples strong { margin-top: 4px; }
.ratio-visual,
.ratio-examples article:nth-child(2n) .ratio-visual,
.ratio-examples article:nth-child(3n) .ratio-visual {
  background:
    linear-gradient(145deg, rgba(255,255,255,.12), transparent 46%),
    linear-gradient(135deg, #245bd3, #7245d9 56%, #ec8b4e) !important;
}

/* Price and automatic discount stay on one compact line. */
.generation-choice-grid .choice {
  min-height: 50px;
  padding: 5px 5px 3px;
  gap: 2px;
}
.generation-choice-grid .choice strong { line-height: 1; }
.generation-price-row {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1;
}
.generation-price-row small,
.generation-price-row em {
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}
.generation-price-row em { font-size: 9px; }

/* Font cards show the user's exact text with less vertical padding. */
.font-grid { gap: 5px; }
.font-choice {
  min-height: 42px;
  padding: 4px 10px;
}
.font-preview-text {
  font-size: clamp(16px, 4.5vw, 21px);
  line-height: 1;
}

@media (max-width: 640px) {
  .overlay-panel-body .ratio-examples { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .generation-choice-grid .choice { min-height: 48px; padding-bottom: 2px; }
  .font-choice { min-height: 40px; padding-block: 3px; }
}
.studio-tour-spotlight {
  transition: left .12s var(--ease), top .12s var(--ease), width .12s var(--ease), height .12s var(--ease);
}

/* Compact final layout refinements */
.generation-card > .step-heading,
.prompt-preview-card > .step-heading,
.final-card > .step-heading {
  align-items: center;
}

/* Remove the oversized gap below the payment lead. */
#paymentPage .payment-page-card {
  gap: 7px;
}
#paymentPage .detail-heading {
  margin-bottom: 0;
}
#paymentPage .detail-heading p {
  margin-top: 2px;
}

/* Empty history must stay compact instead of looking like a large card. */
#historyPage .detail-card {
  min-height: 0;
}
#historyPage .detail-heading {
  margin-bottom: 8px;
}
#historyPage .orders-list .empty-state {
  padding: 9px 6px;
}

/* Aspect-ratio examples: one visual language, centered caption and visible ratio. */
.ratio-examples article {
  text-align: center;
}
.ratio-examples strong {
  text-align: center;
}
.ratio-examples .ratio-visual,
.ratio-examples article:nth-child(2n) .ratio-visual,
.ratio-examples article:nth-child(3n) .ratio-visual {
  place-items: center;
  background:
    linear-gradient(145deg, rgba(255,255,255,.12), transparent 46%),
    linear-gradient(135deg, #245bd3, #7245d9 56%, #ec8b4e) !important;
}
.ratio-examples .ratio-visual span {
  display: grid !important;
  place-items: center;
  position: absolute;
  inset: 50% auto auto 50%;
  min-width: 42px;
  min-height: 28px;
  margin: 0;
  padding: 4px 8px;
  transform: translate(-50%, -50%);
  border-radius: 9px;
  background: rgba(8,12,20,.58);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

/* Result, review, history and navigation refinements */
#backBtn.active .bottom-icon {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(var(--accent-rgb), .30);
}

.processing-result-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}
.processing-result-actions .secondary-button {
  width: 100%;
  min-height: 42px;
  justify-content: center;
}

#reviewsPage .detail-card {
  min-height: 0;
}
#reviewsPage .detail-heading {
  margin-bottom: 7px;
}
#reviewsPage .reviews-list .empty-state {
  padding: 9px 6px;
}

.order-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.order-actions .order-action {
  min-width: 0;
  min-height: 36px;
  padding: 5px;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  white-space: normal;
}
@media (max-width: 380px) {
  .order-actions .order-action {
    font-size: 8.7px;
    padding-inline: 3px;
  }
}

/* Studio cleanup, font dropdown, history preview and separated payments */
.step-heading-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.clear-studio-button {
  width: 31px;
  height: 31px;
  min-height: 31px;
  padding: 0;
  border: 1px solid rgba(217, 63, 63, .34);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(217, 63, 63, .10);
  color: #df4d4d;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.clear-studio-button:hover {
  border-color: rgba(217, 63, 63, .55);
  background: rgba(217, 63, 63, .16);
}
.clear-studio-button:active { transform: scale(.94); }
.clear-studio-button .ui-icon { width: 17px; height: 17px; }

.font-select { position: relative; }
.font-select-toggle {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px 11px;
  display: grid;
  grid-template-columns: minmax(0,1fr) 18px;
  gap: 8px;
  align-items: center;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.font-select-toggle.has-selection {
  border-color: rgba(var(--accent-rgb), .38);
  background: var(--accent-soft);
  color: var(--text);
}
.font-select-toggle .ui-icon {
  width: 17px;
  height: 17px;
  transform: rotate(90deg);
  transition: transform .16s ease;
}
.font-select-toggle.open .ui-icon { transform: rotate(-90deg); }
.font-selected-preview {
  min-width: 0;
  overflow: hidden;
  white-space: pre-line;
  text-overflow: ellipsis;
  font-size: clamp(15px, 4.2vw, 20px);
  line-height: 1.05;
  font-weight: 800;
}
.font-dropdown {
  max-height: 300px;
  margin-top: 6px;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  display: grid;
  gap: 5px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(20, 28, 42, .16);
}
.font-dropdown[hidden] { display: none !important; }
.font-dropdown .font-choice {
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}
.font-dropdown .font-choice.active {
  border-color: rgba(var(--accent-rgb), .44);
  background: var(--accent-soft);
  color: var(--accent);
}
.font-dropdown .font-preview-text {
  font-size: clamp(15px, 4.25vw, 20px);
  line-height: 1.06;
}
.font-choice[data-font="Rubik Mono One"] .font-preview-text { letter-spacing: .025em; font-weight: 400; }
.font-choice[data-font="Bebas Neue"] .font-preview-text { font-size: clamp(19px, 5vw, 24px); letter-spacing: .035em; font-weight: 400; }
.font-choice[data-font="Gagalin"] .font-preview-text { letter-spacing: .01em; font-weight: 400; }
.font-choice[data-font="Montserrat"] .font-preview-text { letter-spacing: -.015em; font-weight: 900; }
.font-choice[data-font="Inter"] .font-preview-text { letter-spacing: -.03em; font-weight: 800; }
.font-choice[data-font="Roboto"] .font-preview-text { letter-spacing: 0; font-weight: 700; }
.font-choice[data-font="Lobster"] .font-preview-text,
.font-choice[data-font="Pacifico"] .font-preview-text { font-weight: 400; }

.confirm-modal {
  position: fixed;
  z-index: 145;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}
.confirm-modal[hidden] { display: none !important; }
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 14, .64);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.confirm-panel {
  position: relative;
  width: min(100%, 380px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
  text-align: center;
}
.confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(217, 63, 63, .12);
  color: #df4d4d;
}
.confirm-icon .ui-icon { width: 23px; height: 23px; }
.confirm-panel h2 { margin: 0; font-size: 18px; }
.confirm-panel p { margin: 8px 0 16px; color: var(--muted); font-size: 11.5px; line-height: 1.48; }
.confirm-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.danger-button {
  min-height: 42px;
  border: 1px solid rgba(217, 63, 63, .48);
  border-radius: 14px;
  background: #d94b4b;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.payment-method-list { display: grid; gap: 7px; }
.payment-method-sbp {
  background: rgba(37, 180, 135, .12);
  color: #22a878;
}

.order-card-layout {
  display: grid;
  grid-template-columns: 88px minmax(0,1fr);
  gap: 10px;
  align-items: stretch;
}
.order-card-body { min-width: 0; }
.order-thumbnail {
  position: relative;
  min-height: 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface-muted));
}
.order-thumbnail img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .18s ease;
}
.order-thumbnail.loaded img { opacity: 1; }
.order-thumbnail.loaded .order-thumbnail-placeholder { opacity: 0; }
.order-thumbnail-placeholder {
  color: var(--accent);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .04em;
}
.order-thumbnail-count {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 2;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(7, 12, 20, .72);
  color: #fff;
  font-size: 9px;
  font-weight: 850;
}

@media (max-width: 380px) {
  .step-heading-tools { gap: 4px; }
  .instruction-button { padding-inline: 8px; }
  .order-card-layout { grid-template-columns: 76px minmax(0,1fr); gap: 8px; }
}


/* Custom font selection and explicit Info close action */
.font-choice-custom {
  min-height: 48px;
  display: grid !important;
  align-content: center;
  gap: 3px;
  font-family: inherit !important;
  text-align: left;
}
.font-choice-custom .font-custom-title { font-size: 13px; font-weight: 850; }
.font-choice-custom small { color: var(--muted); font-size: 10px; line-height: 1.25; }
.custom-font-wrap { margin-top: 7px; display: grid; gap: 5px; }
.custom-font-wrap[hidden] { display: none !important; }
.custom-font-input {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 14px;
  padding: 0 12px; background: var(--surface-soft); color: var(--text); outline: none;
  font: inherit; font-size: 13px;
}
.custom-font-input:focus { border-color: rgba(var(--accent-rgb), .62); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .11); }
.custom-font-wrap small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.overlay-close { color: var(--text-soft); transition: transform .16s ease, border-color .16s ease, color .16s ease, background .16s ease; }
.overlay-close:active { transform: scale(.92); }
.overlay-close:hover { border-color: rgba(var(--accent-rgb), .35); color: var(--text); background: var(--accent-soft); }
