:root {
  --bg: #f7f7fb;
  --text: #101827;
  --muted: #657085;
  --line: #d8deea;
  --panel: #ffffff;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(16, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
a,
textarea {
  font: inherit;
}

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

.top-panel,
.status-panel,
.result-panel,
.error-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 24px;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.input-form {
  display: grid;
  gap: 12px;
}

label,
.caption-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  background: #fbfcff;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

button,
.download-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button:active,
.download-button:active {
  transform: translateY(1px);
}

.ghost-button {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
}

.status-panel,
.result-panel,
.error-panel {
  margin-top: 16px;
}

.loader {
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border: 4px solid #d7f3ef;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.status-panel p,
.error-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.thumbnail {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 8px;
  background: #e7ebf2;
}

.caption-box {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.caption-box p {
  margin: 8px 0 0;
  line-height: 1.7;
  white-space: pre-wrap;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.error-panel {
  border-color: rgba(180, 35, 24, 0.35);
}

.error-panel h2 {
  color: var(--danger);
}

.hidden {
  display: none;
}

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

@media (min-width: 480px) {
  .button-grid {
    grid-template-columns: 1fr 1fr;
  }
}
