/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ─────────────────────────────────────────────────────────────────────────── */
/* DESIGN TOKENS                                                               */
/* ─────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sidebar-bg:      #1e3a5f;
  --sidebar-w:       240px;
  --sidebar-active:  #2a4f7c;
  --sidebar-hover:   rgba(255,255,255,0.08);
  --sidebar-text:    #ffffff;
  --sidebar-muted:   rgba(255,255,255,0.6);
  --sidebar-border:  rgba(255,255,255,0.08);

  /* Main layout */
  --main-bg:         #f4f6f9;
  --header-bg:       #ffffff;
  --header-h:        60px;
  --header-border:   #e5e7eb;

  /* Surfaces */
  --surface:         #ffffff;
  --surface-2:       #f8fafc;
  --surface-3:       #f1f5f9;

  /* Text */
  --text:            #1a1a2e;
  --text-muted:      #6b7280;

  /* Border */
  --border:          #e5e7eb;

  /* Accent / primary */
  --accent:          #2563eb;
  --accent-dim:      rgba(37,99,235,0.1);
  --accent-hover:    #1d4ed8;

  /* Semantic */
  --green:           #16a34a;
  --green-dim:       rgba(22,163,74,0.1);
  --red:             #dc2626;
  --red-dim:         rgba(220,38,38,0.1);
  --orange:          #d97706;
  --orange-dim:      rgba(217,119,6,0.1);

  /* Misc */
  --radius:          10px;
  --radius-sm:       6px;
  --font:            'Sora', -apple-system, sans-serif;
  --mono:            'JetBrains Mono', monospace;

  /* Card shadow */
  --shadow-card:     0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-modal:    0 20px 60px rgba(0,0,0,.18);
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* BASE                                                                        */
/* ─────────────────────────────────────────────────────────────────────────── */

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--main-bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* SCREENS — global                                                            */
/* ─────────────────────────────────────────────────────────────────────────── */

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* TOAST                                                                       */
/* ─────────────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 600;
  white-space: nowrap;
  transition: opacity .3s;
}
.toast.hidden { display: none; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* LOADING OVERLAY                                                             */
/* ─────────────────────────────────────────────────────────────────────────── */

.loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(244,246,249,0.88);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  backdrop-filter: blur(4px);
}
.loading-overlay.hidden { display: none; }
.loading-msg { color: var(--text-muted); font-size: .9rem; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ─────────────────────────────────────────────────────────────────────────── */
/* APP SIDEBAR                                                                 */
/* ─────────────────────────────────────────────────────────────────────────── */

.app-sidebar {
  display: none;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

/* Show sidebar on app screens */
body[data-screen="my-exams"]       .app-sidebar,
body[data-screen="dashboard"]      .app-sidebar,
body[data-screen="flashcards"]     .app-sidebar,
body[data-screen="session-review"] .app-sidebar,
body[data-screen="mode"]           .app-sidebar {
  display: flex;
}

/* Push content right when sidebar visible */
body[data-screen="my-exams"]       #screen-my-exams.active,
body[data-screen="dashboard"]      #screen-dashboard.active,
body[data-screen="flashcards"]     #screen-flashcards.active,
body[data-screen="session-review"] #screen-session-review.active,
body[data-screen="mode"]           #screen-mode.active {
  margin-left: var(--sidebar-w);
}

/* Brand */
.sidebar-brand {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-brand-icon svg { width: 32px; height: 32px; }
.sidebar-wordmark { display: flex; flex-direction: column; }
.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sidebar-text);
  letter-spacing: -.3px;
  line-height: 1.15;
}
.sidebar-subtitle {
  font-size: 10px;
  color: var(--sidebar-muted);
  font-weight: 400;
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-muted);
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
}
.sidebar-nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}
.sidebar-nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}
.sidebar-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-nav-item:hover svg,
.sidebar-nav-item.active svg { opacity: 1; }

.sidebar-nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 6px 4px;
}

/* Shop link */
.sidebar-shop-section {
  padding: 0 8px 8px;
  flex-shrink: 0;
}
.sidebar-shop-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.sidebar-shop-btn:hover {
  border-color: rgba(255,255,255,0.5);
  color: #fff;
  background: rgba(255,255,255,0.05);
}

/* User info */
.sidebar-user {
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  min-width: 0;
}
.sidebar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px; font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 11px; color: var(--sidebar-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.sidebar-logout-btn {
  background: none; border: none;
  color: var(--sidebar-muted);
  cursor: pointer; padding: 6px;
  border-radius: 6px;
  display: flex; align-items: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.sidebar-logout-btn:hover {
  color: var(--sidebar-text);
  background: rgba(255,255,255,0.09);
}
.sidebar-logout-btn svg { width: 16px; height: 16px; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* TOP BAR (dash-header) — app screens                                         */
/* ─────────────────────────────────────────────────────────────────────────── */

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.dash-header-left  { display: flex; align-items: center; gap: 20px; }
.dash-header-right { display: flex; align-items: center; gap: 12px; }

/* Page title — shown when sidebar is present */
.topbar-page-title {
  display: none;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
body[data-screen="my-exams"]  .topbar-page-title,
body[data-screen="dashboard"] .topbar-page-title {
  display: block;
}

/* Topbar avatar */
.topbar-avatar,
.topbar-avatar-dash {
  display: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 13px; font-weight: 700;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  cursor: default;
  flex-shrink: 0;
}
body[data-screen="my-exams"]  .topbar-avatar,
body[data-screen="dashboard"] .topbar-avatar-dash {
  display: flex;
}

/* Hide elements that are duplicated by the sidebar */
body[data-screen="my-exams"]  .dash-header .code-logo,
body[data-screen="dashboard"] .dash-header .code-logo,
body[data-screen="dashboard"] #btn-back-to-exams,
body[data-screen="my-exams"]  .dash-header .shop-link,
body[data-screen="dashboard"] .dash-header .shop-link,
body[data-screen="my-exams"]  #my-exams-welcome,
body[data-screen="dashboard"] #dash-welcome,
body[data-screen="my-exams"]  #btn-exams-logout,
body[data-screen="dashboard"] #btn-dash-logout,
body[data-screen="my-exams"]  #theme-toggle-exams,
body[data-screen="dashboard"] #theme-toggle-dash {
  display: none !important;
}

.dash-welcome {
  font-size: .85rem;
  color: var(--text-muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shop link (original header variant) */
.shop-link {
  text-decoration: none;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  transition: all .15s;
}
.shop-link:hover { border-color: var(--accent); color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* BUTTONS                                                                     */
/* ─────────────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-green  { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: #15803d; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-full { width: 100%; }
.btn-sm   { padding: 7px 14px; font-size: .82rem; }

/* Theme toggle */
.theme-toggle {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* AUTH SCREENS (login, register, forgot pw, code entry, email, reset)        */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-login,
#screen-forgot-password,
#screen-code,
#screen-email,
#screen-reset-password {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--main-bg);
}

.code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.auth-card { max-width: 400px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card p  { font-size: .88rem; color: var(--text-muted); margin-bottom: 20px; }

.code-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.5px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.code-logo svg { width: 40px; height: 40px; }

.code-card h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.code-card p {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* Input wrapper */
.code-input-wrap {
  position: relative;
  margin-bottom: 12px;
}
.pw-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  display: flex; align-items: center;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { pointer-events: none; }

/* Auth text inputs */
#code-input,
#firstname-input, #email-input,
#login-email, #login-password,
#reg-firstname, #reg-email, #reg-password, #reg-confirm,
#forgot-email,
#reset-new-password, #reset-confirm-password,
#redeem-code-input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
#code-input {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
}
#code-input::placeholder { letter-spacing: 1px; font-size: .95rem; font-weight: 400; color: var(--text-muted); }

#code-input:focus,
#firstname-input:focus, #email-input:focus,
#login-email:focus, #login-password:focus,
#reg-firstname:focus, #reg-email:focus,
#reg-password:focus, #reg-confirm:focus,
#forgot-email:focus,
#reset-new-password:focus, #reset-confirm-password:focus,
#redeem-code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: var(--surface);
}

#login-email::placeholder, #login-password::placeholder,
#reg-firstname::placeholder, #reg-email::placeholder,
#reg-password::placeholder, #reg-confirm::placeholder,
#forgot-email::placeholder,
#reset-new-password::placeholder, #reset-confirm-password::placeholder,
#firstname-input::placeholder, #email-input::placeholder {
  color: var(--text-muted);
  font-size: .9rem;
}

.code-error {
  color: var(--red);
  font-size: .85rem;
  min-height: 20px;
  margin-bottom: 16px;
  text-align: left;
}
.code-error.hidden { visibility: hidden; }

/* Google button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: 16px;
}
.btn-google:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: .78rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}
.auth-link {
  font-size: .82rem;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }

.auth-note {
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
}

/* Exam info card (after code validation) */
.exam-info-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  text-align: left;
}
.exam-info-card.hidden { display: none; }
.exam-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .88rem;
  padding: 4px 0;
  color: var(--text-muted);
}
.exam-info-row span:last-child { color: var(--text); font-weight: 500; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* MY EXAMS SCREEN                                                             */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-my-exams.active {
  background: var(--main-bg);
}

.my-exams-body {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}
.my-exams-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.my-exams-heading h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }

.my-exams-empty { display: flex; justify-content: center; padding: 60px 0; }

.my-exams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.exam-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  box-shadow: var(--shadow-card);
}
.exam-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37,99,235,.1);
}
.exam-card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 16px; line-height: 1.3; }
.exam-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.exam-card-stat { display: flex; flex-direction: column; gap: 3px; }
.exam-card-stat-value { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; color: var(--text); }
.exam-card-stat-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

.exam-card-readiness {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.exam-card-readiness-bar-wrap {
  flex: 1; height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin: 0 12px;
}
.exam-card-readiness-bar { height: 100%; border-radius: 99px; transition: width .6s ease; }
.readiness-bar-green   { background: var(--green); }
.readiness-bar-ltgreen { background: #7ec88a; }
.readiness-bar-yellow  { background: var(--orange); }
.readiness-bar-red     { background: var(--red); }

.exam-card-readiness-label { font-size: .75rem; font-weight: 600; white-space: nowrap; }
.exam-card-last-session    { font-size: .75rem; color: var(--text-muted); margin-top: 10px; }

.exam-card-new {
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  color: var(--text-muted);
  font-size: .9rem;
  box-shadow: none;
}
.exam-card-new:hover { border-color: var(--accent); color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* DASHBOARD SCREEN                                                            */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-dashboard.active { background: var(--main-bg); }

.dash-body {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}

/* New student welcome */
.dash-new-student { display: flex; justify-content: center; padding: 60px 0; }
.dash-welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  max-width: 480px;
  box-shadow: var(--shadow-card);
}
.dash-welcome-icon { font-size: 3rem; margin-bottom: 16px; }
.dash-welcome-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 10px; }
.dash-welcome-card p  { color: var(--text-muted); font-size: .9rem; line-height: 1.6; margin-bottom: 28px; }

/* Hero stats */
.dash-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.hero-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.hero-stat-icon  { font-size: 1.4rem; margin-bottom: 8px; }
.hero-stat-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.hero-stat-value.score-green  { color: var(--green); }
.hero-stat-value.score-yellow { color: var(--orange); }
.hero-stat-value.score-red    { color: var(--red); }
.hero-stat-label {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Domain callout */
.dash-domain-callout {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 24px;
  gap: 0;
  box-shadow: var(--shadow-card);
}
.domain-callout-item {
  flex: 1; display: flex; align-items: center; gap: 10px;
}
.domain-callout-divider {
  width: 1px; height: 40px;
  background: var(--border);
  margin: 0 24px;
}
.callout-icon  { font-size: 1.2rem; }
.callout-label {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); min-width: 70px;
}
.callout-domain { font-size: .9rem; font-weight: 600; color: var(--text); flex: 1; }
.callout-score  { font-family: var(--mono); font-size: .9rem; font-weight: 700; }
.strongest .callout-score { color: var(--green); }
.weakest   .callout-score { color: var(--red); }

/* Charts row */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 14px;
  margin-bottom: 24px;
}
.dash-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.dash-chart-card.chart-wide   { min-height: 280px; }
.dash-chart-card.chart-square { min-height: 240px; }
.dash-card-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.dash-chart-empty {
  color: var(--text-muted); font-size: .85rem;
  text-align: center; padding: 40px 0;
}
.dash-chart-wrap { height: 200px; position: relative; }

/* Readiness */
.dash-readiness-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.readiness-bar-wrap {
  height: 16px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}
.readiness-bar {
  height: 100%; border-radius: 99px;
  transition: width .6s ease; width: 0%;
}
.readiness-bar.readiness-red     { background: var(--red); }
.readiness-bar.readiness-yellow  { background: var(--orange); }
.readiness-bar.readiness-ltgreen { background: #7ec88a; }
.readiness-bar.readiness-green   { background: var(--green); }

.readiness-zones {
  display: flex; justify-content: space-between; margin-bottom: 8px;
}
.zone { font-size: .65rem; color: var(--text-muted); text-align: center; line-height: 1.3; width: 25%; }
.zone-red     { color: rgba(220,38,38,0.6); }
.zone-yellow  { color: rgba(217,119,6,0.6); }
.zone-ltgreen { color: rgba(126,200,138,0.6); }
.zone-green   { color: rgba(22,163,74,0.6); }
.readiness-label {
  font-family: var(--mono);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-top: 8px;
}

/* Recent sessions */
.dash-sessions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.sessions-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.sessions-table th {
  text-align: left;
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.sessions-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.sessions-table tr:last-child td { border-bottom: none; }
.sessions-table tr:hover td { background: var(--surface-2); }
.sessions-table tbody tr { cursor: pointer; }

.sess-score-badge {
  display: inline-block;
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px;
}
.sess-score-badge.score-pass { background: var(--green-dim); color: var(--green); }
.sess-score-badge.score-fail { background: var(--red-dim);   color: var(--red); }
.dash-empty-msg { color: var(--text-muted); font-size: .85rem; padding: 8px 0; }

/* Resources */
.dash-resources-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.resources-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.resource-item {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.resource-name {
  display: flex; align-items: center; gap: 10px;
  font-size: .9rem; color: var(--text); font-weight: 500;
}
.resource-icon { font-size: 1.1rem; }
.btn-download {
  font-size: .78rem; padding: 6px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer; font-family: var(--font); font-weight: 600;
  transition: all .15s;
}
.btn-download:hover { background: var(--accent); color: white; }

/* Mode legend */
.mode-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 0; padding: 12px 16px 16px; font-size: .78rem; }
.mode-legend-item { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.mode-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Start new session */
.dash-start-wrap { display: flex; justify-content: center; gap: 12px; padding: 8px 0 24px; flex-wrap: wrap; }
.dash-start-btn  { padding: 14px 40px; font-size: 1rem; }

/* Upsell */
.dash-upsell { margin: 8px 0 24px; }
.upsell-content {
  display: flex; align-items: center;
  justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; gap: 16px;
  box-shadow: var(--shadow-card);
}
.upsell-content:hover { border-color: var(--accent); transition: border-color .15s; }
.upsell-text { display: flex; align-items: center; gap: 14px; }
.upsell-icon { font-size: 1.6rem; }
.upsell-heading { font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.upsell-subtext { font-size: .8rem; color: var(--text-muted); }
.btn-upsell {
  white-space: nowrap; text-decoration: none;
  font-size: .82rem; font-weight: 600; padding: 8px 16px;
  background: var(--accent); color: white;
  border-radius: 8px; transition: opacity .15s;
}
.btn-upsell:hover { opacity: .85; }

/* Recs grid */
.recs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rec-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: var(--shadow-card);
}
.rec-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.rec-text { font-size: .85rem; line-height: 1.5; color: var(--text-muted); }
.rec-text strong { color: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* MODE SELECTION SCREEN                                                       */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-mode {
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background: var(--main-bg);
}

.mode-container { width: 100%; max-width: 560px; }

.mode-header { text-align: center; margin-bottom: 28px; }
.mode-header h1 { font-size: 1.2rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.mode-header p  { font-size: .88rem; color: var(--text-muted); }
.mode-header .code-logo { justify-content: center; margin-bottom: 20px; }

.mode-cards { display: flex; gap: 14px; margin-bottom: 24px; }
.mode-card {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px 18px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .1s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-family: var(--font);
  box-shadow: var(--shadow-card);
}
.mode-card:hover    { border-color: var(--accent); background: var(--accent-dim); }
.mode-card.selected { border-color: var(--accent); background: var(--accent-dim); }
.mode-card:active   { transform: scale(.98); }

.mode-card-icon  { font-size: 1.8rem; line-height: 1; }
.mode-card-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.mode-card-desc  { font-size: .78rem; color: var(--text-muted); line-height: 1.5; }

.mode-options {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.mode-option-group { display: flex; flex-direction: column; gap: 8px; }
.mode-option-label {
  font-size: .75rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.mode-domain-sel {
  width: 100%; padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: .9rem;
  outline: none; cursor: pointer; transition: border-color .15s;
}
.mode-domain-sel:focus { border-color: var(--accent); }

.q-count-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.q-count-btn {
  padding: 8px 20px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--mono); font-size: .88rem; font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.q-count-btn:hover    { border-color: var(--accent); color: var(--text); }
.q-count-btn.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.sim-exam-info {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.sim-info-row { display: flex; align-items: center; gap: 10px; }
.sim-info-icon  { font-size: 1rem; }
.sim-info-label { font-size: .8rem; color: var(--text-muted); min-width: 100px; }
.sim-info-value { font-family: var(--mono); font-size: .9rem; font-weight: 600; color: var(--text); }
.sim-info-note  { font-size: .75rem; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

.mode-actions { display: flex; gap: 10px; justify-content: space-between; }
.mode-actions .btn { flex: 1; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* EXAM SCREEN                                                                 */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-exam { background: var(--main-bg); }

/* Exam header */
.exam-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.exam-logo {
  font-size: .95rem; font-weight: 700;
  color: var(--accent); letter-spacing: -.3px; white-space: nowrap;
}
.exam-title-badge {
  background: var(--accent-dim); color: var(--accent);
  font-size: .75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
  border: 1px solid rgba(37,99,235,.25);
  white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 220px;
}
.header-spacer { flex: 1; }
.q-counter {
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
}
.exam-timer {
  font-family: var(--mono); font-size: .95rem; font-weight: 700;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px; min-width: 70px; text-align: center;
}
.exam-timer.warning { color: var(--orange); border-color: var(--orange); }
.exam-timer.danger  { color: var(--red); border-color: var(--red); animation: pulse-timer 1s infinite; }

@keyframes pulse-timer { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

.sidebar-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer; font-size: 1rem; line-height: 1;
  display: none;
}

/* Exam layout */
.exam-layout { flex: 1; display: flex; overflow: hidden; position: relative; }

/* Exam progress sidebar */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; flex-shrink: 0;
  transition: transform .25s ease;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--border);
  font-size: .8rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.sidebar-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 2px; display: none;
}

.progress-section { padding: 16px; border-bottom: 1px solid var(--border); }
.progress-bar-wrap {
  height: 6px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden; margin-bottom: 12px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 99px; transition: width .3s ease; width: 0%;
}
.progress-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-pill {
  font-size: .72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 99px;
  display: flex; align-items: center; gap: 4px;
}
.stat-pill.answered  { background: var(--accent-dim); color: var(--accent); }
.stat-pill.unanswered{ background: var(--surface-3);  color: var(--text-muted); }
.stat-pill.flagged   { background: var(--orange-dim); color: var(--orange); }

.navigator-section { padding: 16px; }
.navigator-label {
  font-size: .72rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 10px;
}
.nav-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.nav-cell {
  aspect-ratio: 1; border-radius: 4px; border: none; cursor: pointer;
  font-family: var(--mono); font-size: .62rem; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  transition: background .12s, transform .1s; position: relative;
}
.nav-cell:hover      { transform: scale(1.1); }
.nav-cell.current    { outline: 2px solid var(--accent); outline-offset: 1px; color: var(--text); }
.nav-cell.answered   { background: var(--accent-dim); color: var(--accent); }
.nav-cell.correct    { background: var(--green-dim);  color: var(--green); }
.nav-cell.incorrect  { background: var(--red-dim);    color: var(--red); }
.nav-cell.flagged::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--orange);
}

.domain-section { padding: 16px; border-top: 1px solid var(--border); }
.domain-item { margin-bottom: 10px; }
.domain-item-label {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-muted); margin-bottom: 4px;
}
.domain-item-bar  { height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.domain-item-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* Question area */
.question-area {
  flex: 1; overflow-y: auto;
  padding: 28px 32px 100px;
  display: flex; flex-direction: column; gap: 20px;
}
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
  box-shadow: var(--shadow-card);
}
.question-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.q-domain-badge {
  background: var(--surface-2); color: var(--text-muted);
  font-size: .72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border);
}
.q-diff-badge { font-size: .72rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.q-diff-badge.Easy   { background: var(--green-dim);  color: var(--green); }
.q-diff-badge.Medium { background: var(--accent-dim); color: var(--accent); }
.q-diff-badge.Hard   { background: var(--red-dim);    color: var(--red); }

.question-text { font-size: 1rem; line-height: 1.65; color: var(--text); margin-bottom: 24px; }

/* Options */
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left; width: 100%;
}
.option-card:hover:not(.locked) { border-color: var(--accent); background: var(--accent-dim); }
.option-card.selected { border-color: var(--accent); background: var(--accent-dim); }
.option-card.correct  { border-color: var(--green) !important; background: var(--green-dim) !important; }
.option-card.wrong    { border-color: var(--red) !important; background: var(--red-dim) !important; opacity: .65; }
.option-card.locked   { cursor: default; }

.option-letter {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 50%; background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  color: var(--text-muted); transition: background .15s, color .15s;
}
.option-card.selected .option-letter { background: var(--accent); color: #fff; }
.option-card.correct  .option-letter { background: var(--green);  color: #fff; }
.option-card.wrong    .option-letter { background: var(--red);    color: #fff; }

.option-text { font-size: .9rem; line-height: 1.5; color: var(--text); padding-top: 3px; }

/* Explanation */
.explanation-panel {
  margin-top: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  animation: fadeIn .2s ease;
}
.explanation-panel.hidden { display: none; }
.explanation-verdict {
  font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px; display: block;
}
.explanation-verdict.correct { color: var(--green); }
.explanation-verdict.wrong   { color: var(--red); }
.explanation-body { font-size: .85rem; line-height: 1.65; color: var(--text-muted); }
.explanation-body .rationale-line { margin-bottom: 6px; }
.explanation-body .rationale-line strong { color: var(--text); }
.explanation-body .rationale-correct strong { color: var(--green); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Nav controls */
.nav-controls {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px;
  box-shadow: var(--shadow-card);
}
.nav-controls .spacer { flex: 1; }

.btn-flag {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius);
  padding: 10px 16px; font-family: var(--font);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-flag:hover   { border-color: var(--orange); color: var(--orange); }
.btn-flag.flagged { border-color: var(--orange); color: var(--orange); background: var(--orange-dim); }

.btn-submit-exam { background: var(--green); color: #fff; font-weight: 700; }
.btn-submit-exam:hover { background: #15803d; }

.btn-end-exam {
  background: transparent;
  border: 1.5px solid rgba(220,38,38,0.35);
  color: var(--red);
  font-size: .8rem; padding: 5px 12px;
  border-radius: 8px; cursor: pointer;
  font-family: var(--font); font-weight: 500;
  transition: all .15s;
}
.btn-end-exam:hover { background: var(--red-dim); border-color: var(--red); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  z-index: 99; background: rgba(26,26,46,.4);
}
.sidebar-overlay.open { display: block; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* RESULTS SCREEN                                                              */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-results {
  align-items: center;
  padding: 40px 24px 80px;
  overflow-y: auto;
  background: var(--main-bg);
}
.results-container { width: 100%; max-width: 720px; }

.results-header {
  display: flex; align-items: center; gap: 40px; margin-bottom: 36px;
}
.score-ring-wrap { position: relative; flex-shrink: 0; width: 140px; height: 140px; }
.score-ring { width: 140px; height: 140px; transform: rotate(-90deg); }
.score-ring-bg   { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.score-ring-fill {
  fill: none; stroke: var(--green); stroke-width: 10;
  stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1), stroke .3s;
}
.score-ring-fill.fail { stroke: var(--red); }
.score-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-pct {
  font-family: var(--mono); font-size: 1.8rem;
  font-weight: 700; color: var(--text); line-height: 1;
}
.score-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.results-right { flex: 1; min-width: 0; }
.pass-fail-badge {
  font-size: .9rem; font-weight: 700;
  padding: 8px 20px; border-radius: 99px;
  display: inline-block; margin-bottom: 20px;
}
.pass-fail-badge.pass { background: var(--green-dim); color: var(--green); border: 1px solid rgba(22,163,74,.3); }
.pass-fail-badge.fail { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(220,38,38,.3); }

.result-stats { display: flex; gap: 20px; }
.result-stat-num {
  font-family: var(--mono); font-size: 1.4rem; font-weight: 700;
  display: block; color: var(--text);
}
.result-stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* Domain breakdown */
.breakdown-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.breakdown-card h3 {
  font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.breakdown-table { width: 100%; border-collapse: collapse; }
.breakdown-table th {
  text-align: left; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.breakdown-table td   { padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.breakdown-table tr:last-child td { border-bottom: none; }
.breakdown-table tr:hover td { background: var(--surface-2); }
.breakdown-table .pct-cell { font-family: var(--mono); font-weight: 600; }
.pct-pass { color: var(--green); }
.pct-fail { color: var(--red); }
.breakdown-bar-cell { width: 120px; }
.breakdown-bar-wrap { height: 4px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.breakdown-bar-fill { height: 100%; border-radius: 99px; transition: width .6s ease; }
.breakdown-bar-fill.pass { background: var(--green); }
.breakdown-bar-fill.fail { background: var(--red); }

.results-actions { display: flex; gap: 12px; margin-bottom: 32px; }

/* Review section */
.review-section { display: flex; flex-direction: column; gap: 16px; }
.review-section.hidden { display: none; }
.review-q-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.review-q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.review-q-num { font-family: var(--mono); font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.review-verdict { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.review-verdict.correct { background: var(--green-dim); color: var(--green); }
.review-verdict.wrong   { background: var(--red-dim);   color: var(--red); }
.review-q-text { font-size: .9rem; line-height: 1.55; margin-bottom: 14px; }
.review-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.review-opt {
  display: flex; gap: 10px; font-size: .82rem;
  padding: 7px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.review-opt .opt-l { font-family: var(--mono); font-weight: 700; color: var(--text-muted); }
.review-opt.correct-opt { background: var(--green-dim); border-color: rgba(22,163,74,.3); color: var(--text); }
.review-opt.correct-opt .opt-l { color: var(--green); }
.review-opt.user-wrong  { background: var(--red-dim); border-color: rgba(220,38,38,.3); }
.review-rationale {
  font-size: .8rem; line-height: 1.6; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px;
}
.review-rationale strong { color: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* SESSION REVIEW SCREEN                                                       */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-session-review.active { background: var(--main-bg); }

.sr-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.sr-summary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 24px; margin-bottom: 24px;
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}
.sr-summary-score { font-size: 2.8rem; font-weight: 700; font-family: var(--mono); line-height: 1; }
.sr-summary-score.pass { color: var(--green); }
.sr-summary-score.fail { color: var(--red); }
.sr-summary-meta { display: flex; flex-direction: column; gap: 4px; }
.sr-summary-meta-item { font-size: .82rem; color: var(--text-muted); }
.sr-summary-meta-item span { color: var(--text); font-weight: 500; }
.sr-pass-badge {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: 3px 10px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .05em;
}
.sr-pass-badge.pass { background: var(--green-dim); color: var(--green); }
.sr-pass-badge.fail { background: var(--red-dim);   color: var(--red); }

.sr-section-title {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 14px;
}
.sr-question-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px; margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.sr-question-card.sr-correct { border-left: 3px solid var(--green); }
.sr-question-card.sr-wrong   { border-left: 3px solid var(--red); }
.sr-q-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 12px;
}
.sr-q-num    { font-size: .72rem; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.sr-q-domain {
  font-size: .68rem; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-muted); flex-shrink: 0;
}
.sr-q-text { font-size: .92rem; line-height: 1.55; color: var(--text); margin-bottom: 14px; }
.sr-options { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.sr-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 13px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  font-size: .85rem; line-height: 1.45; color: var(--text);
}
.sr-opt.sr-opt-correct {
  border-color: rgba(22,163,74,.4); background: var(--green-dim);
}
.sr-opt.sr-opt-selected-wrong {
  border-color: rgba(220,38,38,.4); background: var(--red-dim); opacity: .85;
}
.sr-opt-letter {
  font-weight: 700; font-size: .78rem;
  min-width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text-muted);
  flex-shrink: 0; margin-top: 1px;
}
.sr-opt.sr-opt-correct .sr-opt-letter        { background: var(--green); color: #fff; }
.sr-opt.sr-opt-selected-wrong .sr-opt-letter { background: var(--red);   color: #fff; }
.sr-explanation {
  font-size: .82rem; line-height: 1.6; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px;
}
.sr-explanation strong { color: var(--text); font-weight: 600; }
.sr-row-review-btn {
  background: transparent; border: none; color: var(--accent);
  font-size: .78rem; font-weight: 600; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.sr-row-review-btn:hover { background: var(--accent-dim); }

/* ─────────────────────────────────────────────────────────────────────────── */
/* FLASHCARDS SCREEN                                                           */
/* ─────────────────────────────────────────────────────────────────────────── */

#screen-flashcards.active { background: var(--main-bg); }

.fc-mode-card-grid { display: flex; flex-direction: column; gap: 12px; width: 100%; margin: 16px 0 20px; }
.fc-mode-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px; padding: 22px 24px;
  cursor: pointer; text-align: left;
  color: var(--text); font-family: var(--font);
  display: flex; align-items: center; gap: 18px; width: 100%;
  transition: border-color .15s, background .15s, transform .1s;
  box-shadow: var(--shadow-card);
}
.fc-mode-btn:hover    { border-color: var(--accent); transform: translateY(-1px); }
.fc-mode-btn.fc-selected { border-color: var(--accent); background: var(--accent-dim); }
.fc-mode-icon { font-size: 1.8rem; flex-shrink: 0; }
.fc-mode-name { font-size: 1rem; font-weight: 600; }
.fc-mode-desc { font-size: .8rem; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

.fc-domain-row { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-bottom: 16px; }
.fc-domain-sel {
  flex: 1; padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: .9rem; outline: none; cursor: pointer;
}
.fc-domain-sel:focus { border-color: var(--accent); }

.fc-start-btns { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.fc-start-btns .btn { width: 100%; justify-content: center; }

.fc-top-bar {
  height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.fc-progress-track { flex: 1; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.fc-progress-fill  { height: 100%; background: var(--accent); border-radius: 3px; transition: width .35s ease; }
.fc-progress-text  { font-size: .78rem; color: var(--text-muted); white-space: nowrap; font-family: var(--mono); }

.fc-card-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px 20px 16px;
}

/* 3-D flip card */
.flashcard {
  width: 100%; max-width: 680px; height: 340px;
  perspective: 1200px; cursor: pointer;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.flashcard-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4, 0, .2, 1);
}
.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 18px; padding: 28px 32px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; overflow: hidden;
}
.flashcard-front { background: var(--surface); border: 1.5px solid var(--border); box-shadow: var(--shadow-card); }
.flashcard-back  {
  background: var(--surface); border: 1.5px solid var(--accent);
  transform: rotateY(180deg); justify-content: center; overflow-y: auto;
}
.fc-domain-chip {
  flex-shrink: 0; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--accent); background: var(--accent-dim);
  padding: 3px 10px; border-radius: 99px; margin-bottom: 14px;
}
.fc-question-text { font-size: 1rem; font-weight: 500; line-height: 1.6; color: var(--text); max-height: 220px; overflow-y: auto; }
.fc-tap-hint      { margin-top: 18px; font-size: .73rem; color: var(--text-muted); flex-shrink: 0; }
.fc-answer-letter { flex-shrink: 0; font-size: 1.5rem; font-weight: 700; color: var(--green); font-family: var(--mono); margin-bottom: 2px; }
.fc-answer-text   { flex-shrink: 0; font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: 14px; line-height: 1.45; }
.fc-explanation   { font-size: .8rem; color: var(--text-muted); line-height: 1.6; overflow-y: auto; text-align: left; width: 100%; }

.fc-actions {
  display: flex; gap: 14px; justify-content: center;
  padding: 12px 24px 32px; flex-shrink: 0;
}
.fc-actions.invisible { visibility: hidden; pointer-events: none; }
.btn-fc-review {
  padding: 12px 28px; background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-family: var(--font);
  font-size: .92rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-fc-review:hover { border-color: var(--orange); color: var(--orange); }
.btn-fc-gotit {
  padding: 12px 32px; background: var(--green);
  border: none; border-radius: var(--radius);
  color: #fff; font-family: var(--font);
  font-size: .92rem; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.btn-fc-gotit:hover { background: #15803d; }

/* Completion */
.fc-complete-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center; min-height: 100vh;
}
.fc-complete-wrap h2  { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.fc-complete-stats    { display: flex; gap: 20px; margin-bottom: 36px; flex-wrap: wrap; justify-content: center; }
.fc-stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 28px; min-width: 100px;
  box-shadow: var(--shadow-card);
}
.fc-stat-num   { font-size: 2rem; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.fc-stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-top: 4px; }
.fc-complete-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* MODALS                                                                      */
/* ─────────────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,26,46,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 380px; width: 100%;
  box-shadow: var(--shadow-modal);
}
.modal-box h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }
.modal-box h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }

.modal-stats { display: flex; gap: 12px; margin-bottom: 28px; }
.modal-stat {
  flex: 1; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; text-align: center;
}
.modal-stat-num {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700;
  display: block; margin-bottom: 2px;
}
.modal-stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.modal-stat.answered  .modal-stat-num { color: var(--accent); }
.modal-stat.remaining .modal-stat-num { color: var(--text-muted); }
.modal-stat.flagged   .modal-stat-num { color: var(--orange); }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* UTILITIES                                                                   */
/* ─────────────────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────────────────── */
/* RESPONSIVE                                                                  */
/* ─────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* ── Sidebar hidden on mobile ── */
  .app-sidebar { display: none !important; }

  body[data-screen="my-exams"]       #screen-my-exams.active,
  body[data-screen="dashboard"]      #screen-dashboard.active,
  body[data-screen="flashcards"]     #screen-flashcards.active,
  body[data-screen="session-review"] #screen-session-review.active,
  body[data-screen="mode"]           #screen-mode.active {
    margin-left: 0;
  }

  /* Restore hidden header elements */
  body[data-screen="my-exams"]  .dash-header .code-logo,
  body[data-screen="dashboard"] .dash-header .code-logo  { display: flex !important; }
  body[data-screen="my-exams"]  .topbar-page-title,
  body[data-screen="dashboard"] .topbar-page-title       { display: none !important; }
  body[data-screen="my-exams"]  #my-exams-welcome,
  body[data-screen="dashboard"] #dash-welcome            { display: inline !important; }
  body[data-screen="my-exams"]  #btn-exams-logout,
  body[data-screen="dashboard"] #btn-dash-logout         { display: inline-flex !important; }
  body[data-screen="dashboard"] #btn-back-to-exams       { display: inline-flex !important; }
  body[data-screen="my-exams"]  #theme-toggle-exams,
  body[data-screen="dashboard"] #theme-toggle-dash       { display: flex !important; }

  /* ── Exam header ── */
  .exam-logo { display: none; }
  .exam-title-badge { max-width: 140px; font-size: .7rem; }
  .sidebar-toggle { display: flex; }

  /* ── Exam sidebar as drawer ── */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 100; transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open  { transform: translateX(0); }
  .sidebar-close { display: block; }

  /* ── Question area ── */
  .question-area { padding: 16px 16px 100px; }
  .question-card { padding: 18px; }

  /* ── Nav controls fixed on mobile ── */
  .nav-controls {
    position: fixed; bottom: 0; left: 0; right: 0;
    border-radius: 0; border-left: none; border-right: none; border-bottom: none;
    z-index: 40; padding: 12px 16px; gap: 8px;
  }
  .btn-flag { padding: 10px 12px; }

  /* ── Results ── */
  .results-header { flex-direction: column; align-items: flex-start; gap: 20px; }
  .result-stats   { flex-wrap: wrap; }
  .modal-stats    { flex-direction: column; gap: 8px; }

  /* ── Nav grid denser ── */
  .nav-grid { grid-template-columns: repeat(10, 1fr); }

  /* ── Dash ── */
  .dash-hero-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-charts-row { grid-template-columns: 1fr 1fr; }
  .dash-domain-callout { flex-direction: column; gap: 12px; }
  .domain-callout-divider { width: 100%; height: 1px; margin: 4px 0; }
  .my-exams-body { padding: 20px 16px 60px; }
  .my-exams-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .code-card { padding: 32px 20px; }
  .modal-box { padding: 24px 20px; }
  .dash-body { padding: 20px 16px 60px; }
  .dash-welcome-card { padding: 32px 20px; }
  .dash-charts-row { grid-template-columns: 1fr; }
  .flashcard { height: 300px; }
  .fc-question-text { font-size: .92rem; }
}
