:root {
  --ink: #17211b;
  --muted: #65736b;
  --paper: #fffaf0;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(23, 33, 27, 0.14);
  --accent: #e36f2c;
  --accent-dark: #9d3f1b;
  --green: #2f7d4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(227, 111, 44, 0.28), transparent 28rem),
    radial-gradient(circle at 85% 0%, rgba(47, 125, 79, 0.2), transparent 24rem),
    linear-gradient(135deg, #fff3d9, #f4f0df 55%, #eaf1df);
}

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

.hero,
.grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 22px;
  align-items: stretch;
}

.hero {
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.94;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0 0 16px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.subcopy {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
}

.panel,
.identity-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(55, 42, 25, 0.14);
  backdrop-filter: blur(18px);
}

.grid {
  margin-bottom: 22px;
}

label {
  display: block;
  margin: 12px 0 8px;
  color: var(--muted);
  font-weight: 700;
}

input,
textarea,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  font: inherit;
}

input,
textarea {
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.82);
}

textarea {
  min-height: 132px;
  resize: vertical;
}

button {
  margin-top: 14px;
  padding: 13px 16px;
  border: 0;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(157, 63, 27, 0.18);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease,
    opacity 140ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.04);
  box-shadow: 0 14px 30px rgba(157, 63, 27, 0.22);
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 16px rgba(157, 63, 27, 0.2);
}

button:disabled,
button.is-submitting {
  cursor: not-allowed;
  opacity: 0.68;
  filter: saturate(0.72);
}

body.modal-open {
  overflow: hidden;
}

.identity-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}

.ghost-button {
  color: var(--accent-dark);
  border: 1px solid rgba(157, 63, 27, 0.24);
  background: rgba(255, 255, 255, 0.65);
}

.size-control {
  margin-top: 12px;
}

.size-control label {
  margin-top: 0;
}

.size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.size-presets button {
  width: auto;
  min-width: 118px;
  flex: 1 1 calc(33.333% - 8px);
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(23, 33, 27, 0.12);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.15;
}

.size-presets button:hover,
.size-presets button.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), #1d5132);
}

.source-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.source-preview:empty {
  display: none;
}

.source-preview-item {
  position: relative;
  aspect-ratio: 1;
}

.source-preview-open {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(23, 33, 27, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  cursor: zoom-in;
}

.source-preview-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 160ms ease;
}

.source-preview-open:hover img,
.source-preview-open:focus-visible img {
  transform: scale(1.04);
}

.source-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  color: white;
  background: rgba(23, 33, 27, 0.82);
  box-shadow: 0 6px 16px rgba(23, 33, 27, 0.25);
  font-size: 15px;
  line-height: 1;
  opacity: 0;
}

.source-preview-item:hover .source-preview-remove,
.source-preview-item:focus-within .source-preview-remove {
  opacity: 1;
}

@media (hover: none) {
  .source-preview-remove {
    opacity: 1;
  }
}

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

.history-head button {
  width: auto;
  margin: 0;
  padding-inline: 22px;
}

.jobs {
  display: grid;
  gap: 14px;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
}

.job {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
}

.job img,
.placeholder {
  width: 140px;
  height: 140px;
  border-radius: 16px;
  object-fit: cover;
  background: #eee3cd;
}

.image-button {
  width: 140px;
  height: 140px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}

.image-button img {
  display: block;
  transition: transform 180ms ease;
}

.image-button:hover img {
  transform: scale(1.04);
}

.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.job-meta span {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(23, 33, 27, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.status.succeeded {
  color: white;
  background: var(--green);
}

.status.failed {
  color: white;
  background: #a83232;
}

pre {
  white-space: pre-wrap;
  color: #a83232;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 27, 0.72);
  backdrop-filter: blur(12px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 26px;
  background: #fffaf0;
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.36);
}

.modal-card img {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  justify-self: center;
  border-radius: 18px;
  object-fit: contain;
}

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

.modal-actions button,
.modal-actions .download {
  width: auto;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
}

.modal-actions .download {
  color: white;
  background: var(--green);
  font-weight: 800;
}

@media (max-width: 820px) {
  .hero,
  .grid,
  .job {
    grid-template-columns: 1fr;
  }

  .size-presets button {
    flex-basis: calc(50% - 8px);
  }

  .job img,
  .image-button,
  .placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}

@media (max-width: 460px) {
  .size-presets button {
    flex-basis: 100%;
  }
}
