:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #657083;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --warning: #9a5b13;
  --code: #111827;
  --shadow: 0 18px 44px rgba(28, 36, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

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

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

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.toolbar h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
  letter-spacing: 0;
}

.toolbar p {
  margin: 7px 0 0;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.request-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.output-panel {
  min-height: 640px;
  padding: 18px;
}

.span-2 {
  grid-column: span 2;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

.section-title h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

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

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 110px;
  padding: 10px 11px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: #aeb7c5;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
}

.button.danger {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.image-list {
  display: grid;
  gap: 10px;
}

.image-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.thumb {
  width: 72px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef1f5;
}

.advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.advanced summary,
.raw-response summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.advanced textarea {
  margin-top: 10px;
  font-family: "Cascadia Code", Consolas, monospace;
}

.status {
  display: flex;
  align-items: center;
  min-height: 48px;
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.status.error {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff4f2;
  color: var(--danger);
}

.status.loading {
  border-color: rgba(154, 91, 19, 0.35);
  background: #fff8eb;
  color: var(--warning);
}

.status.success {
  border-color: rgba(15, 118, 110, 0.35);
  background: #effaf8;
  color: var(--accent-dark);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.result-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #eef1f5;
}

.result-actions {
  display: flex;
  gap: 8px;
  padding: 10px;
}

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

.usage {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.usage h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.usage dl {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 8px 16px;
  margin: 0;
}

.usage dt {
  color: var(--muted);
}

.usage dd {
  margin: 0;
  font-weight: 600;
}

.raw-response {
  margin-top: 18px;
}

.raw-response pre {
  max-height: 360px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--code);
  color: #e5e7eb;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

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

  .output-panel {
    min-height: 420px;
  }
}

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

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

  .toolbar-actions {
    justify-content: stretch;
  }

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

  .request-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .span-2 {
    grid-column: span 1;
  }

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

  .thumb {
    width: 100%;
    max-height: 220px;
  }
}
