:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1e2433;
  --muted: #6b7385;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --amber-soft: #fdf3e2;
  --border: #e6e9f0;
  --shadow: 0 6px 24px rgba(30, 36, 51, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

button, .btn, .mode-card, .btn-icon, .mic-btn {
  touch-action: manipulation;      /* remove 300ms tap delay / double-tap zoom */
  -webkit-user-select: none;
  user-select: none;
}

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

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport for mobile URL-bar/keyboard */
  display: flex;
  flex-direction: column;
}

.screen { flex: 1; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-big { width: 100%; padding: 17px; font-size: 18px; border-radius: 14px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid #f3c1c1; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-icon {
  background: transparent; border: none; font-size: 20px; cursor: pointer;
  color: var(--muted); padding: 6px 10px; border-radius: 10px;
}
.btn-icon:hover { background: var(--primary-soft); }

/* ---------- Home ---------- */
.home-screen { position: relative; background: linear-gradient(180deg, #eef0ff 0%, #f4f6fb 46%); }

.home-bg {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.home-bg::before, .home-bg::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55;
}
.home-bg::before {
  width: 380px; height: 380px; background: #c7d2fe; top: -120px; right: -120px;
}
.home-bg::after {
  width: 320px; height: 320px; background: #fbcfe8; bottom: 8%; left: -140px; opacity: .4;
}

.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.owner-chip {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; box-shadow: 0 2px 8px rgba(30,36,51,.06);
}

.home-wrap { position: relative; z-index: 1; padding: 6px 20px 40px; }
.hero { text-align: center; margin: 18px 0 24px; }
.hero-badge {
  display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--primary);
  background: #fff; border: 1px solid #dbe0ff; border-radius: 999px;
  padding: 7px 14px; margin-bottom: 16px; box-shadow: 0 2px 10px rgba(79,70,229,.08);
}
.hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -.03em; line-height: 1.08; font-weight: 800; }
.hero .grad {
  background: linear-gradient(90deg, #4f46e5, #7c3aed 55%, #db2777);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.tagline { color: var(--muted); margin: 0 auto; max-width: 380px; font-size: 15.5px; }

.hero-stats {
  display: flex; justify-content: center; gap: 10px; margin: 20px 0 4px; flex-wrap: wrap;
}
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 18px; min-width: 96px; box-shadow: 0 2px 10px rgba(30,36,51,.05);
  display: flex; flex-direction: column; align-items: center;
}
.stat-num { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; }

.features {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 24px;
}
.feature {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 13px 14px; display: flex; flex-direction: column; gap: 2px;
}
.feature span { font-size: 22px; }
.feature b { font-size: 13.5px; }
.feature i { font-size: 12px; color: var(--muted); font-style: normal; }
@media (max-width: 380px) { .features { grid-template-columns: 1fr; } }

.site-footer { text-align: center; margin-top: 34px; color: var(--muted); font-size: 14px; }
.site-footer p { margin: 4px 0; }
.foot-note { font-size: 12px; color: #9aa1b3; }

.banner {
  background: var(--amber-soft); color: #8a5a10;
  border: 1px solid #f0d9ac; border-radius: 12px;
  padding: 12px 14px; font-size: 14px; margin: 0 0 18px;
}
.banner code { background: #fff; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.banner-warn { background: #fde8e8; color: #9b1c1c; border-color: #f5c6c6; }
.banner-warn b { color: #7f1d1d; }

.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 12px; text-align: center; font-weight: 700; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.mode-card {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column;
  gap: 4px; transition: border-color .12s ease, transform .06s ease, box-shadow .15s ease;
}
.mode-card:hover { border-color: #c7d0f8; box-shadow: 0 8px 20px rgba(79, 70, 229, .10); transform: translateY(-2px); }
.mode-card:active { transform: scale(.98); }
.mode-card.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 8px 22px rgba(79, 70, 229, .18); }
.mode-emoji {
  font-size: 26px; width: 46px; height: 46px; border-radius: 12px;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.mode-card.selected .mode-emoji { background: #fff; }
.mode-name { font-weight: 700; font-size: 15px; }
.mode-desc { font-size: 12.5px; color: var(--muted); }
@media (max-width: 420px) {
  .mode-grid { grid-template-columns: 1fr; }
}

.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 14px; }

/* ---------- Prep (Part 2) ---------- */
.prep-wrap { padding: 24px 20px; text-align: center; }
.phase-tag {
  display: inline-block; background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  letter-spacing: .04em;
}
.prep-topic { font-size: 24px; margin: 16px 0; }
.prep-bullets { text-align: left; padding-left: 20px; color: var(--muted); font-size: 15px; }
.prep-bullets li { margin: 8px 0; }
.prep-timer { margin: 26px 0; }
.timer-ring {
  width: 150px; height: 150px; border-radius: 50%;
  margin: 0 auto; display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  border: 8px solid var(--primary); background: var(--primary-soft);
}
.prep-wrap .btn { margin-top: 12px; }

/* ---------- Session ---------- */
.session-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.session-left { display: flex; align-items: center; gap: 10px; }
.session-title { font-weight: 700; font-size: 15px; }
.status-pill {
  font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap;
}
.status-pill.speaking { background: var(--amber-soft); color: var(--amber); }
.status-pill.listening { background: var(--green-soft); color: var(--green); }

.transcript {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.msg { max-width: 86%; padding: 12px 14px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.msg .who { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; opacity: .7; }
.msg.examiner { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
.msg.user .who { color: #d8dcff; }
.msg.interim { align-self: flex-end; background: var(--primary-soft); color: var(--primary); font-style: italic; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 13px; text-align: center; }

.speech-timer {
  position: relative; height: 30px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; margin: 0 16px 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.speech-timer-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green-soft); transition: width .5s linear; }
.speech-timer span { position: relative; font-weight: 700; font-size: 14px; z-index: 1; }

.controls {
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--border);
}
.input-row { display: flex; gap: 8px; margin-bottom: 12px; }
.text-input {
  flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; outline: none;  /* 16px prevents iOS auto-zoom on focus */
}
.text-input:focus { border-color: var(--primary); }
.mic-row { display: flex; align-items: center; gap: 12px; }
.mic-btn {
  width: 68px; height: 68px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .06s ease, background .12s ease;
}
.mic-btn:active { transform: scale(.94); }
.mic-btn.listening { background: var(--red); animation: pulse 1.2s infinite; }
.mic-hint { flex: 1; color: var(--muted); font-size: 13px; }
.mode-toggle {
  background: var(--primary-soft); color: var(--primary); border: 1px solid #dbe0ff;
  border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 700;
  cursor: pointer; flex-shrink: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); }
  70% { box-shadow: 0 0 0 16px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ---------- Results ---------- */
.results-wrap { padding: 22px 16px 48px; }
.result-header { text-align: center; margin-bottom: 20px; }
.band-badge {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 15px; color: var(--muted);
}
.band-badge .band { font-size: 48px; font-weight: 800; color: var(--primary); line-height: 1; }
.result-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 17px; margin: 0 0 12px; }
.card h3 { font-size: 14.5px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }

.bar-row { margin: 10px 0; }
.bar-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.bar-label .val { font-weight: 700; }
.bar-track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s ease; }
.bar-fill.warn { background: var(--amber); }
.bar-fill.bad { background: var(--red); }

table.bands { width: 100%; border-collapse: collapse; }
table.bands th, table.bands td {
  text-align: left; padding: 9px 8px; font-size: 14px; border-bottom: 1px solid var(--border);
}
table.bands th { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
table.bands td.band-cell { font-weight: 800; color: var(--primary); }
table.bands tr:last-child td { border-bottom: none; }

.criterion-comment { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

.correction { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fbfcfe; }
.correction .orig { color: var(--red); font-size: 14.5px; }
.correction .fix { color: var(--green); font-size: 14.5px; margin-top: 6px; }
.correction .expl { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 999px; margin-bottom: 8px; letter-spacing: .03em;
}
.tag.grammar { background: var(--red-soft); color: var(--red); }
.tag.vocab { background: var(--amber-soft); color: var(--amber); }
.tag.nat { background: #e8f0fe; color: #1a56db; }
.tag.fluency { background: var(--green-soft); color: var(--green); }
.tag.lang { background: #f3e8ff; color: #7c3aed; }

.improved { border-left: 3px solid var(--green); background: var(--green-soft); border-radius: 0 12px 12px 0; padding: 12px 14px; margin-bottom: 12px; }
.improved .orig { color: var(--muted); font-size: 14px; }
.improved .imp { font-size: 14.5px; margin-top: 6px; }
.improved .note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.chip { display: inline-block; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 6px 12px; font-size: 13px; margin: 0 6px 6px 0; }
.chip.warn { background: var(--amber-soft); color: var(--amber); }

ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin: 7px 0; font-size: 14.5px; }

.vocab-row { border-bottom: 1px solid var(--border); padding: 10px 0; }
.vocab-row:last-child { border-bottom: none; }
.vocab-row .from { color: var(--red); font-weight: 600; }
.vocab-row .to { color: var(--green); font-weight: 600; }

.actions-row { display: flex; gap: 10px; margin: 18px 0; }
.actions-row .btn { flex: 1; }

.method-note { font-size: 12.5px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 12px; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1e2433; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; z-index: 100; max-width: 90%; text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.toast.error { background: var(--red); }

/* ---------- Mobile optimizations ---------- */
@media (max-width: 480px) {
  .hero h1 { font-size: 34px; }
  .home-wrap { padding: 4px 16px 32px; }
  .mode-grid { gap: 10px; }

  /* Bigger, thumb-friendly controls */
  .btn-big { padding: 18px; font-size: 18px; }
  .mic-btn { width: 76px; height: 76px; }
  .text-input { font-size: 16px; }

  /* Wider tap target for the end-test button */
  .btn-block { min-height: 52px; }

  /* Results: full-width action buttons, larger */
  .actions-row { flex-direction: column; }
  .actions-row .btn { min-height: 52px; font-size: 16px; }
  .card { padding: 16px 14px; }
}

/* iPhone notch / home indicator safe areas */
@supports (padding: max(0px)) {
  .controls { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .session-head { padding-top: max(12px, env(safe-area-inset-top)); }
}

/* ---------- Desktop / large screen optimizations ---------- */
@media (min-width: 820px) {
  .app { max-width: 1120px; }

  /* Home — fill the screen with a wide, centered layout */
  .topbar { max-width: 1040px; margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; }
  .home-wrap { max-width: 1040px; margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; }

  .hero { margin: 40px 0 36px; }
  .hero h1 { font-size: 60px; }
  .tagline { max-width: 560px; font-size: 17px; }

  .hero-stats { gap: 16px; }
  .stat { min-width: 140px; padding: 16px 22px; }
  .stat-num { font-size: 30px; }
  .stat-label { font-size: 12.5px; }

  .features { grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 10px 0 32px; }
  .feature { padding: 18px; }
  .feature span { font-size: 26px; }

  .mode-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .mode-card { padding: 20px 18px; }

  .section-label { margin-top: 8px; }

  /* Session — centered chat column (reads better than full-width lines) */
  #screen-session .session-head,
  #screen-session .transcript,
  #screen-session .speech-timer,
  #screen-session .controls {
    max-width: 800px; width: 100%; margin-left: auto; margin-right: auto;
  }

  /* Results — wide but readable */
  .results-wrap { max-width: 900px; margin-left: auto; margin-right: auto; }
  .result-header .band { font-size: 60px; }
}

/* Extra-large screens */
@media (min-width: 1300px) {
  .app { max-width: 1280px; }
  .topbar, .home-wrap { max-width: 1200px; }
  .mode-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Desktop: make the Full Mock Test a full-width "featured" card (3+2 -> clean rows) */
@media (min-width: 820px) {
  .mode-card[data-mode="mock"] {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .mode-card[data-mode="mock"] .mode-emoji { margin-bottom: 0; }
  .mode-card[data-mode="mock"] .mode-name { font-size: 17px; }
  .mode-card[data-mode="mock"] .mode-desc { margin-left: auto; font-size: 13.5px; }
}

/* =========================================================================
   Complete IELTS Platform — navigation, dashboard, test engine, modules
   ========================================================================= */

/* ---------- Global navigation ---------- */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(30,36,51,.05);
}
.topnav-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 18px;
}
.topnav-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.topnav-links { display: flex; gap: 2px; flex: 1; }
.topnav-links a {
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 9px; white-space: nowrap;
}
.topnav-links a:hover { background: var(--primary-soft); color: var(--primary); }
.topnav-links a.active { background: var(--primary-soft); color: var(--primary); }
.topnav .owner-chip { display: none; }

.bottomnav {
  display: none;
}

.app { padding-top: 58px; }

body.nav-hidden .topnav, body.nav-hidden .bottomnav { display: none !important; }
body.nav-hidden .app { padding-top: 0; }

@media (min-width: 900px) {
  .topnav .owner-chip { display: inline-block; margin-left: auto; }
}

@media (max-width: 899px) {
  .topnav-links { display: none; }
  .topnav-inner { justify-content: space-between; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--border);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1 0 auto; text-align: center; text-decoration: none; color: var(--muted);
    font-size: 10.5px; font-weight: 600; padding: 8px 10px 10px;
    display: flex; flex-direction: column; gap: 2px; align-items: center;
    min-width: 62px;
  }
  .bottomnav a span { font-size: 19px; line-height: 1; }
  .bottomnav a.active { color: var(--primary); }
  .app { padding-bottom: 62px; }
  body.nav-hidden .app { padding-bottom: 0; }
}

/* ---------- Shared module layout ---------- */
.module-wrap { padding: 24px 20px 48px; max-width: 900px; margin: 0 auto; width: 100%; }
.module-head { margin: 4px 0 20px; }
.module-head h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.sub { color: var(--muted); font-size: 14.5px; margin: 0; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.error-box {
  background: var(--red-soft); color: var(--red); border: 1px solid #f3c1c1;
  border-radius: 12px; padding: 16px; margin: 16px 0; font-size: 14px;
}
.warn-text { color: var(--amber); font-size: 13px; font-weight: 600; margin: 8px 0; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.card-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }

/* ---------- Segmented toggle ---------- */
.seg-toggle { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 18px; gap: 4px; }
.seg {
  border: none; background: transparent; padding: 10px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  touch-action: manipulation;
}
.seg.on { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(30,36,51,.1); }

/* ---------- Test cards / lists ---------- */
.test-list { display: flex; flex-direction: column; gap: 12px; }
.test-card {
  background: #fbfcfe; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.test-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.test-title { font-weight: 700; font-size: 15px; }
.test-meta { color: var(--muted); font-size: 12.5px; }

/* ---------- Dashboard ---------- */
.dash-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dash-hero h1 { font-size: 24px; margin: 0 0 4px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-band-card { text-align: center; }
.dash-band-num { font-size: 52px; font-weight: 800; color: var(--primary); line-height: 1; margin: 6px 0; }
.skill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.skill-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px;
  text-align: center; background: #fbfcfe;
}
.skill-emoji { font-size: 24px; }
.skill-name { font-size: 13px; font-weight: 700; margin: 4px 0; }
.skill-band { font-size: 22px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.qa-btn {
  border: 1px solid var(--border); background: #fbfcfe; border-radius: 12px;
  padding: 14px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  text-align: left; touch-action: manipulation;
}
.qa-btn:hover { border-color: #c7d0f8; }
.qa-primary { background: var(--primary); color: #fff; border-color: var(--primary); grid-column: 1 / -1; text-align: center; font-size: 16px; }

.activity-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-label { font-weight: 600; font-size: 14px; }
.activity-date { color: var(--muted); font-size: 12.5px; }
.activity-band { font-weight: 800; color: var(--primary); font-size: 16px; }

/* ---------- Test header / timer ---------- */
.test-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; margin-bottom: 16px; position: sticky; top: 66px; z-index: 10;
}
.test-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.timer-pill {
  background: var(--primary-soft); color: var(--primary); font-weight: 800;
  font-variant-numeric: tabular-nums; padding: 8px 14px; border-radius: 999px; font-size: 15px;
  white-space: nowrap;
}

/* ---------- Reading layout ---------- */
.reading-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.passage-pane, .question-pane {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}
.passage { margin-bottom: 18px; }
.passage h3 { font-size: 15px; margin: 0 0 8px; }
.passage p { font-size: 14px; line-height: 1.7; margin: 0 0 10px; color: #333a49; }
.question-view { min-height: 140px; }
.qnav-wrap { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.qnav-head { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.question-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.question-actions .btn { flex: 1; font-size: 13px; padding: 10px; }

@media (max-width: 820px) {
  .reading-layout { grid-template-columns: 1fr; }
  .test-header { top: 8px; }
}

/* ---------- Question rendering ---------- */
.question-block { margin-bottom: 6px; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-num { font-weight: 800; color: var(--primary); font-size: 14px; }
.q-text { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.q-prompt { font-size: 14px; color: #333a49; margin-bottom: 10px; }
.q-body { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; font-size: 14px;
}
.opt:hover { border-color: #c7d0f8; }
.opt input { accent-color: var(--primary); }
.opt-letter { font-weight: 700; color: var(--primary); min-width: 16px; }
.opt-text { flex: 1; }
.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-inline { flex: 1; min-width: 90px; justify-content: center; }
.match-row, .field-row { display: flex; align-items: center; gap: 10px; }
.match-label { flex: 1; font-size: 13.5px; }
.match-select { padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; background: #fff; }
.field-label { font-size: 13px; color: var(--muted); font-weight: 600; min-width: 90px; }

/* ---------- Question navigator ---------- */
.qnavigator { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.qnav-btn {
  position: relative; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  touch-action: manipulation;
}
.qnav-btn span { line-height: 1; }
.qnav-btn i { font-style: normal; font-size: 10px; height: 11px; color: var(--amber); }
.qnav-btn.answered { background: var(--green-soft); border-color: #b7e0c3; }
.qnav-btn.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.qnav-btn.reviewed { border-style: dashed; }

/* ---------- Result review ---------- */
.result-stats { display: flex; gap: 12px; margin-bottom: 16px; }
.rstat {
  flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; text-align: center;
}
.rstat-num { font-size: 26px; font-weight: 800; color: var(--primary); }
.rstat-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.review-row { border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.review-row.ok { border-left-color: var(--green); }
.review-row.bad { border-left-color: var(--red); }
.review-q { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.review-ans { font-size: 13.5px; margin: 3px 0; }
.review-ans span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Listening ---------- */
.listen-body { display: flex; flex-direction: column; gap: 16px; }
.listen-part { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.listen-part-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.listen-controls { display: flex; gap: 8px; }
.transcript-box {
  background: var(--bg); border-radius: 10px; padding: 12px; font-size: 13px;
  line-height: 1.6; color: #333a49; margin-bottom: 12px; max-height: 260px; overflow-y: auto;
}
.listen-questions { display: flex; flex-direction: column; gap: 14px; }
.listen-q { border-top: 1px solid var(--border); padding-top: 14px; }

/* ---------- Writing ---------- */
.writing-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.writing-prompt h3, .writing-editor h3 { margin-top: 0; }
.editor-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.word-count { font-weight: 700; color: var(--primary); }
.writing-textarea {
  width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; font-size: 15px; line-height: 1.6; resize: vertical; font-family: inherit;
  outline: none;
}
.writing-textarea:focus { border-color: var(--primary); }
.chart-box { margin-top: 14px; }
.draft-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; background: var(--amber-soft); border-color: #f0d9ac; }
@media (max-width: 820px) { .writing-layout { grid-template-columns: 1fr; } }

/* ---------- Dialog ---------- */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(20,24,36,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog { background: #fff; border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialog h3 { margin: 0 0 10px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }
.dialog-actions .btn { flex: 1; }

/* ---------- Mock test ---------- */
.mock-setup .field-row { margin-bottom: 16px; }
.mock-progress { margin-bottom: 20px; }
.progress-track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.progress-steps { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.step { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.step.done { color: var(--green); }
.step.now { color: var(--primary); background: var(--primary-soft); }

/* ---------- Progression chart ---------- */
.prog-chart { display: flex; align-items: flex-end; gap: 14px; height: 240px; padding: 10px 4px 0; }
.prog-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 40px; }
.prog-val { font-size: 13px; font-weight: 800; color: var(--primary); }
.prog-bar { width: 100%; max-width: 60px; background: linear-gradient(180deg, var(--primary), #8b7cf6); border-radius: 8px 8px 0 0; }
.prog-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.skill-prog-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.skill-prog-row:last-child { border-bottom: none; }
.skill-prog-name { font-weight: 600; font-size: 14px; }
.skill-prog-vals { color: var(--primary); font-weight: 700; font-size: 13.5px; }

/* ---------- Resources ---------- */
.resource-list { display: flex; flex-direction: column; }
.resource-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}
.resource-link:last-child { border-bottom: none; }
.resource-link:hover .resource-name { color: var(--primary); }
.resource-arrow { color: var(--muted); }

/* ---------- Responsive (smaller screens) ---------- */
@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .skill-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .result-stats { flex-direction: row; flex-wrap: wrap; }
  .module-head h1 { font-size: 22px; }
}

/* ---------- Auth / account ---------- */
.nav-auth-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 700;
  cursor: pointer; flex-shrink: 0; touch-action: manipulation;
}
.nav-auth-btn:hover { border-color: #c7d0f8; color: var(--primary); }
.nav-auth-btn.signed-in { background: var(--green-soft); border-color: #b7e0c3; color: var(--green); }
.nav-auth-btn #nav-auth-status { font-size: 12px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 899px) {
  .nav-auth-btn { order: 2; }
  .nav-auth-btn #nav-auth-status { display: none; }
}

.auth-dialog { max-width: 400px; }
.auth-divider {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  font-size: 12px; margin: 16px 0; text-transform: uppercase; letter-spacing: .05em;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-dialog .field-label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 2px 0 4px; }

/* ---------- Login / Signup screen ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(160deg, #eef0ff 0%, #f4f6fb 45%, #fdf0f7 100%);
}
.login-card {
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 28px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(30, 36, 51, .12);
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.login-brand h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.login-brand .brand-logo { width: 40px; height: 40px; }
.login-avatar {
  width: 64px; height: 64px; border-radius: 50%; margin: 16px auto 8px;
  background: var(--primary-soft); color: var(--primary); font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.login-card h2 { text-align: center; margin: 6px 0 4px; }
.login-tabs { width: 100%; margin: 14px 0 18px; }
.login-tabs .seg { flex: 1; text-align: center; }
.login-card form .field-label { display: block; margin: 10px 0 4px; }
.login-card form .text-input { width: 100%; }
.pw-row { display: flex; gap: 8px; }
.pw-row .text-input { flex: 1; }
.login-msg { min-height: 20px; font-size: 13.5px; margin: 10px 0; text-align: center; }
.login-msg.err { color: var(--red); }
.login-msg.ok { color: var(--green); }
.danger-text { color: var(--red) !important; }
.login-card .btn-block { margin-top: 8px; }
