:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-deep: #ffffff;
  --card: #ffffff;
  --card-soft: #f9fbff;
  --text: #111827;
  --muted: #68738b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eef4ff;
  --border: #d9e1ef;
  --border-blue: #a9c5ff;
  --input-bg: #ffffff;
  --danger: #be123c;
  --warning: #8a4b0f;
  --warning-bg: #fff7ed;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.22), 0 3px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 32px 48px 60px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before,
body::after {
  content: "";
  display: none;
  position: fixed;
  z-index: -1;
  pointer-events: none;
}

body::before {
  right: -270px;
  bottom: -290px;
  width: 600px;
  height: 600px;
  border: 2px solid rgba(50, 110, 255, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(40, 90, 220, 0.03), 0 0 0 150px rgba(40, 90, 220, 0.02);
}

body::after {
  left: -250px;
  bottom: -150px;
  width: 400px;
  height: 400px;
  border: 2px solid rgba(57, 115, 255, 0.08);
  transform: rotate(25deg);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1550px, 100%);
  margin: 0 auto;
}

.app-header {
  margin-bottom: 34px;
}

.app-header h1 {
  margin: 0;
  color: #17213b;
  font-size: clamp(29px, 3vw, 46px);
  font-weight: 800;
  line-height: 1;
}

.app-header p {
  margin: 11px 0 0;
  color: #6a7692;
  font-size: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 670px;
  padding: 27px 32px 34px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--card), var(--card-soft));
  box-shadow: var(--shadow);
}

.card-top,
.result-title-wrap {
  display: flex;
  align-items: center;
  gap: 17px;
}

.card-top {
  margin-bottom: 22px;
}

.mini-icon {
  display: grid;
  flex: 0 0 55px;
  width: 55px;
  height: 55px;
  place-items: center;
  border: 1px solid #dfe9ff;
  border-radius: 17px;
  color: var(--primary);
  background: linear-gradient(145deg, #eef4ff, #f5f8ff);
}

.mini-icon svg {
  width: 26px;
  height: 26px;
}

h2,
p {
  margin: 0;
}

h2 {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}

.card-top p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 9px;
  margin-bottom: 20px;
}

.message-field {
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.label-row span,
.result-field > span:first-child {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.label-row strong,
.label-row em {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--primary-light);
  color: #4773c4;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  min-height: 130px;
  padding: 18px;
  resize: none;
  font-size: 14px;
  line-height: 1.45;
}

#message {
  height: 100%;
}

textarea::placeholder,
input::placeholder {
  color: #8e98aa;
}

textarea:focus,
input:focus {
  border-color: #78a5ff;
  box-shadow: 0 0 0 4px rgba(39, 103, 235, 0.09);
}

.input-box {
  position: relative;
  display: block;
}

.input-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: #8697bb;
  pointer-events: none;
  transform: translateY(-50%);
}

.input-box input {
  height: 53px;
  padding: 0 16px 0 48px;
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--primary-dark);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.28);
}

.btn-secondary {
  border: 1px solid var(--border);
  color: #4d5d7c;
  background: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
  background: #f8faff;
}

.generate-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  font-size: 14px;
}

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

.btn.feedback-busy:disabled {
  opacity: 1;
}

.btn.feedback-busy svg {
  animation: button-spin 0.8s linear infinite;
}

.btn.feedback-error {
  color: #ffffff;
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: none;
}

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

.form-status:empty {
  display: none;
}

.form-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-status.error {
  color: var(--danger);
  font-weight: 700;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

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

.refresh-btn {
  min-width: 198px;
  height: 48px;
  color: #1f5adc;
  border-color: #bfd2ff;
}

.image-area {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 226px;
  min-height: 226px;
  overflow: hidden;
  border: 1.5px dashed var(--border-blue);
  border-radius: 12px;
  background:
    radial-gradient(circle at center, rgba(63, 115, 255, 0.08), transparent 30%),
    linear-gradient(145deg, #fbfdff, #f5f8ff);
  text-align: center;
}

.image-area img:not(.generated-product-image) {
  display: block;
}

.image-area img.generated-product-image,
.image-area > img:not(.empty-illustration) {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--muted);
}

.preview-icon {
  display: grid;
  width: 100px;
  height: 100px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 50%;
  color: #7195ef;
  background: rgba(82, 126, 232, 0.09);
}

.preview-icon svg {
  width: 44px;
  height: 44px;
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.empty-state span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.image-actions {
  margin-top: 15px;
}

.affiliate-link-field {
  margin-top: 16px;
  margin-bottom: 0;
}

.resolved-link-box {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.resolved-link-box > svg {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  color: #8697bb;
  pointer-events: none;
  transform: translateY(-50%);
}

.resolved-link-box input {
  min-width: 0;
  height: 48px;
  padding: 0 16px 0 48px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
}

.copy-link-btn {
  min-width: 148px;
  height: 48px;
  white-space: nowrap;
}

.divider {
  height: 1px;
  margin: 20px 0 18px;
  background: #e1e6ef;
}

.result-field {
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  margin-bottom: 0;
}

.result-text-wrap {
  position: relative;
  display: block;
  height: 100%;
  min-height: 0;
}

#resultText {
  height: 100%;
  min-height: 165px;
}

.final-actions {
  margin-top: 14px;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.warning {
  border: 1px solid #fed7aa;
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 1050px) {
  body {
    padding: 28px 22px 50px;
  }

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

  .card {
    min-height: 0;
  }

  #message {
    height: 240px;
  }

  .result-field {
    height: 220px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 20px 14px 35px;
  }

  .app-header {
    gap: 13px;
  }

  .header-icon {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }

  .app-header h1 {
    font-size: 30px;
  }

  .app-header p {
    font-size: 13px;
  }

  .card {
    padding: 22px 18px;
    border-radius: 16px;
  }

  .result-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .refresh-btn,
  .image-actions .btn,
  .copy-link-btn,
  .final-actions .btn {
    width: 100%;
  }

  .resolved-link-box {
    grid-template-columns: 1fr;
  }

  .resolved-link-box > svg {
    top: 24px;
  }

  .button-row {
    flex-direction: column;
  }
}
