:root {
  --green-950: #063c2a;
  --green-900: #075035;
  --green-800: #096442;
  --green-700: #0b7a4f;
  --green-600: #12945e;
  --green-500: #18aa6d;
  --green-100: #ddf6ea;
  --green-50: #f1fbf6;
  --orange-700: #d96a00;
  --orange-600: #ef7d00;
  --orange-500: #ff9518;
  --orange-100: #fff0dd;
  --blue-700: #0867db;
  --blue-500: #2489f3;
  --blue-100: #e7f2ff;
  --purple-600: #7c4dcc;
  --purple-100: #f0e8ff;
  --sky-600: #0785b8;
  --sky-100: #e2f6ff;
  --red-600: #dc3030;
  --gray-950: #152033;
  --gray-850: #283548;
  --gray-800: #303b4e;
  --gray-700: #4e596b;
  --gray-500: #7d8798;
  --gray-400: #aab3c0;
  --gray-300: #d8dee8;
  --gray-200: #e8edf3;
  --gray-100: #f3f6f9;
  --white: #ffffff;
  --shadow-sm: 0 5px 16px rgba(24, 52, 91, 0.08);
  --shadow-md: 0 12px 35px rgba(24, 52, 91, 0.12);
  --shadow-lg: 0 20px 58px rgba(17, 49, 75, 0.17);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #edf7f2;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--gray-950);
  background:
    radial-gradient(circle at 8% 0%, rgba(18, 148, 94, 0.11), transparent 28%),
    radial-gradient(circle at 100% 9%, rgba(255, 149, 24, 0.10), transparent 24%),
    #f8fcfa;
  font-family: Inter, ui-rounded, "SF Pro Display", "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

body.panel-open { overflow: hidden; }

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

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

button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 1240px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 65px rgba(12, 69, 48, 0.08);
}

.page-container {
  padding: 24px 24px 34px;
}

.app-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(13px + var(--safe-top)) 24px 13px;
  border-bottom: 1px solid rgba(216, 222, 232, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 24px rgba(23, 67, 51, 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
}

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

.app-brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--green-700), var(--green-500));
  box-shadow: 0 10px 24px rgba(11, 122, 79, 0.24);
}

.app-brand-mark img { width: 100%; height: 100%; object-fit: cover; }

.app-brand h1 {
  margin: 0;
  color: var(--green-950);
  font-size: clamp(1.34rem, 3vw, 1.72rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.app-brand p {
  margin: 5px 0 0;
  color: var(--gray-500);
  font-size: 0.82rem;
}

.header-actions { display: flex; align-items: center; gap: 9px; }

.icon-button {
  display: inline-flex;
  min-width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
  color: var(--green-900);
  font-size: 17px;
}

.icon-button span { font-size: 0.72rem; font-weight: 800; }

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  border: 0;
  border-radius: 15px;
  font-weight: 800;
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}

.button:active { transform: scale(.985); }
.button:disabled { cursor: wait; opacity: .62; }

.button-primary {
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  box-shadow: 0 10px 24px rgba(11, 122, 79, .23);
  color: #fff;
}

.button-secondary {
  border: 1px solid var(--gray-300);
  background: #fff;
  color: var(--green-900);
}

.button-danger {
  background: linear-gradient(135deg, #d82727, #f04444);
  color: #fff;
}

.button-block { width: 100%; }

.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 132px;
  margin-bottom: 17px;
  padding: 24px 26px;
  overflow: hidden;
  border: 1px solid rgba(8, 101, 67, 0.13);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 92% 10%, rgba(255, 149, 24, .24), transparent 34%),
    linear-gradient(135deg, #f2fff8, #edf8ff);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
  font-size: .67rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.welcome-card h2 {
  margin: 0;
  color: var(--green-950);
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 850;
  letter-spacing: -.035em;
  line-height: 1.08;
}

.welcome-card p {
  margin: 8px 0 0;
  color: var(--gray-500);
  font-size: .9rem;
}

.welcome-badge {
  display: flex;
  min-width: 185px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 18px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 20px;
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-sm);
  color: var(--green-800);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.25;
}

.welcome-badge i { color: #18a955; font-size: 29px; }

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 18px;
}

.summary-card {
  display: flex;
  min-width: 0;
  min-height: 102px;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid rgba(216, 222, 232, 0.86);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
  color: var(--gray-950);
  text-align: left;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.summary-card:hover,
.summary-card.active {
  transform: translateY(-2px);
  border-color: rgba(18, 148, 94, .35);
  box-shadow: 0 12px 26px rgba(17, 73, 51, .12);
}

.summary-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 15px;
  background: var(--blue-100);
  color: var(--blue-700);
  font-size: 20px;
}

.summary-card.is-orange .summary-icon { background: var(--orange-100); color: var(--orange-700); }
.summary-card.is-green .summary-icon { background: var(--green-100); color: var(--green-700); }
.summary-card.is-purple .summary-icon { background: var(--purple-100); color: var(--purple-600); }
.summary-card.is-sky .summary-icon { background: var(--sky-100); color: var(--sky-600); }

.summary-card > span:last-child { min-width: 0; }
.summary-card small { display: block; color: var(--gray-500); font-size: .65rem; font-style: normal; }
.summary-card strong { display: block; margin-top: 1px; color: var(--green-950); font-size: .98rem; line-height: 1.12; }
.summary-card em { display: block; overflow: hidden; margin-top: 4px; color: var(--gray-500); font-size: .67rem; font-style: normal; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }

.editor-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 276px;
  align-items: start;
  gap: 17px;
}

.preview-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow-md);
}

.preview-card__header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: rgba(255, 255, 255, .97);
}

.preview-heading { display: flex; min-width: 0; align-items: center; gap: 11px; }
.preview-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 14px; background: var(--green-100); color: var(--green-700); font-size: 18px; }
.preview-heading h3 { margin: 0; color: var(--green-950); font-size: .98rem; font-weight: 850; letter-spacing: -.02em; }
.preview-heading p { overflow: hidden; max-width: 420px; margin: 3px 0 0; color: var(--gray-500); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }

.zoom-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.zoom-controls button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  background: #fff;
  color: var(--gray-700);
}

.zoom-controls button:hover { background: var(--gray-100); }
.zoom-controls span { min-width: 51px; color: var(--green-900); font-size: .7rem; font-weight: 900; text-align: center; border-right: 1px solid var(--gray-200); border-left: 1px solid var(--gray-200); }

.canvas-viewport {
  display: flex;
  min-height: 715px;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 28px;
  background:
    radial-gradient(circle at 30% 10%, rgba(18, 148, 94, .08), transparent 32%),
    linear-gradient(145deg, #eef6f2, #f7fafc);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.canvas-scaler {
  width: 360px;
  height: 640px;
  flex: 0 0 auto;
  transform-origin: top center;
  transition: transform .18s ease;
}

.canvas {
  position: relative;
  width: 360px;
  height: 640px;
  overflow: hidden;
  border: 6px solid #fff;
  border-radius: 20px;
  background: #c9e6cc;
  box-shadow: 0 24px 60px rgba(15, 54, 39, .25);
  touch-action: pan-y;
}

.overlay-solido,
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay-solido { z-index: 1; }
.overlay { z-index: 2; }
.top-band { position: absolute; top: 0; right: 0; left: 0; height: 90px; }

.editable-layer {
  position: absolute;
  z-index: 3;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: outline-color .15s, box-shadow .15s;
}

.editable-layer.selected {
  outline: 2px solid var(--blue-500) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(36, 137, 243, .18) !important;
  cursor: grab;
  touch-action: none;
}

.editable-layer.selected::before {
  position: absolute;
  top: -25px;
  left: 0;
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--blue-700);
  color: #fff;
  content: "ARRASTE";
  font: 800 8px/1 Inter, sans-serif;
  letter-spacing: .08em;
}

.layer-title { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.85); color: #111; font-weight: 900; text-align: center; text-transform: uppercase; }
.layer-box { padding: 12px; border-radius: 14px; background: rgba(255,255,255,.88); color: #111; }
.layer-box b { font-weight: 900; text-decoration: underline; }
.layer-footer { padding: 10px; border-radius: 12px; background: rgba(255,255,255,.88); color: #111; font-weight: 700; text-align: center; }
.layer-icon { width: 120px; height: 120px; background-position: center; background-repeat: no-repeat; background-size: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }

.preview-card__footer {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-500);
  font-size: .7rem;
  text-align: center;
}

.preview-card__footer i { color: var(--green-600); }

.helper-column { display: grid; gap: 12px; position: sticky; top: 96px; }
.helper-card { padding: 18px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow-sm); }
.helper-card__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: var(--green-100); color: var(--green-700); font-size: 19px; }
.helper-card--orange .helper-card__icon { background: var(--orange-100); color: var(--orange-700); }
.helper-card h3 { margin: 12px 0 5px; color: var(--green-950); font-size: .92rem; font-weight: 850; }
.helper-card p { margin: 0; color: var(--gray-500); font-size: .75rem; line-height: 1.48; }
.desktop-save-card { min-height: 56px; box-shadow: 0 14px 28px rgba(11, 122, 79, .22); }

.bottom-nav { display: none; }

/* Painéis laterais e bottom sheets */
.edit-box {
  position: fixed;
  z-index: 90;
  top: 0;
  right: -510px;
  bottom: 0;
  width: min(500px, 96vw);
  overflow: auto;
  background: #f8fbfa;
  box-shadow: -20px 0 60px rgba(15, 44, 34, .24);
  transition: right .24s ease;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.edit-box.active { right: 0; }

.panel-backdrop {
  position: fixed;
  z-index: 85;
  inset: 0;
  background: rgba(11, 35, 28, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  backdrop-filter: blur(2px);
}

.panel-backdrop.active { opacity: 1; pointer-events: auto; }

.card {
  min-height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #f8fbfa;
  box-shadow: none;
}

.card-head {
  position: sticky;
  z-index: 6;
  top: 0;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(18px);
}

.panel-title { display: flex; min-width: 0; align-items: center; gap: 11px; }
.panel-title__icon { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; border-radius: 14px; background: var(--green-100); color: var(--green-700); font-size: 19px; }
.panel-title h2 { margin: 0; color: var(--green-950); font-size: 1rem; font-weight: 850; letter-spacing: -.02em; }
.panel-title p { margin: 3px 0 0; color: var(--gray-500); font-size: .67rem; }
.panel-close { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border: 1px solid var(--gray-200); border-radius: 14px; background: #fff; box-shadow: var(--shadow-sm); color: var(--gray-700); font-size: 18px; }

.card-body { padding: 18px 18px 34px; }

.panel-intro {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 15px;
  padding: 13px 14px;
  border: 1px solid #cfe7dc;
  border-radius: 15px;
  background: var(--green-50);
  color: var(--green-900);
  font-size: .74rem;
  line-height: 1.45;
}

.panel-intro i { margin-top: 2px; color: var(--green-600); }

.form-section {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.form-section:last-child { margin-bottom: 0; }
.form-section__heading { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.form-section__heading > span { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: var(--orange-100); color: var(--orange-700); }
.form-section__heading h3 { margin: 0; color: var(--green-950); font-size: .88rem; font-weight: 850; }
.form-section__heading p { margin: 2px 0 0; color: var(--gray-500); font-size: .66rem; }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.form-group { margin-bottom: 13px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; margin-bottom: 6px; color: var(--gray-800); font-size: .75rem; font-weight: 800; }

.form-control,
.card-body select:not(.format-select),
.card-body input[type="text"],
.card-body input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--gray-300);
  border-radius: 13px;
  outline: none;
  background: #fff;
  box-shadow: none;
  color: var(--gray-950);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus,
.card-body select:focus,
.card-body input[type="text"]:focus,
.card-body input[type="search"]:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(24, 170, 109, .12);
}

.input-group { display: flex; width: 100%; }
.input-group .form-control { flex: 1; border-radius: 13px 0 0 13px; }
.input-group-btn { width: auto; }
.input-group-btn .btn { min-height: 48px; border-radius: 0 13px 13px 0; }

.btn {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 800;
}

.btn-primary { border-color: var(--green-700); background: var(--green-700); }
.btn-primary:hover,
.btn-primary:focus { border-color: var(--green-800); background: var(--green-800); }
.btn-success { border-color: var(--green-600); background: var(--green-600); }
.btn-warning { border-color: var(--orange-600); background: var(--orange-600); color: #fff; }
.btn-info { border-color: var(--blue-500); background: var(--blue-500); }

.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.modo-imagem-btn,
.modo-cor-btn {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 13px;
  background: #fff;
  color: var(--gray-700);
  font-size: .73rem;
  font-weight: 800;
}

.modo-imagem-btn.active,
.modo-cor-btn.active {
  border-color: var(--green-600);
  background: var(--green-50);
  box-shadow: 0 0 0 3px rgba(24, 170, 109, .1);
  color: var(--green-800);
}

.range-row { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 12px; }
.range-row label { margin: 0; color: var(--gray-700); font-size: .75rem; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--green-600); }
input[type="color"] { width: 100%; min-height: 45px; padding: 4px; border: 1px solid var(--gray-300); border-radius: 12px; background: #fff; }

.nav-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 0 0 13px; border: 0; }
.nav-tabs > li { float: none; margin: 0; }
.nav-tabs > li > a { display: flex; min-height: 44px; align-items: center; justify-content: center; margin: 0; border: 1px solid var(--gray-300); border-radius: 12px; background: #fff; color: var(--gray-700); font-size: .72rem; font-weight: 800; }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus { border: 1px solid var(--green-600); border-radius: 12px; background: var(--green-50); color: var(--green-800); }

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

.thumb {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 15px;
  background: var(--gray-100);
  box-shadow: 0 3px 11px rgba(24, 52, 91, .06);
  cursor: pointer;
}

.thumb:hover { border-color: #81d9af; transform: translateY(-1px); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }

.gradient-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.btn-gradient-preset { min-height: 54px; border: 0 !important; border-radius: 12px !important; padding: 8px 4px !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3), var(--shadow-sm); font-size: .65rem !important; font-weight: 850; }

.color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.color-field label { display: block; margin-bottom: 6px; color: var(--gray-700); font-size: .72rem; font-weight: 800; }
.gradient-preview-wrap { padding: 10px; border: 1px solid var(--gray-200); border-radius: 14px; background: var(--gray-100); }
#gradiente_preview { height: 54px !important; border-radius: 11px !important; }

.panel-actions { display: grid; gap: 9px; margin-top: 16px; }
.panel-actions--sticky { position: sticky; bottom: -34px; z-index: 4; margin: 18px -18px -34px; padding: 14px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--gray-200); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }

.export-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 15px; }
.export-preview-card { display: grid; place-items: center; min-height: 360px; padding: 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); background: var(--gray-100); }
#export-preview { display: inline-block; overflow: hidden; max-width: 100%; border: 0 !important; border-radius: 16px !important; background: transparent !important; padding: 0 !important; box-shadow: var(--shadow-md); }
.export-actions { display: grid; gap: 10px; }
.export-button { display: flex; min-height: 58px; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--gray-200); border-radius: 15px; background: #fff; box-shadow: var(--shadow-sm); color: var(--gray-850); text-align: left; }
.export-button > i { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: var(--green-100); color: var(--green-700); font-size: 17px; }
.export-button.is-whatsapp > i { background: #e2f8ea; color: #18a955; }
.export-button.is-json > i { background: var(--blue-100); color: var(--blue-700); }
.export-button.is-template > i { background: var(--orange-100); color: var(--orange-700); }
.export-button strong { display: block; font-size: .8rem; }
.export-button small { display: block; margin-top: 2px; color: var(--gray-500); font-size: .65rem; font-weight: 500; }

/* Menus de edição sobre o canvas */
.format-menu,
.image-menu {
  position: fixed;
  z-index: 110;
  display: none;
  border: 1px solid var(--gray-200);
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.format-menu.active,
.image-menu.active { display: flex; }
.format-menu { min-width: 290px; flex-direction: column; padding: 8px; }
.wysiwyg-header { display: flex; align-items: center; justify-content: space-between; padding: 5px 6px 9px; color: var(--gray-500); font-size: .68rem; font-weight: 800; }
.wysiwyg-header button { border: 0; background: transparent; color: var(--gray-700); font-size: 20px; }
.format-tools { display: flex; flex-wrap: wrap; gap: 5px; }
.format-btn,
.image-menu-btn { display: flex; width: 38px; height: 38px; align-items: center; justify-content: center; border: 1px solid var(--gray-200); border-radius: 10px; background: #fff; }
.format-btn:hover,
.image-menu-btn:hover { background: var(--gray-100); }
.format-btn.active { background: var(--blue-700); color: #fff; }
.format-select { max-width: 132px; height: 38px; border: 1px solid var(--gray-200); border-radius: 10px; }
.image-menu { gap: 5px; padding: 7px; }
.image-menu-btn.danger { color: var(--red-600); }

/* Loader inspirado no aplicativo da coleção */
.app-loader {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eff8f3;
}

.app-loader__surface {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(330px, .96fr);
  width: min(900px, 100%);
  min-height: 500px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(11, 80, 53, .18);
}

.app-loader__hero {
  position: relative;
  display: grid;
  min-height: 500px;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 14%, rgba(255,255,255,.28), transparent 28%),
    linear-gradient(145deg, #08734b, #06422f);
}

.loader-brand-card { position: relative; z-index: 2; display: grid; place-items: center; color: #fff; text-align: center; }
.boot-logo { width: 128px; height: 128px; margin-bottom: 18px; border: 5px solid rgba(255,255,255,.82); border-radius: 50%; box-shadow: 0 16px 36px rgba(0,0,0,.22); }
.loader-brand-card span { font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .78; }
.loader-brand-card strong { max-width: 270px; margin-top: 7px; font-size: 1.55rem; line-height: 1.12; }

.loader-road { position: absolute; right: -12%; bottom: -8%; left: -12%; height: 40%; background: linear-gradient(180deg, #26362f, #101a16); transform: rotate(-7deg); }
.loader-road__line { position: absolute; top: 50%; width: 16%; height: 8px; border-radius: 99px; background: rgba(255,255,255,.78); }
.loader-road__line--one { left: 8%; }
.loader-road__line--two { left: 42%; }
.loader-road__line--three { left: 76%; }
.loader-truck { position: absolute; top: 22%; left: 34%; color: var(--orange-500); font-size: 66px; filter: drop-shadow(0 8px 8px rgba(0,0,0,.32)); animation: truck-bob 1.2s ease-in-out infinite; }
@keyframes truck-bob { 0%,100% { transform: translateY(0) rotate(7deg); } 50% { transform: translateY(-5px) rotate(7deg); } }

.app-loader__panel { display: flex; justify-content: center; flex-direction: column; padding: 42px; }
.app-loader__status-wrap { margin-bottom: 18px; }
.app-loader__status { margin: 0; color: var(--green-950); font-size: 1.03rem; font-weight: 850; }
.app-loader__items { margin: 5px 0 0; color: var(--gray-500); font-size: .76rem; }
.app-loader__track { position: relative; height: 10px; overflow: hidden; border-radius: 99px; background: var(--gray-200); }
.app-loader__fill { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-700), var(--green-500), var(--orange-500)); transition: width .25s ease; }
.boot-steps { display: flex; justify-content: space-between; gap: 7px; margin-top: 12px; }
.boot-step { color: var(--gray-400); font-size: .57rem; font-weight: 750; }
.boot-step.active { color: var(--green-700); font-weight: 900; }
.app-loader__tip { display: flex; align-items: flex-start; gap: 9px; margin-top: 26px; padding: 13px; border-radius: 15px; background: var(--orange-100); color: #965005; font-size: .7rem; line-height: 1.45; }
.app-loader__tip i { margin-top: 2px; color: var(--orange-700); }

.swal2-container { z-index: 400 !important; }



.editable-layer.dragging {
  z-index: 8;
  cursor: grabbing !important;
  transition: none !important;
}

.editable-layer.inline-editing,
.editable-layer.inline-editing .inline-value {
  user-select: text;
  -webkit-user-select: text;
}

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

.template-layout-card {
  position: relative;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 17px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.template-layout-card:hover,
.template-layout-card.is-current {
  border-color: var(--green-500);
  box-shadow: 0 12px 28px rgba(11,122,79,.18);
}

.template-layout-card__preview {
  position: relative;
  display: block;
  height: 210px;
  overflow: hidden;
  background: #eef3f0;
}

.template-layout-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-layout-card__check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--green-600);
  box-shadow: var(--shadow-sm);
  color: #fff;
}

.template-layout-card.is-current .template-layout-card__check { display: grid; }

.template-layout-card__body { display: block; padding: 12px 13px 13px; }
.template-layout-card__body strong { display: block; color: var(--green-950); font-size: .78rem; }
.template-layout-card__body small { display: block; margin-top: 3px; color: var(--gray-500); font-size: .63rem; line-height: 1.35; }

@media (max-width: 1080px) {
  .workflow-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-stage { grid-template-columns: minmax(0, 1fr) 240px; }
}

@media (max-width: 820px) {
  body.has-bottom-nav { padding-bottom: calc(84px + var(--safe-bottom)); }
  .app-shell { width: min(100%, 760px); }
  .page-container { padding: 16px 14px 24px; }
  .app-header { min-height: 66px; padding: calc(8px + var(--safe-top)) 14px 8px; }
  .app-brand-mark { width: 46px; height: 46px; border-radius: 16px; }
  .app-brand h1 { font-size: 1.13rem; }
  .app-brand p { font-size: .68rem; }
  .icon-button { width: 42px; min-width: 42px; height: 42px; padding: 0; border-radius: 14px; }
  .icon-button span,
  .primary-action span { display: none; }
  .primary-action { width: 42px; min-height: 42px; padding: 0; border-radius: 14px; }
  .workflow-grid { display: none; }
  .editor-stage { display: block; }
  .helper-column { display: none; }
  .preview-card { border-radius: 22px; }
  .preview-card__header { min-height: 62px; padding: 9px 10px; }
  .preview-icon { width: 38px; height: 38px; border-radius: 13px; }
  .preview-heading h3 { font-size: .87rem; }
  .preview-heading p { max-width: 44vw; font-size: .61rem; }
  .zoom-controls button { width: 32px; height: 34px; }
  .zoom-controls span { min-width: 42px; font-size: .62rem; }
  .canvas-viewport { min-height: calc(100vh - 334px); padding: 16px 8px 34px; }
  .preview-card__footer { min-height: 39px; padding: 7px 10px; font-size: .62rem; }

  .bottom-nav {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(100%, 760px);
    min-height: calc(72px + var(--safe-bottom));
    margin: 0 auto;
    padding: 7px 5px calc(6px + var(--safe-bottom));
    border-top: 1px solid rgba(216,222,232,.9);
    background: rgba(255,255,255,.95);
    box-shadow: 0 -12px 35px rgba(26,55,91,.10);
    backdrop-filter: blur(18px);
  }

  .bottom-nav-item {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--gray-500);
    font-size: .61rem;
    font-weight: 750;
  }

  .bottom-nav-icon { display: grid; width: 30px; height: 30px; place-items: center; font-size: 20px; }
  .bottom-nav-item.is-active { color: var(--green-700); }
  .bottom-nav-item.is-featured .bottom-nav-icon {
    width: 48px;
    height: 48px;
    margin-top: -23px;
    border: 4px solid #fff;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-700), var(--green-500));
    box-shadow: 0 8px 20px rgba(11,122,79,.30);
    color: #fff;
  }

  .edit-box {
    top: auto;
    right: 0;
    bottom: -92vh;
    left: 0;
    width: 100%;
    height: min(84vh, 760px);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -22px 60px rgba(15, 44, 34, .24);
    transition: bottom .25s ease;
  }

  .edit-box::before {
    position: sticky;
    z-index: 8;
    top: 0;
    display: block;
    width: 42px;
    height: 5px;
    margin: 8px auto -13px;
    border-radius: 99px;
    background: #cdd5df;
    content: "";
  }

  .edit-box.active { right: 0; bottom: 0; }
  .card { border-radius: 24px 24px 0 0; }
  .card-head { min-height: 72px; padding: 16px 14px 10px; border-radius: 24px 24px 0 0; }
  .panel-title__icon { width: 39px; height: 39px; border-radius: 13px; }
  .panel-title h2 { font-size: .9rem; }
  .panel-title p { font-size: .61rem; }
  .panel-close { width: 39px; height: 39px; border-radius: 13px; }
  .card-body { padding: 14px 13px calc(94px + var(--safe-bottom)); }
  .form-section { padding: 14px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .template-layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-layout { grid-template-columns: 1fr; }
  .export-preview-card { min-height: 280px; }
  .panel-actions--sticky { bottom: calc(-94px - var(--safe-bottom)); margin: 18px -13px calc(-94px - var(--safe-bottom)); padding: 13px 13px calc(13px + var(--safe-bottom)); }
  .format-menu { right: 10px !important; bottom: calc(82px + var(--safe-bottom)) !important; left: 10px !important; top: auto !important; min-width: 0; }
  .image-menu { top: auto !important; bottom: calc(82px + var(--safe-bottom)) !important; left: 50% !important; transform: translateX(-50%); }
  .editable-layer.selected::before { font-size: 7px; }

  .app-loader { padding: 0; }
  .app-loader__surface { grid-template-columns: 1fr; width: 100%; min-height: 100%; border: 0; border-radius: 0; }
  .app-loader__hero { min-height: 52vh; }
  .loader-brand-card strong { font-size: 1.35rem; }
  .boot-logo { width: 108px; height: 108px; }
  .app-loader__panel { justify-content: flex-start; min-height: 48vh; padding: 28px 24px; }
}

@media (max-width: 430px) {
  .page-container { padding-right: 10px; padding-left: 10px; }
  .preview-heading p { max-width: 35vw; }
  .canvas-viewport { padding-right: 4px; padding-left: 4px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-layout-card__preview { height: 190px; }
  .form-row,
  .color-grid { grid-template-columns: 1fr; }
  .gradient-preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .app-brand p { display: none; }
  .header-actions { gap: 5px; }
  .preview-heading p { display: none; }
  .zoom-controls span { display: none; }
}

/* Miniaturas de modelos geradas pelo JavaScript */
.template-thumb {
  display: flex;
  min-height: 168px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 8px;
  border-color: var(--gray-200);
  background: #fff;
  text-align: center;
}

.modelo-preview {
  width: 100%;
  height: 122px;
  overflow: hidden;
  border-radius: 11px;
  background: var(--gray-100);
}

.modelo-preview img { width: 100%; height: 100%; object-fit: cover; }
.modelo-nome { overflow: hidden; width: 100%; padding: 9px 4px 2px; color: var(--green-950); font-size: .7rem; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.delete-template { position: absolute; top: 7px; right: 7px; display: grid; width: 32px; height: 32px; min-height: 0; place-items: center; padding: 0; border: 0; border-radius: 10px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-sm); color: var(--red-600); }
.subtle { grid-column: 1 / -1; padding: 18px; border-radius: 14px; background: var(--gray-100); color: var(--gray-500); font-size: .74rem; text-align: center; }
.image-placeholder { filter: none; }

/* Correções de edição e exportação limpa */
.canvas.capture-mode .editable-layer.selected,
.canvas.capture-mode .editable-layer.dragging,
.canvas.capture-mode .editable-layer.inline-editing {
  outline: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
  cursor: default !important;
}


.canvas.capture-mode .image-placeholder {
  visibility: hidden !important;
}

.canvas.capture-mode .editable-layer::before,
.canvas.capture-mode .editable-layer::after,
.canvas.capture-mode .inline-value::before,
.canvas.capture-mode .inline-value::after {
  display: none !important;
  content: none !important;
}

.inline-value {
  min-width: 8px;
  border-radius: 3px;
}

.editable-layer.inline-editing {
  outline: 2px solid var(--green-500) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(24, 170, 109, .16) !important;
  cursor: text !important;
  touch-action: manipulation;
}

.editable-layer.inline-editing::before {
  background: var(--green-700);
  content: "EDITANDO";
}

.inline-value[contenteditable="true"] {
  display: inline-block;
  min-width: 22px;
  padding: 1px 3px;
  outline: 1px dashed rgba(11, 122, 79, .65);
  outline-offset: 2px;
  background: rgba(255, 255, 255, .42);
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.format-btn--edit {
  width: auto;
  min-width: 72px;
  gap: 6px;
  padding: 0 10px;
  background: var(--green-100);
  color: var(--green-800);
  font-size: .68rem;
  font-weight: 850;
}

.panel-shortcut {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(11, 122, 79, .18);
  border-radius: 15px;
  background: linear-gradient(135deg, var(--green-50), #fff);
  color: var(--green-900);
  text-align: left;
}

.panel-shortcut > i {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-700);
}

.panel-shortcut strong,
.panel-shortcut small { display: block; }
.panel-shortcut strong { font-size: .78rem; }
.panel-shortcut small { margin-top: 2px; color: var(--gray-500); font-size: .64rem; }

.gallery-status {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed var(--gray-300);
  border-radius: 14px;
  color: var(--gray-500);
  font-size: .72rem;
  text-align: center;
}

@media (max-width: 820px) {
  /* No celular o topo participa do fluxo e não cobre cards ou ferramentas. */
  .app-header {
    position: relative;
    top: auto;
  }

  .editor-page {
    padding-top: 14px;
  }

  .format-btn--edit {
    min-width: 66px;
  }
}

/* =========================================================
   GERAÇÃO DE ANÚNCIOS COM IA
   ========================================================= */
.summary-card.is-ai {
  border-color: rgba(108, 72, 214, .22);
  background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(245,241,255,.96));
}
.summary-card.is-ai .summary-icon {
  background: linear-gradient(135deg, #6d42da, #9c5cff);
  color: #fff;
  box-shadow: 0 10px 22px rgba(109,66,218,.22);
}
.ai-header-action {
  min-height: 44px;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid rgba(109,66,218,.22);
  border-radius: 14px;
  background: linear-gradient(135deg, #6d42da, #9c5cff);
  box-shadow: 0 10px 22px rgba(109,66,218,.22);
  color: #fff;
  font-weight: 850;
}
.ai-header-action:hover { transform: translateY(-1px); color: #fff; }
.layer-logo {
  display: none;
  width: 74px;
  height: 74px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 5px 9px rgba(0,0,0,.24));
}
.ai-title-icon { background: linear-gradient(135deg, #6d42da, #9c5cff) !important; color: #fff !important; }
.edit-box-ai { width: min(620px, 96vw); }
.ai-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 13px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: #f8fafc;
}
.ai-status-card__icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 18px;
}
.ai-status-card strong,
.ai-status-card small { display: block; }
.ai-status-card strong { color: var(--gray-900); font-size: .78rem; }
.ai-status-card small { margin-top: 3px; color: var(--gray-500); font-size: .65rem; line-height: 1.4; }
.ai-status-card.is-ready { border-color: rgba(18,148,94,.24); background: #effcf6; }
.ai-status-card.is-ready .ai-status-card__icon { background: var(--green-100); color: var(--green-700); }
.ai-status-card.is-error { border-color: rgba(220,38,38,.22); background: #fff5f5; }
.ai-status-card.is-error .ai-status-card__icon { background: #fee2e2; color: #b91c1c; }
.ai-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  border-radius: 15px;
  background: var(--gray-100);
}
.ai-tab {
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--gray-500);
  font-size: .72rem;
  font-weight: 850;
}
.ai-tab.is-active { background: #fff; box-shadow: var(--shadow-sm); color: #6d42da; }
.ai-tab-panel { display: none; }
.ai-tab-panel.is-active { display: block; }
.ai-intro { border-color: rgba(109,66,218,.18); background: #f7f3ff; color: #5b36b9; }
.ai-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.ai-choice-card {
  position: relative;
  display: grid;
  min-height: 154px;
  grid-template-columns: 42px 1fr;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: .18s ease;
}
.ai-choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.ai-choice-card__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: #f1ecff; color: #6d42da; }
.ai-choice-card strong,
.ai-choice-card small { display: block; }
.ai-choice-card strong { color: var(--gray-900); font-size: .75rem; line-height: 1.25; }
.ai-choice-card small { margin-top: 4px; color: var(--gray-500); font-size: .63rem; line-height: 1.42; }
.ai-choice-card em {
  grid-column: 1 / -1;
  justify-self: start;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-800);
  font-size: .56rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}
.ai-choice-card.is-selected { border-color: #8f64ea; background: #faf7ff; box-shadow: 0 0 0 3px rgba(109,66,218,.11); }
.ai-color-pair > div { display: flex; gap: 8px; }
.ai-color-pair input { width: 54px; height: 42px; padding: 3px; border: 1px solid var(--gray-200); border-radius: 10px; background: #fff; }
.ai-reference-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-bottom: 13px; }
.ai-toggle-card {
  display: grid;
  grid-template-columns: 22px 58px 1fr;
  align-items: center;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--gray-200);
  border-radius: 15px;
  background: #fff;
  cursor: pointer;
}
.ai-toggle-card input { width: 18px; height: 18px; accent-color: #6d42da; }
.ai-toggle-card__preview { display: grid; width: 58px; height: 58px; overflow: hidden; place-items: center; border-radius: 13px; background: var(--gray-100); color: var(--gray-400); font-size: 22px; }
.ai-toggle-card__preview img { width: 100%; height: 100%; object-fit: contain; }
.ai-toggle-card strong,
.ai-toggle-card small { display: block; }
.ai-toggle-card strong { color: var(--gray-900); font-size: .7rem; }
.ai-toggle-card small { margin-top: 3px; color: var(--gray-500); font-size: .59rem; line-height: 1.35; }
.ai-toggle-card.is-disabled { opacity: .52; }
.ai-file-input { height: auto; padding: 9px; font-size: .66rem; }
.ai-data-summary { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-bottom: 11px; }
.ai-data-summary > div { min-width: 0; padding: 9px 10px; border-radius: 11px; background: var(--gray-100); }
.ai-data-summary span,
.ai-data-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-data-summary span { color: var(--gray-500); font-size: .56rem; font-weight: 800; text-transform: uppercase; }
.ai-data-summary strong { margin-top: 3px; color: var(--gray-900); font-size: .66rem; }
.ai-cost-note { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 10px 12px; border-radius: 12px; background: #fff8e7; color: #8a6113; font-size: .62rem; line-height: 1.4; }
.ai-generate-button { min-height: 54px; background: linear-gradient(135deg, #6d42da, #9c5cff); box-shadow: 0 12px 25px rgba(109,66,218,.25); }
.ai-generate-button:disabled { opacity: .55; cursor: not-allowed; }
.ai-inline-note { display: none; margin-top: 6px; color: #7c5bb9; font-size: .58rem; line-height: 1.35; }
.ai-history-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ai-history-toolbar strong,
.ai-history-toolbar small { display: block; }
.ai-history-toolbar strong { color: var(--gray-900); font-size: .8rem; }
.ai-history-toolbar small { margin-top: 2px; color: var(--gray-500); font-size: .62rem; }
.ai-history-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.ai-history-card { overflow: hidden; border: 1px solid var(--gray-200); border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm); }
.ai-history-card__image { position: relative; height: 260px; overflow: hidden; background: var(--gray-100); }
.ai-history-card__image img { width: 100%; height: 100%; object-fit: cover; }
.ai-history-card__image > span { position: absolute; top: 9px; left: 9px; padding: 4px 7px; border-radius: 999px; background: rgba(11,122,79,.92); color: #fff; font-size: .54rem; font-weight: 900; text-transform: uppercase; }
.ai-history-card.is-error .ai-history-card__image > span { background: rgba(185,28,28,.92); }
.ai-history-card__body { padding: 11px 12px 8px; }
.ai-history-card__body strong,
.ai-history-card__body small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-history-card__body strong { color: var(--gray-900); font-size: .72rem; }
.ai-history-card__body small { margin-top: 3px; color: var(--gray-500); font-size: .6rem; }
.ai-history-card__meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-history-card__meta span { padding: 4px 6px; border-radius: 7px; background: var(--gray-100); color: var(--gray-600); font-size: .52rem; }
.ai-history-card__actions { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--gray-200); }
.ai-history-card__actions button { min-height: 40px; border: 0; border-right: 1px solid var(--gray-200); background: #fff; color: var(--gray-600); }
.ai-history-card__actions button:last-child { border-right: 0; }
.ai-history-card__actions button:hover { background: var(--gray-100); color: #6d42da; }
.ai-history-card__actions button.danger:hover { background: #fff1f1; color: #b91c1c; }
.ai-history-placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: var(--gray-400); font-size: 34px; }
.ai-empty-history { grid-column: 1 / -1; display: grid; min-height: 220px; place-items: center; align-content: center; gap: 7px; border: 1px dashed var(--gray-300); border-radius: 17px; color: var(--gray-500); text-align: center; }
.ai-empty-history i { color: #8f64ea; font-size: 32px; }
.ai-empty-history strong { color: var(--gray-800); font-size: .78rem; }
.ai-empty-history small { font-size: .63rem; }
.ai-swal-progress { display: grid; justify-items: center; gap: 8px; padding: 12px; }
.ai-swal-progress > i { color: #7c4de2; font-size: 34px; }
.ai-swal-progress strong { color: #263238; font-size: .9rem; }
.ai-swal-progress small { max-width: 360px; color: #718096; font-size: .72rem; line-height: 1.5; }

@media (max-width: 1080px) {
  .workflow-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .ai-header-action { width: 42px; min-width: 42px; height: 42px; padding: 0; border-radius: 14px; }
  .ai-header-action span { display: none; }
  .bottom-nav { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .edit-box-ai { width: 100%; }
  .ai-mode-grid,
  .ai-reference-grid,
  .ai-history-grid { grid-template-columns: 1fr; }
  .ai-choice-card { min-height: 126px; }
  .ai-history-card__image { height: 360px; }
}

@media (max-width: 430px) {
  .ai-data-summary { grid-template-columns: 1fr; }
  .ai-history-card__image { height: 330px; }
  .bottom-nav-item { font-size: .55rem; }
  .bottom-nav-icon { width: 27px; height: 27px; font-size: 18px; }
}
@media (min-width: 1081px) {
  .workflow-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.ai-custom-instructions { min-height: 88px; resize: vertical; }
.ai-prompt-preview-button { margin-bottom: 8px; }
.ai-prompt-preview {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 13px;
  border: 1px solid rgba(109,66,218,.18);
  border-radius: 13px;
  background: #18142a;
  color: #efeaff;
  font: 500 .62rem/1.55 Inter, monospace;
  white-space: pre-wrap;
}


/* Ações indisponíveis para formatos que não cabem no editor manual 9:16. */
.ai-history-card__actions button.is-disabled,
.ai-history-card__actions button:disabled {
  opacity: .38;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* =========================================================
   IA V5: IDENTIDADE VISUAL + VARIAÇÃO ANTI-REPETIÇÃO
   ========================================================= */
.ai-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ai-form-spaced { margin-top: 12px; }
.ai-color-pair > small { display: block; margin-top: 5px; color: var(--gray-500); font-size: .56rem; line-height: 1.35; }
.ai-color-pair.is-disabled { opacity: .42; }
.ai-color-pair.is-disabled input { pointer-events: none; }

.ai-identity-switch {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 11px;
  margin-bottom: 13px;
  padding: 13px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: .18s ease;
}
.ai-identity-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ai-identity-switch__icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 18px;
}
.ai-identity-switch strong,
.ai-identity-switch small { display: block; }
.ai-identity-switch strong { color: var(--gray-900); font-size: .74rem; }
.ai-identity-switch small { margin-top: 3px; color: var(--gray-500); font-size: .61rem; line-height: 1.35; }
.ai-identity-switch.is-active { border-color: rgba(109,66,218,.32); background: #faf7ff; box-shadow: 0 0 0 3px rgba(109,66,218,.08); }
.ai-identity-switch.is-active .ai-identity-switch__icon { background: #eee7ff; color: #6d42da; }
.ai-switch-pill { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--gray-300); transition: .18s ease; }
.ai-switch-pill i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.16); transition: .18s ease; }
.ai-identity-switch.is-active .ai-switch-pill { background: #7c4de2; }
.ai-identity-switch.is-active .ai-switch-pill i { transform: translateX(18px); }

#ai-brand-generation-fields { transition: opacity .18s ease; }
#ai-brand-generation-fields.is-disabled { opacity: .42; pointer-events: none; }
.ai-brand-summary {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 86px;
  margin: 2px 0 12px;
  padding: 11px;
  border: 1px solid rgba(109,66,218,.16);
  border-radius: 16px;
  background: linear-gradient(135deg, #fbf9ff, #fff);
}
.ai-brand-summary__logo {
  display: grid;
  width: 68px;
  height: 68px;
  overflow: hidden;
  place-items: center;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  color: var(--gray-400);
  font-size: 24px;
}
.ai-brand-summary__logo img { width: 100%; height: 100%; object-fit: contain; }
.ai-brand-summary__body { min-width: 0; }
.ai-brand-summary__body > strong,
.ai-brand-summary__body > small { display: block; }
.ai-brand-summary__body > strong { color: var(--gray-900); font-size: .78rem; }
.ai-brand-summary__body > small { display: -webkit-box; overflow: hidden; margin-top: 4px; color: var(--gray-500); font-size: .61rem; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ai-brand-summary__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 8px; color: var(--gray-600); font-size: .57rem; font-weight: 750; }
.ai-brand-swatches { display: inline-flex; gap: 4px; }
.ai-brand-swatches i { display: block; width: 18px; height: 18px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.ai-variation-rule { display: flex; align-items: flex-start; gap: 9px; margin-top: 11px; padding: 10px 11px; border-radius: 12px; background: #eefcf7; color: #176b4b; font-size: .61rem; line-height: 1.45; }
.ai-variation-rule i { margin-top: 2px; color: var(--green-700); }

.ai-brand-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.ai-brand-toolbar strong,
.ai-brand-toolbar small { display: block; }
.ai-brand-toolbar strong { color: var(--gray-900); font-size: .82rem; }
.ai-brand-toolbar small { margin-top: 3px; color: var(--gray-500); font-size: .62rem; }
.ai-brand-toolbar .button { min-height: 40px; padding: 0 13px; }
.ai-brand-form-section { margin-bottom: 0; }
.ai-brand-logo-editor { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 14px; margin: 13px 0 16px; }
.ai-brand-logo-preview { display: grid; width: 96px; height: 96px; overflow: hidden; place-items: center; border: 1px solid var(--gray-200); border-radius: 20px; background: #fff; box-shadow: var(--shadow-sm); color: var(--gray-400); font-size: 30px; }
.ai-brand-logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.ai-subheading { margin-top: 18px; }
.ai-brand-color-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
.ai-brand-color-grid label { display: grid; gap: 6px; color: var(--gray-600); font-size: .57rem; font-weight: 850; text-align: center; text-transform: uppercase; }
.ai-brand-color-grid input { width: 100%; height: 48px; padding: 4px; border: 1px solid var(--gray-200); border-radius: 12px; background: #fff; }
.ai-brand-reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; min-height: 90px; margin-bottom: 11px; }
.ai-brand-reference-item { position: relative; height: 118px; overflow: hidden; border: 1px solid var(--gray-200); border-radius: 13px; background: var(--gray-100); }
.ai-brand-reference-item img { width: 100%; height: 100%; object-fit: cover; }
.ai-brand-reference-item button { position: absolute; top: 6px; right: 6px; display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; background: rgba(15,23,42,.78); color: #fff; }
.ai-brand-actions { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 15px; }
.ai-brand-actions .button { min-height: 48px; }
.ai-brand-actions .button.is-disabled,
.ai-brand-actions .button:disabled { opacity: .4; cursor: not-allowed; }

.ai-history-card__brand { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--gray-700); font-size: .57rem; font-weight: 800; }
.ai-history-swatch { display: inline-block; width: 17px; height: 17px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.13); }
.gallery-status.is-error { border-color: rgba(220,38,38,.28); color: #b91c1c; background: #fff7f7; }

@media (max-width: 820px) {
  .ai-tabs { position: sticky; top: 0; z-index: 4; }
  .ai-brand-color-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ai-brand-reference-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 430px) {
  .ai-tab { font-size: .64rem; }
  .ai-tab i { margin-right: 3px; }
  .ai-brand-logo-editor { grid-template-columns: 76px 1fr; }
  .ai-brand-logo-preview { width: 76px; height: 76px; border-radius: 16px; }
  .ai-brand-actions { grid-template-columns: 1fr; }
  .ai-brand-reference-item { height: 132px; }
}
