:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --canvas: #e9eeeb;
  --ink: #17211d;
  --ink-soft: #36423c;
  --muted: #6e7a74;
  --line: #d9e0dc;
  --line-strong: #c6d0ca;
  --accent: #e45f3d;
  --accent-dark: #c94d30;
  --green: #286651;
  --green-soft: #e8f1ed;
  --blue: #386a9c;
  --danger: #b33a32;
  --danger-soft: #fbebe8;
  --shadow: 0 12px 30px rgba(24, 37, 31, .08);
  --topbar-height: 64px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

*, *::before, *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button, select {
  cursor: pointer;
}

button:disabled, select:disabled, input:disabled, textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(56, 106, 156, .25);
  outline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon, .check-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

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

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
}

.brand-copy {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 9px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 750;
}

.brand-copy span {
  padding-left: 9px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.button, .icon-button, .api-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-weight: 650;
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.button {
  gap: 8px;
  padding: 0 14px;
}

.button:active, .icon-button:active, .api-status:active {
  transform: translateY(1px);
}

.button-quiet {
  color: var(--ink-soft);
  border-color: var(--line);
  background: var(--surface);
}

.button-quiet:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button-dark {
  color: #fff;
  background: var(--ink);
}

.button-dark:hover {
  background: #25332c;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(228, 95, 61, .18);
}

.button-primary:hover {
  background: var(--accent-dark);
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--ink-soft);
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button.compact {
  width: 34px;
  min-height: 34px;
}

.danger-hover:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.language-button {
  min-width: 62px;
  padding-inline: 10px;
}

.api-status {
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 650;
}

.api-status:hover {
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aeb8b3;
  flex: 0 0 auto;
}

.api-status.is-connected .status-dot,
.result-state.is-success .status-dot {
  background: #2e8a61;
  box-shadow: 0 0 0 3px rgba(46, 138, 97, .12);
}

.workspace {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-height));
}

.setup-panel {
  position: relative;
  z-index: 2;
  max-height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 24px 26px 28px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: thin;
}

.setup-heading, .result-header, .examples-heading, .section-heading, .textarea-footer, .generation-summary, .upload-preview, .setting-row, .toggle-row, .drawer-header, .connection-status, .endpoint-row {
  display: flex;
  align-items: center;
}

.setup-heading {
  justify-content: space-between;
  margin-bottom: 25px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.step-counter {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.control-section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-top: 1px;
  font-size: 14px;
  font-weight: 750;
}

.section-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.step-number {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}

.upload-zone {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 94px;
  padding: 15px;
  border: 1px dashed #aebcb5;
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-soft);
  text-align: left;
}

.upload-zone:hover, .upload-zone.is-dragging {
  border-color: var(--green);
  background: #f2f7f5;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-right: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--green);
  background: var(--surface);
}

.upload-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.upload-copy strong {
  font-size: 13px;
}

.upload-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.upload-preview {
  min-height: 72px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.upload-preview img {
  width: 54px;
  height: 54px;
  margin-right: 10px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--canvas);
}

.upload-meta {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.upload-meta strong {
  max-width: 210px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.field-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
}

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

.scene-option {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 14px;
  align-items: center;
  min-height: 60px;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
}

.scene-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.scene-option.is-selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.scene-option strong, .scene-option small {
  display: block;
  min-width: 0;
}

.scene-option strong {
  font-size: 11px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.scene-option small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.scene-swatch {
  position: relative;
  display: block;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.scene-swatch span {
  position: absolute;
  display: block;
}

.scene-white {
  background: #fff;
}

.scene-white span {
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8ddda;
}

.scene-lifestyle {
  background: #d9c8aa;
}

.scene-lifestyle span {
  right: 7px;
  bottom: 0;
  width: 15px;
  height: 33px;
  background: #5c7a61;
  transform: rotate(20deg);
}

.scene-studio {
  background: #25302b;
}

.scene-studio span {
  left: 10px;
  bottom: 7px;
  width: 22px;
  height: 22px;
  border: 1px solid #d8aa73;
  border-radius: 50%;
  background: #6f5746;
}

.scene-inuse {
  background: #b9d0d8;
}

.scene-inuse span {
  right: 7px;
  bottom: 0;
  width: 22px;
  height: 34px;
  border-radius: 13px 13px 0 0;
  background: #d79674;
  transform: rotate(-12deg);
}

.check-icon {
  width: 14px;
  height: 14px;
  color: transparent;
  stroke-width: 2.5;
}

.scene-option.is-selected .check-icon {
  color: var(--green);
}

textarea, select, input[type="password"], input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

textarea {
  min-height: 108px;
  padding: 11px 12px;
  line-height: 1.5;
  resize: vertical;
}

textarea::placeholder, input::placeholder {
  color: #98a29d;
}

textarea:focus, select:focus, input:focus {
  border-color: var(--blue);
}

.textarea-footer {
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

#characterCount {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.output-settings {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.setting-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.setting-row-stack {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.setting-label, .settings-pair label > span, .field-label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.segmented {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

.segmented button.is-selected {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(24, 37, 31, .12);
}

.settings-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.settings-pair label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

select {
  height: 38px;
  padding: 0 34px 0 10px;
  color: var(--ink);
}

.toggle-row {
  position: relative;
  justify-content: space-between;
  min-height: 52px;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row:last-child {
  border-bottom: 0;
}

.toggle-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

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

.toggle-row small {
  color: var(--muted);
  font-size: 10px;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 12px;
  background: #bcc5c0;
  flex: 0 0 auto;
  transition: background-color .15s ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  content: "";
  transition: transform .15s ease;
}

.toggle-row input:checked + .toggle {
  background: var(--green);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(16px);
}

.toggle-row input:focus-visible + .toggle {
  outline: 3px solid rgba(56, 106, 156, .25);
  outline-offset: 2px;
}

.generate-area {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.generation-summary {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.generation-summary strong {
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generate-button {
  width: 100%;
  min-height: 48px;
}

.result-panel {
  min-width: 0;
  max-height: calc(100vh - var(--topbar-height));
  overflow-y: auto;
  padding: 24px 28px 32px;
  background: var(--bg);
}

.result-header {
  min-height: 42px;
  margin-bottom: 16px;
}

.result-header > div:first-child {
  margin-right: auto;
}

.result-actions {
  display: flex;
  gap: 7px;
  margin-left: 14px;
}

.result-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  gap: 7px;
  margin-left: 14px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, .68);
  font-size: 11px;
  font-weight: 700;
}

.result-state.is-working .status-dot {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.result-state.is-error .status-dot {
  background: var(--danger);
}

@keyframes pulse {
  50% { opacity: .35; }
}

.result-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
}

.stage-empty, .stage-error {
  display: flex;
  max-width: 360px;
  align-items: center;
  padding: 28px;
  flex-direction: column;
  text-align: center;
}

.empty-icon, .error-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border: 1px solid #cbd5cf;
  border-radius: 7px;
  color: var(--green);
  background: rgba(255, 255, 255, .6);
}

.empty-icon .icon, .error-icon .icon {
  width: 22px;
  height: 22px;
}

.stage-empty h3, .stage-error h3 {
  font-size: 16px;
}

.stage-empty p, .stage-error p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.error-icon {
  color: var(--danger);
  border-color: #ebc8c4;
  background: var(--danger-soft);
}

.stage-error .button {
  margin-top: 16px;
}

.stage-loading {
  display: flex;
  width: min(420px, calc(100% - 40px));
  align-items: center;
  flex-direction: column;
}

.render-placeholder {
  position: relative;
  display: grid;
  width: min(280px, 78%);
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cbd5cf;
  border-radius: 7px;
  color: var(--green);
  background: #f7f9f8;
}

.render-placeholder .icon {
  width: 28px;
  height: 28px;
}

.scan-line {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(228, 95, 61, .32);
  animation: scan 2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { transform: translateY(18px); opacity: .45; }
  50% { transform: translateY(245px); opacity: 1; }
}

.loading-copy {
  display: flex;
  width: min(280px, 78%);
  justify-content: space-between;
  gap: 10px;
  margin: 13px 0;
  font-size: 12px;
}

.loading-copy span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.stage-result img {
  position: absolute;
  inset: 18px;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  object-fit: contain;
}

.result-caption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(217, 224, 220, .8);
  border-radius: 5px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .9);
  font-size: 10px;
  box-shadow: 0 4px 12px rgba(24, 37, 31, .08);
}

.result-thumbnails {
  display: flex;
  min-height: 74px;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
}

.result-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
}

.result-thumb.is-selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

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

.examples-section {
  margin-top: 24px;
}

.examples-heading {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 11px;
}

.examples-heading h3 {
  font-size: 13px;
}

.examples-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.sample-badge, .field-badge {
  padding: 3px 7px;
  border: 1px solid #c7d9d1;
  border-radius: 4px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

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

.example-item {
  display: grid;
  min-width: 0;
  grid-template-columns: 56px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, .74);
  text-align: left;
}

.example-item:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: 0 5px 14px rgba(24, 37, 31, .06);
}

.example-item img {
  width: 56px;
  height: 54px;
  border-radius: 5px;
  object-fit: cover;
}

.example-item span {
  min-width: 0;
}

.example-item strong, .example-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-item strong {
  font-size: 11px;
}

.example-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.example-item > .icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.mobile-action {
  display: none;
}

.drawer-overlay {
  position: fixed;
  z-index: 79;
  inset: 0;
  background: rgba(18, 27, 23, .36);
}

.drawer {
  position: fixed;
  z-index: 80;
  top: 0;
  right: 0;
  width: min(410px, 100%);
  height: 100vh;
  visibility: hidden;
  background: var(--surface);
  box-shadow: -18px 0 46px rgba(18, 27, 23, .14);
  transform: translateX(100%);
  transition: transform .22s ease, visibility .22s;
}

.drawer.is-open {
  visibility: visible;
  transform: translateX(0);
}

.drawer-header {
  justify-content: space-between;
  min-height: 75px;
  padding: 15px 18px 14px 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  font-size: 18px;
}

.drawer-content {
  height: calc(100vh - 75px);
  overflow-y: auto;
  padding: 22px;
}

.connection-status {
  gap: 12px;
  margin-bottom: 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.connection-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  color: var(--green);
  background: var(--green-soft);
}

.connection-status > div {
  display: flex;
  flex-direction: column;
}

.connection-status strong {
  font-size: 12px;
}

.connection-status > div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 17px 0 7px;
}

.secret-field {
  position: relative;
}

.secret-field input {
  height: 44px;
  padding: 0 46px 0 12px;
}

.secret-field .icon-button {
  position: absolute;
  top: 5px;
  right: 5px;
}

.full-select {
  height: 44px;
}

.endpoint-row {
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.endpoint-row code {
  overflow: hidden;
  padding: 3px 5px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-button {
  width: 100%;
  min-height: 46px;
  margin-top: 20px;
}

.account-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 7px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.account-link:hover {
  color: var(--green);
}

.account-link .icon {
  width: 14px;
  height: 14px;
}

.history-empty {
  display: flex;
  align-items: center;
  padding: 50px 18px;
  flex-direction: column;
  color: var(--muted);
  text-align: center;
}

.history-empty > span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--green);
  background: var(--green-soft);
}

.history-empty strong {
  color: var(--ink);
  font-size: 13px;
}

.history-empty p {
  margin-top: 5px;
  font-size: 11px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.history-item img {
  width: 58px;
  height: 58px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--canvas);
}

.history-item strong, .history-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.history-item button {
  width: 26px;
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.history-item button:hover {
  color: var(--green);
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(360px, calc(100% - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toast-in .18s ease-out;
}

.toast.is-error {
  border-color: #ebc8c4;
}

.toast .icon {
  width: 17px;
  height: 17px;
  color: var(--green);
}

.toast.is-error .icon {
  color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: 430px minmax(0, 1fr);
  }

  .result-panel {
    padding-right: max(32px, calc((100vw - 1540px) / 2));
    padding-left: max(32px, calc((100vw - 1540px) / 2));
  }

  .result-stage {
    min-height: 520px;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 380px minmax(0, 1fr);
  }

  .setup-panel {
    padding-inline: 22px;
  }

  .result-panel {
    padding-inline: 20px;
  }

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

@media (max-width: 820px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .topbar {
    height: 58px;
    padding-inline: 12px;
  }

  :root {
    --topbar-height: 58px;
  }

  .brand-copy span, .desktop-command, .api-status {
    display: none;
  }

  .brand img {
    width: 32px;
    height: 32px;
  }

  .top-actions {
    gap: 0;
  }

  .language-button {
    min-width: 52px;
    border: 0;
    background: transparent;
  }

  .workspace {
    display: block;
    min-height: auto;
  }

  .setup-panel, .result-panel {
    max-height: none;
    overflow: visible;
  }

  .setup-panel {
    padding: 20px 16px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .setup-heading {
    margin-bottom: 18px;
  }

  .control-section {
    padding-block: 18px;
  }

  .generate-area {
    display: none;
  }

  .result-panel {
    padding: 20px 16px 24px;
  }

  .result-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .result-actions {
    order: 3;
    width: 100%;
    margin: 10px 0 0;
  }

  .result-actions .button {
    flex: 1;
  }

  .result-stage {
    min-height: 360px;
  }

  .examples-section {
    margin-top: 20px;
  }

  .mobile-action {
    position: fixed;
    z-index: 60;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
  }

  .mobile-action .button {
    width: 100%;
    min-height: 46px;
  }

  .drawer {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(88vh, 700px);
    border-radius: 8px 8px 0 0;
    transform: translateY(100%);
  }

  .drawer.is-open {
    transform: translateY(0);
  }

  .drawer-content {
    height: calc(100% - 75px);
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .topbar {
    padding-inline: 8px;
  }

  .brand-copy strong {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .scene-option {
    grid-template-columns: 38px minmax(0, 1fr) 12px;
    gap: 7px;
    min-height: 56px;
    padding: 7px;
  }

  .scene-swatch {
    width: 38px;
    height: 38px;
  }

  .settings-pair {
    grid-template-columns: 1fr 1fr;
  }

  .ratio-control {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }

  .result-stage {
    min-height: 320px;
  }

  .result-caption {
    right: 8px;
    bottom: 8px;
  }

  .examples-heading p {
    max-width: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
