:root {
  --ink: #0b1625;
  --muted: #607083;
  --line: rgba(15, 27, 42, 0.13);
  --panel: rgba(255, 255, 255, 0.92);
  --blue: #0b84d8;
  --cyan: #05a8c7;
  --green: #138a62;
  --rose: #c83d5b;
  --paper: #f4f8fb;
  --shadow: 0 22px 64px rgba(20, 38, 58, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(125deg, rgba(11, 132, 216, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(19, 138, 98, 0.11), transparent 30%),
    linear-gradient(180deg, #fff 0%, var(--paper) 100%);
}

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

.app-shell {
  min-height: 100vh;
  padding: clamp(18px, 3vw, 36px);
}

.workspace {
  width: min(1480px, 100%);
  min-height: calc(100vh - clamp(36px, 6vw, 72px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-panel {
  padding: clamp(22px, 3vw, 34px);
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand img {
  width: clamp(44px, 5vw, 56px);
  height: clamp(44px, 5vw, 56px);
  object-fit: contain;
  flex: 0 0 auto;
}

.brand p,
.preview-toolbar p {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 28px);
  line-height: 1.12;
  letter-spacing: 0;
}

.generator-form {
  display: grid;
  gap: 18px;
}

.api-grid,
.settings-grid {
  display: grid;
  gap: 14px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.remember-row span {
  color: #27374a;
  font-size: 14px;
  font-weight: 800;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea {
  min-height: 188px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

select,
input {
  height: 44px;
  padding: 0 12px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--blue);
}

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

output {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(11, 132, 216, 0.72);
  box-shadow: 0 0 0 4px rgba(11, 132, 216, 0.12);
}

.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  cursor: pointer;
}

.action-row {
  display: grid;
}

.primary-action,
.secondary-action {
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-action {
  height: 52px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  box-shadow: 0 16px 34px rgba(11, 132, 216, 0.26);
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.preview-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: clamp(18px, 3vw, 34px);
  gap: 18px;
}

.preview-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.preview-toolbar strong {
  display: block;
  font-size: clamp(20px, 2.4vw, 34px);
  line-height: 1.1;
}

.preview-stage {
  min-height: 520px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(10, 23, 38, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(10, 23, 38, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(10, 23, 38, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(10, 23, 38, 0.035) 75%),
    #fff;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  overflow: auto;
  padding: clamp(14px, 2vw, 22px);
}

.preview-stage.is-loading {
  animation: pulse 1.2s ease-in-out infinite;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state span {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(11, 132, 216, 0.92), rgba(19, 138, 98, 0.92)),
    #fff;
  box-shadow: 0 18px 38px rgba(11, 132, 216, 0.24);
}

.empty-state p {
  margin: 0;
  font-weight: 800;
}

.results-grid {
  width: 100%;
  align-self: start;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.result-card {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.result-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

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

.secondary-action {
  height: 42px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.secondary-action:hover {
  border-color: rgba(11, 132, 216, 0.55);
}

.prompt-note,
.usage-panel {
  border-left: 4px solid var(--green);
  padding: 12px 14px;
  background: rgba(19, 138, 98, 0.08);
  color: #24463b;
  line-height: 1.55;
}

.prompt-note.is-error {
  border-left-color: var(--rose);
  background: rgba(200, 61, 91, 0.08);
  color: #6b2738;
}

.usage-panel {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  border-left-color: var(--blue);
  background: rgba(11, 132, 216, 0.07);
  color: #23405a;
  font-size: 13px;
  white-space: pre-wrap;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.72;
  }
}

@media (max-width: 940px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-stage {
    min-height: 420px;
  }
}

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

  .workspace {
    min-height: 100vh;
    border: 0;
  }

  .brand {
    align-items: flex-start;
  }

  .settings-grid,
  .result-actions {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

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