/*
 * Early — system wizualny (issue #14)
 * Bez frameworków, bez builda. Mobile-first, duże cele dotykowe (>=48px),
 * zaokrąglenia 16-24px, karty/przyciski z dolnym "cieniem" 4px w stylu Duolingo.
 *
 * Spis sekcji:
 *   1. Fonty
 *   2. Tokeny (:root) + tryb ciemny
 *   3. Reset / baza
 *   4. Layout (.container, .path grid >=900px)
 *   5. Topbar
 *   6. Ścieżka: .unit-section, .node, .node-ring, .exam-cards
 *   7. Karta zadania: .exercise, .prompt, .btn-speak
 *   8. Odpowiedzi: .choices, .tiles, .sentence-slot, .match-cols, .buckets,
 *      .order-list, .input-answer
 *   9. Postęp i dolny pasek: .progress, .bottom-bar, .result-bar
 *  10. Podsumowanie i powtórka: .summary, .review-list
 *  11. Panel rodzica: .tabs, .table, .chart-bars
 *  12. Komponenty ogólne: .btn, .badge, .avatar, .profile-grid
 *  13. Animacje + prefers-reduced-motion
 */

/* ---------- 1. Fonty ---------- */
/* Google Fonts "Nunito" ładowany opcjonalnie z index.html (font-display: swap).
   Tu tylko deklarujemy stos z bezpiecznym fallbackiem systemowym. */
:root {
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- 2. Tokeny ---------- */
:root {
  --bg: #f7f9fc;
  --card: #ffffff;
  --text: #26272b;
  --muted: #6b7280;
  --border: #e5e7eb;

  --accent: #58cc02;
  --accent-dark: #4aa302;
  --success: #58cc02;
  --success-dark: #4aa302;
  --danger: #ff4b4b;
  --danger-dark: #d63333;
  --warning: #ffc800;
  --warning-dark: #e0a800;

  /* Domyślny kolor sekcji unitu — nadpisywany inline per sekcja: style="--unit-color:#1cb0f6" */
  --unit-color: #1cb0f6;

  --radius: 20px;
  --radius-sm: 16px;
  --radius-lg: 24px;

  /* "Cień" dolny 4px w stylu Duolingo dla kart/przycisków */
  --shadow: 0 4px 0 0 var(--border);

  --gutter: 16px;
  --container-max: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --card: #1c1f2a;
    --text: #eef1f6;
    --muted: #9aa4b6;
    --border: #2c3142;

    --accent: #58cc02;
    --accent-dark: #4aa302;
    --success: #58cc02;
    --success-dark: #4aa302;
    --danger: #ff5c5c;
    --danger-dark: #cc3d3d;
    --warning: #ffcd1f;
    --warning-dark: #cc9f00;

    --unit-color: #3fb6f5;
    --shadow: 0 4px 0 0 rgba(0, 0, 0, 0.35);
  }
}

/* ---------- 3. Reset / baza ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }
img.emoji { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-dark); }

h1, h2, h3, h4, p { margin: 0; }

/* Cele dotykowe */
button, .btn, .tile, .choice, .node, .tab, input.input-answer {
  touch-action: manipulation;
}

/* ---------- 4. Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.path {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 24px var(--gutter) 32px;
  max-width: var(--container-max);
  margin: 0 auto;
  width: 100%;
}

/* Jedna kolumna na każdej szerokości (Michał 27.09), unity oddzielone linią. */
.path { max-width: 680px; gap: 0; }
.unit-section + .unit-section {
  margin-top: 28px;
  padding-top: 32px;
  border-top: 3px dashed var(--border);
}

/* ---------- 5. Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  background: var(--card);
  border-bottom: 2px solid var(--border);
}

.topbar .avatar { flex: 0 0 auto; }

.topbar .goal {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar .goal-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .streak {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 16px;
}

.topbar .streak img.emoji { width: 20px; height: 20px; }

.btn-review {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 0 0 var(--accent-dark);
  white-space: nowrap;
}

.btn-review:active { transform: translateY(4px); box-shadow: none; }

.btn-review .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
}

/* ---------- 6. Ścieżka ---------- */
.unit-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unit-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--card);
  border: 2px solid var(--border);
  border-left: 6px solid var(--unit-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.unit-header .unit-num {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--unit-color);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}

.unit-header .unit-body { flex: 1 1 auto; min-width: 0; }

.unit-header .unit-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--unit-color);
}

.unit-header .unit-desc {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

.unit-header .btn-unit-test {
  flex: 0 0 auto;
}

.nodes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
}

.node-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 96px;
}

.node-wrap:nth-child(odd) { transform: translateX(-48px); }
.node-wrap:nth-child(even) { transform: translateX(48px); }
.node-wrap.node-wrap-test { transform: none; width: auto; margin-top: 12px; }

.node, .exam-card, .btn, .btn-review { text-decoration: none; }

.node-title-test { color: var(--text); font-size: 15px; max-width: none; }
.test-status {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
}
.test-status.passed { color: #fff; background: var(--success); }
.btn-unit-test.passed { color: var(--success-dark); border-color: var(--success); }

.node-ring {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* --pct ustawiane inline per węzeł, np. style="--pct:66%" (korony 0-3 => 0/33/66/100%) */
  background: conic-gradient(var(--warning) var(--pct, 0%), var(--border) 0);
  padding: 4px;
}

.node {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 44px;
}

.node img.emoji { width: 34px; height: 34px; }

.node-title {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
  max-width: 96px;
}

/* stan: ukończona lekcja */
.node.done {
  background: var(--accent);
  border-color: var(--accent-dark);
  box-shadow: 0 4px 0 0 var(--accent-dark);
}

.node.done::after {
  content: '\2713';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--card);
  color: var(--accent-dark);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

/* stan: sugerowana następna lekcja */
.node.next {
  border-color: var(--accent);
  animation: node-pulse 1.6s ease-in-out infinite;
}

/* stan: test unitu — tarcza/sześciokąt */
.node.test {
  border-radius: 22%;
  clip-path: polygon(50% 0%, 100% 20%, 100% 65%, 50% 100%, 0% 65%, 0% 20%);
  background: var(--warning);
  border-color: var(--warning-dark);
  box-shadow: 0 4px 0 0 var(--warning-dark);
}

.node.test.passed {
  background: var(--success);
  border-color: var(--success-dark);
  box-shadow: 0 4px 0 0 var(--success-dark);
}

/* stan: powtórka */
.node.practice {
  background: var(--card);
  border-style: dashed;
  border-color: var(--muted);
  color: var(--muted);
}

.exams-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px var(--gutter) 120px;
  border-top: 3px dashed var(--border);
}
.exams-title { font-size: 20px; font-weight: 800; margin: 0 0 12px; }
.exam-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.exam-card.passed { border-color: var(--success); }

.exam-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.exam-card img.emoji { width: 40px; height: 40px; }
.exam-card .exam-title { font-weight: 800; font-size: 15px; }
.exam-card .exam-sub { font-size: 13px; color: var(--muted); }

/* ---------- 7. Karta zadania ---------- */
.exercise {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: exercise-fade-in 250ms ease both;
}

.instruction {
  font-size: 15px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.prompt-img,
img.prompt-img {
  width: 128px;
  height: 128px;
  object-fit: contain;
}

.prompt-text {
  font-size: 29px;
  font-weight: 800;
}

.prompt-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-speak {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
  box-shadow: 0 3px 0 0 var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.btn-speak:active { transform: translateY(3px); box-shadow: none; }

/* ---------- 8. Odpowiedzi ---------- */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choices.list { grid-template-columns: 1fr; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 14px 10px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.choices.list .choice {
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
}

.choice img.emoji,
.choice .choice-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.choices.list .choice img.emoji,
.choices.list .choice .choice-img {
  width: 40px;
  height: 40px;
}

.choice .choice-caption { font-size: 16px; font-weight: 700; }

.choice.selected {
  border-color: #1cb0f6;
  box-shadow: 0 4px 0 0 #1899d6;
}

.choice.correct {
  border-color: var(--success-dark);
  background: color-mix(in srgb, var(--success) 14%, var(--card));
  box-shadow: 0 4px 0 0 var(--success-dark);
  animation: choice-bounce 300ms ease;
}

.choice.wrong {
  border-color: var(--danger-dark);
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  box-shadow: 0 4px 0 0 var(--danger-dark);
  animation: choice-shake 400ms ease;
}

/* Kafelki rozsypanki */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.tile {
  min-height: 48px;
  padding: 10px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 0 var(--border);
  font-weight: 700;
  font-size: 18px;
}

.tile:active { transform: translateY(3px); box-shadow: none; }

.tile.used {
  opacity: 0.35;
  pointer-events: none;
  box-shadow: none;
}

.sentence-slot {
  min-height: 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 3px dashed var(--border);
}

.sentence-slot .tile { box-shadow: none; }

.sentence-slot:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-size: 15px;
  padding: 0 8px;
}

/* Dopasowywanie par */
.match-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.match-col { display: flex; flex-direction: column; gap: 10px; }

.match-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 8px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 0 var(--border);
  font-weight: 700;
  font-size: 16px;
}

.match-item.selected { border-color: #1cb0f6; box-shadow: 0 3px 0 0 #1899d6; }

.match-item.matched {
  border-color: var(--success-dark);
  background: color-mix(in srgb, var(--success) 14%, var(--card));
  box-shadow: none;
  opacity: 0.7;
}

.match-item.shake { animation: choice-shake 400ms ease; }
.match-mistakes { margin: 12px 0 0; text-align: center; font-weight: 700; color: #ea2b2b; }

/* Koszyki kategorii */
.buckets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bucket {
  min-height: 140px;
  padding: 12px;
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bucket-header {
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  color: var(--muted);
}

.bucket-items { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* Numerowanie / ułóż kolejność */
.order-list { display: flex; flex-direction: column; gap: 8px; }

.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 0 var(--border);
}

.order-item .order-num {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.order-item .order-text { flex: 1 1 auto; font-weight: 700; }

/* Pole tekstowe */
.input-answer {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-size: 25px;
  font-weight: 700;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}

.input-answer:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ---------- 9. Postęp / dolny pasek ---------- */
.progress {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress .progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 200ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .progress .progress-fill { transition: none; }
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px var(--gutter);
  background: var(--card);
  border-top: 2px solid var(--border);
}

@media (max-width: 640px) {
  .bottom-bar .btn.primary { width: 100%; }
}

.result-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--gutter);
  color: #fff;
  transform: translateY(0);
  animation: result-slide-up 220ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  .result-bar { animation: none; }
}

.result-bar .result-text { font-weight: 800; font-size: 17px; }
.result-bar .btn.btn-to-cards { color: #fff; border-color: rgba(255,255,255,.75); background: transparent; box-shadow: none; white-space: nowrap; }
.result-bar .btn.btn-to-cards:disabled { opacity: .9; }
@media (max-width: 520px) {
  .result-bar { flex-wrap: wrap; gap: 10px; }
  .result-bar > div:first-child { flex: 1 1 100%; }
  .result-bar .btn.btn-to-cards { flex: 1 1 auto; }
}
.result-bar .result-sub { font-weight: 600; font-size: 15px; opacity: 0.9; }

.result-bar.ok { background: var(--success); }
.result-bar.bad { background: var(--danger); }

.result-bar .btn { flex: 0 0 auto; }

/* ---------- 10. Podsumowanie i powtórka ---------- */
.summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px var(--gutter) 24px;
  text-align: center;
}

.summary .summary-score {
  font-size: 57px;
  font-weight: 900;
  color: var(--accent-dark);
}

.summary .summary-xp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 21px;
  font-weight: 800;
  color: var(--warning-dark);
}

.summary .summary-crown { font-size: 41px; }

.wrong-list {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-top: 8px;
}

.wrong-list .wrong-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

.wrong-list .wrong-item img.emoji { width: 28px; height: 28px; }
.wrong-list .wrong-item .wrong-pl { color: var(--muted); font-size: 14px; }

.review-list { display: flex; flex-direction: column; gap: 10px; }

.review-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.review-card .review-img { width: 48px; height: 48px; flex: 0 0 auto; }
.review-card .review-img img.emoji { width: 48px; height: 48px; }

.review-card .review-body { flex: 1 1 auto; min-width: 0; }
.review-card .review-en { font-weight: 800; font-size: 17px; }
.review-card .review-pl { font-size: 14px; color: var(--muted); }

.review-card .review-meta {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.boxes { display: flex; gap: 4px; }

.boxes .box-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.boxes .box-dot.filled { background: var(--accent); }

.review-card .wrong-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--danger-dark);
}

/* ---------- 11. Panel rodzica ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
}

.tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }

.table-wrap { width: 100%; overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.table th {
  background: var(--bg);
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.table tbody tr:last-child td { border-bottom: none; }

/* Tabela responsywna: karty na wąskim ekranie, bez container queries */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: none;
    padding: 4px 14px;
  }
  .table td::before {
    content: attr(data-label);
    font-weight: 800;
    color: var(--muted);
    flex: 0 0 auto;
  }
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 8px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.chart-bars .bar {
  flex: 1 1 0;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}

.chart-bars .bar.today { background: var(--warning); }

/* ---------- 12. Komponenty ogólne ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 0 0 var(--border);
}

.btn:active { transform: translateY(4px); box-shadow: none; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
  box-shadow: 0 4px 0 0 var(--accent-dark);
}

.btn.ghost {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent-dark);
  box-shadow: none;
}

.btn.ghost:active { transform: none; }

.btn.danger {
  background: var(--danger);
  border-color: var(--danger-dark);
  color: #fff;
  box-shadow: 0 4px 0 0 var(--danger-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.badge.gold { background: color-mix(in srgb, var(--warning) 20%, var(--card)); border-color: var(--warning-dark); color: var(--warning-dark); }
.badge.success { background: color-mix(in srgb, var(--success) 18%, var(--card)); border-color: var(--success-dark); color: var(--success-dark); }

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  font-size: 27px;
  overflow: hidden;
}

.avatar img.emoji { width: 30px; height: 30px; }
.avatar.lg { width: 72px; height: 72px; font-size: 39px; }
.avatar.lg img.emoji { width: 42px; height: 42px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 16px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.profile-card .profile-name { font-weight: 800; font-size: 16px; }

/* ---------- 13. Animacje ---------- */
@keyframes choice-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  65% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

@keyframes choice-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

@keyframes exercise-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes node-pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  50% { box-shadow: var(--shadow), 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
}

@keyframes result-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* app.js additions */
/* Drobne klasy pomocnicze używane przez router i ekrany (profil, home, zaślepki). */

.screen-title {
  font-size: 23px;
  font-weight: 900;
  text-align: center;
  padding: 8px 0 16px;
}

.field-label {
  display: block;
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-error {
  color: var(--danger-dark);
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0 0;
}

.field-hint {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  margin: 24px auto 0;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

/* practice additions */
/* Ekran „Do powtórki” (#/practice): statystyki, rozkład po pudełkach, ikony
   typu na kartach bez obrazka. Karty/tabs/boxes/badge/wrong-count/btn — patrz
   sekcje 10-12 wyżej. */

.practice-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin: 4px 0 16px;
}

.practice-stats .stat {
  text-align: center;
}

.practice-stats .stat-value {
  font-size: 23px;
  font-weight: 900;
  line-height: 1.1;
}

.practice-stats .stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.box-dist {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.box-dist-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.review-icon {
  font-size: 31px;
  line-height: 1;
}

.review-card .btn-speak {
  width: 36px;
  height: 36px;
  font-size: 15px;
}

/* render.js additions */
/* Renderowanie 25 typów zadań (issue #15): warianty przycisku 🔊, obrazki w
   parach (match-item bez własnego rozmiaru w bazowych regułach), pola
   promptu bez klasy (num/pl/hint), stany correct/wrong dla tile/order-item/
   input, lista słów do sortowania, kursor na elementach bez natywnego
   :hover (div zamiast button/input). Nie zmienia reguł powyżej. */

.choice, .match-item, .order-item, .bucket {
  cursor: pointer;
}

.btn-speak.lg {
  width: 80px;
  height: 80px;
  font-size: 35px;
}

.btn-speak.sm {
  width: 30px;
  height: 30px;
  font-size: 14px;
  box-shadow: 0 2px 0 0 var(--border);
}

.choice-caption-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.choices.list .choice-caption-row {
  justify-content: flex-start;
}

.prompt-num {
  font-size: 65px;
  font-weight: 900;
  line-height: 1;
}

.prompt-pl {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.prompt-hint {
  font-family: 'Courier New', Courier, monospace;
  font-size: 33px;
  font-weight: 800;
  letter-spacing: 6px;
}

/* Obrazki/kolory w parach dopasowania — img.emoji bazowo ma width:1em (za małe). */
.match-item img.emoji,
.match-item .match-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.match-item {
  flex-wrap: wrap;
  gap: 6px;
}

.match-item.wrong {
  border-color: var(--danger-dark);
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  box-shadow: none;
}

.order-item .order-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-item .order-text img.emoji {
  width: 40px;
  height: 40px;
}

.order-item.correct {
  border-color: var(--success-dark);
  background: color-mix(in srgb, var(--success) 14%, var(--card));
}

.order-item.wrong {
  border-color: var(--danger-dark);
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
}

.tile.selected {
  border-color: #1cb0f6;
  box-shadow: 0 3px 0 0 #1899d6;
}

.tile.correct {
  border-color: var(--success-dark);
  background: color-mix(in srgb, var(--success) 14%, var(--card));
  box-shadow: none;
}

.tile.wrong {
  border-color: var(--danger-dark);
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  box-shadow: none;
  animation: choice-shake 400ms ease;
}

.sort-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding-top: 4px;
}

.input-answer.correct {
  border-color: var(--success-dark);
  background: color-mix(in srgb, var(--success) 10%, var(--card));
}

.input-answer.wrong {
  border-color: var(--danger-dark);
  background: color-mix(in srgb, var(--danger) 10%, var(--card));
  animation: choice-shake 400ms ease;
}

/* profile/parent additions */
/* Ekrany #/profile, #/parent, #/oral/:id: karty statystyk, wykres XP z
   podpisami dni, odznaki, akcje profilu, dane (eksport/import) i egzamin
   ustny (odpowiedź oczekiwana, przyciski oceny, duży głośnik). */

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stat-card .stat-value {
  font-size: 23px;
  font-weight: 900;
}

.stat-card .stat-sub {
  font-size: 13px;
  color: var(--muted);
}

.section-title {
  font-weight: 800;
  font-size: 16px;
  margin: 20px 0 10px;
}

.badge-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge.danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--card));
  border-color: var(--danger-dark);
  color: var(--danger-dark);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* Wykres XP z podpisem dnia pod każdym słupkiem — wariant .chart-bars z
   kolumnami zamiast gołych .bar, żeby zmieścić etykietę "pn/wt/…". */
.chart-bars.profile-chart {
  height: auto;
  align-items: flex-end;
  gap: 6px;
}

.chart-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.chart-col .bar-area {
  height: 88px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.chart-col .bar {
  width: 100%;
  min-height: 3px;
}

.chart-col .bar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.file-input-hidden {
  display: none;
}

/* Egzamin ustny (#/oral/:id) */
.oral-progress-label {
  text-align: center;
  font-weight: 800;
  color: var(--muted);
  font-size: 15px;
}

.oral-speak-big {
  width: 76px;
  height: 76px;
  font-size: 35px;
}

.oral-answer {
  width: 100%;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oral-answer .oral-answer-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
}

.oral-answer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.oral-grade-row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.oral-grade-row .btn {
  flex: 1 1 0;
  max-width: 220px;
}

/* session additions */
/* screens/session.js — nagłówek runnera (X + pasek postępu + licznik). */

.session-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--gutter);
}

.session-quit {
  flex: 0 0 auto;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
}

.session-header .progress {
  flex: 1 1 auto;
}

.session-count {
  flex: 0 0 auto;
  min-width: 44px;
  text-align: right;
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
}

/* ---- poprawki po pierwszym teście z dzieckiem (#25) ---- */

/* Pasek z przyciskiem zasłaniał treść na dole: robimy pod niego miejsce. */
.exercise { margin-bottom: 96px; }

/* Wybór kart do powtórki */
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.picked-bar[hidden] { display: none; }

.picked-bar {
  position: sticky;
  top: 8px;
  z-index: 15;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  padding: 10px 12px;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.review-pick {
  width: 26px;
  height: 26px;
  margin-right: 4px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.review-card .review-img img.emoji { width: 64px; height: 64px; }
.review-icon { font-size: 34px; }

/* Głośnik na pasku wyniku: czyta poprawną odpowiedź na żądanie. */
.result-bar .result-speak {
  margin-left: auto;
  margin-right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
}

/* Większe obrazki w zadaniach */
.choice img.emoji { width: 124px; height: 124px; }
.choices.list .choice img.emoji { width: 52px; height: 52px; }
.match-item img.emoji { width: 52px; height: 52px; }
img.prompt-img { width: 168px; height: 168px; }

/* ---- test i lekcja: przyklejony nagłówek, stopka nad klawiaturą (#26) ---- */

.session-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding-bottom: 6px;
  box-shadow: 0 6px 12px -8px rgba(0, 0, 0, 0.25);
}

.session-top .session-title {
  margin: 4px 0 6px;
}

/* X wyraźnie odsunięty od paska postępu i większy: to cel dla palca. */
.session-header { gap: 18px; }

.session-quit {
  min-height: 52px;
  min-width: 52px;
  font-size: 26px;
  line-height: 1;
  border-width: 2px;
}

.session-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  transition: transform 120ms ease;
}

.session-footer .bottom-bar,
.session-footer .result-bar {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
}

/* Lista replik po polsku w zadaniu z dialogiem. */
.prompt-lines {
  margin: 8px auto 0;
  padding: 12px 16px;
  max-width: 520px;
  text-align: left;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.035);
}

.prompt-lines li {
  margin: 2px 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.field-tip {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- 14. Fiszki (#/cards, #/cards-session) ---------- */
.btn-cards {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 2px solid #1899d6;
  background: #1cb0f6;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 0 0 #1899d6;
  white-space: nowrap;
  text-decoration: none;
}
.btn-cards .count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: #1899d6;
  font-size: 13px;
  text-align: center;
}
.btn-cards:active { transform: translateY(4px); box-shadow: none; }
@media (max-width: 520px) { .btn-cards { font-size: 0; gap: 0; } .btn-cards::before { content: '🃏'; font-size: 20px; } }

.cards-screen { padding: 16px var(--gutter) 64px; max-width: 680px; }
.cards-actions { display: grid; gap: 12px; margin: 12px 0; }
.cards-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cards-card-title { font-weight: 800; font-size: 18px; }
.cards-card-sub { color: var(--muted); font-size: 14px; margin-top: -6px; }
.cards-sizes { display: flex; gap: 10px; flex-wrap: wrap; }
.cards-add { margin-bottom: 12px; }
.cards-h2 { font-size: 18px; font-weight: 800; margin: 24px 0 10px; }
.cards-search { margin-bottom: 10px; }
.cards-list { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.cards-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}
.cards-row-body { flex: 1 1 auto; min-width: 0; }
.cards-row-en { font-weight: 700; }
.cards-row-pl { color: var(--muted); font-size: 14px; }
.cards-dots { display: inline-flex; gap: 4px; }
.cards-dots .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.cards-dots .dot.on { background: var(--success); }
.cards-learned { color: var(--success-dark); font-weight: 800; font-size: 13px; white-space: nowrap; }
.cards-del, .cards-add-btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 20px; }
.cards-add-btn.in { color: var(--success-dark); }

.flash-session .container { padding-bottom: 140px; }
.flashcard-scene { perspective: 1400px; margin: 16px auto 0; max-width: 520px; position: relative; }
/* dwie karty „pod spodem”: widać, że to talia */
.flashcard-scene::before,
.flashcard-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 2px solid var(--border);
  z-index: 0;
}
.flashcard-scene::before { transform: translate(10px, 10px) rotate(2.5deg); opacity: 0.55; }
.flashcard-scene::after { transform: translate(5px, 5px) rotate(1.2deg); opacity: 0.8; }
.flashcard { position: relative; z-index: 1; min-height: 340px; }
.flashcard-inner {
  position: relative;
  min-height: 340px;
  transform-style: preserve-3d;
  transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 20px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flashcard-face.back { transform: rotateY(180deg); }
.flashcard-face.back.ok { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--card)); }
.flashcard-face.back.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--card)); }
.flashcard-kind {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.flashcard-prompt { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 800; }
.flashcard-ask { color: var(--muted); font-weight: 700; }
.flashcard-face .input-answer { max-width: 380px; }
.flashcard-verdict { font-size: 22px; font-weight: 800; }
.flashcard-face.back.ok .flashcard-verdict { color: var(--success-dark); }
.flashcard-face.back.bad .flashcard-verdict { color: var(--danger); }
.flashcard-pl { font-size: 20px; color: var(--muted); font-weight: 700; }
.flashcard-given { font-size: 15px; color: var(--danger); }
.flashcard-learned { font-weight: 800; color: var(--success-dark); }
.flash-bar { display: flex; gap: 12px; justify-content: flex-end; }
.flash-bar .btn.primary { min-width: 160px; }

.flashcard.deal-in { animation: flash-deal 420ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes flash-deal {
  from { opacity: 0; transform: translateX(80px) rotate(8deg) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .flashcard.deal-in { animation: none; }
  .flashcard-inner { transition: none; }
}
