:root {
  --navy: #0b2e4f;
  --navy-dark: #071f38;
  --blue: #1a73c1;
  --blue-light: #e8f1fb;
  --green: #1a8a5a;
  --amber: #b8860b;
  --red: #c0392b;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-300: #d3d8de;
  --gray-500: #7c8592;
  --gray-700: #3d4451;
  --text: #1c232b;
  --radius: 8px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--gray-50);
}

a { color: var(--blue); }

/* ---------- Top bar (test-taking) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: 10px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; }
.topbar .section-name { font-size: .95rem; opacity: .9; }
.topbar .timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem; font-weight: 700;
  background: rgba(255,255,255,.12);
  padding: 4px 12px; border-radius: 6px;
}
.topbar .timer.low { background: var(--red); }

/* ---------- Generic layout helpers ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 80px; }
.card {
  background: #fff; border: 1px solid var(--gray-100); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.center-card { max-width: 480px; margin: 60px auto; }
h1, h2, h3 { line-height: 1.3; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
.muted { color: var(--gray-500); }
.small { font-size: .875rem; }

/* ---------- Buttons / forms ---------- */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 6px; padding: 10px 18px;
  font-size: .95rem; font-weight: 600; transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--text); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .9rem; }
input[type=text], input[type=email], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 160px; line-height: 1.55; }
.error-box {
  background: #fdecea; border: 1px solid #f5c6c0; color: var(--red);
  padding: 10px 14px; border-radius: 6px; margin: 12px 0; font-size: .9rem;
}
.hint { color: var(--gray-500); font-size: .82rem; margin-top: 4px; }

/* ---------- Question navigator ---------- */
.qnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.qnav button {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--gray-300);
  background: #fff; font-size: .85rem; font-weight: 600; color: var(--gray-700);
}
.qnav button.answered { background: var(--blue-light); border-color: var(--blue); color: var(--blue); }
.qnav button.current { outline: 2px solid var(--navy); outline-offset: 1px; }

/* ---------- Reading split view ---------- */
.split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--gray-100); border-radius: var(--radius); overflow: hidden;
  background: #fff;
}
.split-pane { padding: 20px; max-height: 65vh; overflow-y: auto; }
.split-pane.left { border-right: 1px solid var(--gray-100); background: var(--gray-50); }
.passage-title { font-weight: 700; margin-bottom: 10px; }
.passage-body { white-space: pre-wrap; line-height: 1.7; font-size: .98rem; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .split-pane { max-height: none; }
}

/* ---------- Question blocks ---------- */
.question { padding: 14px 0; border-bottom: 1px solid var(--gray-100); }
.question:last-child { border-bottom: none; }
.q-number {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: .8rem; font-weight: 700; margin-right: 8px;
}
.q-text { font-weight: 500; margin: 6px 0 10px; }
.q-options label {
  font-weight: 400; display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; cursor: pointer;
}
.q-options input { margin-top: 3px; }
.q-hint { color: var(--gray-500); font-size: .82rem; }

/* ---------- Listening ---------- */
.audio-box { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.audio-box audio { width: 100%; margin-top: 10px; }
.replay-note { font-size: .82rem; opacity: .85; margin-top: 6px; }

/* ---------- Writing ---------- */
.wordcount { font-size: .85rem; color: var(--gray-500); margin-top: 6px; }
.wordcount.ok { color: var(--green); font-weight: 600; }
.prompt-box { background: var(--blue-light); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; white-space: pre-wrap; line-height: 1.6; }

/* ---------- Speaking ---------- */
.record-box { text-align: center; padding: 20px; }
.record-indicator {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--red);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.big-timer { font-size: 2.4rem; font-variant-numeric: tabular-nums; font-weight: 700; margin: 10px 0; }

/* ---------- Results ---------- */
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 16px 0; }
.score-tile { background: var(--gray-50); border: 1px solid var(--gray-100); border-radius: var(--radius); padding: 16px; text-align: center; }
.score-tile .band { font-size: 1.8rem; font-weight: 800; color: var(--navy); }
.score-tile .label { font-size: .82rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; }
.pending-pill { display: inline-block; background: #fff3cd; color: var(--amber); border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600; }
.review-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: .92rem; }
.review-row.correct .mark { color: var(--green); }
.review-row.incorrect .mark { color: var(--red); }
.review-row .mark { font-weight: 700; width: 20px; }

/* ---------- Teacher dashboard ---------- */
table.grid-table { width: 100%; border-collapse: collapse; }
table.grid-table th, table.grid-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gray-100); font-size: .92rem; }
table.grid-table th { color: var(--gray-500); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
.status-pill { padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.status-pill.submitted { background: #fff3cd; color: var(--amber); }
.status-pill.graded { background: #e2f4ea; color: var(--green); }
.status-pill.not_submitted { background: var(--gray-100); color: var(--gray-500); }
.rubric-row { display: grid; grid-template-columns: 1.4fr repeat(4, 90px); gap: 8px; align-items: center; margin: 6px 0; }
.rubric-row label { margin: 0; font-weight: 500; }
