:root {
  color-scheme: light;
  --ink: #1b2434;
  --muted: #667085;
  --line: #d7dde8;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #0b5e58;
  --coral: #d9634f;
  --yellow: #f5c85c;
  --blue: #dceaf8;
  --shadow: 0 22px 60px rgba(27, 36, 52, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(245, 200, 92, 0.22), transparent 36%),
    linear-gradient(135deg, rgba(220, 234, 248, 0.88), rgba(251, 250, 247, 0.9) 48%, rgba(217, 99, 79, 0.1)),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

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

.workspace {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.intro {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 4px 0 2px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 3.1vw, 44px);
  line-height: 1.08;
  font-weight: 850;
}

h2 {
  font-size: 24px;
}

.api-cluster {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.docs-link,
.api-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(27, 36, 52, 0.06);
}

.docs-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.docs-link:hover {
  border-color: rgba(15, 118, 110, 0.5);
  background: rgba(255, 255, 255, 0.94);
}

.api-chip {
  flex: 0 0 auto;
  display: grid;
  gap: 4px;
  padding: 10px 13px;
  color: var(--muted);
  font-size: 12px;
}

.api-chip strong {
  color: var(--ink);
  font-size: 13px;
}

.tool-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 0.86fr) minmax(480px, 1.14fr);
  gap: 20px;
  min-height: 0;
}

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

.composer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-head label,
.field span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.counter {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 850;
}

.counter[data-mode="error"] {
  background: rgba(217, 99, 79, 0.14);
  color: #a23c2d;
}

textarea {
  flex: 1;
  min-height: 420px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  outline: none;
  background: #fffefd;
  color: var(--ink);
  line-height: 1.62;
  font-size: 15px;
}

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

textarea[data-mode="error"] {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(217, 99, 79, 0.12);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 12px;
}

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

select,
input,
.locked-count {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  outline: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 52px;
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%231b2434' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 18px center;
  background-repeat: no-repeat;
  background-size: 18px 18px;
}

.locked-count {
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: var(--ink);
  font-weight: 850;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.result-meta button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  background: var(--teal);
  color: white;
}

.primary-button:hover {
  background: var(--teal-dark);
}

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

.button-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.ghost-button {
  padding: 0 14px;
  background: #f1f5f9;
  color: var(--ink);
}

.output {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
  overflow: hidden;
}

.output-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 12px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill[data-mode="loading"] {
  background: rgba(245, 200, 92, 0.25);
  color: #8a5b00;
}

.status-pill[data-mode="success"] {
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal-dark);
}

.status-pill[data-mode="error"] {
  background: rgba(217, 99, 79, 0.12);
  color: #a23c2d;
}

.empty-state {
  flex: 1;
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  border: 1px dashed #c6cfda;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(220, 234, 248, 0.68), rgba(255, 255, 255, 0.6)),
    white;
  color: var(--muted);
  text-align: center;
}

.preview-mark {
  width: 112px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.9), rgba(15, 118, 110, 0.2)),
    linear-gradient(45deg, transparent 52%, rgba(245, 200, 92, 0.9) 53%);
  box-shadow: inset 0 0 0 1px rgba(27, 36, 52, 0.12);
}

.preview-mark.warning {
  background: linear-gradient(135deg, rgba(217, 99, 79, 0.95), rgba(245, 200, 92, 0.55));
}

.loader {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(15, 118, 110, 0.14);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

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

.result-item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #111827;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.result-meta a {
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.result-meta button {
  min-height: 34px;
  padding: 0 10px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 13px;
}

.raw-response {
  max-height: 190px;
  margin: 10px 0 0;
  overflow: auto;
  border-radius: 8px;
  padding: 14px;
  background: #111827;
  color: #d8e6f3;
  font-size: 12px;
  line-height: 1.55;
}

.raw-panel {
  margin-top: 14px;
}

.raw-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

  .workspace {
    min-height: calc(100vh - 36px);
  }

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

  .api-cluster {
    justify-content: flex-start;
  }

  h1 {
    font-size: clamp(28px, 7vw, 38px);
  }

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

  textarea {
    min-height: 360px;
  }
}

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

  .actions,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .primary-button,
  .ghost-button {
    justify-content: center;
  }
}
