/* ═══════════════════════════════════════════════════════════════════════════
   GIT A/L MCQ  —  Stylesheet
   Font: Inter via Google Fonts (loaded in HTML)
═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --surface-sub:   #f1f5f9;

  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --text-1:        #0f172a;
  --text-2:        #334155;
  --text-3:        #64748b;

  --accent:        #4f46e5;
  --accent-dim:    #eef2ff;
  --accent-dark:   #4338ca;

  --green:         #059669;
  --green-dim:     #d1fae5;
  --green-text:    #065f46;

  --red:           #dc2626;
  --red-dim:       #fee2e2;
  --red-text:      #991b1b;

  --amber:         #d97706;
  --amber-dim:     #fef3c7;

  --nav-bg:        #0f172a;
  --nav-border:    #1e293b;

  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 8px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);

  --t: 140ms ease;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI",
               "Noto Sans Sinhala", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text-2);
  -webkit-font-smoothing: antialiased;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  letter-spacing: -0.01em;
}
.topbar h1:hover { color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 0.6rem; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255,255,255,.06);
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,.08);
}
.timer.low { color: #fbbf24; background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.2); }

.user-info { display: flex; align-items: center; gap: 0.5rem; }

.user-email {
  font-size: 0.78rem;
  color: #64748b;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout, .btn-admin {
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border: 1px solid #1e293b;
  border-radius: var(--r-sm);
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--t), border-color var(--t), background var(--t);
  display: inline-flex;
  align-items: center;
}
.btn-logout:hover, .btn-admin:hover {
  color: #e2e8f0;
  border-color: #334155;
  background: rgba(255,255,255,.05);
}

/* ── Page layout ─────────────────────────────────────────────────────────── */
main {
  max-width: 760px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 0.875rem;
  box-shadow: var(--shadow-xs);
}
.card > h2:first-child {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--r);
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: background var(--t), box-shadow var(--t), transform var(--t);
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dark); box-shadow: 0 2px 8px rgba(79,70,229,.35); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-strong);
}
.btn.outline:hover { background: var(--surface-sub); border-color: var(--border-strong); box-shadow: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Home — intro ────────────────────────────────────────────────────────── */
.intro-card p { margin: 0 0 0.5rem; font-size: 0.875rem; color: var(--text-2); }
.intro-card p b { color: var(--text-1); font-weight: 600; }
.intro-meta { font-size: 0.78rem; color: var(--text-3); margin: 0.6rem 0 1.1rem; }

/* ── Section label ───────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 1.75rem 0 0.65rem;
}

/* ── Paper grid ──────────────────────────────────────────────────────────── */
.paper-list {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.2rem;
  transition: box-shadow var(--t), border-color var(--t);
}
.paper-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.paper-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
}
.paper-card .meta {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 0.3rem;
}
.paper-card .best {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 0.85rem;
  min-height: 1.1em;
}
.paper-card .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Quiz header ─────────────────────────────────────────────────────────── */
.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 0.4rem;
}
.progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.topic-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--amber-dim);
  color: var(--amber);
  margin-bottom: 0.75rem;
}

.question {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.7;
  margin: 0 0 1.1rem;
  white-space: pre-wrap;
}
.question img { max-width: 100%; border-radius: var(--r); }

/* ── Answer options ──────────────────────────────────────────────────────── */
.options { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }

.option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.5;
}
.option:hover { border-color: var(--accent); background: var(--accent-dim); }

.option .num {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-sub);
  transition: background var(--t), border-color var(--t), color var(--t);
}

.option.selected                   { border-color: var(--accent); background: var(--accent-dim); }
.option.selected .num              { background: var(--accent); border-color: var(--accent); color: #fff; }

.option.correct                    { border-color: var(--green); background: var(--green-dim); }
.option.correct .num               { background: var(--green); border-color: var(--green); color: #fff; }

.option.wrong                      { border-color: var(--red); background: var(--red-dim); }
.option.wrong .num                 { background: var(--red); border-color: var(--red); color: #fff; }

.options.locked .option            { cursor: default; }
.options.locked .option:not(.correct):not(.wrong):not(.selected):hover {
  border-color: var(--border);
  background: var(--surface);
}

/* ── Explanation ─────────────────────────────────────────────────────────── */
.explanation {
  margin-top: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.65;
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Question palette ────────────────────────────────────────────────────── */
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.palette button {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-3);
  font-family: inherit;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.palette button.answered { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.palette button.current  { outline: 2px solid var(--accent); outline-offset: 2px; }
.palette button.correct  { background: var(--green-dim); border-color: var(--green); color: var(--green-text); }
.palette button.wrong    { background: var(--red-dim); border-color: var(--red); color: var(--red-text); }

/* ── Result screen ───────────────────────────────────────────────────────── */
.result-wrap { text-align: center; padding: 0.5rem 0 1.25rem; }
.result-wrap .paper-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
}
.result-score {
  font-size: 3.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-1);
  line-height: 1;
  margin-bottom: 0.2rem;
}
.result-pct {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 1.1rem;
  letter-spacing: -0.01em;
}
.result-chips { display: flex; gap: 0.45rem; justify-content: center; flex-wrap: wrap; }
.chip {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--surface-sub);
  color: var(--text-3);
  border: 1px solid var(--border);
}
.chip.pass { background: var(--green-dim); color: var(--green-text); border-color: var(--green); }
.chip.fail { background: var(--red-dim); color: var(--red-text); border-color: var(--red); }

/* ── Auth / login screen ─────────────────────────────────────────────────── */
.auth-card {
  max-width: 380px;
  margin: 5rem auto 2rem;
  text-align: center;
}
.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}
.auth-card p {
  font-size: 0.875rem;
  color: var(--text-3);
  margin: 0 0 1.5rem;
  line-height: 1.6;
}
.auth-btn { width: 100%; padding: 0.65rem 1rem; font-size: 0.9rem; }

/* ── Stats card (home page) ──────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.stat-box {
  flex: 1;
  min-width: 80px;
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.8rem 0.9rem;
  text-align: center;
}
.stat-box.stat-passed { background: var(--green-dim); border-color: var(--green); }
.stat-box.stat-failed { background: var(--red-dim);   border-color: var(--red);   }

.stat-num {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-box.stat-passed .stat-num { color: var(--green-text); }
.stat-box.stat-failed .stat-num { color: var(--red-text); }
.stat-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-top: 0.15rem;
}

/* ── History ─────────────────────────────────────────────────────────────── */
.history-details summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-3);
  user-select: none;
  padding: 0.25rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.history-details summary::before {
  content: "▶";
  font-size: 0.6rem;
  transition: transform var(--t);
  display: inline-block;
}
.history-details[open] summary::before { transform: rotate(90deg); }

.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.82rem;
}
.history-table th {
  text-align: left;
  padding: 0.4rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.history-table td {
  padding: 0.55rem 0.65rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--bg);
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface-sub); }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge-pass, .badge-fail {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-pass { background: var(--green-dim); color: var(--green-text); }
.badge-fail { background: var(--red-dim);   color: var(--red-text); }

/* ── Admin header additions ──────────────────────────────────────────────── */
.topbar-home { color: #94a3b8; text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.topbar-home:hover { color: #e2e8f0; }

.admin-badge {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(79,70,229,.25);
  color: #a5b4fc;
  border: 1px solid rgba(79,70,229,.4);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.45rem;
}

.table-scroll { overflow-x: auto; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 2.5rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.meta   { font-size: 0.8rem; color: var(--text-3); }

/* ── Language toggle ─────────────────────────────────────────────────────── */
.lang-toggle {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.lang-btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.lang-btn:hover { background: var(--surface-sub); color: var(--text-2); }
.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Landing page
═══════════════════════════════════════════════════════════════════════════ */
#landing { max-width: 860px; margin: 0 auto; padding: 0 1.25rem 3rem; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.landing-hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
}
.landing-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 1rem;
}
.landing-h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-1);
  line-height: 1.15;
  margin: 0 0 0.5rem;
}
.landing-h1-si {
  display: block;
  font-size: 0.65em;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 0.3rem;
}
.landing-desc {
  font-size: 1rem;
  color: var(--text-2);
  line-height: 1.7;
  max-width: 600px;
  margin: 1rem auto 1.75rem;
}
.landing-desc span[lang="si"] {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.9em;
  color: var(--text-3);
}
.landing-cta-row { display: flex; justify-content: center; }
.landing-cta-btn {
  font-size: 1rem;
  padding: 0.75rem 2rem;
  border-radius: var(--r-lg);
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
}
.landing-cta-btn:hover { box-shadow: 0 6px 18px rgba(79,70,229,.45); }

/* ── Stats strip ─────────────────────────────────────────────────────────── */
.landing-stats {
  display: flex;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: 0 0 2.5rem;
  background: var(--surface);
}
.lstat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.1rem 0.75rem;
  border-right: 1px solid var(--border);
}
.lstat:last-child { border-right: none; }
.lstat strong {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
}
.lstat span {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-top: 0.2rem;
  text-align: center;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.landing-section { margin-bottom: 2.5rem; }
.landing-sh {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  margin: 0 0 1rem;
}

/* ── Features grid ───────────────────────────────────────────────────────── */
.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
}
.lfeat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  transition: box-shadow var(--t), border-color var(--t);
}
.lfeat:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lfeat-icon { font-size: 1.5rem; margin-bottom: 0.6rem; }
.lfeat h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 0.35rem;
}
.lfeat p {
  font-size: 0.8rem;
  color: var(--text-3);
  margin: 0;
  line-height: 1.55;
}
.lfeat p span[lang="si"] { display: block; margin-top: 0.3rem; }

/* ── Units list ──────────────────────────────────────────────────────────── */
.landing-units {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.landing-units li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.landing-units li span[lang="si"] { color: var(--text-3); font-size: 0.82em; }
.unit-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: var(--r-sm);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Bottom CTA ──────────────────────────────────────────────────────────── */
.landing-bottom-cta {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2.5rem 1.5rem;
}
.landing-bottom-cta h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.landing-bottom-cta p {
  font-size: 0.875rem;
  color: var(--text-3);
  margin: 0 0 0.4rem;
}
.landing-bottom-cta .landing-cta-btn { margin-top: 1.25rem; }

/* ── Subject cards (landing) ─────────────────────────────────────────────── */
.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.subject-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.subject-info h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
}
.subject-info p {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.5;
}

.subject-badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.subject-badge-live {
  background: var(--green-dim);
  color: var(--green-text);
  border: 1px solid var(--green);
}

.coming-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.subject-soon {
  padding: 0.7rem 1rem;
  border-style: dashed;
  opacity: 0.7;
}
.subject-soon span {
  font-size: 0.82rem;
  color: var(--text-3);
}

/* ── Feedback button (topbar) ────────────────────────────────────────────── */
.btn-feedback {
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: 1px solid #1e293b;
  border-radius: var(--r-sm);
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.btn-feedback:hover { color: #e2e8f0; border-color: #334155; background: rgba(255,255,255,.05); }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
  animation: fadeIn 120ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 150ms ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.modal-close {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: none;
  background: var(--surface-sub);
  color: var(--text-3);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--t);
}
.modal-close:hover { background: var(--border); }

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-3);
  margin: 0 0 1rem;
}

/* ── Star rating ─────────────────────────────────────────────────────────── */
.star-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.star-btn {
  font-size: 1.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--border-strong);
  transition: color var(--t), transform var(--t);
  padding: 0;
  line-height: 1;
}
.star-btn:hover,
.star-btn.active { color: #f59e0b; }
.star-btn:hover  { transform: scale(1.15); }

/* ── Feedback textarea ───────────────────────────────────────────────────── */
.feedback-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 0.7rem 0.85rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-2);
  background: var(--surface);
  resize: vertical;
  min-height: 90px;
  transition: border-color var(--t);
  margin-bottom: 0.75rem;
}
.feedback-textarea:focus { outline: none; border-color: var(--accent); }

/* ── Feedback status message ─────────────────────────────────────────────── */
.feedback-status { font-size: 0.82rem; min-height: 1.2em; margin: 0 0 0.75rem; }
.feedback-status.success { color: var(--green); }
.feedback-status.error   { color: var(--red); }

/* ── Modal action row ────────────────────────────────────────────────────── */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ── Admin feedback stars ────────────────────────────────────────────────── */
.feedback-stars { color: #f59e0b; letter-spacing: 0.05em; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile & Touch Responsive
═══════════════════════════════════════════════════════════════════════════ */

/* ── Global touch improvements ───────────────────────────────────────────── */
button, a, .option, .lang-btn, .paper-card, .palette button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent horizontal body scroll */
html, body { overflow-x: hidden; }

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
/* Desktop: show label, hide icon */
.btn-icon { display: none; }

@media (max-width: 540px) {
  .topbar { padding: 0 0.875rem; height: 50px; }
  .topbar h1 { font-size: 0.85rem; white-space: nowrap; }
  .topbar-right { gap: 0.3rem; }

  /* Hide email, show only icon on small screens */
  .user-email  { display: none; }
  .btn-label   { display: none; }
  .btn-icon    { display: inline; font-size: 0.95rem; }

  .btn-admin   { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
  .btn-logout  { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
  .btn-feedback { padding: 0.25rem 0.55rem; }
}

/* ── Main container ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 0 0.875rem; margin: 0.875rem auto; }
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 1.1rem 1rem; border-radius: var(--r); }
}

/* ── Paper grid ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .paper-list {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.5rem;
  }
  .paper-card { padding: 0.9rem 1rem; }
  .paper-card h3 { font-size: 0.82rem; }
}
@media (max-width: 360px) {
  .paper-list { grid-template-columns: 1fr; }
}

/* ── Quiz ────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Quiz meta bar — let it wrap naturally */
  .quiz-meta { font-size: 0.72rem; flex-wrap: wrap; gap: 0.2rem; }

  /* Question text */
  .question { font-size: 0.975rem; }

  /* Options — bigger touch target */
  .option {
    padding: 0.875rem 0.875rem;
    min-height: 52px;
    gap: 0.65rem;
    font-size: 0.875rem;
  }
  .option .num {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.72rem;
  }

  /* Nav buttons — full-width row, each takes equal space */
  .nav {
    gap: 0.4rem;
    flex-wrap: nowrap;
  }
  .nav .btn {
    flex: 1;
    min-height: 46px;
    padding: 0.5rem 0.6rem;
    font-size: 0.82rem;
    justify-content: center;
  }

  /* Palette — slightly larger touch targets */
  .palette { gap: 0.35rem; }
  .palette button {
    width: 2.15rem;
    height: 2.15rem;
    font-size: 0.7rem;
    border-radius: var(--r-sm);
  }

  /* Explanation */
  .explanation { font-size: 0.82rem; padding: 0.75rem 0.875rem; }
}

@media (max-width: 360px) {
  .nav .btn { font-size: 0.75rem; padding: 0.5rem 0.4rem; }
  .palette button { width: 1.95rem; height: 1.95rem; }
}

/* ── Result screen ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .result-score { font-size: 3rem; }
  .result-pct   { font-size: 1rem; }
  .result-chips { gap: 0.35rem; }
  .chip         { font-size: 0.75rem; padding: 0.2rem 0.6rem; }
}

/* ── Stats card (home) ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stat-num   { font-size: 1.35rem; }
  .stats-row  { gap: 0.5rem; }
}

/* ── Lang toggle ─────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .lang-btn { font-size: 0.75rem; padding: 0.25rem 0.65rem; }
}

/* ── History table ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .history-table th,
  .history-table td { padding: 0.4rem 0.45rem; font-size: 0.77rem; }
}

/* ── Section title ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .section-title { margin: 1.25rem 0 0.5rem; }
}

/* ── Auth card ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .auth-card { margin-top: 3rem; }
  .auth-btn  { font-size: 0.875rem; }
}

/* ── Feedback modal ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box {
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-width: 100%;
    padding: 1.25rem 1.25rem 2rem; /* extra bottom for home indicator */
  }
  .modal-actions { flex-direction: column-reverse; gap: 0.4rem; }
  .modal-actions .btn { width: 100%; justify-content: center; min-height: 46px; }
  .star-btn { font-size: 2rem; }
}

/* ── Landing hero ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #landing { padding-bottom: 2rem; }
  .landing-hero { padding: 2.5rem 0.25rem 2rem; }
  .landing-h1 { font-size: clamp(1.65rem, 7vw, 2.2rem); }
  .landing-desc { font-size: 0.9rem; }
  .landing-cta-btn { font-size: 0.9rem; padding: 0.7rem 1.25rem; }
}

/* ── Landing stats strip ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .landing-stats { flex-wrap: wrap; }
  .lstat {
    flex: 1 0 calc(50% - 1px);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .lstat:nth-child(2n) { border-right: none; }
  .lstat:nth-last-child(-n+2) { border-bottom: none; }
  .lstat strong { font-size: 1.4rem; }
}

/* ── Features grid ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .landing-features { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .lfeat { padding: 0.9rem; }
  .lfeat h3 { font-size: 0.82rem; }
  .lfeat p  { font-size: 0.75rem; }
}
@media (max-width: 340px) {
  .landing-features { grid-template-columns: 1fr; }
}

/* ── Units list ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .landing-units { grid-template-columns: 1fr; }
  .landing-units li { font-size: 0.82rem; }
}

/* ── Coming soon grid ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .coming-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .subject-soon span { font-size: 0.75rem; }
}
@media (max-width: 340px) {
  .coming-grid { grid-template-columns: 1fr; }
}

/* ── Admin table ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .admin-badge { display: none; }
}

/* ── iOS safe area ───────────────────────────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .topbar  { padding-left:  max(1.5rem, env(safe-area-inset-left)); padding-right: max(1.5rem, env(safe-area-inset-right)); }
  .footer  { padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1.5rem)); }
  @media (max-width: 480px) {
    .modal-box { padding-bottom: max(2rem, calc(env(safe-area-inset-bottom) + 1.5rem)); }
  }
}

/* ── AI Explainer ────────────────────────────────────────────────────────── */
.ai-explainer-wrap { margin-top: 0.75rem; }

.btn-ai-explain {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background var(--t), box-shadow var(--t);
}
.btn-ai-explain:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79,70,229,.3);
}
.btn-ai-explain:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-explanation {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.7;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.3rem;
  vertical-align: middle;
}

/* ── Admin AI access toggles ─────────────────────────────────────────────── */
.access-status { color: var(--text-3); font-size: 0.82rem; }
.access-status.enabled { color: var(--green-text); font-weight: 600; }

.btn-access {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid;
  transition: background var(--t);
}
.btn-access.grant  { color: var(--green-text); border-color: var(--green); background: var(--green-dim); }
.btn-access.grant:hover  { background: var(--green); color: #fff; }
.btn-access.revoke { color: var(--red-text); border-color: var(--red); background: var(--red-dim); }
.btn-access.revoke:hover { background: var(--red); color: #fff; }
.btn-access:disabled { opacity: 0.5; cursor: not-allowed; }
