:root {
  --bg: #f6f1e9;
  --surface: #fffdf9;
  --ink: #1f1a17;
  --muted: #6b625b;
  --line: #e4dbcf;
  --accent: #9c3d2e;
  --accent-ink: #ffffff;
  --mpesa: #2e8b3e;
  --error: #b42318;
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 16px 64px;
  display: grid;
  gap: 40px;
}

@media (min-width: 900px) {
  .page {
    grid-template-columns: 1.25fr 1fr;
    align-items: start;
    padding-top: 72px;
  }
  .order { position: sticky; top: 32px; }
}

/* Book */
.book { display: grid; gap: 28px; }

@media (min-width: 600px) {
  .book { grid-template-columns: 220px 1fr; align-items: start; }
}

.cover-wrap { margin: 0; justify-self: center; }

.cover {
  display: block;
  width: 220px;
  max-width: 60vw;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px 10px 10px 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 18px 40px -12px rgba(60,30,20,.35);
}

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

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.1;
}

.author { margin: 8px 0 0; color: var(--muted); }

.tagline {
  margin: 20px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  font-style: italic;
}

.description p { margin: 14px 0 0; color: #3a332e; }

/* Order card */
.order {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 10px 30px -18px rgba(60,30,20,.3);
}

.order h2 {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.label em { font-style: normal; font-weight: 400; color: var(--muted); }

.qty-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.price { text-align: right; }
.unit-price { font-family: var(--serif); font-size: 22px; font-weight: 600; }

.stepper {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 20px;
  color: var(--ink);
  cursor: pointer;
}
.stepper button:hover { background: var(--bg); }
.stepper input {
  width: 52px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  font: 600 16px var(--sans);
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.field { display: block; margin-bottom: 16px; }

.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: 16px var(--sans);
  color: var(--ink);
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[aria-invalid="true"] { border-color: var(--error); }

.hint { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.error { display: block; font-size: 13px; color: var(--error); margin: 4px 0 0; min-height: 0; }
.error:empty { display: none; }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 24px 0 16px;
  font-size: 16px;
}
.total-row strong { font-family: var(--serif); font-size: 28px; }

.submit {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--mpesa);
  color: var(--accent-ink);
  font: 600 17px var(--sans);
  cursor: pointer;
  transition: filter .15s;
}
.submit:hover { filter: brightness(1.08); }
.submit:disabled { opacity: .7; cursor: progress; }

.form-message { margin: 12px 0 0; font-size: 14px; color: var(--error); text-align: center; }
.form-message:empty { display: none; }

.result { text-align: center; padding: 12px 0; }
.result h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 22px; }
.result p { margin: 0 0 16px; color: #3a332e; }
.result[data-tone="good"] h3 { color: var(--mpesa); }
.result[data-tone="bad"] h3 { color: var(--error); }
.result .submit { margin-bottom: 12px; }

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--line);
  border-top-color: var(--mpesa);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

.link-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: 500 15px var(--sans);
  text-decoration: underline;
  cursor: pointer;
}
