:root {
  --paper: #f7f1e3;
  --paper-edge: #efe7d3;
  --ink: #1f1b16;
  --ink-soft: #4a423a;
  --rule-red: #c0392b;
  --rule-blue: #9fb0c3;
  --stamp: #1f6f54;
  --accent: #2c5f8a;
  --bar-bg: #e3d9c2;
  --shadow: rgba(31, 27, 22, 0.18);

  --serif-body: "Newsreader", Georgia, "Times New Roman", serif;
  --serif-display: "Libre Caslon Display", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;
  --hand: "Caveat", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, #fbf6ea 0%, var(--paper) 55%, var(--paper-edge) 100%);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.sheet {
  max-width: 820px;
  margin: 2.5rem auto;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-left: 3px double var(--rule-red);
  box-shadow: 0 14px 40px var(--shadow);
  padding: 3rem 3rem 3.5rem 3.75rem;
  position: relative;
}

/* red margin rule */
.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.5rem;
  width: 1px;
  background: rgba(192, 57, 43, 0.35);
}

@media (max-width: 640px) {
  .sheet { margin: 0; padding: 1.75rem 1.25rem 2.5rem 2rem; border-left-width: 2px; }
  .sheet::before { left: 1.1rem; }
  body { font-size: 17px; }
}

.label {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

h1, h2, h3 { font-family: var(--serif-display); font-weight: 400; line-height: 1.15; }

h1 { font-size: 2.6rem; margin: 0.2rem 0 0.4rem; letter-spacing: 0.01em; }
@media (max-width: 640px) { h1 { font-size: 2rem; } }

.subtitle { font-style: italic; color: var(--ink-soft); margin: 0 0 1.5rem; }

hr.rule {
  border: none;
  border-top: 1px solid rgba(31, 27, 22, 0.2);
  margin: 1.75rem 0;
}

.hand { font-family: var(--hand); color: var(--rule-red); font-size: 1.45rem; line-height: 1.2; }

button {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.82rem;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 0.85rem 1.6rem;
  border-radius: 2px;
  transition: transform 0.08s ease, background 0.15s ease;
}
button:hover { background: #000; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
button.secondary:hover { background: var(--ink); color: var(--paper); }

/* ---------- intro ---------- */
.intro ul { color: var(--ink-soft); }
.intro li { margin-bottom: 0.4rem; }
.meta-line { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- questions ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.25rem 0 1rem;
}
.section-head h2 { margin: 0; }
.section-head .label { white-space: nowrap; }

.q { margin: 1.6rem 0 2rem; }
.q .qnum {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--rule-red);
  letter-spacing: 0.1em;
}
.q .qtext { margin: 0.3rem 0 0.9rem; }
.q .marks { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft); }

.opts { list-style: none; margin: 0; padding: 0; }
.opts li { margin: 0.45rem 0; }
.opts label {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(31, 27, 22, 0.18);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.opts label:hover { background: rgba(192, 57, 43, 0.05); }
.opts input { margin-top: 0.35rem; accent-color: var(--rule-red); }
.opts .optkey { font-family: var(--mono); font-weight: 700; }

.opts label.correct { border-color: var(--stamp); background: rgba(31, 111, 84, 0.1); }
.opts label.wrong   { border-color: var(--rule-red); background: rgba(192, 57, 43, 0.1); }

.why {
  font-family: var(--hand);
  color: var(--rule-red);
  font-size: 1.25rem;
  line-height: 1.25;
  margin: 0.5rem 0 0;
  padding-left: 0.4rem;
}

textarea {
  width: 100%;
  min-height: 8.5rem;
  resize: vertical;
  font-family: var(--serif-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(31, 27, 22, 0.25);
  border-radius: 3px;
  padding: 0.8rem;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 1.49rem,
    rgba(159, 176, 195, 0.35) 1.5rem
  );
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.counter {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: right;
  margin-top: 0.3rem;
}
.counter.warn { color: var(--rule-red); font-weight: 700; }

.submit-row { margin-top: 2.5rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* ---------- loading ---------- */
.loading { display: flex; align-items: center; gap: 0.9rem; color: var(--ink-soft); }
.spinner {
  width: 1.1rem; height: 1.1rem;
  border: 2px solid rgba(31, 27, 22, 0.25);
  border-top-color: var(--rule-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- results ---------- */
.stamp {
  display: inline-block;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 1rem;
  color: var(--stamp);
  border: 3px solid var(--stamp);
  border-radius: 4px;
  padding: 0.5rem 1.1rem;
  transform: rotate(-4deg);
  box-shadow: inset 0 0 0 1px rgba(31, 111, 84, 0.3);
  margin: 0.5rem 0 1.5rem;
}

.score-big {
  font-family: var(--serif-display);
  font-size: 2.2rem;
}
.score-big .slash { color: var(--ink-soft); }
.score-sub { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); }

.axes { margin: 1.5rem 0; }
.axis { margin: 0.9rem 0; }
.axis .axis-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.05em;
}
.axis .track {
  height: 0.7rem;
  background: var(--bar-bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.25rem;
}
.axis .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--stamp));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.axis .note { font-style: italic; color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.25rem; }

.fr-result { margin: 1.4rem 0; padding-bottom: 1.2rem; border-bottom: 1px dotted rgba(31,27,22,0.25); }
.fr-result .fr-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
}
.fr-result .fr-q { font-style: italic; color: var(--ink-soft); font-size: 0.95rem; }
.fr-result .fr-score { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.fr-result .fr-feedback { font-family: var(--hand); color: var(--rule-red); font-size: 1.3rem; line-height: 1.3; margin-top: 0.4rem; }
.fr-result .fr-answer {
  font-size: 0.92rem; color: var(--ink-soft);
  background: rgba(159,176,195,0.12); border-left: 2px solid var(--rule-blue);
  padding: 0.5rem 0.75rem; margin-top: 0.6rem; white-space: pre-wrap;
}

.gaps { background: rgba(192, 57, 43, 0.06); border-left: 3px solid var(--rule-red); padding: 0.8rem 1.1rem; margin: 1.4rem 0; }
.gaps h3 { margin: 0 0 0.5rem; }
.gaps ul { margin: 0; padding-left: 1.2rem; }
.gaps li { margin: 0.3rem 0; }

.banner {
  border: 1px solid var(--rule-red);
  background: rgba(192, 57, 43, 0.08);
  border-radius: 3px;
  padding: 0.9rem 1.1rem;
  margin: 1.2rem 0;
  font-size: 0.95rem;
}
.banner strong { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; }

.hidden { display: none !important; }

.foot { margin-top: 2.5rem; font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); text-align: center; letter-spacing: 0.05em; }
