.image-page {
  min-height: 100vh;
  background: #f5f7fb;
}

.image-main {
  width: 100%;
  min-height: calc(100vh - 57px);
  padding: 40px 24px;
}

.image-content {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 24px;
}

.image-heading h1 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 32px;
}

.image-heading p {
  margin: 4px 0 0;
  color: #4b5563;
  font-size: 14px;
  line-height: 23.1px;
}

.image-mode {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #f3dcc0;
  border-radius: 8px;
  background: #fff7ed;
}

.image-mode button {
  min-width: 112px;
  padding: 8px 24px;
  border: 0;
  border-radius: 6px;
  color: #4b5563;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 23.1px;
  transition: color 150ms ease, background-color 150ms ease,
    box-shadow 150ms ease, transform 150ms ease;
}

.image-mode button:hover:not(.image-mode__active) {
  color: #111827;
}

.image-mode button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.image-mode .image-mode__active {
  color: #fff;
  background: linear-gradient(135deg, #ffb623 0%, #ea580c 55%, #fbbf24 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.image-mode button:active {
  transform: translateY(1px);
}

.image-workspace {
  position: relative;
  top: 0.645833px;
  display: grid;
  width: 100%;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
}

.image-card {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(17, 24, 39, 0.08);
}

.image-editor {
  display: flex;
  height: auto;
  min-height: 374.765625px;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
  padding: 20.322916px 20px 20px;
}

[data-image-panel][hidden],
[data-image-text-only][hidden] {
  display: none;
}

.image-editor--reference {
  height: 407px;
  gap: 16px;
}

.image-reference__header {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: space-between;
}

.image-reference__header > span {
  padding: 2px 10px;
  border-radius: 999px;
  color: #4b5563;
  background: #fff7ed;
  font-size: 12px;
  line-height: 20px;
}

.image-reference {
  position: relative;
  min-height: 160px;
  overflow: hidden;
  border: 2px dashed #d6d3d1;
  border-radius: 12px;
  background: #fff7ed;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.image-reference__picker {
  display: flex;
  min-height: 156px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  text-align: center;
}

.image-reference__picker strong {
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
  line-height: 23px;
}

.image-reference__picker span {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 12px;
  line-height: 20px;
}

.image-reference:focus-within {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.13);
}

.image-reference--dragover {
  border-color: #f59e0b;
  background: #ffedd5;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.image-reference__previews {
  display: grid;
  min-height: 0;
  padding: 8px 12px 12px;
  grid-template-columns: repeat(4, minmax(0, 96px));
  grid-auto-rows: 96px;
  gap: 10px;
  align-content: start;
  justify-content: start;
}

.image-reference__previews[hidden] {
  display: none;
}

.image-reference:has(.image-reference__previews:not([hidden])) .image-reference__picker {
  min-height: 40px;
  flex-direction: row;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid rgba(17, 24, 39, 0.08);
}

.image-reference[data-image-reference-count="4"] .image-reference__picker {
  display: none;
}

.image-reference[data-image-reference-count="4"] {
  cursor: default;
}

.image-reference:has(.image-reference__previews:not([hidden])) .image-reference__picker span {
  margin-top: 0;
}

.image-reference__preview {
  position: relative;
  width: 96px;
  height: 96px;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f4f6;
  aspect-ratio: 1;
}

.image-reference__preview-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: zoom-in;
}

.image-reference__preview-button:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.5);
  outline-offset: -3px;
}

.image-reference__preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-reference__remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.image-transform-description {
  height: 96px;
  min-height: 96px;
  resize: none;
  line-height: 24.5px;
}

.image-field-group {
  min-width: 0;
}

.image-style-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.image-label {
  display: block;
  margin: 0 0 6px;
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  line-height: 23.1px;
}

.image-label span {
  color: #ef4444;
}

.image-field,
.image-select {
  display: block;
  width: 100%;
  border: 1px solid rgba(17, 24, 39, 0.16);
  border-radius: 8px;
  outline: 0;
  color: #111827;
  background: #f3f4f6;
  font-size: 14px;
  font-weight: 400;
  transition: border-color 150ms ease, background-color 150ms ease,
    box-shadow 150ms ease;
}

.image-field {
  padding: 10px 14px;
  line-height: 23.1px;
}

.image-field::placeholder {
  color: #6b7280;
  opacity: 1;
}

.image-field:focus,
.image-select:focus {
  border-color: #f59e0b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.13);
}

.image-description {
  display: inline-block;
  height: 112px;
  min-height: 112px;
  resize: none;
  line-height: 24.5px;
}

.image-counter {
  height: 16px;
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 16px;
  text-align: right;
}

.image-styles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.image-styles button {
  min-width: 74px;
  padding: 6px 12px;
  border: 1px solid rgba(17, 24, 39, 0.16);
  border-radius: 8px;
  color: #4b5563;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  transition: color 150ms ease, border-color 150ms ease,
    background-color 150ms ease, transform 150ms ease;
}

.image-styles button:hover:not(.image-style__active) {
  color: #4b5563;
  border-color: rgba(17, 24, 39, 0.16);
  background: #fff;
}

.image-styles .image-style__active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #ffb623 0%, #ea580c 55%, #fbbf24 100%);
}

.image-styles button:active {
  transform: translateY(1px);
}

.image-negative {
  height: 45.09375px;
}

.image-sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  width: 260px;
  flex-direction: column;
  gap: 12px;
}

.image-options {
  height: 480.46875px;
  padding: 21px 20px 20px;
}

[data-image-active-mode="image"] .image-options {
  height: 388px;
}

.image-options__title {
  height: 16px;
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}

.image-option-group {
  margin-top: 16px;
}

.image-count-options {
  display: flex;
  width: 100%;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: #fff7ed;
}

.image-count-options button {
  min-width: 0;
  flex: 1;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  color: #4b5563;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 23.1px;
  transition: color 150ms ease, background-color 150ms ease,
    box-shadow 150ms ease, transform 150ms ease;
}

.image-count-options button:hover:not(.image-option__active) {
  color: #111827;
}

.image-count-options .image-option__active {
  color: #fff;
  background: linear-gradient(135deg, #ffb623 0%, #ea580c 55%, #fbbf24 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.image-count-options button:active {
  transform: translateY(1px);
}

.image-select {
  height: 44px;
  padding: 10px 14px;
}

.image-cost {
  height: 16px;
  margin: 16px 0 0;
  color: #4b5563;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.image-cost strong {
  margin-left: 3px;
  color: #f59e0b;
  font-weight: 600;
}

.image-retention {
  min-height: 42px;
  margin: 16px 0 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 21px;
}

.image-submit {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #ffb623 0%, #ea580c 55%, #fbbf24 100%);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.28);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 23.1px;
  transition: filter 150ms ease, opacity 150ms ease,
    box-shadow 150ms ease, transform 150ms ease;
}

.image-submit:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.image-submit:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.image-note {
  min-height: 88px;
  padding: 12px 16px;
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 8px;
  color: #4b5563;
  background: #fff7ed;
  font-size: 12px;
  line-height: 21px;
}

.image-note strong {
  color: #111827;
  font-weight: 600;
}

.image-task {
  padding: 16px 18px;
  border: 1px solid #dbe1ea;
  border-radius: 8px;
  background: #fff;
}

.image-task__summary,
.image-task__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-task__summary > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
}

.image-task__label,
.image-task__progress-text {
  color: #6b7280;
  font-size: 12px;
  line-height: 20px;
}

.image-task__summary strong {
  color: #111827;
  font-size: 14px;
  line-height: 22px;
}

.image-task__track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 4px;
  background: #e5e7eb;
}

.image-task__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #ea580c;
  transition: width 180ms ease;
}

.image-task__error {
  margin: 10px 0 0;
  color: #b91c1c;
  font-size: 12px;
  line-height: 20px;
}

.image-task__actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.image-task__actions button {
  min-width: 88px;
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 18px;
}

.image-task__actions button:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

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

.image-results {
  margin-top: 28px;
}

.image-results__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.image-results__heading h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  letter-spacing: 0;
}

.image-results__heading span {
  color: #6b7280;
  font-size: 12px;
}

.image-results__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 320px));
  gap: 16px;
  justify-content: start;
}

.image-result {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.image-result__preview {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #f3f4f6;
  cursor: zoom-in;
}

.image-result__preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f9fafb;
  transition: transform 180ms ease;
}

.image-result__preview:hover img {
  transform: scale(1.015);
}

.image-result__preview:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.32);
  outline-offset: -3px;
}

.image-result__download {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 6px;
  color: #111827;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.14);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
}

.image-result__download[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.62;
}

.image-result__download:hover {
  border-color: rgba(245, 158, 11, 0.42);
  color: #c2410c;
  background: #fff;
}

.image-result__download:focus-visible,
.image-preview-dialog__actions button:focus-visible,
.image-preview-dialog__actions a:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.32);
  outline-offset: 2px;
}

.image-preview-dialog {
  width: min(1120px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.38);
}

.image-preview-dialog::backdrop {
  background: rgba(3, 7, 18, 0.82);
}

.image-preview-dialog__panel {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  max-height: calc(100dvh - 32px);
}

.image-preview-dialog__toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.image-preview-dialog__toolbar strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-dialog__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.image-preview-dialog__actions button,
.image-preview-dialog__actions a {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  color: #f9fafb;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  text-decoration: none;
}

.image-preview-dialog__actions button:hover,
.image-preview-dialog__actions a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.image-preview-dialog__actions a[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.6;
}

.image-preview-dialog__actions [hidden] {
  display: none;
}

.image-preview-dialog__stage {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 16px;
  overflow: auto;
}

.image-preview-dialog__stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 116px);
  object-fit: contain;
}

@media (max-width: 640px) {
  .image-results__grid {
    grid-template-columns: minmax(0, 320px);
  }

  .image-preview-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .image-preview-dialog__panel {
    max-height: calc(100dvh - 16px);
  }

  .image-preview-dialog__stage {
    padding: 8px;
  }
}

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

@media (max-width: 900px) {
  .image-main {
    padding: 28px 16px 40px;
  }

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

  .image-sidebar {
    position: static;
    width: 100%;
  }

  .image-options {
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }


  [data-image-active-mode="image"] .image-options {
    height: auto;
  }

  .image-options__title,
  .image-cost,
  .image-retention,
  .image-submit {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .image-option-group {
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .image-main {
    padding: 24px 12px 36px;
  }

  .image-heading h1 {
    font-size: 22px;
  }

  .image-mode {
    width: 100%;
  }

  .image-mode button {
    min-width: 0;
    flex: 1;
    padding-right: 12px;
    padding-left: 12px;
  }

  .image-editor,
  .image-options {
    height: auto;
    padding: 16px;
  }

  .image-reference__previews {
    grid-template-columns: repeat(2, minmax(0, 96px));
  }

  .image-styles {
    gap: 6px;
  }

  .image-styles button {
    min-width: calc(25% - 5px);
    padding-right: 7px;
    padding-left: 7px;
    font-size: 11px;
  }

  .image-options {
    display: block;
  }

  .image-option-group,
  .image-cost,
  .image-retention,
  .image-submit {
    margin-top: 16px;
  }
}
