:root {
  --green: #00845d;
  --green-dark: #064b35;
  --mint: #e5f4ec;
  --ink: #17231f;
  --muted: #66746f;
  --line: #d9e2de;
  --panel: #ffffff;
  --bg: #f4f7f5;
  --gold: #d9a84f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.app-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.editor,
.preview-panel,
.result-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(14, 53, 39, 0.08);
}

.editor {
  padding: 24px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.badge {
  flex: 0 0 auto;
  color: var(--green-dark);
  background: var(--mint);
  border: 1px solid #b8dccb;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}

.form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input[type="file"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input[type="file"] {
  padding: 12px;
}

textarea {
  min-height: 240px;
  padding: 14px;
  resize: vertical;
  line-height: 1.7;
}

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.submit-button.is-loading .spinner {
  display: block;
}

.preview-panel {
  padding: 20px;
}

.preview-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfb;
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.preview-card span {
  display: block;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.result-section {
  margin-top: 18px;
  padding: 22px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

#modelLabel {
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-height: 24px;
  color: var(--muted);
  line-height: 1.5;
}

.status.error {
  color: #b42318;
}

.answer {
  margin-top: 12px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.task-log {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.task-log li {
  display: grid;
  grid-template-columns: minmax(88px, auto) 76px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.task-log strong {
  color: var(--green-dark);
  font-size: 14px;
}

.task-log span {
  color: var(--muted);
  font-size: 13px;
}

.task-log p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.image-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.image-results a {
  display: block;
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
}

.image-results img {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
  }

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

  .title-row,
  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-log li {
    grid-template-columns: 1fr;
  }
}
