/* LAYOUT */
  .app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
  nav { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 0; display: flex; flex-direction: column; }

  /* ── Mobile hamburger button (visible only ≤1024px) ──────────────────── */
  .nav-toggle {
    display: none;
    position: fixed;
    /* iOS notch fix: respect safe-area-inset (notch i kamerę) */
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    z-index: 100;
    width: 44px; height: 44px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  .nav-toggle span {
    display: block;
    width: 20px; height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
  }
  .nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { opacity: 0; }
  .nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    animation: navOverlayFadeIn .25s ease;
  }
  .nav-overlay.open { display: block; }
  @keyframes navOverlayFadeIn { from { opacity: 0; } to { opacity: 1; } }

  /* ── Language switcher (PL / EN flags) ─────────────────────────────────── */
  .lang-switcher {
    display: flex;
    gap: 6px;
    padding: 0 20px 14px;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
  }
  .lang-btn {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.45;
    filter: grayscale(0.6);
    transition: opacity .18s, filter .18s, transform .18s, border-color .18s, background .18s;
  }
  .lang-btn:hover {
    opacity: 0.9;
    filter: grayscale(0);
    transform: scale(1.08);
  }
  .lang-btn.active {
    opacity: 1;
    filter: grayscale(0);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
  }
  .lang-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }

  nav .logo { padding: 0 20px 24px; font-size: 15px; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); margin-bottom: 12px; }
  nav .logo span { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }
  nav .logo .nav-admin-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-top: 6px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
  }

  /* ── Admin-only UI toggle ──────────────────────────────────────────────
     Element z klasą .admin-only jest niewidoczny dla wszystkich.
     Klasa body.is-admin (ustawiana przez applyRoleUI) ujawnia te elementy.
     Czystsze niż inline style toggle przez JS. */
  .admin-only { display: none !important; }
  body.is-admin .admin-only { display: inline-block !important; }
  body.is-admin #imp-public-row.admin-only { display: flex !important; }
  body.is-admin button.admin-only { display: inline-flex !important; }
  nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted); text-decoration: none; font-size: 14px; transition: all .15s; cursor: pointer; border: none; background: none; width: 100%; }
  nav a:hover, nav a.active { color: var(--text); background: var(--surface2); }
  nav a.active { border-left: 3px solid var(--accent); padding-left: 17px; }
  nav .icon { font-size: 16px; width: 20px; text-align: center; }
  nav .nav-divider { height: 1px; background: var(--border); margin: 8px 0; }
  nav .nav-section { padding: 6px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
  main { padding: 32px; overflow-y: auto; }

  /* PAGES */
  .page { display: none; }
  .page.active { display: block; }

  /* DASHBOARD */
  .kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 20px; }
  .kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
  .kpi .value { font-size: 32px; font-weight: 700; }
  .kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .section-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
  .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
  .chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .chart-card .section-title { margin-bottom: 12px; font-size: 15px; }
  .category-bars { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
  .cat-row { margin-bottom: 14px; }
  .cat-row:last-child { margin-bottom: 0; }
  .cat-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
  .bar-bg { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }
  .recent-sessions { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .session-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .session-row:last-child { border-bottom: none; }
  .session-score { font-weight: 600; }
  .score-good { color: var(--accent2); }
  .score-mid { color: var(--yellow); }
  .score-bad { color: var(--red); }
  .empty-state { color: var(--muted); font-size: 14px; text-align: center; padding: 32px; }

  /* ASCII WALKER */
  .ascii-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px;
    position: relative; height: 130px; overflow: hidden;
    background-image: repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(108,99,255,.03) 40px, rgba(108,99,255,.03) 41px);
  }
  .ascii-stage { position: absolute; inset: 0; }
  .ascii-walker { position: absolute; bottom: 26px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .ascii-char {
    font-family: 'Courier New', monospace; font-size: 13px; line-height: 1.3;
    color: var(--accent); user-select: none; white-space: pre; text-align: center;
    filter: drop-shadow(0 0 6px rgba(108,99,255,.5));
  }
  .ascii-bubble {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: transparent; padding: 0;
    font-size: 13px; color: var(--accent2); white-space: pre;
    font-family: 'Courier New', monospace; line-height: 1.4;
    opacity: 0; transition: opacity .4s; pointer-events: none; z-index: 10;
    text-shadow: 0 0 10px rgba(74,222,128,0.6);
  }
  .ascii-bubble.side-right { left: calc(100% + 10px); right: auto; }
  .ascii-bubble.side-left  { right: calc(100% + 10px); left: auto; }
  .ascii-bubble.show { opacity: 1; }
  .ascii-floor { position: absolute; bottom: 22px; left: 0; right: 0; height: 1px; background: var(--border); }
  .ascii-dots {
    position: absolute; bottom: 10px; left: 0; right: 0;
    display: flex; justify-content: center; gap: 6px;
    font-size: 10px; color: var(--border); letter-spacing: 6px;
  }
  .ascii-label { position: absolute; top: 10px; right: 14px; font-size: 10px; color: var(--muted); opacity: .6; }

  /* QUIZ SETUP */
  .quiz-setup { max-width: 560px; }
  .setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 16px; }
  .setup-card h2 { font-size: 20px; margin-bottom: 24px; }
  .field { margin-bottom: 20px; }
  .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
  select, input[type=number] {
    width: 100%; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px;
  }
  .btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all .15s; }
  .btn:active { transform: scale(0.97); }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: #5b54e8; }
  .btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
  .btn-ghost:hover { background: var(--border); }
  .btn-sm { padding: 8px 14px; font-size: 12px; }
  .btn-full { width: 100%; justify-content: center; }
  kbd { display: inline-block; padding: 1px 5px; font-size: 10px; font-family: 'Courier New', monospace; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2); border-radius: 3px; margin-left: 4px; vertical-align: middle; opacity: 0.75; }
  .btn-icon { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); padding: 8px 12px; font-size: 13px; }
  .btn-icon:hover { color: var(--text); border-color: var(--accent); }
  .quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .quick-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; cursor: pointer; text-align: left; transition: all .18s; }
  .quick-btn:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(108,99,255,.2); }
  .quick-btn .q-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
  .quick-btn .q-sub { font-size: 12px; color: var(--muted); }
  .setup-toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  input[type=file] { display: none; }

  /* QUIZ IN PROGRESS */
  #quiz-active { display: none; max-width: 960px; }
  .quiz-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; }
  .quiz-header-left { flex: 1; min-width: 0; }
  .quiz-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 2px; }
  .quiz-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
  .quiz-progress-text { font-size: 13px; color: var(--muted); }
  .progress-bar { height: 5px; background: var(--surface2); border-radius: 3px; margin-bottom: 6px; width: 280px; }
  .progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: 3px; transition: width .4s ease; }
  .category-badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 500; }
  .cat-1 { background: #1e3a5f; color: #60a5fa; }
  .cat-2 { background: #1a3a2a; color: #4ade80; }
  .cat-3 { background: #3a2a1a; color: #fb923c; }
  .question-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 16px; }
  .question-text { font-size: 19px; line-height: 1.65; margin-bottom: 28px; font-weight: 400; }
  .options { display: flex; flex-direction: column; gap: 10px; }
  .option {
    display: flex; align-items: flex-start; gap: 14px; padding: 15px 18px;
    background: var(--surface2); border: 2px solid var(--border); border-radius: 10px;
    cursor: pointer; transition: all .15s; font-size: 15px; line-height: 1.5;
  }
  .option:hover:not(.disabled) { border-color: var(--accent); background: #1e2038; transform: translateX(3px); }
  .opt-letter {
    font-weight: 700; min-width: 28px; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--border); font-size: 12px; flex-shrink: 0; margin-top: 2px;
  }
  .option.correct { border-color: var(--accent2); background: #0f2a1a; }
  .option.correct .opt-letter { background: var(--accent2); color: #000; }
  .option.wrong { border-color: var(--red); background: #2a0f0f; }
  .option.wrong .opt-letter { background: var(--red); color: #000; }
  .option.disabled { cursor: default; transform: none !important; }
  .kbd-hint { margin-top: 12px; font-size: 11px; color: var(--muted); text-align: right; }

  /* EXPLANATION */
  .explanation { display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
  .explanation.show { display: block; }
  .expl-header { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 16px; }
  .expl-row { display: flex; gap: 10px; margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
  .expl-row:last-child { margin-bottom: 0; }
  .expl-letter { font-weight: 700; min-width: 24px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; flex-shrink: 0; margin-top: 2px; }
  .expl-correct .expl-letter { background: var(--accent2); color: #000; }
  .expl-wrong .expl-letter { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
  .meta-row { font-size: 12px; color: var(--muted); margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); line-height: 1.7; }
  .quiz-nav { display: flex; gap: 12px; align-items: center; }

  /* RESULTS */
  #quiz-results { display: none; max-width: 600px; }
  .results-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; text-align: center; margin-bottom: 24px; }
  .results-score { font-size: 64px; font-weight: 800; margin: 8px 0; }
  .results-label { font-size: 15px; color: var(--muted); }
  .results-sub { font-size: 14px; color: var(--muted); margin-top: 8px; }
  .results-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 24px 0; }
  .results-stat { background: var(--surface2); border-radius: 10px; padding: 16px; }
  .results-stat .rs-val { font-size: 24px; font-weight: 700; }
  .results-stat .rs-lab { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .results-breakdown { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
  .breakdown-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
  .breakdown-row:last-child { border-bottom: none; }
  .results-actions { display: flex; gap: 12px; }

  /* STATS PAGE */
  .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
  .hard-questions { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .hard-q-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; border-radius: 6px; transition: background .12s; }
  .hard-q-row:last-child { border-bottom: none; }
  .hard-q-row:hover { background: var(--surface2); }
  .hard-q-text { flex: 1; margin-right: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .accuracy-pill { padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }

  /* ANIMATIONS */
  @keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes fadeInScale { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
  @keyframes slideDown { from { opacity: 0; max-height: 0; transform: translateY(-8px); } to { opacity: 1; max-height: 800px; transform: translateY(0); } }
  @keyframes pulseGreen { 0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } 50% { box-shadow: 0 0 0 6px rgba(74,222,128,0.2); } }
  @keyframes shakeRed { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }
  @keyframes countPop { 0% { opacity: 0; transform: scale(0.5); } 70% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
  @keyframes kpiBounce { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
  @keyframes optionIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
  @keyframes glowPulse { 0%,100% { filter: drop-shadow(0 0 4px rgba(108,99,255,.4)); } 50% { filter: drop-shadow(0 0 12px rgba(108,99,255,.9)); } }

  .page.active { animation: fadeInUp .22s ease both; }
  .question-card.animate-in { animation: fadeInScale .2s ease both; }
  .option.appear { animation: optionIn .15s ease both; }
  .option.anim-correct { animation: pulseGreen .5s ease; }
  .option.anim-wrong { animation: shakeRed .35s ease; }
  .explanation.show { animation: slideDown .3s ease both; overflow: hidden; }
  .results-score.animate { animation: countPop .5s cubic-bezier(.34,1.56,.64,1) both; }
  .kpi.animate .value { animation: kpiBounce .35s ease both; }
  .ascii-char { animation: glowPulse 3s ease infinite; }
  @keyframes timerPulseRed { 0%,100%{opacity:1}50%{opacity:.5} }

  /* TIMER BAR */
  .timer-bar-bg { height: 4px; background: var(--surface2); border-radius: 3px; width: 260px; overflow: hidden; margin-top: 5px; }
  .timer-bar-fill { height: 100%; border-radius: 3px; width: 0%; background: var(--accent2); transition: width .95s linear, background-color .4s; }
  .timer-display { font-size: 12px; font-family: 'Courier New', monospace; color: var(--muted); transition: color .3s; }
  .timer-red { color: var(--red) !important; font-weight: 700; animation: timerPulseRed .8s ease infinite; }

  /* MODAL */
  .modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:500; display:flex; align-items:center; justify-content:center; animation:fadeInUp .18s ease; }
  .modal-box { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:32px; width:360px; max-width:90vw; }
  .modal-box h3 { font-size:17px; margin-bottom:8px; }
  .modal-box p { font-size:13px; color:var(--muted); margin-bottom:20px; line-height:1.5; }
  .modal-box input[type=text] { width:100%; background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:10px 12px; border-radius:8px; font-size:15px; margin-bottom:16px; }
  .modal-box input[type=text]:focus { outline:none; border-color:var(--accent); }
  .modal-actions { display:flex; gap:10px; justify-content:flex-end; }
  /* VERSION BADGE + HISTORY MODAL */
  .app-version { display:inline-block; margin-top:5px; font-size:10px; font-weight:500; color:var(--accent); background:rgba(108,99,255,.12); border:1px solid rgba(108,99,255,.25); border-radius:4px; padding:1px 6px; cursor:pointer; letter-spacing:.3px; transition:background .15s; }
  .app-version:hover { background:rgba(108,99,255,.25); }
  /* EXAM DATE */
  .exam-date-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:16px 20px; margin-bottom:16px; }
  .exam-date-label { font-size:12px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin-bottom:10px; }
  .exam-date-row { display:flex; gap:10px; align-items:center; }
  .exam-date-row input[type=date] { background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:7px 10px; border-radius:8px; font-size:14px; flex:1; min-width:0; }
  .exam-date-row input[type=date]:focus { outline:none; border-color:var(--accent); }
  .exam-date-status { margin-top:8px; font-size:13px; min-height:18px; }
  /* EXAM COUNTDOWN on Dashboard */
  .exam-countdown-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; margin-bottom:20px; }
  .ec-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; font-size:14px; }
  .ec-days-badge { font-size:13px; font-weight:700; border:1px solid; border-radius:20px; padding:2px 12px; }
  .ec-bar-wrap { margin-bottom:6px; }
  .ec-meta { font-size:11px; color:var(--muted); margin-top:6px; }
  /* STUDY PROGRESS CHART */
  .ec-legend { display:flex; gap:20px; margin-top:10px; font-size:12px; color:var(--muted); flex-wrap:wrap; }
  .ec-leg-item { display:flex; align-items:center; gap:6px; }
  .ec-leg-dot { width:10px; height:3px; border-radius:2px; display:inline-block; }
  /* QUIZ countdown badge */
  .q-exam-cd { font-size:11px; color:var(--muted); background:rgba(108,99,255,.1); border:1px solid rgba(108,99,255,.2); border-radius:4px; padding:1px 8px; }
  .vh-modal-box { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:28px 32px; width:520px; max-width:92vw; max-height:80vh; display:flex; flex-direction:column; }
  .vh-modal-box h3 { font-size:16px; font-weight:700; margin-bottom:16px; }
  .vh-table { width:100%; border-collapse:collapse; font-size:13px; overflow-y:auto; }
  .vh-table th { text-align:left; padding:6px 10px; color:var(--muted); font-weight:500; border-bottom:1px solid var(--border); font-size:11px; text-transform:uppercase; letter-spacing:.5px; }
  .vh-table td { padding:9px 10px; border-bottom:1px solid rgba(46,50,80,.5); vertical-align:top; line-height:1.45; }
  .vh-table tr:last-child td { border-bottom:none; }
  .vh-table .vh-ver { font-weight:700; color:var(--accent); white-space:nowrap; }
  .vh-table .vh-date { color:var(--muted); white-space:nowrap; font-size:12px; }
  .vh-scroll { overflow-y:auto; flex:1; }

  /* AI EXPLAIN */
  .ai-explain-btn { margin-top: 14px; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .ai-disclaimer { font-size: 11px; color: var(--muted); line-height: 1.5; max-width: 420px; padding-top: 3px; }
  #btn-ai-explain:disabled { opacity: 0.4; cursor: not-allowed; }
  .ai-explain-result { margin-top: 14px; padding: 16px; background: rgba(108,99,255,.07); border: 1px solid rgba(108,99,255,.25); border-radius: 10px; font-size: 13px; line-height: 1.7; color: var(--text); display: none; }
  .ai-explain-result.show { display: block; animation: slideDown .3s ease both; }
  .ai-explain-result .ai-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 8px; }
  .ai-explain-result.loading .ai-label::after { content: ' ⏳'; }
  /* FC AI EXPLAIN */
  .fc-ai-wrap { margin-top: 16px; display: none; width: 100%; max-width: 720px; }
  .fc-ai-wrap.show { display: block; }
  .fc-ai-btn-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
  .fc-ai-disclaimer { font-size: 11px; color: var(--muted); line-height: 1.5; max-width: 420px; padding-top: 3px; }
  #btn-fc-ai-explain:disabled { opacity: 0.4; cursor: not-allowed; }
  .fc-ai-result { padding: 16px; background: rgba(108,99,255,.07); border: 1px solid rgba(108,99,255,.25); border-radius: 10px; font-size: 13px; line-height: 1.7; color: var(--text); display: none; }
  .fc-ai-result.show { display: block; animation: slideDown .3s ease both; }
  .fc-ai-result .fc-ai-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 10px; }
  .fc-ai-result.loading .fc-ai-label::after { content: ' ⏳'; }
  .fc-ai-context { margin-bottom: 12px; }
  .fc-ai-context p { margin: 0; }
  .fc-ai-example { margin-bottom: 12px; padding: 10px 14px; background: var(--surface2); border-radius: 6px; font-style: italic; font-size: 13px; color: var(--muted); }
  .fc-ai-remember { padding: 10px 14px; background: rgba(74,222,128,.08); border-left: 3px solid var(--accent2); border-radius: 6px; font-size: 13px; }
  .fc-ai-remember .fc-ai-remember-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent2); margin-bottom: 4px; }

  .ai-why-correct { margin-bottom: 12px; }
  .ai-why-correct p { margin: 0; }
  .ai-why-wrong { margin-bottom: 12px; }
  .ai-why-wrong ul { margin: 6px 0 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
  .ai-why-wrong ul li { display: flex; gap: 8px; }
  .ai-why-wrong ul li .ai-opt { font-weight: 700; color: var(--red); min-width: 18px; }
  .ai-key-concept { margin-top: 12px; padding: 10px 14px; background: rgba(74,222,128,.08); border-left: 3px solid var(--accent2); border-radius: 6px; font-size: 13px; }
  .ai-key-concept .ai-key-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent2); margin-bottom: 4px; }

  /* SETTINGS PAGE */
  .settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 16px; max-width: 560px; }
  .settings-card h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
  .settings-card .settings-desc { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
  .settings-key-row { display: flex; gap: 10px; align-items: center; }
  .settings-key-row input[type=password] { flex: 1; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
  .settings-key-row input[type=password]:focus { outline: none; border-color: var(--accent); }
  .settings-status { margin-top: 10px; font-size: 12px; min-height: 18px; }
  .settings-status.ok { color: var(--accent2); }
  .settings-status.err { color: var(--red); }
  .settings-notice { font-size: 12px; color: var(--muted); margin-top: 12px; padding: 10px 14px; background: var(--surface2); border-radius: 8px; border-left: 3px solid var(--border); line-height: 1.6; }

  /* TOAST */
  .toast {
    position: fixed; bottom: 24px; right: 24px; background: var(--surface2);
    border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px;
    font-size: 13px; color: var(--text); z-index: 1000;
    animation: fadeInUp .2s ease; box-shadow: 0 8px 32px rgba(0,0,0,.4);
    display: flex; align-items: center; gap: 8px;
  }
  .toast.success { border-color: var(--accent2); }
  .toast.error { border-color: var(--red); }

  /* CATEGORY SEEN/REMAINING */
  .cat-seen { font-size: 11px; color: var(--muted); margin-top: 3px; }

  /* STUDY TOOLS STATS */
  .tool-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
  .tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .tool-card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 14px; }
  .tool-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tool-stat { text-align: center; padding: 10px 6px; background: var(--surface2); border-radius: 10px; }
  .tool-stat .ts-val { font-size: 20px; font-weight: 700; }
  .tool-stat .ts-lab { font-size: 10px; color: var(--muted); margin-top: 3px; }
  .tool-sessions { margin-top: 14px; }
  .tool-session-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
  .tool-session-row:last-child { border-bottom: none; }
  .tool-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 16px 0; }
/* ── AUTH OVERLAY (Prep3) ───────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#auth-overlay.hidden { display: none; }

#auth-overlay {
  background:
    radial-gradient(at 20% 30%, rgba(14, 165, 233, 0.08) 0%, transparent 40%),
    radial-gradient(at 80% 70%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    var(--bg);
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: 100%; max-width: 440px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(14, 165, 233, 0.1);
  animation: authFadeIn .4s ease-out;
}

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

/* ── Hero: gradient header z brandem ──────────────────────────────────── */
.auth-hero {
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #8b5cf6 100%);
  color: #ffffff;
  padding: 36px 36px 28px;
  text-align: center;
}
.auth-brand-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}
.auth-brand {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.auth-tagline {
  font-size: 13.5px;
  opacity: 0.92;
  letter-spacing: 0.3px;
}

/* ── Content: form area ────────────────────────────────────────────────── */
.auth-content { padding: 28px 36px 24px; }

.auth-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.3px;
  font-style: italic;
}

.auth-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  padding: 10px 20px; cursor: pointer; font-size: 14px;
  font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .2s;
}
.auth-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 6px;
}
.auth-field input {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
  outline: none; transition: border-color .2s;
}
.auth-field input:focus { border-color: var(--accent); }

.auth-submit {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #0ea5e9 0%, #8b5cf6 100%);
  color: #fff;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  margin-top: 6px;
  letter-spacing: 0.2px;
  transition: transform .15s, box-shadow .15s, opacity .2s;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}
.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.35);
}
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: .5; cursor: not-allowed; }

.auth-error {
  margin-top: 12px; font-size: 13px;
  color: var(--red); min-height: 18px;
}

/* ── NAV — multi-exam & user (Prep3) ───────────────────────── */
.nav-active-exam {
  margin: 0 12px 8px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.nav-exam-label { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.nav-exam-name { color: var(--accent); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-user {
  margin: 4px 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.nav-user-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-logout {
  font-size: 11px; color: var(--muted);
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; cursor: pointer;
  white-space: nowrap; transition: color .2s;
}
.nav-user-logout:hover { color: var(--red); border-color: var(--red); }

/* ── SETTINGS HUB (Prep3) ───────────────────────────────────── */
#settings-hub { max-width: 700px; }
.settings-hub-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.settings-hub-sub   { font-size: 14px; color: var(--muted); margin-bottom: 28px; }

.settings-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.settings-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.settings-tile:hover { border-color: var(--accent); background: var(--surface2); }
.st-icon  { font-size: 26px; margin-bottom: 10px; }
.st-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.st-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }

.settings-subsection { display: none; max-width: 560px; }
.settings-subsection.active { display: block; }

.settings-section-back {
  display: inline-flex; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 18px;
  cursor: pointer; transition: color .15s;
}
.settings-section-back:hover { color: var(--text); }

.settings-card h2 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.settings-card-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

/* ── MY EXAMS PAGE (Prep3) ──────────────────────────────────── */
.exams-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.exams-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.exams-tab {
  padding: 10px 20px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all .15s;
}
.exams-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.exams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.exams-empty {
  grid-column: 1/-1; text-align: center;
  padding: 48px 20px; color: var(--muted); font-size: 14px;
}
.exams-empty .icon { font-size: 32px; margin-bottom: 10px; }

.exam-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: border-color .15s;
}
.exam-card:hover { border-color: var(--accent); }
.exam-card.is-active { border-color: var(--accent2); }

.exam-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; margin-bottom: 8px;
}
.exam-card-name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.exam-card-desc { font-size: 13px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }
.exam-card-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

.exam-card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.exam-card-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; border: 1px solid;
}
.exam-card-badge.owner  { color: var(--accent);  border-color: var(--accent);  background: rgba(108,99,255,.12); }
.exam-card-badge.public { color: var(--muted);   border-color: var(--border);  background: var(--surface2); }
.exam-card-badge.active { color: var(--accent2); border-color: var(--accent2); background: rgba(74,222,128,.12); }

.exam-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ── EXAM SESSION PAGE (Prep3) ──────────────────────────────── */
.exam-session-wrap {
  max-width: 540px; margin: 0 auto; text-align: center; padding: 20px 0;
}
.exam-session-crest { font-size: 48px; margin-bottom: 10px; }
.exam-session-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.exam-session-subtitle { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.exam-session-notice {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px;
  text-align: left; font-size: 14px; line-height: 1.7;
  margin-bottom: 28px; color: var(--muted);
}
.exam-options-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }
.exam-options-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px;
}
.exam-option-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.exam-option-card:hover { border-color: var(--accent); background: var(--surface2); }
.exam-opt-num   { font-size: 28px; font-weight: 800; color: var(--accent); }
.exam-opt-label { font-size: 12px; color: var(--muted); margin: 2px 0; }
.exam-opt-time  { font-size: 11px; color: var(--muted); }
.exam-session-divider { border: none; border-top: 1px solid var(--border); margin: 0 0 20px; }
.exam-session-footer { font-size: 13px; color: var(--muted); line-height: 1.7; }
.exam-session-footer a { color: var(--accent); cursor: pointer; }

/* ── Docs Page ─────────────────────────────────────────── */
.docs-layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; max-width: 1200px; }
.docs-toc { position: sticky; top: 0; align-self: start; }
.docs-toc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.docs-toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 12px; }
.docs-toc a { display: block; font-size: 13px; color: var(--muted); text-decoration: none; padding: 5px 0; border-left: 2px solid transparent; padding-left: 10px; transition: all .15s; }
.docs-toc a:hover { color: var(--text); border-left-color: var(--accent); }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }
.docs-toc .toc-sub { font-size: 12px; padding-left: 20px; }
.docs-toc-divider { height: 1px; background: var(--border); margin: 8px 0; }
.docs-content { min-width: 0; }
.docs-header { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.docs-header h1 { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.docs-header .docs-subtitle { font-size: 14px; color: var(--muted); }
.docs-header .docs-badge { display: inline-block; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; margin-left: 10px; vertical-align: middle; }
.docs-section { margin-bottom: 40px; scroll-margin-top: 20px; }
.docs-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
.docs-section-icon { font-size: 22px; }
.docs-section-header h2 { font-size: 20px; font-weight: 700; color: var(--accent); }
.docs-section-header .docs-part-label { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.docs-subsection { margin-bottom: 24px; }
.docs-subsection h3 { font-size: 15px; font-weight: 700; color: var(--accent2); margin-bottom: 12px; padding-left: 10px; border-left: 3px solid var(--accent2); }
.docs-table-wrap { overflow-x: auto; margin-bottom: 16px; border-radius: 8px; border: 1px solid var(--border); }
.docs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.docs-table th { background: var(--surface2); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.docs-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; line-height: 1.5; }
.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: rgba(108,99,255,.04); }
.docs-table td:first-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.docs-table td strong { color: var(--accent); }
.docs-table td em { color: var(--accent2); font-style: italic; }
.docs-tip { background: rgba(108,99,255,.1); border: 1px solid rgba(108,99,255,.35); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.6; }
.docs-tip .tip-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 6px; }
.docs-warn { background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35); border-left: 4px solid var(--yellow); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.6; }
.docs-warn .warn-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--yellow); margin-bottom: 6px; }
.docs-info { background: rgba(74,222,128,.07); border: 1px solid rgba(74,222,128,.25); border-left: 4px solid var(--accent2); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.6; }
.docs-info .info-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent2); margin-bottom: 6px; }
.docs-list { list-style: none; padding: 0; margin-bottom: 16px; }
.docs-list li { padding: 5px 0 5px 20px; position: relative; font-size: 13.5px; line-height: 1.6; color: var(--text); border-bottom: 1px solid rgba(255,255,255,.04); }
.docs-list li:last-child { border-bottom: none; }
.docs-list li::before { content: '▸'; position: absolute; left: 0; color: var(--accent); font-size: 11px; top: 7px; }
.docs-list li strong { color: var(--accent2); }
.docs-list li em { color: var(--muted); font-style: italic; }
.docs-code { font-family: 'Courier New', monospace; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; font-size: 13px; color: var(--accent2); margin-bottom: 16px; line-height: 1.7; white-space: pre; overflow-x: auto; }
.docs-levels { display: flex; gap: 0; margin-bottom: 16px; }
.docs-level { flex: 1; padding: 12px; text-align: center; font-size: 12px; border: 1px solid var(--border); }
.docs-level:first-child { border-radius: 8px 0 0 8px; }
.docs-level:last-child { border-radius: 0 8px 8px 0; }
.docs-level .lvl-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.docs-level .lvl-sub { color: var(--muted); font-size: 11px; }
.docs-level.lvl-ani { background: rgba(74,222,128,.08); border-color: rgba(74,222,128,.3); }
.docs-level.lvl-agi { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.3); }
.docs-level.lvl-asi { background: rgba(248,113,113,.08); border-color: rgba(248,113,113,.3); }
.docs-level .lvl-name.g { color: var(--accent2); }
.docs-level .lvl-name.y { color: var(--yellow); }
.docs-level .lvl-name.r { color: var(--red); }
.docs-risk-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.docs-risk-item { border-radius: 8px; padding: 12px 14px; border: 1px solid var(--border); font-size: 13px; }
.docs-risk-item .risk-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.docs-risk-item .risk-title { font-weight: 700; margin-bottom: 4px; }
.docs-risk-item .risk-desc { color: var(--muted); font-size: 12px; }
.risk-unacceptable { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.4); }
.risk-unacceptable .risk-label { color: var(--red); }
.risk-high { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.35); }
.risk-high .risk-label { color: var(--yellow); }
.risk-limited { background: rgba(108,99,255,.08); border-color: rgba(108,99,255,.3); }
.risk-limited .risk-label { color: var(--accent); }
.risk-minimal { background: rgba(74,222,128,.07); border-color: rgba(74,222,128,.25); }
.risk-minimal .risk-label { color: var(--accent2); }
.docs-kri { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.docs-kri-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.docs-kri-item .kri-letter { font-size: 28px; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.docs-kri-item .kri-name { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.docs-kri-item .kri-desc { font-size: 12px; color: var(--muted); }
.kri-s .kri-letter { color: var(--accent); }
.kri-a .kri-letter { color: var(--accent2); }
.kri-f .kri-letter { color: var(--yellow); }
.kri-e .kri-letter { color: #a78bfa; }
.docs-lifecycle { display: flex; flex-direction: column; gap: 0; margin-bottom: 16px; }
.docs-lc-step { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-bottom: none; font-size: 13px; }
.docs-lc-step:first-child { border-radius: 8px 8px 0 0; }
.docs-lc-step:last-child { border-bottom: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.docs-lc-step .lc-num { min-width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.docs-lc-step .lc-title { font-weight: 700; color: var(--accent2); margin-bottom: 3px; }
.docs-lc-step .lc-risk { font-size: 12px; color: var(--muted); }
.docs-p { font-size: 14px; line-height: 1.7; margin-bottom: 14px; color: var(--text); }
.docs-p strong { color: var(--accent2); }
.docs-p em { color: var(--muted); font-style: italic; }
.docs-back-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; margin-bottom: 24px; transition: all .15s; text-decoration: none; }
.docs-back-btn:hover { color: var(--text); border-color: var(--accent); }
.docs-domain-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.docs-domain-tab { padding: 8px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.docs-domain-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.docs-domain-tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Tier A
   Breakpoints: tablet ≤1024px, mobile ≤640px, small-mobile ≤380px
   ═════════════════════════════════════════════════════════════════════════ */

/* ── TABLET + MOBILE (≤1024px) ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Layout: ukryty sidebar, slide-in z lewej po klik burger */
  .app { grid-template-columns: 1fr; }
  body { overflow: auto; height: auto; min-height: 100vh; }

  nav {
    position: fixed;
    top: 0; bottom: 0; left: -280px;
    width: 260px;
    z-index: 95;
    transition: left .25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
  }
  nav.open { left: 0; }

  .nav-toggle { display: flex; }

  main {
    padding: 64px 16px 24px;  /* top padding na burger button */
  }

  /* Logo w nav — wyśrodkowane, mniejsze, bo burger button blokuje lewy róg */
  nav .logo {
    padding: 24px 20px 24px;
    font-size: 14px;
  }

  /* Touch-friendly: wszystkie buttony i linki min 44px */
  nav a { padding: 12px 20px; min-height: 44px; }
  .btn { padding: 12px 20px; min-height: 44px; }
  .btn-sm { padding: 10px 14px; min-height: 38px; font-size: 13px; }
  .btn-filter { padding: 10px 14px; min-height: 40px; }
  input, select, textarea { font-size: 16px; min-height: 44px; padding: 12px; }

  /* Dashboard: KPI 6→3 kolumny, charts 2→1 kolumna */
  .kpi-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .charts-row { grid-template-columns: 1fr; gap: 12px; }

  /* Quiz: header w kolumnie, mniejszy padding karty */
  .quiz-header { flex-direction: column; gap: 12px; }
  .quiz-header-right { width: 100%; flex-wrap: wrap; }
  .question-card { padding: 18px; }
  .kbd-hint { display: none; }  /* shortcuts klawiszowe niepotrzebne na mobile */

  /* Modale: lepszy padding na mobile */
  .modal-content, .modal-inner {
    max-width: calc(100vw - 24px);
    margin: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
}

/* ── MOBILE (≤640px) ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* KPI 3→2 kolumny */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 22px; }

  /* Login screen — bliżej krawędzi */
  .auth-box { margin: 12px; max-width: calc(100vw - 24px); }
  .auth-hero { padding: 28px 24px 22px; }
  .auth-brand-icon { font-size: 36px; }
  .auth-brand { font-size: 24px; }
  .auth-content { padding: 22px 22px 18px; }

  /* Main padding redukcja */
  main { padding: 56px 12px 16px; }

  /* Quiz options — czytelne na mobile */
  .option { padding: 14px; font-size: 14px; }
  .question-card { padding: 16px; }
  .question-text { font-size: 15px; }
}

/* ── SMALL MOBILE (≤380px) — iPhone SE, najtrudniejsze ─────────────────── */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }  /* single column dla najmniejszych */
  .auth-hero { padding: 24px 20px 20px; }
  .auth-brand { font-size: 22px; }
}

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE TIER B — Polished components
   ═════════════════════════════════════════════════════════════════════════ */

/* ── List Questions: tabela z horizontal scroll na tablecie/mobile ────── */
@media (max-width: 1024px) {
  /* Wrapper z horizontal scroll dla wszystkich tabel */
  .lq-table, .mq-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .lq-filters { flex-wrap: wrap; gap: 8px; }
  .lq-filters select, .lq-filters input {
    flex: 1;
    min-width: calc(50% - 4px);
  }

  /* Domain coverage chart container responsive */
  .docs-table-wrap, .vh-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Question Editor: 4-input options grid → 2 cols → 1 col ──────────── */
@media (max-width: 1024px) {
  .qe-options-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .qe-modal-box {
    max-width: calc(100vw - 24px) !important;
    margin: 12px !important;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
  .qe-scroll { padding: 16px; }
  .qe-row2 { flex-direction: column; gap: 12px; }
}
@media (max-width: 640px) {
  .qe-options-grid { grid-template-columns: 1fr; }
}

/* ── Settings: hubcards 1 col + Exam Session: better mobile ──────────── */
@media (max-width: 640px) {
  .settings-hub, .hub-grid {
    grid-template-columns: 1fr !important;
  }
  .results-grid, .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .results-grid .results-stat,
  .stats-grid > * { padding: 14px 10px; }
}

/* ── Modale generic responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .modal-overlay, .preview-overlay {
    padding: 12px;
  }
  .modal-box, .preview-box {
    max-width: calc(100vw - 24px) !important;
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 20px;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE: MATERIAŁY (docs-*) — Domain 1/2/3 reading view
   ═════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  /* Layout: ukryć TOC sidebar, content full-width */
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .docs-toc {
    position: static;
    margin-bottom: 16px;
  }
  .docs-toc-card { padding: 14px; }
  .docs-toc a { padding: 8px 0 8px 10px; }  /* touch-friendly */

  /* Headers mniejsze */
  .docs-header { margin-bottom: 20px; padding-bottom: 14px; }
  .docs-header h1 { font-size: 22px; }
  .docs-header .docs-subtitle { font-size: 13px; }
  .docs-section { margin-bottom: 28px; }
  .docs-section-header h2 { font-size: 18px; }
  .docs-subsection h3 { font-size: 14px; }
  .docs-p { font-size: 13.5px; }
  .docs-list li { font-size: 13.5px; }

  /* Widgety stackowane na mobile */
  .docs-levels {
    flex-direction: column;
    gap: 6px;
  }
  .docs-level:first-child,
  .docs-level:last-child,
  .docs-level { border-radius: 8px; }
}

@media (max-width: 640px) {
  /* Risk levels + KRI: 2 cols → 1 col na phone */
  .docs-risk-levels { grid-template-columns: 1fr; }
  .docs-kri { grid-template-columns: 1fr 1fr; gap: 8px; }
  .docs-kri-item { padding: 10px 12px; }
  .docs-kri-item .kri-letter { font-size: 24px; }

  /* Lifecycle step: mniejszy padding */
  .docs-lc-step { padding: 10px 12px; gap: 10px; font-size: 12.5px; }
  .docs-lc-step .lc-num { min-width: 22px; height: 22px; font-size: 10px; }

  /* Domain tabs scroll horizontal jeśli za szerokie */
  .docs-domain-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .docs-domain-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 12.5px;
  }

  /* Callout boxes: mniejszy padding */
  .docs-tip, .docs-warn, .docs-info { padding: 10px 12px; font-size: 13px; }
  .docs-code { padding: 10px 12px; font-size: 12px; }
}

@media (max-width: 380px) {
  .docs-kri { grid-template-columns: 1fr; }
  .docs-header h1 { font-size: 20px; }
  .docs-section-header h2 { font-size: 16px; }
}

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE TIER C2 — Swipe gestures animations
   ═════════════════════════════════════════════════════════════════════════ */

/* Swipe out — gdy detektor wykryje swipe, dodaje klasę → animacja */
.swipe-out-right {
  animation: swipeRight .22s cubic-bezier(0.55, 0, 0.55, 1) forwards;
}
.swipe-out-left {
  animation: swipeLeft .22s cubic-bezier(0.55, 0, 0.55, 1) forwards;
}
@keyframes swipeRight {
  to { transform: translateX(80vw) rotate(8deg); opacity: 0; }
}
@keyframes swipeLeft {
  to { transform: translateX(-80vw) rotate(-8deg); opacity: 0; }
}

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE TIER C3 — Polish animations
   ═════════════════════════════════════════════════════════════════════════ */

/* Stagger reveal dla list/grid items (KPI, sesje, etc.) */
.stagger-in > * {
  opacity: 0;
  animation: staggerFadeUp .4s ease forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: .05s; }
.stagger-in > *:nth-child(2) { animation-delay: .10s; }
.stagger-in > *:nth-child(3) { animation-delay: .15s; }
.stagger-in > *:nth-child(4) { animation-delay: .20s; }
.stagger-in > *:nth-child(5) { animation-delay: .25s; }
.stagger-in > *:nth-child(6) { animation-delay: .30s; }
.stagger-in > *:nth-child(n+7) { animation-delay: .35s; }

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

/* Smooth page transition — slide z prawej */
.page.active {
  animation: pageSlideIn .28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pageSlideIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Bouncy burger menu (overshoot bounce dla nav open) */
@media (max-width: 1024px) {
  nav {
    transition: left .35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  }
}

/* Skeleton loaders — placeholder kontent podczas fetch */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skeletonShimmer {
  0%   { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.long  { width: 100%; }
.skeleton-card { height: 80px; margin-bottom: 12px; }

/* Honor user reduced-motion preference (accessibility) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
