:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #5b6472;
  --brand: #1f4e8c;
  --brand-dark: #173a68;
  --accent: #c8841f;
  --good: #2e7d32;
  --bad: #b3261e;
  --border: #e2ded5;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(31, 41, 51, 0.10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

body, button, input, select, textarea { font-family: inherit; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--brand); color: #fff; padding: 8px 12px; z-index: 50;
}
.skip-link:focus { left: 0; }

/* Top bar */
.topbar {
  background: var(--brand);
  color: #fff;
  position: sticky; top: 0; z-index: 40;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1000px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; font-size: 20px;
}
.brand-text { font-weight: 700; font-size: 18px; }
.brand-ar { font-size: 14px; opacity: .85; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: #fff; text-decoration: none; padding: 7px 11px; border-radius: 8px; font-size: 15px;
}
.nav a:hover, .nav a[aria-current="page"] { background: rgba(255,255,255,.18); }
.nav-toggle { display: none; background: rgba(255,255,255,.16); color:#fff; border:0; border-radius:8px; padding:8px 12px; }

/* Layout */
.container { max-width: 1000px; margin: 0 auto; padding: 20px 16px 60px; min-height: 60vh; }
.footer { border-top: 1px solid var(--border); padding: 18px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}

h1 { font-size: 1.9rem; margin: 0 0 6px; }
h2 { font-size: 1.35rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 1.05rem; }

.ar { direction: rtl; text-align: right; font-size: 1.02rem; color: #3a3f47; }
.ar-block { background: #f3efe6; border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px;
  border-radius: 999px; background: #e8eef7; color: var(--brand); letter-spacing: .03em;
}
.badge.ar { background: #f5ecdd; color: #8a5a12; }
.badge.math { background: #e5f2e8; color: #256b33; }
.badge.english { background: #eef0f7; color: #3a4a8c; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.secondary:hover { background: #eef4fb; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.speak {
  background: #fff; color: var(--brand); border: 1px solid var(--border); padding: 5px 10px; font-size: 13px;
}
.btn.speak:hover { background: #eef4fb; }
.btn.speak.ar { color: #8a5a12; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Grids */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Skill tiles */
.tile { display: block; text-decoration: none; color: var(--ink); }
.tile h3 { margin-bottom: 2px; }

/* Lesson list */
.lesson-list { list-style: none; padding: 0; margin: 0; }
.lesson-list li { border-bottom: 1px solid var(--border); }
.lesson-list li:last-child { border-bottom: 0; }
.lesson-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 8px;
  text-decoration: none; color: var(--ink); border-radius: 8px;
}
.lesson-link:hover { background: #f0f4f9; }
.lesson-check { color: var(--good); font-weight: 700; min-width: 18px; text-align: center; }
.lesson-title { flex: 1; }

/* Choices */
.choices { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.choice {
  text-align: left; background: #fff; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font-size: 16px; width: 100%;
}
.choice:hover { border-color: var(--brand); }
.choice.selected { border-color: var(--brand); background: #eef4fb; }
.choice.correct { border-color: var(--good); background: #e7f4e8; }
.choice.wrong { border-color: var(--bad); background: #fbeaea; }
.choice:disabled { cursor: default; }

.feedback { padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.feedback.ok { background: #e7f4e8; border: 1px solid var(--good); }
.feedback.no { background: #fbeaea; border: 1px solid var(--bad); }

/* Flashcard */
.flashcard {
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 28px 22px;
  text-align: center; cursor: pointer; min-height: 240px; display: flex;
  flex-direction: column; justify-content: center; background: var(--surface); box-shadow: var(--shadow);
}
.flashcard .word { font-size: 2rem; font-weight: 800; margin-bottom: 6px; }
.flashcard .pron { color: var(--muted); }
.flashcard .flip-hint { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* Progress bars */
.bar { background: #e8e4da; border-radius: 999px; height: 12px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.good > span { background: var(--good); }
.bar.warn > span { background: var(--accent); }

.stat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* Tables / summaries */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Placement */
.placement-progress { color: var(--muted); margin-bottom: 12px; }

/* Utility */
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }
.small { font-size: 14px; }
.rtl { direction: rtl; text-align: right; }

.tag {
  display: inline-block; background: #eef0f3; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; margin: 2px 3px 2px 0;
}

/* Timed mode */
.timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand); }
.timer.warn { color: var(--accent); }
.timer.danger { color: var(--bad); }

/* Responsive */
@media (max-width: 720px) {
  .nav-toggle { display: inline-block; }
  .nav { display: none; width: 100%; flex-direction: column; margin-left: 0; }
  .nav.open { display: flex; }
  .nav a { padding: 10px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat, .kv { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ---- Nida School additions (auth, teach-first home, driving) ---- */
.auth-form { max-width: 460px; margin: 30px auto; }
.auth-form-inner { display: grid; gap: 12px; }
.auth-form-inner .choice { width: 100%; }

.home-actions { display: grid; gap: 12px; margin-bottom: 16px; }
.action-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.action-card:hover { border-color: var(--brand); background: #f4f8fc; }
.action-num {
  min-width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}

.big-btn { font-size: 20px; padding: 16px 26px; min-width: 160px; }

@media (max-width: 720px) {
  .action-card { padding: 14px; }
  .action-num { min-width: 34px; height: 34px; font-size: 16px; }
}
