/* ==========================================================================
   Design system — jeden ekran naraz, duże przyciski, zero rozpraszaczy.
   Jasny motyw domyślnie, ciemny przez prefers-color-scheme.
   ========================================================================== */

:root {
  --bg: #f4f5fb;
  --bg-elevated: #ffffff;
  --text: #1c1e2b;
  --text-muted: #5b5f78;
  --border: #dfe1ee;
  --accent: #4f5bd5;
  --accent-strong: #3a44b8;
  --accent-soft: #e7e9fb;
  --good: #1f9d55;
  --good-soft: #e3f7ea;
  --bad: #d5392f;
  --bad-soft: #fce9e7;
  --mid: #d18a17;
  --mid-soft: #fbf0dd;
  --xp-gold: #c8971f;
  --xp-gold-soft: #fbf1dc;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(30, 33, 60, 0.08);
  --shadow-lg: 0 16px 40px rgba(30, 33, 60, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap-min: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141f;
    --bg-elevated: #1c1f30;
    --text: #eef0fb;
    --text-muted: #a4a8c4;
    --border: #2b2f47;
    --accent: #7c86ec;
    --accent-strong: #96a0ff;
    --accent-soft: #262b52;
    --good: #4cc783;
    --good-soft: #163828;
    --bad: #ef6a60;
    --bad-soft: #3a2223;
    --mid: #e3ac4c;
    --mid-soft: #3a2f18;
    --xp-gold: #e3ac4c;
    --xp-gold-soft: #362a13;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
}

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

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

button {
  font-family: inherit;
}

/* ---- jeden ekran naraz: kontener wyśrodkowany, wąski, czytelny ---- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  gap: 20px;
  animation: screen-in 0.22s ease;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-title {
  font-size: 1.3rem;
  font-weight: 700;
}

.screen-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}

.screen-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- przyciski: duże cele dotykowe, wyraźna hierarchia ---- */
.btn {
  min-height: var(--tap-min);
  border-radius: var(--radius-md);
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  min-height: 44px;
}

.btn-good {
  background: var(--good-soft);
  color: var(--good);
  border: 2px solid var(--good);
}
.btn-mid {
  background: var(--mid-soft);
  color: var(--mid);
  border: 2px solid var(--mid);
}
.btn-bad {
  background: var(--bad-soft);
  color: var(--bad);
  border: 2px solid var(--bad);
}

.btn-block { width: 100%; }

.btn-grade-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.btn-grade-row .btn { flex-direction: column; font-size: 0.95rem; padding: 12px 8px; gap: 4px; }
.btn-grade-row .btn .emoji { font-size: 1.4rem; }

/* ---- karty / panele ---- */
.card-panel {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  width: fit-content;
}

/* ---- fiszka ---- */
.flashcard {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
  gap: 16px;
  text-align: center;
}
.flashcard-front {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}
.flashcard-back {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.55;
  text-align: left;
  border-top: 1px dashed var(--border);
  padding-top: 16px;
  margin-top: 4px;
}
.flashcard-back ul { margin: 8px 0 0; padding-left: 20px; }

/* ---- pigułka informacyjna po błędzie ---- */
.info-pill {
  background: var(--bad-soft);
  border: 1px solid var(--bad);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-pill-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--bad);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.info-pill-text {
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--text);
}
.info-pill-source {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- pasek postępu ---- */
.progress-track {
  height: 14px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.4s ease;
}
.progress-fill.xp { background: linear-gradient(90deg, var(--xp-gold), #f0c869); }
.progress-fill.good { background: linear-gradient(90deg, var(--good), #57d492); }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ---- odznaki / xp ---- */
.badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--xp-gold-soft);
  border: 1px solid var(--xp-gold);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.badge-icon { font-size: 1.8rem; }
.badge-title { font-weight: 700; font-size: 0.95rem; }
.badge-desc { font-size: 0.8rem; color: var(--text-muted); }

/* ---- checklisty samooceny ---- */
.checklist { display: flex; flex-direction: column; gap: 10px; }
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  min-height: var(--tap-min);
  font-size: 0.98rem;
}
.checklist-item.checked {
  border-color: var(--good);
  background: var(--good-soft);
}
.checklist-item .box {
  width: 24px; height: 24px; flex: 0 0 auto;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.checklist-item.checked .box {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}

/* ---- nawigacja dolna / pulpit ---- */
.nav-grid {
  display: grid;
  gap: 14px;
}
.nav-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}
.nav-tile:active { transform: scale(0.98); }
.nav-tile .icon { font-size: 1.8rem; }
.nav-tile.locked { opacity: 0.5; cursor: not-allowed; }
.nav-tile-title { font-weight: 700; font-size: 1.02rem; }
.nav-tile-desc { font-size: 0.82rem; color: var(--text-muted); }

.top-links {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- textarea / formularze toru pisemnego ---- */
textarea, input[type=text] {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 14px;
  resize: vertical;
}
textarea:focus, input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---- timer ---- */
.timer-ring {
  font-variant-numeric: tabular-nums;
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
}

/* ---- mapa braków (panel rodzica) ---- */
.heat-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.heat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.heat-row .dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.heat-row .label { flex: 1; font-size: 0.92rem; }
.heat-row .stat { font-size: 0.8rem; color: var(--text-muted); }
.heat-red .dot { background: var(--bad); }
.heat-yellow .dot { background: var(--mid); }
.heat-green .dot { background: var(--good); }

.muted { color: var(--text-muted); font-size: 0.88rem; }
.center { text-align: center; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.empty-state .icon { font-size: 2.4rem; }

::selection { background: var(--accent-soft); }

@media (min-width: 700px) {
  .screen { padding-top: calc(40px + var(--safe-top)); }
}
