:root {
    --bg: #0a0a0f;
    --surface: #111118;
    --card: #16161f;
    --border: #2a2a3a;
    --accent: #6c63ff;
    --accent2: #ff6584;
    --accent3: #43e97b;
    --text: #e8e8f0;
    --muted: #9090a8;
    --success: #43e97b;
    --error: #ff6584;
    --warning: #ffd166;
  }

  body.light-mode {
    --bg: #f4f4f8;
    --surface: #ffffff;
    --card: #ffffff;
    --border: #d8d8e8;
    --accent: #5b53e8;
    --accent2: #e8355a;
    --accent3: #1db954;
    --text: #1a1a2e;
    --muted: #7070a0;
    --success: #1db954;
    --error: #e8355a;
    --warning: #c98b00;
  }

  body.light-mode::before {
    background-image:
      linear-gradient(rgba(91,83,232,0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(91,83,232,0.04) 1px, transparent 1px);
  }

  body.light-mode::after {
    background: radial-gradient(circle, rgba(91,83,232,0.06) 0%, transparent 70%);
  }

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

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
  }

  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(108,99,255,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(108,99,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
  }

  body::after {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(108,99,255,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
  }

  .screen { position: relative; z-index: 1; }

  /* ========== HOME — REDESIGN ========== */
  #home {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1.5rem 3rem;
    direction: rtl;
  }

  /* Top bar */
  .home-topbar {
    width: 100%;
    max-width: 780px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 0;
    margin-bottom: 0.5rem;
  }
  .home-topbar-left { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
  .home-topbar-right { display: flex; align-items: center; gap: 0.6rem; }
  .home-user-info {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: var(--muted);
  }
  .home-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--accent);
    background: rgba(108,99,255,0.12);
    border: 1px solid rgba(108,99,255,0.25);
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
  }

  /* Hero */
  .home-hero {
    width: 100%;
    max-width: 780px;
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2.2rem;
  }
  h1.hero-title {
    font-family: 'Syne', sans-serif;
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.04em;
    background: linear-gradient(160deg, var(--text) 0%, rgba(180,175,255,0.85) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.6rem;
  }
  h1.hero-title em {
    font-style: normal;
    background: linear-gradient(120deg, var(--accent) 0%, #a78bfa 50%, var(--accent2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .hero-sub {
    font-size: 0.85rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    margin-bottom: 1.8rem;
  }

  /* Stats row */
  .home-stats-row {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
  }
  .home-stat {
    display: flex;
    flex-direction: column;
    padding: 0 1.4rem 0 0;
  }
  .home-stat:first-child { padding-right: 0; }
  .home-stat-num {
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
  }
  .home-stat-lbl {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
  }
  .home-stat-sep {
    width: 1px;
    height: 32px;
    background: var(--border);
    margin: 0 1.4rem 0 0;
  }

  /* Section wrapper */
  .home-section {
    width: 100%;
    max-width: 780px;
    margin-bottom: 2.2rem;
  }
  .home-section-hd {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 1rem;
  }
  .home-section-tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--accent);
    opacity: 0.6;
    letter-spacing: 0.1em;
  }
  .home-section-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  /* Quiz cards — horizontal list */
  .home-quiz-grid {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .hq-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
    position: relative;
    overflow: hidden;
    direction: rtl;
  }
  .hq-card:hover {
    border-color: rgba(108,99,255,0.45);
    background: rgba(108,99,255,0.03);
    transform: translateX(-2px);
  }
  .hq-accent-bar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 14px 14px 0;
    opacity: 0.7;
  }
  .hq-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
  .hq-body { flex: 1; min-width: 0; }
  .hq-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
  }
  .hq-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hq-count {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    color: var(--accent);
    background: rgba(108,99,255,0.1);
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .hq-primary { border-color: rgba(108,99,255,0.3); }

  /* Vocab cards — 2-col grid */
  .home-vocab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
  }
  .hv-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.3rem 1.1rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    direction: rtl;
    text-align: right;
  }
  .hv-card:hover {
    border-color: rgba(108,99,255,0.4);
    transform: translateY(-3px);
  }
  .hv-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
  }
  .hv-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
  }
  .hv-desc {
    font-size: 0.76rem;
    color: var(--muted);
    line-height: 1.4;
  }
  .hv-pill {
    font-family: 'Space Mono', monospace;
    font-size: 0.62rem;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    margin-top: 0.2rem;
  }

  /* Auth btn */
  .btn-google {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
  }
  .btn-google:hover { border-color: var(--accent); color: var(--accent); }

  /* Keep old stats-strip/stat-item/mode-grid in case used elsewhere */
  .stats-strip { display:flex;gap:2rem;flex-wrap:wrap;justify-content:center; }
  .stat-item { text-align:center; }
  .stat-num { font-family:'Space Mono',monospace;font-size:1.8rem;font-weight:700;color:var(--accent); }
  .stat-label { font-size:0.75rem;color:var(--muted);text-transform:uppercase;letter-spacing:0.1em;margin-top:0.2rem; }
  .auth-strip { display:flex;align-items:center;gap:1rem;flex-wrap:wrap;justify-content:center; }
  .logo-area { text-align:center; }
  .badge { display:inline-block;background:rgba(108,99,255,0.15);border:1px solid rgba(108,99,255,0.3);color:var(--accent);font-family:'Space Mono',monospace;font-size:0.7rem;letter-spacing:0.2em;padding:0.4rem 1rem;border-radius:100px;margin-bottom:1.5rem;text-transform:uppercase; }

  /* home section label (keep for other uses) */
  .home-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 0.6rem;
    padding-right: 0.2rem;
    width: 100%;
    max-width: 860px;
  }

  /* ========== CONFIG ========== */
  #config, #exam-config, #streak-config {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1.5rem;
  }

  .config-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 520px;
  }

  .config-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.8rem;
  }

  .field { margin-bottom: 1.4rem; }

  .field label {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.6rem;
    font-family: 'Space Mono', monospace;
  }

  .field select, .field input[type=range] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
  }

  .field select:focus { border-color: var(--accent); }

  .field input[type=range] {
    padding: 0.6rem 0;
    accent-color: var(--accent);
    direction: rtl;
  }

  .range-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
  }

  .range-val {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    color: var(--accent);
    font-weight: 700;
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1.8rem;
    border-radius: 10px;
    font-family: 'Syne', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
  }

  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { background: #7c74ff; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(108,99,255,0.35); }

  .btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
  }

  .btn-ghost:hover { color: var(--text); border-color: var(--muted); }

  .btn-report {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    font-size: 0.75rem;
    opacity: 0.5;
    margin-right: auto;
  }
  .btn-report:hover { color: #ff6b6b; border-color: rgba(255,107,107,0.3); opacity: 1; }

  .btn-row {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
  }

  /* ========== QUIZ ========== */
  #quiz {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    max-width: 780px;
    margin: 0 auto;
    gap: 1.5rem;
  }

  .quiz-header { display: flex; align-items: center; gap: 1rem; }

  .progress-wrap {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #9c94ff);
    border-radius: 100px;
    transition: width 0.4s ease;
  }

  .prog-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
  }

  .score-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    background: rgba(108,99,255,0.15);
    color: var(--accent);
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    white-space: nowrap;
  }

  .q-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    animation: fadeUp 0.3s ease;
  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .q-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
    flex-wrap: nowrap;
    direction: rtl;
  }

  .q-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
  }

  .q-icon-btns {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
  }

  .tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .tag-src  { background: rgba(108,99,255,0.15); color: var(--accent); }
  .tag-k    { background: rgba(255,209,102,0.15); color: var(--warning); }
  .tag-qnum { background: rgba(255,150,80,0.15); color: #ff9650; font-weight: 600; }
  .multi-hint {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    padding: 0.4rem 0;
    letter-spacing: 0.03em;
  }

  .tag-link {
    background: rgba(108,99,255,0.1);
    color: var(--accent);
    border: 1px solid rgba(108,99,255,0.25);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.18s;
    cursor: pointer;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    letter-spacing: 0.05em;
  }
  .tag-link:hover {
    background: rgba(108,99,255,0.22);
    border-color: var(--accent);
    transform: translateY(-1px);
  }
  .tag-link.answers {
    background: rgba(67,233,123,0.08);
    color: var(--accent3);
    border-color: rgba(67,233,123,0.2);
  }
  .tag-link.answers:hover {
    background: rgba(67,233,123,0.18);
    border-color: var(--accent3);
  }

  /* Theme toggle */
  .theme-toggle-btn {
    position: fixed;
    top: 0.9rem;
    left: 1rem;
    z-index: 150;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(17,17,24,0.95);
    backdrop-filter: blur(8px);
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  }
  .theme-toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.05);
  }

  body.light-mode .sidebar {
    background: rgba(255,255,255,0.97);
    box-shadow: -2px 0 16px rgba(0,0,0,0.08);
  }
  body.light-mode .top-logo-bar .logo-home-btn {
    background: rgba(255,255,255,0.95);
  }
  body.light-mode .theme-toggle-btn {
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  .q-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 1.8rem;
    font-weight: 400;
    max-width: 100%;
  }

  .q-text img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  .q-text table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .options { display: flex; flex-direction: column; gap: 0.75rem; }

  .option {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
  }

  .option:hover:not(.disabled) {
    border-color: var(--accent);
    background: rgba(108,99,255,0.06);
  }

  .option.correct  { border-color: var(--success); background: rgba(67,233,123,0.1); }
  .option.wrong    { border-color: var(--error); background: rgba(255,101,132,0.1); }
  .option.selected { border-color: var(--accent); background: rgba(108,99,255,0.12); }
  .option.selected .opt-letter { background: var(--accent); color: white; }
  .option.multi-confirm {
    justify-content: center;
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: 600;
    margin-top: 0.3rem;
  }
  .option.multi-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--border);
    border-color: var(--border);
    color: var(--muted);
  }
  .option.multi-confirm:hover:not(:disabled):not(.disabled) {
    background: var(--accent-hover, #5a52e0);
    border-color: var(--accent-hover, #5a52e0);
  }

  .opt-letter {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 6px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.18s;
  }

  .option.correct .opt-letter { background: var(--success); color: #0a0a0f; }
  .option.wrong   .opt-letter { background: var(--error); color: white; }

  .opt-text {
    font-size: 0.9rem;
    line-height: 1.55;
    padding-top: 0.1rem;
    color: var(--text);
  }

  .explanation {
    background: rgba(108,99,255,0.07);
    border: 1px solid rgba(108,99,255,0.2);
    border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
    padding: 1rem 1.2rem;
    margin-top: 1.2rem;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text);
    animation: fadeUp 0.25s ease;
    direction: ltr;
    text-align: left;
  }

  .explanation strong {
    color: var(--accent);
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 0.75rem;
    direction: rtl;
    text-align: right;
  }

  .exp-intro {
    margin-bottom: 0.85rem;
    color: var(--text);
    line-height: 1.7;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(108,99,255,0.15);
    text-align: left;
  }

  .exp-bullets {
    margin: 0.3rem 0 0 1.2rem;
    padding: 0;
    line-height: 1.8;
  }
  .exp-bullets li { color: var(--text); }

  .exp-options {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  .exp-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    text-align: left;
    direction: ltr;
  }

  .exp-row-correct {
    background: rgba(45,212,160,0.06);
    border-color: rgba(45,212,160,0.2);
  }

  .exp-letter {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: rgba(108,99,255,0.15);
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
  }

  .exp-row-correct .exp-letter {
    background: rgba(45,212,160,0.15);
    color: var(--success);
  }

  .exp-body {
    flex: 1;
    line-height: 1.6;
    color: var(--text);
  }

  .exp-row-correct .exp-body {
    color: var(--text);
  }

  .exp-tag {
    font-size: 0.68rem;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--success);
    background: rgba(45,212,160,0.12);
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    margin-top: 2px;
    flex-shrink: 0;
  }

  /* Legacy fallback */
  .explanation .exp-line {
    display: block;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(108,99,255,0.08);
  }
  .explanation .exp-line:last-child { border-bottom: none; }
  .explanation .exp-correct { color: var(--success); }

  .q-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* ========== RESULTS ========== */
  #results {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 2rem;
  }

  .result-hero { text-align: center; }

  .score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) var(--pct), var(--border) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    position: relative;
  }

  .score-circle::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: var(--bg);
  }

  .score-inner { position: relative; z-index: 1; text-align: center; }

  .score-pct {
    font-family: 'Space Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
  }

  .score-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .result-title {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
  }

  .result-sub { color: var(--muted); font-size: 0.95rem; }

  .result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 480px;
  }

  .rstat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.2rem;
    text-align: center;
  }

  .rstat-num {
    font-family: 'Space Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
  }

  .rstat-num.green { color: var(--success); }
  .rstat-num.red   { color: var(--error); }
  .rstat-num.gray  { color: var(--muted); }

  .rstat-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.3rem;
  }

  .review-list {
    width: 100%;
    max-width: 780px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .review-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.4rem;
  }

  .review-item.wrong-item   { border-color: rgba(255,101,132,0.3); background: rgba(255,101,132,0.04); }
  .review-item.correct-item { border-color: rgba(67,233,123,0.2); }

  .review-q { font-size: 0.9rem; line-height: 1.6; margin-bottom: 0.8rem; color: var(--text); }

  .review-answers {
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .review-correct { color: var(--success); }
  .review-wrong   { color: var(--error); text-decoration: line-through; }

  /* Utility */
  .hidden { display: none !important; }

  /* Loading */
  #loading {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Mono', monospace;
    color: var(--muted);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    position: relative;
    z-index: 1;
  }

  .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 1rem;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  .review-heading {
    font-family: 'Syne', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
  }

  .pass-badge {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    border-radius: 100px;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.8rem;
  }

  .pass-badge.pass { background: rgba(67,233,123,0.15); color: var(--success); border: 1px solid rgba(67,233,123,0.3); }
  .pass-badge.fail { background: rgba(255,101,132,0.15); color: var(--error); border: 1px solid rgba(255,101,132,0.3); }

  select option { background: #1a1a26; color: #e8e8f0; }
  body.light-mode select option { background: #ffffff; color: #1a1a2e; }
  body.light-mode .field select {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border);
  }

  /* ========== LANGUAGE TOGGLE ========== */
  .lang-toggle {
    display: flex;
    flex-direction: row !important;
    direction: ltr !important;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }

  .lang-btn {
    flex: 1;
    padding: 0.55rem 1.4rem;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
  }

  .lang-btn.active {
    background: var(--accent);
    color: white;
  }

  .lang-btn:hover:not(.active) { color: var(--text); }

  /* RTL overrides for Hebrew mode */
  body.lang-he {
    direction: rtl;
  }

  body.lang-he .q-card,
  body.lang-he .q-text,
  body.lang-he .opt-text,
  body.lang-he .config-box,
  body.lang-he .review-q,
  body.lang-he .review-answers,
  body.lang-he .mode-card,
  body.lang-he .mode-title,
  body.lang-he .mode-desc,
  body.lang-he .stat-label,
  body.lang-he .result-hero,
  body.lang-he .rstat-label,
  body.lang-he .page-sub,
  body.lang-he .login-sub {
    direction: rtl;
    text-align: right;
  }

  /* Explanation is always LTR (English text) — override lang-he */
  body.lang-he .explanation {
    direction: ltr;
    text-align: left;
  }
  body.lang-he .explanation strong {
    direction: rtl;
    text-align: right;
  }
  body.lang-he .exp-row,
  body.lang-he .exp-body,
  body.lang-he .exp-intro {
    direction: ltr;
    text-align: left;
  }

  /* Light mode: stronger backgrounds for better contrast */
  body.light-mode .explanation {
    background: rgba(108,99,255,0.06);
    border-color: rgba(108,99,255,0.25);
  }
  body.light-mode .exp-row {
    background: rgba(0,0,0,0.03);
  }
  body.light-mode .exp-row-correct {
    background: rgba(45,212,160,0.08);
  }

  body.lang-he .hero-sub {
    direction: rtl;
    text-align: center;
  }

  body.lang-he .option {
    flex-direction: row;
    direction: rtl;
    text-align: right;
  }

  body.lang-he .opt-text {
    text-align: right;
  }

  body.lang-he .q-meta {
    direction: rtl;
  }

  body.lang-he .q-footer {
    flex-direction: row-reverse;
  }

  body.lang-he .quiz-header {
    flex-direction: row-reverse;
  }

  body.lang-he .btn-row {
    flex-direction: row-reverse;
  }

  body.lang-he .auth-strip {
    flex-direction: row-reverse;
  }

  body.lang-he .stats-strip {
    flex-direction: row-reverse;
  }

  body.lang-he .logo-area {
    direction: rtl;
    text-align: center;
  }

  body.lang-he .config-box {
    direction: rtl;
  }

  #review-section { width: 100%; max-width: 780px; }

  @media (max-width: 520px) {
    .mode-grid { grid-template-columns: 1fr 1fr; }
    .result-stats { grid-template-columns: repeat(3, 1fr); }
    h1.hero-title { font-size: 2.5rem; }
  }

  /* ========== GUEST BANNER ========== */
  #login-wall {
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    width: calc(100% - 2rem);
    max-width: 480px;
    animation: slideUp 0.4s ease;
  }

  #login-wall.hidden { display: none; }

  @keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }

  .login-card {
    background: var(--card);
    border: 1px solid rgba(108,99,255,0.3);
    border-radius: 16px;
    padding: 1rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: space-between;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  .login-sub {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.4;
    flex: 1;
    min-width: 160px;
  }

  .login-sub strong {
    color: var(--text);
    display: block;
    margin-bottom: 0.15rem;
    font-family: 'Syne', sans-serif;
    font-size: 0.88rem;
  }

  .btn-google-big {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    background: white;
    color: #333;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-google-big:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  .banner-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    flex-shrink: 0;
  }

  .banner-close:hover { color: var(--text); }

  /* ========== TOP LOGO BAR ========== */
  .top-logo-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 99;
    pointer-events: none;
  }

  .top-logo-bar.hidden { display: none; }

  .logo-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(17,17,24,0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.4rem 0.9rem;
    color: var(--text);
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: all;
    text-decoration: none;
  }

  .logo-home-btn .logo-mark {
    font-size: 1rem;
    color: var(--accent);
  }

  .logo-home-btn:hover {
    border-color: rgba(108,99,255,0.4);
    color: var(--accent);
  }

  /* Add top padding to pages that have the logo bar */
  .has-top-bar {
    padding-top: 64px;
  }

  /* ========== SIDEBAR ========== */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 175px;
    height: 100vh;
    background: rgba(10,10,15,0.98);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar.collapsed { transform: translateX(100%); }

  .sidebar-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 101;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: rgba(17,17,24,0.95);
    backdrop-filter: blur(8px);
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }
  .sidebar-toggle:hover { color: var(--accent); border-color: rgba(108,99,255,0.4); }
  .sidebar:not(.collapsed) ~ .sidebar-toggle { display: none !important; }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.9rem 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
  }
  .sidebar-logo {
    font-size: 0.82rem;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.08em;
  }
  .sidebar-close-btn {
    width: 26px; height: 26px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
  }
  .sidebar-close-btn:hover { color: var(--text); background: rgba(108,99,255,0.1); }

  .nav-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.9rem;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    text-align: right;
    direction: rtl;
    margin: 0 0 1px;
  }
  .nav-btn .nav-icon { font-size: 0.95rem; line-height: 1; flex-shrink: 0; }
  .nav-btn:hover { color: var(--text); background: rgba(108,99,255,0.1); }
  .nav-btn.active { color: var(--accent); background: rgba(108,99,255,0.14); }

  .nav-section-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.9rem 0.9rem 0.3rem;
    opacity: 0.5;
  }

  .nav-count-badge {
    display: inline-block;
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    background: rgba(108,99,255,0.15);
    color: var(--accent);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    margin-right: auto;
  }

  .nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.4rem 0;
    border: none;
  }

  .nav-bottom {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .nav-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem 0.8rem;
  }
  .nav-theme-label {
    font-size: 0.73rem;
    color: var(--muted);
    direction: rtl;
  }
  .theme-switch {
    width: 34px; height: 18px;
    background: var(--border);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
    flex-shrink: 0;
  }
  .theme-switch.on { background: var(--accent); }
  .theme-switch::after {
    content: '';
    position: absolute;
    width: 12px; height: 12px;
    background: white;
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform 0.2s;
  }
  .theme-switch.on::after { transform: translateX(16px); }

  body { padding-right: 175px; transition: padding-right 0.3s cubic-bezier(0.4,0,0.2,1); }
  body.sidebar-collapsed { padding-right: 0; }

  .sidebar.hidden-nav { display: none; }
  .sidebar.hidden-nav ~ .sidebar-toggle { display: none; }

  body.light-mode .sidebar {
    background: rgba(255,255,255,0.98);
    box-shadow: -2px 0 20px rgba(0,0,0,0.08);
  }
  body.light-mode .sidebar-toggle {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  @media (max-width: 520px) {
    .sidebar { width: 160px; }
    body { padding-right: 160px; }
    .sidebar:not(.collapsed) ~ .sidebar-toggle { right: 168px; }
    .home-vocab-grid { grid-template-columns: 1fr; }
    .hq-desc { display: none; }
  }
  }

  /* ========== SAVED PAGE ========== */
  #saved-page {
    min-height: 100vh;
    padding: 2rem 1.5rem 6rem;
    max-width: 780px;
    margin: 0 auto;
  }

  .saved-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.2s;
  }

  .saved-item:hover { border-color: rgba(108,99,255,0.35); }

  .saved-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 1rem 1.2rem 0.8rem;
    cursor: pointer;
  }

  .saved-item-q {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
    flex: 1;
    direction: rtl;
    text-align: right;
  }

  .saved-item-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: center;
  }

  .saved-item-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    padding: 0.2rem;
    border-radius: 6px;
    transition: all 0.15s;
    line-height: 1;
  }

  .saved-item-actions button:hover { color: var(--text); background: rgba(108,99,255,0.1); }
  .saved-item-actions .btn-unstar:hover { color: var(--warning); }
  .saved-item-actions .btn-del-note:hover { color: var(--error); }

  .saved-item-meta {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0 1.2rem 0.8rem;
    direction: rtl;
  }

  .saved-item-answer {
    padding: 0.6rem 1.2rem;
    background: rgba(67,233,123,0.06);
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--success);
    direction: rtl;
    text-align: right;
  }

  .saved-item-note {
    padding: 0.7rem 1.2rem;
    border-top: 1px solid var(--border);
    background: rgba(108,99,255,0.04);
  }

  .saved-item-note textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 40px;
    outline: none;
    direction: rtl;
    text-align: right;
  }

  .saved-item-note-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.3rem;
  }

  .saved-star-indicator { color: #ffd166; }
  .saved-note-indicator { color: var(--accent); font-size: 0.75rem; }
  #stats-page {
    min-height: 100vh;
    padding: 2rem 1.5rem 6rem;
    max-width: 860px;
    margin: 0 auto;
  }

  .page-title {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
  }

  .page-sub {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 2rem;
  }

  .stats-section-title {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--muted);
    margin-bottom: 0.8rem;
    margin-top: 1.8rem;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.8rem;
  }

  .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.2rem;
    text-align: center;
    transition: border-color 0.2s;
  }

  .stat-card:hover { border-color: rgba(108,99,255,0.3); }

  .stat-card .sc-num {
    font-family: 'Space Mono', monospace;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.4rem;
  }

  .stat-card .sc-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.3;
  }

  .sc-num.purple { color: var(--accent); }
  .sc-num.green  { color: var(--success); }
  .sc-num.red    { color: var(--error); }
  .sc-num.yellow { color: var(--warning); }
  .sc-num.white  { color: var(--text); }

  /* Progress bar inside stat card */
  .sc-bar {
    height: 4px;
    background: var(--border);
    border-radius: 100px;
    margin-top: 0.6rem;
    overflow: hidden;
  }
  .sc-bar-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--accent), #9c94ff);
  }

  /* History list */
  .history-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.8rem;
  }

  .history-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .hi-score {
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 3.5rem;
  }

  .hi-score.pass { color: var(--success); }
  .hi-score.fail { color: var(--error); }

  .hi-meta {
    flex: 1;
    font-size: 0.8rem;
    color: var(--muted);
  }

  .hi-detail {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 0.18rem;
    opacity: 0.85;
  }

  .hi-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
  }

  .hi-badge.pass { background: rgba(67,233,123,0.1); color: var(--success); }
  .hi-badge.fail { background: rgba(255,101,132,0.1); color: var(--error); }

  /* ========== ABOUT PAGE ========== */
  #about-page {
    min-height: 100vh;
    padding: 2rem 1.5rem 6rem;
    max-width: 680px;
    margin: 0 auto;
    direction: rtl;
  }

  .about-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.6rem;
    margin-bottom: 1rem;
  }

  .about-section h3 {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--accent);
  }

  .about-section p {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.8;
  }

  .about-section ul {
    list-style: none;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 2;
  }

  .about-section ul li::before {
    content: '✦ ';
    color: var(--accent);
    font-size: 0.65rem;
  }

  .about-badge-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
  }

  .about-tag {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    background: rgba(108,99,255,0.1);
    color: var(--accent);
    border: 1px solid rgba(108,99,255,0.2);
  }
  /* ========== FLASHCARDS PAGE ========== */
  #flashcards-page {
    min-height: 100vh;
    padding: 2rem 1.5rem 6rem;
    max-width: 960px;
    margin: 0 auto;
  }

  .fc-controls {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
  }

  .fc-search-wrap { flex: 1; min-width: 180px; }

  #fc-search {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    padding: 0.6rem 1rem;
    outline: none;
    direction: rtl;
    transition: border-color 0.2s;
  }
  #fc-search:focus { border-color: var(--accent); }

  .fc-progress-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.4rem;
  }

  .fc-prog-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 100px;
    overflow: hidden;
  }

  .fc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
  }

  /* The flip card container */
  .fc-card {
    height: 180px;
    perspective: 1000px;
    cursor: pointer;
  }

  .fc-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.4,0,0.2,1);
    border-radius: 14px;
  }

  .fc-card.flipped .fc-card-inner {
    transform: rotateY(180deg);
  }

  .fc-front, .fc-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
    overflow: hidden;
  }

  .fc-front {
    background: var(--card);
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
  }

  .fc-back {
    background: var(--surface);
    transform: rotateY(180deg);
    justify-content: flex-start;
    border-color: rgba(108,99,255,0.3);
  }

  .fc-card:hover .fc-front,
  .fc-card:hover .fc-back { border-color: rgba(108,99,255,0.45); }

  .fc-card.known .fc-front { border-color: rgba(67,233,123,0.4); background: rgba(67,233,123,0.04); }
  .fc-card.known .fc-back  { border-color: rgba(67,233,123,0.4); }

  .fc-term {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    direction: rtl;
    line-height: 1.4;
  }

  /* Prominent tap hint */
  .fc-hint {
    font-size: 0.7rem;
    color: var(--accent);
    font-family: 'Space Mono', monospace;
    background: rgba(108,99,255,0.1);
    border: 1px solid rgba(108,99,255,0.25);
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
    letter-spacing: 0.03em;
  }

  .fc-back-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.58rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
  }

  .fc-definition {
    font-size: 0.78rem;
    line-height: 1.65;
    color: var(--text);
    direction: rtl;
    text-align: right;
    overflow-y: auto;
    flex: 1;
  }

  .fc-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    flex-shrink: 0;
  }

  .fc-known-btn {
    font-size: 0.7rem;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    white-space: nowrap;
  }

  .fc-known-btn:hover,
  .fc-card.known .fc-known-btn {
    background: rgba(67,233,123,0.15);
    border-color: rgba(67,233,123,0.5);
    color: var(--success);
  }

  .fc-id {
    font-family: 'Space Mono', monospace;
    font-size: 0.58rem;
    color: var(--muted);
    opacity: 0.5;
  }

  /* ── ONE-AT-A-TIME MODE ── */
  #fc-one {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-bottom: 2rem;
  }

  .fco-counter {
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.1em;
  }

  .fco-stage {
    width: 100%;
    max-width: 520px;
    perspective: 1200px;
    cursor: pointer;
    user-select: none;
    touch-action: pan-y;
  }

  .fco-card {
    width: 100%;
    height: 300px;
    position: relative;
  }

  .fco-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.42s cubic-bezier(0.4,0,0.2,1);
    border-radius: 20px;
  }

  .fco-card.flipped .fco-card-inner { transform: rotateY(180deg); }

  .fco-front, .fco-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.8rem 1.8rem 3rem;
    border: 1px solid var(--border);
    overflow: hidden;
  }

  .fco-front {
    background: var(--card);
    border-color: rgba(108,99,255,0.22);
    gap: 0.8rem;
  }

  .fco-back {
    background: var(--surface);
    transform: rotateY(180deg);
    border-color: rgba(108,99,255,0.4);
    justify-content: flex-start;
    padding-top: 2.4rem;
    align-items: flex-end;
  }

  .fco-card.is-known .fco-front { border-color: rgba(67,233,123,0.5); background: rgba(67,233,123,0.03); }
  .fco-card.is-known .fco-back  { border-color: rgba(67,233,123,0.5); }

  .fco-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    position: absolute;
    top: 0.85rem;
    right: 1.1rem;
  }

  .fco-content {
    font-family: 'Syne', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    direction: rtl;
    line-height: 1.45;
  }

  .fco-back .fco-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    text-align: right;
    line-height: 1.75;
    overflow-y: auto;
    max-height: 210px;
    width: 100%;
    margin-top: 0.4rem;
  }

  /* compact tap hint */
  .fco-tap-hint {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent);
    font-family: 'Space Mono', monospace;
    background: rgba(108,99,255,0.12);
    border: 1px solid rgba(108,99,255,0.28);
    border-radius: 20px;
    padding: 0.22rem 0.75rem;
    position: absolute;
    bottom: 0.85rem;
    letter-spacing: 0.04em;
    pointer-events: none;
  }

  /* bottom bar: ← [⭐ ידוע] → */
  .fco-bottom {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    max-width: 520px;
  }

  .fco-nav-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px;
    padding: 0 !important;
    font-size: 1.15rem !important;
    border-radius: 12px !important;
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  .fco-known-solo {
    flex: 1;
    padding: 0.72rem;
    border-radius: 14px;
    border: 1px solid rgba(67,233,123,0.3);
    background: rgba(67,233,123,0.07);
    color: var(--success);
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
  }
  .fco-known-solo:hover      { background: rgba(67,233,123,0.16); transform: translateY(-1px); }
  .fco-known-solo.is-known   { background: rgba(67,233,123,0.2); border-color: rgba(67,233,123,0.6); }

  /* swipe animations */
  .fco-card.swipe-right { animation: fco-swipe-right 0.3s ease forwards; }
  .fco-card.swipe-left  { animation: fco-swipe-left  0.3s ease forwards; }
  .fco-card.swipe-in-right { animation: fco-in-right 0.3s ease forwards; }
  .fco-card.swipe-in-left  { animation: fco-in-left  0.3s ease forwards; }

  @keyframes fco-swipe-right  { to { transform: translateX(115%) rotate(6deg);  opacity: 0; } }
  @keyframes fco-swipe-left   { to { transform: translateX(-115%) rotate(-6deg); opacity: 0; } }
  @keyframes fco-in-right     { from { transform: translateX(-60%) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes fco-in-left      { from { transform: translateX(60%)  rotate(4deg);  opacity: 0; } to { transform: none; opacity: 1; } }

  /* ── COMPACT ICON TOOLBAR ── */
  .fc-toolbar {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-wrap: wrap;
  }

  .fc-icon-group {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }

  .fc-icon-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
  }
  .fc-icon-btn.active                { background: var(--accent); color: #fff; }
  .fc-icon-btn:not(.active):hover    { background: rgba(108,99,255,0.1); color: var(--text); }

  .fc-icon-btn-solo {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .fc-icon-btn-solo:hover  { color: var(--text); background: rgba(108,99,255,0.1); border-color: rgba(108,99,255,0.3); }
  .fc-icon-btn-solo.active { background: rgba(108,99,255,0.15); border-color: var(--accent); color: var(--accent); }

  @media (max-width: 520px) {
    .fc-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .fc-card { height: 150px; }
    .fc-term { font-size: 0.85rem; }
    .fco-card { height: 260px; }
    .fco-content { font-size: 1.05rem; }
  }

/* ── Source multi-select checkboxes ── */
.src-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  margin-top: 0.3rem;
}
.src-checks label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 2rem;
  border: 1.5px solid var(--border, #ddd);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.src-checks label:has(input:checked) {
  background: var(--accent, #6c63ff);
  border-color: var(--accent, #6c63ff);
  color: #fff;
}
.src-checks label:hover {
  border-color: var(--accent, #6c63ff);
}
.src-checks input[type=checkbox] {
  display: none;
}
.src-check-all {
  font-weight: 700 !important;
}


  /* ========== QUESTION PREVIEW MODAL ========== */
  .q-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .q-modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.8rem;
    position: relative;
    animation: slideUp 0.25s ease;
    direction: rtl;
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .q-modal::-webkit-scrollbar { width: 4px; }
  .q-modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  .q-modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  .q-modal-close:hover { color: var(--text); border-color: var(--muted); }

  .q-modal-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    direction: rtl;
  }

  .q-modal-text {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    margin-bottom: 1.4rem;
    direction: rtl;
    text-align: right;
  }

  .q-modal-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
  }

  .q-modal-option {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    direction: rtl;
  }

  .q-modal-option.correct {
    border-color: var(--success);
    background: rgba(67,233,123,0.08);
  }

  .q-modal-option .opt-letter {
    background: var(--border);
    flex-shrink: 0;
    margin-top: 0.1rem;
  }

  .q-modal-option.correct .opt-letter {
    background: var(--success);
    color: #0a0a0f;
  }

  .q-modal-exp {
    background: rgba(108,99,255,0.07);
    border: 1px solid rgba(108,99,255,0.2);
    border-right: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
    padding: 0.9rem 1rem;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--text);
    direction: rtl;
    text-align: right;
  }

  .q-modal-exp strong {
    color: var(--accent);
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 0.5rem;
  }

/* ── Exam nav bar pill hover ── */
#exam-nav-pills button:hover {
  filter: brightness(1.15);
  transform: scale(1.1);
}

/* ══════════════════════════════════════════
   EXAM CONFIG SCREEN
══════════════════════════════════════════ */

.exam-cfg-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.2rem 2.5rem 2rem;
  width: 100%;
  max-width: 520px;
  direction: rtl;
}

/* Header */
.exam-cfg-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.exam-cfg-icon {
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.exam-cfg-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.exam-cfg-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.03em;
}

/* K-level strip */
.exam-klevel-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.55rem;
  justify-content: center;
}
.exam-klevel-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex: 1;
}
.ekb-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}
.k1 .ekb-label { background: rgba(253,186,116,0.18); color: #f59e0b; }
.k2 .ekb-label { background: rgba(108,99,255,0.15); color: var(--accent); }
.k3 .ekb-label { background: rgba(67,233,123,0.15); color: var(--success); }
.ekb-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.ekb-desc {
  font-size: 0.68rem;
  color: var(--muted);
}
.exam-klevel-sep {
  color: var(--border);
  font-size: 1.1rem;
  font-weight: 300;
  flex-shrink: 0;
  padding: 0 0.1rem;
}
.exam-klevel-note {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Section label */
.exam-cfg-section { margin-bottom: 1.4rem; }
.exam-cfg-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-family: 'Space Mono', monospace;
}

/* Source tiles grid */
.exam-src-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.exam-src-tile {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  position: relative;
  background: var(--surface);
}
.exam-src-tile input[type=checkbox] { display: none; }
.exam-src-all-tile {
  grid-column: 1 / -1;
  border-color: var(--accent);
  border-style: solid;
  background: rgba(108,99,255,0.1);
}
.exam-src-all-tile .exam-src-tile-tag {
  background: rgba(108,99,255,0.15);
  color: var(--accent);
  border-color: var(--accent);
}
.exam-src-all-tile:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
}
.exam-src-all-tile:has(input:checked) *,
.exam-src-all-tile:has(input:checked) .exam-src-tile-name,
.exam-src-all-tile:has(input:checked) .exam-src-tile-icon {
  color: #fff !important;
}
.exam-src-all-tile:has(input:checked) .exam-src-tile-tag {
  background: rgba(255,255,255,0.2) !important;
  border-color: rgba(255,255,255,0.4) !important;
}
.exam-src-tile:not(.exam-src-all-tile):has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  border-style: solid;
}
.exam-src-tile:not(.exam-src-all-tile):has(input:checked) * {
  color: #fff !important;
}
.exam-src-tile:hover { border-color: var(--accent); }
.exam-src-tile-icon {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  flex-shrink: 0;
  min-width: 1.4rem;
  text-align: center;
}
.exam-src-tile-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.exam-src-all-tile:has(input:checked) .exam-src-tile-name {
  color: #fff;
}
.exam-src-tile-tag {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
  color: var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  border: 1px solid var(--accent);
}
.exam-src-hint {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.55rem;
  text-align: center;
}

/* Actions */
.exam-cfg-actions {
  display: flex;
  gap: 0.75rem;
  flex-direction: row-reverse;
  margin-top: 0.5rem;
}
.exam-cfg-start {
  flex: 1;
  font-size: 1rem !important;
  padding: 0.85rem 1rem !important;
}

/* Light mode tweaks */
body.light-mode .exam-src-tile { background: #f7f7fb; }
body.light-mode .exam-src-all-tile { background: rgba(91,83,232,0.04); }
body.light-mode .exam-src-tile:has(input:checked) { background: var(--accent); }
body.light-mode .exam-src-all-tile:has(input:checked) { background: var(--accent); }
body.light-mode .exam-klevel-strip { background: #f7f7fb; }

/* ═══════════════════════════════════════════════
   GLOSSARY QUIZ GAME
═══════════════════════════════════════════════ */

  .gg-option-btn {
    width: 100%;
    text-align: right;
    background: var(--card);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    font-family: inherit;
    direction: rtl;
  }
  .gg-option-btn:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(108,99,255,0.06);
    transform: translateX(-2px);
  }
  .gg-option-btn.gg-correct {
    border-color: var(--success);
    background: rgba(67,233,123,0.1);
    color: var(--success);
  }
  .gg-option-btn.gg-wrong {
    border-color: var(--error);
    background: rgba(255,101,132,0.1);
    color: var(--error);
  }
  .gg-option-btn:disabled { cursor: default; }

/* ═══════════════════════════════════════════════
   MATCH GAME
═══════════════════════════════════════════════ */

  #match-game-page,
  #glossary-game-page {
    padding: 64px 1.5rem 3rem;
    max-width: 780px;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
  }

  #mg-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .mg-tile {
    background: var(--card);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 0.65rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.45;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    font-family: inherit;
    direction: rtl;
    text-align: right;
    min-height: 64px;
    display: flex;
    align-items: center;
  }

  .mg-term {
    font-weight: 600;
    font-size: 0.82rem;
    border-color: rgba(108,99,255,0.35);
  }

  .mg-def {
    font-size: 0.74rem;
    color: var(--muted);
  }

  .mg-tile:hover:not(:disabled):not(.mg-matched) {
    border-color: var(--accent);
    background: rgba(108,99,255,0.07);
    transform: scale(1.02);
  }

  .mg-tile.mg-active {
    border-color: var(--accent);
    background: rgba(108,99,255,0.14);
    box-shadow: 0 0 0 2px rgba(108,99,255,0.3);
    color: var(--accent);
  }

  .mg-tile.mg-matched {
    border-color: var(--success);
    background: rgba(67,233,123,0.1);
    color: var(--success);
    cursor: default;
    opacity: 0.75;
  }

  .mg-tile.mg-wrong {
    border-color: var(--error);
    background: rgba(255,101,132,0.12);
    animation: mg-shake 0.4s ease;
  }

  .mg-tile.mg-flash-correct {
    animation: mg-pop 0.4s ease;
  }

  @keyframes mg-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
  }

  @keyframes mg-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.06); }
    100% { transform: scale(1); }
  }


/* ═══════════════════════════════════════════════
   STREAK MODE
═══════════════════════════════════════════════ */

  #streak-counter {
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Space Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ff6b35;
  }

  #streak-gameover {
    animation: streak-fade-in 0.3s ease;
  }

  @keyframes streak-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* Home card fire color */
  .hq-card:has(.hq-accent-bar[style*="ff6b35"]) { border-color: rgba(255,107,53,0.2); }
  .hq-card:has(.hq-accent-bar[style*="ff6b35"]):hover { border-color: rgba(255,107,53,0.5); }
