:root {
  --red: #d3222a;
  --ink: #1c2430;
  --muted: #5b6775;
  --line: #e2e6ec;
  --bg: #f4f6f9;
  --ok: #1f8a4c;
  --bad: #c0392b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

/* topbar */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 20px;
}
.brand .badge {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.brand small { display: block; color: var(--muted); }

.container { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(20, 30, 45, .04);
}

/* start */
.start h1 { margin: 0 0 6px; }
.lead { color: var(--muted); margin-top: 0; }
.facts { padding-left: 18px; color: var(--muted); }
.facts strong { color: var(--ink); }
#startForm { margin-top: 18px; display: grid; gap: 14px; }
#startForm label { display: grid; gap: 6px; font-weight: 600; }
#startForm input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.opt { color: var(--muted); font-weight: 400; }

button {
  font: inherit;
  cursor: pointer;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
button:hover { filter: brightness(.97); }

/* sections */
.section-title {
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--red);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.pts { font-size: .7em; color: var(--muted); font-weight: 600; }

.exercise { margin-bottom: 22px; }
.exercise:last-child { margin-bottom: 0; }
.ex-instructions { font-weight: 600; margin: 0 0 8px; }
.ex-example { color: var(--muted); margin: 4px 0 10px; font-style: italic; }
.note { color: var(--muted); font-size: .92em; }

.wordbox {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 8px 0 12px;
}
.wordbox span { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: .92em; }

.items { padding-left: 26px; margin: 0; }
.item { margin-bottom: 12px; }
.q { display: inline; }

.options { display: inline-flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 4px; vertical-align: middle; }
.opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.opt:hover { background: var(--bg); }
.syl-options { font-size: 1.05em; }
.syl-options .opt { font-family: "SFMono-Regular", Menlo, Consolas, monospace; }

.dropdown {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  margin: 0 2px;
}

/* passage */
.passage {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.passage-heading { margin: 0 0 6px; color: var(--red); }
.passage-intro { margin: 0 0 12px; font-weight: 600; }
.passage-entry { margin: 0 0 10px; }

/* audio */
.audio { margin: 6px 0 12px; }
.audio audio { width: 100%; }

/* writing / speaking */
.writing { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.speak-title { margin: 16px 0 6px; }
.speak-list { margin: 0; }

/* submit */
.submit-bar { text-align: center; }
.submit-bar .primary { margin-top: 6px; font-size: 1.05em; }

/* result */
.result-head .headline { color: var(--muted); margin: 0 0 4px; }
.score { display: flex; align-items: baseline; gap: 14px; margin: 6px 0 14px; }
.score-big { font-size: 2.6em; font-weight: 800; color: var(--red); }
.score-pct { font-size: 1.4em; color: var(--muted); }
.breakdown { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.breakdown li { padding: 8px 12px; background: var(--bg); border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.review { width: 100%; border-collapse: collapse; font-size: .94em; }
.review th, .review td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.review tr.ok td:last-child { color: var(--ok); font-weight: 700; }
.review tr.bad td:last-child { color: var(--bad); font-weight: 700; }
.review tr.bad td:nth-child(2) { color: var(--bad); }

#writingFeedback .items { padding-left: 20px; }
#writingFeedback .item { margin-bottom: 12px; }
.fb { color: var(--ink); }

.foot { text-align: center; color: var(--muted); padding: 0 20px 30px; }

@media (max-width: 560px) {
  .card { padding: 18px 16px; }
  .items { padding-left: 20px; }
}

@media print {
  .topbar, .actions, .foot { display: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
