:root {
  --ink: #1a1814;
  --muted: #6d675e;
  --paper: #f4f0e8;
  --sheet: #fffdf9;
  --line: rgba(26, 24, 20, 0.12);
  --accent: #f5c400;
  --accent-ink: #161411;
  --bar: #161411;
  --bar-ink: #f6f1e8;
  --shadow: 0 18px 50px rgba(40, 28, 16, 0.12);
  --sans: "Segoe UI", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(154, 52, 18, 0.08), transparent 60%),
    var(--paper);
}

button, input { font: inherit; }
button { cursor: pointer; }

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 22px;
  background: var(--bar);
  color: var(--bar-ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 680;
}

.brand-copy span,
.progress {
  color: #c9bfb2;
  font-size: 13px;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.progress { margin: 0; }

.download {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 680;
}

.download:hover { filter: brightness(1.06); }
.download:disabled { opacity: 0.6; cursor: wait; }

.download:focus-visible,
.text:focus-visible,
.digits input:focus-visible,
.brand:focus-visible {
  outline: 2px solid #f0b429;
  outline-offset: 2px;
}

main {
  width: min(920px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.status {
  margin: 0 0 18px;
  color: var(--muted);
}

.status[hidden] { display: none; }

.sheet {
  display: grid;
  gap: 22px;
}

.page {
  margin: 0;
  background: var(--sheet);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 88px;
}

.page img {
  display: block;
  width: 100%;
  height: auto;
  background:
    linear-gradient(90deg, rgba(26, 24, 20, 0.04), rgba(26, 24, 20, 0.08), rgba(26, 24, 20, 0.04));
  aspect-ratio: var(--ratio, 595 / 842);
}

.gate {
  width: min(440px, calc(100% - 28px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.gate::backdrop {
  background: rgba(18, 14, 10, 0.62);
}

.gate form { padding: 24px 22px 18px; }

.gate-kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a6a00;
  font-weight: 700;
}

.gate h2 {
  margin: 6px 0 8px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.gate-copy {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.digits {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.digits input {
  width: 100%;
  height: 64px;
  text-align: center;
  font-size: 28px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #faf7f2;
  color: var(--ink);
}

.digits.invalid input {
  border-color: #b42318;
  background: #fff5f4;
}

.gate-error {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: #b42318;
  font-size: 14px;
}

.gate-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.text {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-weight: 650;
}

@media (max-width: 640px) {
  .bar { padding: 10px 12px; }
  .brand-copy span { display: none; }
  .progress { display: none; }
  main { width: min(920px, calc(100% - 16px)); padding-top: 16px; }
  .gate h2 { font-size: 24px; }
}
