:root {
  --ink: #171717;
  --muted: #6f6f69;
  --line: #d9d8d1;
  --paper: #f7f6f0;
  --white: #fff;
  --accent: #c94b31;
  --accent-dark: #9d321f;
  --soft: #eceae1;
  --error: #8d2418;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(23, 23, 23, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
}

button, textarea, input { font: inherit; }

a { color: inherit; }

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--ink);
}

.wordmark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  text-decoration: none;
}

.section-name {
  color: var(--muted);
  font-size: 14px;
}

.intro {
  max-width: 820px;
  padding: 74px 0 42px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 6.4vw, 78px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.lede {
  max-width: 650px;
  margin-bottom: 0;
  color: #41413d;
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.5;
}

.email-gate {
  max-width: 760px;
  margin-bottom: 30px;
  border: 1px solid var(--ink);
  padding: 28px;
  background: var(--white);
}

.email-gate h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 400;
}

.email-gate form > label { display: block; margin-bottom: 8px; font-weight: 700; }
.email-gate form + form { margin-top: 20px; }

.email-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.email-row input {
  min-width: 0;
  border: 1px solid #8d8c84;
  border-radius: 0;
  padding: 12px 14px;
  background: var(--white);
}

.code-row { grid-template-columns: minmax(180px, 280px) auto; }
.gate-note { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.gate-note.is-error { color: var(--error); }

.workbench {
  padding: 34px;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 8px 8px 0 var(--soft);
}

.field-block + .field-block { margin-top: 30px; }

.field-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.field-heading label, .retry-form > label {
  font-weight: 700;
}

.field-heading span, .form-note, #retry-note {
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 250px;
  place-items: center;
  align-content: center;
  overflow: hidden;
  border: 1px dashed #8d8c84;
  background: var(--paper);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: #fffaf5;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-title { font-size: 18px; font-weight: 700; }
.drop-subtitle { margin-top: 5px; color: var(--muted); font-size: 14px; }

.drop-zone img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  background: var(--white);
}

.drop-zone.has-image .drop-title,
.drop-zone.has-image .drop-subtitle { display: none; }

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #8d8c84;
  border-radius: 0;
  padding: 15px 16px;
  background: var(--white);
  color: var(--ink);
  line-height: 1.5;
}

textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.primary-button, .secondary-button, .download-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button {
  margin-top: 28px;
  background: var(--ink);
  color: var(--white);
  font-weight: 700;
}

.primary-button:hover, .download-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--accent);
}

.primary-button:disabled, .secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button, .download-button {
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
}

.download-button { background: var(--ink); color: var(--white); }
.form-note { margin: 12px 0 0; }

.consent-row {
  display: flex;
  max-width: 800px;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.consent-row input { margin-top: 3px; accent-color: var(--accent); }

.status-panel, .error-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 30px;
  border: 1px solid var(--line);
  padding: 26px;
  background: var(--white);
}

.status-panel[hidden], .error-panel[hidden] { display: none; }

.status-panel h2, .error-panel h2 { margin-bottom: 5px; font-size: 20px; }
.status-panel p, .error-panel p { margin-bottom: 0; color: var(--muted); }

.spinner {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.results {
  margin-top: 70px;
  padding-top: 28px;
  border-top: 1px solid var(--ink);
}

.results-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}

.results-heading h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 400;
  letter-spacing: -0.03em;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

figure { min-width: 0; margin: 0; }

figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chart-frame {
  display: grid;
  min-height: 380px;
  place-items: center;
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--white);
}

.chart-frame img {
  display: block;
  width: 100%;
  max-height: 680px;
  object-fit: contain;
}

.result-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.retry-form {
  margin-top: 42px;
  border-top: 1px solid var(--line);
  padding-top: 26px;
}

.retry-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  gap: 10px;
  margin-top: 9px;
}

.retry-row .secondary-button { min-width: 150px; }
#retry-note { margin: 9px 0 0; }

.text-button {
  margin-top: 30px;
  border: 0;
  padding: 0 0 3px;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.error-panel { color: var(--error); }
.error-panel .secondary-button { margin-left: auto; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 90px;
  border-top: 1px solid var(--ink);
  padding: 22px 0 40px;
  color: var(--muted);
  font-size: 13px;
}

footer p { margin: 0; }
.footer-links { display: flex; gap: 18px; }

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1180px); }
  .intro { padding: 50px 0 30px; }
  .email-gate { padding: 20px; }
  .email-row, .code-row { grid-template-columns: 1fr; }
  .workbench { padding: 20px; box-shadow: 5px 5px 0 var(--soft); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-frame { min-height: 260px; }
  .results-heading { align-items: start; flex-direction: column; }
  .retry-row { grid-template-columns: 1fr; }
  .retry-row .secondary-button { width: 100%; }
  footer, .footer-links { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .spinner { animation-duration: 1.8s; }
}
