/* PrepEng — shared design system. One stylesheet, no build step. */

:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e4e7ef;
  --text: #1a1f2e;
  --text-dim: #5a6275;
  --text-faint: #8b92a5;
  --primary: #3d5afe;
  --primary-dark: #2a3eb1;
  --primary-soft: #eaeeff;
  --ielts: #d0312d;
  --toefl: #1a73e8;
  --success: #1a8754;
  --success-soft: #e7f5ee;
  --warn: #b7791f;
  --warn-soft: #fbf3e0;
  --danger: #c0392b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 25, 45, 0.04), 0 4px 16px rgba(20, 25, 45, 0.06);
  --shadow-lg: 0 8px 40px rgba(20, 25, 45, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.center { text-align: center; }

/* Layout ------------------------------------------------------------ */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* Header ------------------------------------------------------------ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--primary); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }

/* Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Cards ------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-pad-lg { padding: 28px; }

/* Badges ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.badge-paid { background: var(--success-soft); color: var(--success); }
.badge-free { background: var(--warn-soft); color: var(--warn); }
.badge-ielts { background: #fdecec; color: var(--ielts); }
.badge-toefl { background: #e8f0fe; color: var(--toefl); }

/* Forms ------------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
input[type="email"], input[type="password"], input[type="text"], textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field + .field { margin-top: 16px; }

/* Auth card --------------------------------------------------------- */
.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card { width: 100%; max-width: 400px; }

/* Alerts ------------------------------------------------------------ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert-error { background: #fcebea; color: var(--danger); border-color: #f5c6c2; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bfe3cf; }
.hidden { display: none !important; }

/* Dashboard widgets ------------------------------------------------- */
.stat { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { font-size: 0.8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 28px 12px;
}

/* Hero (landing) ---------------------------------------------------- */
.hero { padding: 72px 0 56px; text-align: center; }
.hero h1 { font-size: 2.8rem; max-width: 16ch; margin: 0 auto 0.3em; }
.hero p.lead { font-size: 1.2rem; color: var(--text-dim); max-width: 52ch; margin: 0 auto 28px; }
.hero .cta-row { justify-content: center; }

.feature h3 { display: flex; align-items: center; gap: 8px; }
.section { padding: 40px 0; }
.section > h2 { margin-bottom: 16px; }

/* Spec table (marketing exam pages) --------------------------------- */
.spec-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.spec-table th, .spec-table td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.spec-table thead th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); border-bottom: 2px solid var(--border);
}
.spec-table tbody th { font-weight: 700; white-space: nowrap; }
.spec-table tr:last-child td, .spec-table tr:last-child th { border-bottom: none; }
.spec-wrap { overflow-x: auto; }

footer.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 28px 0;
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* Practice picker ---------------------------------------------------- */
.test-card { display: flex; flex-direction: column; gap: 12px; }
.test-card .test-meta { color: var(--text-faint); font-size: 0.85rem; }
.test-card h3 { margin: 0; }
.practice-section-head { margin: 28px 0 4px; }

/* Test runner -------------------------------------------------------- */
.runner-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.runner-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
}
.runner-title { font-weight: 600; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
}
.timer.warn { background: var(--warn-soft); color: var(--warn); }
.timer.danger { background: #fcebea; color: var(--danger); }

.section-block { margin-bottom: 28px; }
.section-block > .section-head {
  border-left: 3px solid var(--primary);
  padding: 4px 0 4px 14px;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0 0 2px; }
.section-audio { width: 100%; max-width: 480px; margin-top: 10px; }

/* Reading passage (runner) ------------------------------------------ */
.reading-passage {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  margin-bottom: 18px;
  max-height: 460px;
  overflow-y: auto;
  line-height: 1.7;
}
.passage-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 10px;
}
.reading-passage p { margin: 0 0 1em; }
.reading-passage p:last-child { margin-bottom: 0; }

/* Listening clip (runner) ------------------------------------------- */
.listening-clip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.listening-clip .passage-label { margin-bottom: 8px; }

.question { padding: 18px 0; border-bottom: 1px solid var(--border); }
.question:last-child { border-bottom: none; }
.question .q-prompt { font-weight: 600; margin-bottom: 12px; display: flex; gap: 10px; }
.q-num {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; font-size: 0.85rem; font-weight: 700;
}
.q-hint { font-size: 0.85rem; color: var(--text-faint); font-weight: 400; }

.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 400; transition: border-color 0.12s, background 0.12s;
}
.option:hover { border-color: var(--primary); background: var(--primary-soft); }
.option input { margin: 0; accent-color: var(--primary); }
.option.checked { border-color: var(--primary); background: var(--primary-soft); }
.gap-input { max-width: 320px; }

/* Writing task (runner) --------------------------------------------- */
.source-material {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
  max-height: 280px;
  overflow-y: auto;
}
.source-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 6px;
}
.source-body { white-space: pre-wrap; color: var(--text-dim); font-size: 0.95rem; }
.essay-input { min-height: 280px; resize: vertical; line-height: 1.6; }
.word-counter {
  margin-top: 8px; font-size: 0.85rem; font-weight: 600;
  color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.word-counter.under { color: var(--warn); }
.word-counter.met { color: var(--success); }

/* Speaking task recorder -------------------------------------------- */
.recorder {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.recorder .rec-hint { margin: 0; font-size: 0.9rem; }
.rec-row { display: flex; align-items: center; gap: 12px; }
.rec-status { font-weight: 600; }
.rec-status.prep { color: var(--warn); }
.rec-status.rec { color: var(--danger); }
.rec-status.done { color: var(--success); }
.rec-clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.recorder audio { width: 100%; max-width: 360px; }

.runner-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }

/* Results ------------------------------------------------------------ */
.score-hero { text-align: center; padding: 28px 20px; }
.score-hero .big { font-size: 3rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.score-hero .scale { color: var(--text-faint); margin-top: 6px; }
.skill-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.skill-tile { text-align: center; }
.skill-tile .skill-score { font-size: 1.6rem; font-weight: 700; }
.pending-note { display: inline-flex; align-items: center; gap: 8px; }

/* AI writing feedback report ----------------------------------------- */
.badge-ai { background: var(--primary-soft); color: var(--primary-dark); }
.feedback-section { margin-top: 8px; }
.feedback-section > h2 { margin-bottom: 16px; }
.feedback-card + .feedback-card { margin-top: 16px; }
.feedback-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.feedback-head h3 { margin: 0; }
.feedback-prompt { font-size: 0.95rem; margin: 8px 0 16px; }
.feedback-audio { width: 100%; margin: 12px 0 4px; }

.criteria { display: flex; flex-direction: column; gap: 14px; margin-bottom: 4px; }
.criterion-head { display: flex; justify-content: space-between; align-items: baseline; }
.criterion-name { font-weight: 600; font-size: 0.95rem; }
.criterion-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.criterion-bar {
  height: 6px; background: var(--surface-2); border-radius: 999px;
  overflow: hidden; margin-top: 6px;
}
.criterion-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.criterion-fb { font-size: 0.88rem; margin: 6px 0 0; }

.feedback-block { margin-top: 16px; }
.feedback-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 6px;
}
.feedback-list { margin: 0; padding-left: 20px; }
.feedback-list li { margin-bottom: 4px; }

.feedback-fold { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.feedback-fold summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; color: var(--primary); }
.feedback-fold summary:hover { text-decoration: underline; }

/* Per-question review ------------------------------------------------ */
.review-card > summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; }
.review-card > summary:hover { color: var(--primary); }
.review-list { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.review-q {
  border: 1px solid var(--border); border-left-width: 3px;
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.review-q.correct { border-left-color: var(--success); }
.review-q.wrong { border-left-color: var(--danger); }
.review-head { display: flex; gap: 10px; align-items: baseline; }
.review-num {
  flex: 0 0 auto; min-width: 24px; height: 24px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; color: var(--text-dim);
}
.review-prompt { flex: 1; font-weight: 600; }
.review-mark { flex: 0 0 auto; font-weight: 700; font-size: 1.1rem; }
.review-mark.ok { color: var(--success); }
.review-mark.no { color: var(--danger); }
.review-answers { margin: 8px 0 0 34px; font-size: 0.92rem; display: flex; flex-direction: column; gap: 2px; }
.review-label { color: var(--text-faint); }
.review-good { color: var(--success); font-weight: 600; }
.review-bad { color: var(--danger); }
.review-explain { margin: 8px 0 0 34px; font-size: 0.9rem; }
.feedback-text {
  white-space: pre-wrap; margin-top: 10px; padding: 14px 16px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 0.95rem; line-height: 1.6; color: var(--text-dim);
}
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  display: inline-block; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .hero h1 { font-size: 2.1rem; }
  .nav a.hide-sm { display: none; }
}
