:root {
  color-scheme: light;
  --ink: #142019;
  --muted: #718078;
  --soft: #eef4ee;
  --panel: rgba(255, 255, 250, 0.88);
  --panel-strong: #fffefa;
  --line: rgba(20, 32, 25, 0.12);
  --line-strong: rgba(20, 32, 25, 0.22);
  --accent: #197056;
  --accent-dark: #102019;
  --mint: #e8f7f0;
  --cream: #fbfaf3;
  --warning: #c07a2c;
  --shadow: 0 18px 46px rgba(22, 35, 27, 0.1);
  --shadow-soft: 0 10px 28px rgba(22, 35, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 32, 25, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 25, 0.055) 1px, transparent 1px),
    linear-gradient(135deg, #fbfaf4 0%, #eef4ed 54%, #faf7ed 100%);
  background-size: 32px 32px, 32px 32px, auto;
  overflow: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-btn:disabled {
  pointer-events: none;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px 18px;
}

body.has-result-view .app-shell {
  grid-template-rows: auto minmax(0, 1fr);
}

.studio-header {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto minmax(300px, 1fr);
  align-items: center;
  gap: 18px;
}

body.has-result-view .studio-header {
  grid-template-columns: auto minmax(0, 1fr);
}

body.has-result-view .mode-tabs,
body.has-result-view #notice-btn,
body.has-result-view #project-btn {
  display: none;
}

body.has-result-view .brand-block h1 {
  font-size: 32px;
}

body.has-result-view .brand-kicker,
body.has-result-view .brand-block span {
  display: none;
}

.brand-block,
.top-actions,
.mode-tabs,
.generate-bar,
.field-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #12241b, #197056);
  box-shadow: 0 14px 28px rgba(25, 112, 86, 0.24);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-kicker {
  margin: 0 0 2px;
  color: #758078;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-block h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

.brand-block span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mode-tabs {
  justify-self: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 250, 0.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.tab {
  min-width: 78px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 10px;
  color: #53625a;
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: #fff;
  background: #111b15;
  box-shadow: 0 10px 20px rgba(17, 27, 21, 0.18);
}

.top-actions {
  justify-content: flex-end;
  gap: 10px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.secondary-btn,
.generate-btn,
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-btn {
  width: 42px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 250, 0.82);
}

.icon-btn.tiny {
  width: 34px;
  min-height: 34px;
  border-radius: 10px;
}

.ghost-btn,
.secondary-btn {
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 250, 0.82);
  font-weight: 800;
}

.primary-btn,
.generate-btn {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(25, 112, 86, 0.22);
}

.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover,
.secondary-btn:hover,
.generate-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
}

.section-head h2,
.subhead h3 {
  margin: 0;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(240px, 285px) minmax(700px, 1fr);
  gap: 12px;
}

body.has-result-view .workspace {
  grid-template-columns: minmax(260px, 300px) minmax(190px, 230px) minmax(0, 1fr);
}

.panel {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.result-panel {
  display: grid;
  grid-template-rows: auto auto minmax(520px, 1fr) auto;
  gap: 10px;
}

body.has-result-view .result-panel {
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.section-head,
.result-head,
.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.step-title span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  background: #102019;
  box-shadow: 0 10px 18px rgba(16, 32, 25, 0.16);
  font-size: 16px;
  font-weight: 900;
}

.step-title h2 {
  color: #102019;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section.compact {
  padding-top: 18px;
}

.panel-section:last-of-type {
  border-bottom: 0;
}

.subhead {
  margin-bottom: 12px;
}

.subhead.compact {
  margin-bottom: 8px;
}

.subhead h3 {
  color: #4e5d55;
  font-size: 14px;
  font-weight: 900;
}

.canvas-control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.78fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.control-field {
  min-width: 0;
}

.field {
  display: grid;
  gap: 8px;
  width: 100%;
}

.field-row {
  gap: 10px;
  margin-bottom: 12px;
}

.field-row:last-child {
  margin-bottom: 0;
}

.field span,
.slider-field > span {
  color: #66746c;
  font-size: 12px;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255, 255, 250, 0.92);
  outline: none;
}

.field textarea {
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(25, 112, 86, 0.45);
  box-shadow: 0 0 0 4px rgba(25, 112, 86, 0.1);
}

.field-hint {
  margin: 8px 0 0;
  color: #8a938c;
  font-size: 12px;
  line-height: 1.5;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(25, 112, 86, 0.1);
  font-size: 12px;
  font-weight: 900;
}

.image-type-list,
.asset-list,
.toggle-list {
  display: grid;
  gap: 10px;
}

.type-card,
.asset-card,
.result-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 250, 0.64);
}

.type-card.active,
.asset-card.active,
.result-card.active {
  border-color: rgba(25, 112, 86, 0.32);
  background: #fffefa;
  box-shadow: 0 10px 22px rgba(25, 112, 86, 0.1);
}

.type-card > svg,
.type-card > span:first-child {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: rgba(25, 112, 86, 0.1);
}

.type-card strong,
.asset-card strong,
.result-card strong,
.upload-zone strong {
  display: block;
  font-size: 14px;
}

.type-card small,
.asset-card small,
.result-card small,
.upload-zone small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.slider-field {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.slider-field > span {
  display: flex;
  justify-content: space-between;
}

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

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334039;
  font-size: 13px;
  font-weight: 800;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  position: relative;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #d7ddd6;
  transition: background 160ms ease;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
  transition: transform 160ms ease;
}

.toggle input:checked + span {
  background: var(--accent);
}

.toggle input:checked + span::after {
  transform: translateX(17px);
}

.prompt-box {
  min-height: 96px;
  padding: 13px;
  border: 1px solid rgba(25, 112, 86, 0.16);
  border-radius: 12px;
  color: #35423b;
  background: rgba(25, 112, 86, 0.07);
  font-size: 13px;
  line-height: 1.65;
}

.text-btn {
  min-height: 30px;
  padding: 0 11px;
  color: var(--accent-dark);
  background: rgba(25, 112, 86, 0.1);
  font-size: 13px;
  font-weight: 900;
}

.generate-bar {
  position: sticky;
  bottom: -18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 16px 0 2px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 250, 0.96) 30%);
}

.secondary-btn,
.generate-btn {
  height: 50px;
}

.secondary-btn {
  width: 100%;
  min-width: 0;
  padding: 0 10px;
}

.layout-test-btn {
  color: #197056;
  background: rgba(232, 247, 240, 0.92);
  border-color: rgba(25, 112, 86, 0.22);
}

.generate-btn {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

.upload-zone {
  min-height: 240px;
  display: grid;
  place-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 24px;
  border: 1px dashed rgba(25, 112, 86, 0.28);
  border-radius: 15px;
  text-align: center;
  background: rgba(239, 246, 239, 0.72);
  cursor: pointer;
}

.upload-zone input {
  display: none;
}

.upload-art {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--accent);
  background: rgba(25, 112, 86, 0.1);
}

.reference-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  background: #f5f8f3;
}

.reference-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.ref-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(16, 32, 25, 0.72);
  font-size: 11px;
  font-weight: 900;
}

.asset-thumb {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #eee;
}

.asset-thumb::after,
.product-visual::after,
.result-preview::after {
  content: "";
  position: absolute;
  inset: auto 16% 8% 16%;
  height: 12%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  filter: blur(8px);
}

.asset-thumb.speaker,
.product-visual.speaker,
.mini-main {
  background:
    radial-gradient(circle at 50% 36%, #454545 0 17%, #111 18% 28%, transparent 29%),
    linear-gradient(90deg, transparent 19%, #1b1b1b 20% 80%, transparent 81%),
    linear-gradient(145deg, #ece8dd, #ffffff);
}

.asset-thumb.bag,
.product-visual.bag {
  background:
    radial-gradient(ellipse at 50% 14%, transparent 0 23%, #cdbb9b 24% 29%, transparent 30%),
    linear-gradient(90deg, transparent 16%, #e8dcc5 17% 83%, transparent 84%),
    linear-gradient(145deg, #fbf8f1, #e9eee9);
}

.reference-note {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 13px;
  color: #5f6b64;
  background: rgba(25, 112, 86, 0.07);
  font-size: 12px;
  line-height: 1.55;
}

.reference-note p {
  margin: 0;
}

#task-title {
  margin: 0 0 4px;
  color: #3a463f;
  font-size: 18px;
  font-weight: 900;
}

body.has-result-view #task-title,
body.has-result-view .result-strip {
  display: none;
}

body.has-result-view .result-head {
  min-height: 40px;
}

.preview-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(246, 249, 245, 0.88);
  overflow: auto;
}

body.has-result-view .preview-stage {
  height: 100%;
  padding: 10px;
  overflow: hidden;
}

.preview-frame {
  width: min(86vh, 100%);
  max-width: 100%;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.preview-frame.has-generated {
  width: min(100%, calc((100vh - 360px) * var(--result-ratio, 1)));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: var(--result-ratio, 1);
}

body.has-result-view .preview-frame.has-generated {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
}

.ratio-square {
  aspect-ratio: 1 / 1;
}

.ratio-portrait {
  width: min(68vh, 100%);
  aspect-ratio: 4 / 5;
}

.ratio-story {
  width: min(58vh, 100%);
  aspect-ratio: 9 / 16;
}

.ratio-wide {
  width: min(112vh, 100%);
  aspect-ratio: 16 / 9;
}

.ad-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 30%, rgba(185, 133, 52, 0.22), transparent 26%),
    linear-gradient(140deg, #fbfbf8 0%, #ecf3ee 58%, #f8efe5 100%);
}

.generated-image {
  position: absolute;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f8f7f2;
  pointer-events: none;
}

.preview-frame.has-generated .ad-canvas {
  position: relative;
  display: grid;
  place-items: center;
  background: #f8f7f2;
  overflow: hidden;
}

body.has-result-view .preview-frame.has-generated .ad-canvas {
  height: 100%;
}

.preview-frame.has-generated .generated-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ad-canvas.has-result .canvas-grid,
.ad-canvas.has-result .sale-tag,
.ad-canvas.has-result .product-visual,
.ad-canvas.has-result .copy-block,
.ad-canvas.has-result .floating-spec {
  opacity: 0;
  pointer-events: none;
}

.ad-canvas.scene {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 38%),
    linear-gradient(90deg, #dfe8e0 0 44%, #ede3d7 45% 100%);
}

.ad-canvas.detail {
  background:
    radial-gradient(circle at 36% 42%, rgba(21, 21, 21, 0.18), transparent 20%),
    linear-gradient(145deg, #f9f7f2, #e8ebe7);
}

.ad-canvas.description {
  background: linear-gradient(180deg, #ffffff 0 24%, #edf4ef 25% 52%, #f4eee5 53% 100%);
}

.canvas-grid {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background:
    linear-gradient(rgba(255, 255, 255, 0.42) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.42) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 52% 44%, transparent 0 27%, black 28% 100%);
}

.sale-tag {
  position: absolute;
  top: 7%;
  left: 7%;
  padding: 8px 12px;
  border: 1px solid rgba(20, 20, 20, 0.12);
  border-radius: 999px;
  color: #2f2f2f;
  background: rgba(255, 255, 255, 0.74);
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 900;
}

.product-visual {
  position: absolute;
  left: 50%;
  top: 48%;
  width: var(--product-size, 46%);
  aspect-ratio: 1 / 1;
  border-radius: 28%;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 32px 42px rgba(0, 0, 0, 0.24));
}

.ad-canvas.scene .product-visual {
  left: 64%;
  top: 43%;
  width: calc(var(--product-size, 46%) * 0.78);
}

.ad-canvas.detail .product-visual {
  left: 66%;
  top: 47%;
  width: calc(var(--product-size, 46%) * 0.72);
}

.ad-canvas.description .product-visual {
  left: 68%;
  top: 34%;
  width: calc(var(--product-size, 46%) * 0.58);
}

.product-visual.speaker::before {
  content: "";
  position: absolute;
  left: 27%;
  right: 27%;
  top: 12%;
  bottom: 12%;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 28%, #6b6b6b 0 17%, #151515 18% 31%, transparent 32%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 7px),
    linear-gradient(90deg, #111, #323232 48%, #0f0f0f);
}

.product-visual.bag::before {
  content: "";
  position: absolute;
  left: 21%;
  right: 21%;
  top: 22%;
  bottom: 12%;
  border-radius: 14% 14% 20% 20%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24), transparent 38%),
    linear-gradient(145deg, #e5d6bb, #c9ad82);
}

.product-visual.bag::after {
  inset: 10% 31% auto 31%;
  height: 28%;
  border: 8px solid #b8915f;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  background: transparent;
  filter: none;
}

.product-visual.uploaded {
  border-radius: 18%;
  background-color: transparent;
}

.product-visual.uploaded::before,
.product-visual.uploaded::after {
  display: none;
}

.copy-block {
  position: absolute;
  left: 7%;
  bottom: 7%;
  width: min(52%, 360px);
}

.copy-block span {
  display: inline-flex;
  margin-bottom: 9px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(25, 112, 86, 0.12);
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 900;
}

.copy-block strong {
  display: block;
  font-size: clamp(24px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.copy-block small {
  display: block;
  margin-top: 10px;
  color: #55635b;
  font-size: clamp(12px, 1.4vw, 16px);
  line-height: 1.5;
}

.floating-spec {
  position: absolute;
  right: 8%;
  min-width: 84px;
  padding: 10px 12px;
  border: 1px solid rgba(20, 20, 20, 0.1);
  border-radius: 14px;
  text-align: center;
  color: #2d2d2d;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.08);
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 900;
}

.spec-one {
  top: 18%;
}

.spec-two {
  bottom: 18%;
}

.result-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.result-card {
  height: 82px;
}

.result-preview {
  position: relative;
  width: 48px;
  border-radius: 11px;
  flex: 0 0 auto;
  align-self: stretch;
  overflow: hidden;
  background: #f2f2f2;
  background-position: center;
  background-size: cover;
}

.result-card strong,
.result-card small {
  white-space: nowrap;
}

.mini-scene {
  background:
    radial-gradient(circle at 52% 38%, #222 0 15%, transparent 16%),
    linear-gradient(90deg, #cad8cb 0 50%, #e7d7c7 51% 100%);
}

.mini-detail {
  background:
    radial-gradient(circle at 52% 42%, #1d1d1d 0 29%, transparent 30%),
    linear-gradient(145deg, #f9f8f5, #e1e4df);
}

.mini-description {
  background:
    linear-gradient(#171717 0 18%, transparent 19%),
    linear-gradient(180deg, #fff 0 33%, #e8f0ea 34% 66%, #f1e4d8 67%);
}

.comparison-divider {
  display: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 14px;
  color: #fff;
  background: #111b15;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(21, 21, 21, 0.22);
  backdrop-filter: blur(3px);
}

.history-drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 40;
  width: min(392px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 250, 0.94);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(24px);
  transform: translateX(calc(100% + 24px));
  transition: transform 220ms ease;
}

.history-drawer.open {
  transform: translateX(0);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.history-head h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

#history-close {
  position: relative;
  z-index: 45;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 10px;
  overflow: auto;
}

.history-empty {
  padding: 18px;
  border: 1px dashed rgba(25, 112, 86, 0.24);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(25, 112, 86, 0.06);
  font-size: 13px;
  line-height: 1.6;
}

.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 250, 0.76);
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item strong {
  font-size: 14px;
}

.history-item small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.history-thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background-position: center;
  background-size: cover;
}

.is-generating .ad-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  background: linear-gradient(100deg, transparent 0 35%, rgba(255, 255, 255, 0.72) 45%, transparent 55% 100%);
  animation: sweep 900ms ease-in-out infinite;
}

@keyframes sweep {
  from {
    transform: translateX(-80%);
  }
  to {
    transform: translateX(80%);
  }
}

@media (max-width: 1320px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .studio-header {
    grid-template-columns: 1fr;
  }

  .mode-tabs,
  .top-actions {
    justify-self: start;
  }

  .workspace {
    grid-template-columns: minmax(300px, 390px) minmax(300px, 1fr);
  }

  .result-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .mode-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .field-row,
  .result-strip {
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .canvas-control-grid {
    grid-template-columns: 1fr;
  }

  .brand-block h1 {
    font-size: 36px;
  }

  .upload-zone {
    min-height: 220px;
  }
}
