:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f4f7fb;
  --text: #0f1b33;
  --muted: #66748c;
  --line: #e1e7f0;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --brand-soft: #eef2ff;
  --accent: #7c3aed;
  --blue: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 18px 45px rgba(15, 27, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

#app,
.shell {
  max-width: 100%;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.side {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 28px 18px;
  box-shadow: 1px 0 0 rgba(15, 27, 51, 0.02);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0;
}

.brand strong {
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--brand);
  font-size: 28px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #40516d;
  padding: 13px 14px;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.main {
  min-width: 0;
  padding: 38px 42px;
}

.create-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 900;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  font-weight: 900;
}

h3 {
  font-size: 15px;
  line-height: 1.4;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.keep-word {
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.22);
}

.btn:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.btn.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}

.btn.secondary:hover {
  background: var(--surface-muted);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--brand);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 390px;
  gap: 18px;
  margin-top: 18px;
}

.dashboard-grid.single {
  grid-template-columns: 1fr;
}

.editor-grid {
  grid-template-columns: minmax(460px, 0.98fr) minmax(440px, 1.02fr);
  align-items: start;
  gap: 22px;
}

.edit-grid {
  grid-template-columns: minmax(0, 1fr);
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(15, 27, 51, 0.06);
}

.card-pad {
  padding: 22px;
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  overflow: hidden;
}

.hero-copy {
  padding: 24px;
}

.hero-image {
  min-height: 260px;
  background: var(--surface-muted);
}

.hero-image img,
.preview-frame img,
.tile-image img,
.version-thumb img,
.dialog-image img,
.design-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.metric {
  position: relative;
  min-height: 142px;
  padding: 20px;
}

.metric p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: inline-block;
  margin-top: 8px;
  font-size: 30px;
  letter-spacing: 0;
}

.metric small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric em {
  display: block;
  margin-top: 12px;
  color: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.metric-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
}

.metric-icon.purple {
  background: #ede9fe;
  color: var(--brand);
}

.metric-icon.green {
  background: #dcfce7;
  color: var(--ok);
}

.metric-icon.blue {
  background: #dbeafe;
  color: var(--blue);
}

.metric-icon.orange {
  background: #ffedd5;
  color: #ea580c;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  text-align: center;
  box-shadow: none;
}

.empty-state h2 {
  margin-bottom: 8px;
}

.error-message {
  margin: 0;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--danger);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.tile {
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.tile-image {
  aspect-ratio: 4 / 3;
  background: var(--surface-muted);
}

.tile-body {
  padding: 16px;
}

.tile-body h3,
.dialog h2 {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  align-self: flex-start;
  justify-self: start;
  border-radius: 999px;
  padding: 0 9px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.ready {
  background: #dcfce7;
  color: var(--ok);
}

.badge.generating {
  background: #fff2df;
  color: #a15c12;
}

.badge.failed {
  background: #fee2e2;
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
}

.link-btn,
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #53627a;
}

.history-list {
  display: grid;
}

.history-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.history-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.history-row img {
  width: 64px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.history-row strong,
.history-row span {
  display: block;
}

.history-row strong {
  margin-bottom: 4px;
}

.history-row span {
  color: var(--muted);
  font-size: 12px;
}

.form {
  display: grid;
  gap: 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-title h2 {
  margin: 0;
}

.step-card {
  display: grid;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(15, 27, 51, 0.05);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-head-between {
  justify-content: space-between;
}

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

.step-label span,
.step-head > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.step-head h3 {
  margin: 0;
  font-size: 17px;
}

.step-head.plain {
  align-items: center;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.drop {
  display: grid;
  min-height: 158px;
  place-items: center;
  border: 1px dashed #c4cedd;
  border-radius: 12px;
  background: #fbfdff;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  padding: 18px;
}

.drop-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
}

.drop strong {
  color: var(--brand);
  font-size: 15px;
}

.drop b {
  color: var(--brand);
}

.drop small {
  margin-top: 6px;
  color: #8492a8;
  font-size: 11px;
}

.drop input {
  display: none;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: #344054;
  padding: 8px 11px;
  cursor: pointer;
}

.chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.control-chip {
  justify-self: end;
}

.output-settings-card {
  gap: 14px;
}

.output-settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.compact-field {
  gap: 8px;
}

.option-grid.compact-option-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.compact-option-grid .option-chip {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  min-height: 58px;
  align-content: center;
  justify-items: start;
  padding: 8px 10px;
  text-align: left;
}

.compact-option-grid .format-icon {
  grid-row: 1 / span 2;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 11px;
}

.compact-option-grid .option-chip strong,
.compact-option-grid .option-chip span {
  min-width: 0;
}

.compact-chip-row {
  gap: 8px;
}

.compact-chip-row .chip {
  padding: 8px 11px;
}

.main-quality-toggle {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 2px;
  padding: 10px 12px;
}

.advanced-card.hidden {
  display: none;
}

.advanced-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
}

.advanced-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(520px, calc(100vw - 28px));
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 48px rgba(15, 23, 42, 0.16);
}

.advanced-drawer-head,
.advanced-drawer-actions {
  padding: 20px 24px;
}

.advanced-drawer-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.advanced-drawer-head h2,
.advanced-drawer-head p {
  margin: 0;
}

.advanced-drawer-head p:not(.eyebrow) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.advanced-drawer-body {
  display: grid;
  gap: 16px;
  overflow-y: auto;
  padding: 18px 24px 84px;
}

.advanced-size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.advanced-size-grid .option-chip {
  min-height: 66px;
}

.advanced-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.advanced-chip-grid .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advanced-chip-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.advanced-chip-scroll .chip {
  flex: 0 0 auto;
}

.advanced-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.advanced-field-head label span,
.field label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.advanced-toggle {
  grid-template-columns: minmax(0, 1fr) auto;
}

.advanced-drawer-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.option-chip {
  display: grid;
  gap: 7px;
  min-height: 112px;
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px;
  text-align: center;
  cursor: pointer;
}

.format-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: #eef2ff;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
}

.format-icon.ig {
  background: linear-gradient(135deg, #fdf2f8, #eef2ff);
  color: #db2777;
}

.format-icon.line {
  background: #dcfce7;
  color: #16a34a;
  font-size: 10px;
}

.format-icon.web {
  background: #f1f5f9;
  color: #64748b;
}

.option-chip span {
  color: var(--muted);
  font-size: 11px;
}

.option-chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.toggle-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
}

.toggle-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.toggle-card strong,
.toggle-card small {
  display: block;
}

.toggle-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.preview-frame {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.1), transparent 45%),
    var(--surface-muted);
}

.preview-frame.contain img {
  object-fit: contain;
  background: #f8fafc;
}

.preview-empty {
  display: grid;
  min-height: 520px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.create-preview {
  position: sticky;
  top: 24px;
}

.preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.preview-title-row h2 {
  margin: 0;
}

.create-preview-frame {
  display: grid;
  min-height: 670px;
  border: 1px dashed #d2dce8;
  background: #fff;
}

.create-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.create-preview-empty {
  display: grid;
  min-height: 670px;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 28px;
  color: #66748c;
  text-align: center;
}

.create-preview-empty strong {
  color: var(--text);
  font-size: 18px;
}

.empty-illustration {
  display: grid;
  width: 150px;
  height: 120px;
  place-items: center;
  border: 2px solid #a5b4fc;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
  color: #818cf8;
  font-size: 50px;
}

.upload-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 78px));
  gap: 14px;
}

.upload-thumb,
.upload-add {
  position: relative;
  width: 78px;
  height: 78px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #d8e1ef;
  border-radius: 9px;
  background: #f8fafc;
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #fff;
  color: #475569;
  cursor: pointer;
}

.upload-add {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: #475569;
  font-size: 28px;
  cursor: pointer;
}

.template-image-block {
  display: grid;
  gap: 8px;
}

.talent-image-block {
  margin-top: 2px;
}

.template-image-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
  background: #fff;
  color: #0f1b33;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.template-image-toggle span:not(.sr-only) {
  display: grid;
  gap: 2px;
}

.template-image-toggle strong {
  font-size: 12px;
}

.template-image-toggle small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.template-image-toggle b {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 18px;
  line-height: 1;
}

.talent-image-toggle {
  border-color: #cfd8e7;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.template-image-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 100%;
  gap: 10px;
  padding: 2px;
}

.template-image-card {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid #d8e1ef;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0;
  cursor: pointer;
}

.template-image-card:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.template-image-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.22);
}

.template-selected-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.template-image-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.talent-image-card img {
  object-position: center top;
}

.talent-price-badge {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 27, 51, 0.82);
  color: #fff;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-usage {
  display: grid;
  gap: 10px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: #f8fbff;
  padding: 12px;
}

.material-usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #344054;
  font-size: 12px;
}

.material-usage-head span {
  color: var(--muted);
  font-weight: 800;
}

.material-usage-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 92px));
  gap: 10px;
}

.material-usage-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #d8e1ef;
  border-radius: 9px;
  background: #fff;
}

.material-usage-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.material-usage-item span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  border-radius: 999px;
  background: rgba(15, 27, 51, 0.72);
  color: #fff;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
}

.preview-variants {
  margin-top: 16px;
}

.preview-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.preview-actions .btn {
  min-height: 56px;
  border: 0;
  border-radius: 0;
}

.assist-note {
  margin: -3px 0 0;
  color: #718096;
  font-size: 12px;
  font-weight: 700;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(246, 247, 244, 0.72);
  backdrop-filter: blur(3px);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid rgba(79, 70, 229, 0.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.version-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px;
}

.version-thumb {
  position: relative;
  width: 94px;
  aspect-ratio: 4 / 3;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--surface-muted);
  cursor: pointer;
}

.version-thumb.active {
  border-color: var(--brand);
}

.version-thumb span {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  padding: 3px 5px;
  font-size: 11px;
  font-weight: 800;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.54);
}

.dialog {
  width: min(1080px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 360px;
}

.dialog-image {
  min-height: 500px;
  background: var(--surface-muted);
}

.design-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card dl {
  margin: 0;
}

.summary-card dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.summary-card dl div:first-child {
  border-top: 0;
}

.summary-card dt,
.summary-card dd {
  margin: 0;
  font-size: 13px;
}

.summary-card dt {
  color: var(--muted);
  font-weight: 800;
}

.summary-card dd {
  color: var(--text);
}

.hint-card {
  background: linear-gradient(135deg, #fff, #f8faff);
}

.hint-card ul {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.9;
}

.sticky-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 14px;
}

.design-shot {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-grid,
  .editor-grid,
  .split,
  .dialog-grid,
  .hero-card {
    grid-template-columns: 1fr;
  }

  .create-preview {
    position: static;
  }

  .history-grid,
  .design-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  html,
  body,
  #app,
  .shell {
    overflow-x: hidden;
  }

  body {
    background: var(--bg);
  }

  .side {
    border-right: 0;
    background: #fff;
    padding: 10px 12px;
    box-shadow: 0 1px 0 var(--line);
  }

  .brand {
    margin-bottom: 8px;
    font-size: 18px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 22px;
  }

  .main {
    padding: 18px 14px 28px;
  }

  .page-head {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
  }

  .create-head {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
  }

  h1 {
    font-size: 25px;
  }

  h2 {
    font-size: 17px;
  }

  .lead {
    font-size: 13px;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .nav button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 8px 6px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
  }

  .actions,
  .sticky-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .actions .btn,
  .sticky-actions .btn {
    width: 100%;
  }

  .history-grid,
  .design-strip {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .metric {
    min-height: 128px;
    padding: 16px;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
  }

  .metric strong {
    font-size: 26px;
  }

  .card-pad {
    padding: 16px;
  }

  .section-head,
  .section-title {
    align-items: start;
    display: grid;
    gap: 8px;
  }

  .step-head-between {
    align-items: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    gap: 10px;
  }

  .step-head-between .btn {
    width: 100%;
  }

  .field-grid,
  .option-grid,
  .output-settings-grid,
  .advanced-size-grid {
    grid-template-columns: 1fr;
  }

  .advanced-drawer {
    width: 100vw;
  }

  .advanced-drawer-head,
  .advanced-drawer-body,
  .advanced-drawer-actions {
    padding-right: 16px;
    padding-left: 16px;
  }

  .advanced-drawer-actions {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    grid-template-columns: 1fr;
  }

  .drop {
    min-height: 108px;
  }

  .upload-thumbs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .template-image-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .material-usage-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .upload-thumb,
  .upload-add {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .option-chip {
    min-height: 74px;
  }

  .history-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .history-row .badge,
  .history-row .icon-btn {
    justify-self: start;
  }

  .preview-frame,
  .preview-empty,
  .create-preview-frame,
  .create-preview-empty {
    min-height: 300px;
  }

  .split {
    gap: 12px;
  }

  .dialog-backdrop {
    padding: 10px;
  }

  .dialog {
    max-height: 94vh;
  }

  .dialog-image {
    min-height: 320px;
  }
}

@media (max-width: 360px) {
  .metric-row,
  .actions,
  .sticky-actions {
    grid-template-columns: 1fr;
  }

  .side {
    padding: 8px 12px;
  }

  .brand {
    margin-bottom: 6px;
  }

  .main {
    padding: 14px 12px 24px;
  }

  h1 {
    font-size: 24px;
  }

  .nav button {
    min-height: 40px;
    gap: 3px;
    padding: 6px 3px;
    font-size: 10px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .card-pad {
    padding: 14px;
  }

  .drop {
    min-height: 116px;
    padding: 12px;
  }

  .drop small {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.35;
  }

  .nav button span:last-child {
    display: inline;
  }

  .nav button::after {
    content: none;
  }

  .template-image-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .material-usage-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}
