* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  gap: 40px;
  align-items: start;
}

.intro {
  padding-top: 12px;
}

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

h1 {
  margin: 0;
  max-width: 10ch;
  font-size: clamp(2.7rem, 8vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.intro p:last-child {
  max-width: 34rem;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.converter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 70px rgb(19 45 35 / 9%);
}

.dropzone {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  border: 2px dashed #b9c9c2;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:active {
  transform: scale(0.995);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.dropzone-icon {
  display: grid;
  width: 84px;
  height: 104px;
  place-items: end center;
  padding-bottom: 18px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 900;
}

.dropzone strong {
  color: var(--text);
  font-size: 1.15rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 20px;
}

fieldset {
  display: flex;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
.quality-control span {
  width: 100%;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}

.quality-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.quality-control input {
  grid-column: 1 / -1;
  accent-color: var(--accent);
}

.quality-control output {
  color: var(--accent-strong);
  font-weight: 800;
}

.range-labels {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  background: #b8c2be;
  cursor: not-allowed;
}

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.status.is-error {
  color: var(--danger);
}

.results-panel {
  margin-top: 32px;
}

.results-panel[hidden] {
  display: none;
}

.results-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.results-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.secondary-button {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent-strong);
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

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

.page-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #eef2ee;
}

.page-card footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.page-card footer div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.page-card strong {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.page-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.download-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.download-button:hover,
.secondary-button:hover {
  background: #d6ece5;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 24px, 680px);
    padding: 28px 0;
  }

  .hero,
  .controls,
  .results-header {
    grid-template-columns: 1fr;
  }

  .results-header {
    display: grid;
    align-items: start;
  }

  h1 {
    max-width: 9ch;
    font-size: clamp(2.5rem, 17vw, 4.5rem);
  }

  .converter {
    padding: 16px;
  }

  .dropzone {
    min-height: 230px;
  }
}
