/* TO DÁŠ! — design systém, tmavý motiv, mobile-first */

:root {
  --bg:         #0f0f13;
  --surface:    #1a1a24;
  --surface2:   #252535;
  --surface3:   #2e2e45;
  --accent:     #6C63FF;
  --accent2:    #FF6584;
  --text:       #f0f0f0;
  --text-muted: #7a7a9a;
  --zelena:     #4ade80;
  --zluta:      #facc15;
  --cervena:    #f87171;
  --radius:     20px;
  --radius-sm:  12px;
  --font:       'Inter', system-ui, sans-serif;
  --nav-h:      64px;
  --top-h:      56px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-text-size-adjust: none;
}

* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; }

/* ── Centering na desktopu ────────────────────────────────────── */
.centered {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Top bar ──────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(15,15,19,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 480px) {
  #topbar    { left: 50%; right: auto; transform: translateX(-50%); width: 480px; }
  #bottomnav { left: 50%; right: auto; transform: translateX(-50%); width: 480px; }
  #main      { left: 50%; right: auto; transform: translateX(-50%); width: 480px; }
}

.app-name {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

.topbar-center { display: flex; align-items: center; }
.topbar-right  { display: flex; align-items: center; gap: 4px; }

/* Kruhový progress denního cíle */
.daily-progress { position: relative; width: 44px; height: 44px; }
.daily-progress svg { transform: rotate(-90deg); }
.progress-bg  { fill: none; stroke: var(--surface3); stroke-width: 3.5; }
.progress-arc {
  fill: none; stroke: var(--accent); stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 113; stroke-dashoffset: 113;
  transition: stroke-dashoffset 0.6s ease;
}
.progress-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text);
}

.streak-badge {
  font-size: 15px; font-weight: 800;
  color: var(--zluta);
  text-shadow: 0 0 12px rgba(250,204,21,0.4);
}

/* ── Layout ───────────────────────────────────────────────────── */
#main {
  position: fixed;
  top: var(--top-h); bottom: var(--nav-h);
  left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  overflow: hidden;
}

.view { display: none; width: 100%; height: 100%; overflow-y: auto; }
.view.active { display: block; }

/* ── Bottom nav ───────────────────────────────────────────────── */
#bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  background: rgba(26,26,36,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 100;
  max-width: 480px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1; background: none; border: none;
  font-size: 22px; cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.15s ease;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.nav-btn.active { opacity: 1; }
.nav-btn:active { transform: scale(0.85); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s, background 0.15s;
  user-select: none; -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.2px;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }
.btn-primary { background: var(--accent);  color: #fff; }
.btn-muted   { background: var(--surface2); color: var(--text); }
.btn-ghost   { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-full    { width: 100%; }
.btn-sm      { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* ── Card slide (scroll-snap) ─────────────────────────────────── */
.feed-container {
  height: 100%; overflow-y: scroll;
  scroll-snap-type: y mandatory;
}

.card-slide {
  height: 100%; min-height: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column;
  padding: 12px 12px 8px;
  position: relative;
}

.card-inner {
  flex: 1; background: var(--surface);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  padding: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: border-color 0.25s ease, transform 0.15s ease;
  will-change: transform;
}

/* Swipe visual feedback */
.card-inner.swipe-yes { border-color: var(--zelena) !important; }
.card-inner.swipe-no  { border-color: var(--cervena) !important; }

/* Nach rating — fade */
.card-slide.done .card-inner { opacity: 0.55; }

/* ── Card meta ────────────────────────────────────────────────── */
.card-meta {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 14px; flex-shrink: 0;
}

.subject-tag {
  display: inline-block;
  padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  color: #fff; letter-spacing: 0.3px;
  max-width: 65%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

.type-icon { font-size: 19px; }

/* ── Card front ───────────────────────────────────────────────── */
.card-front {
  font-size: 22px; font-weight: 700;
  text-align: center;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  line-height: 1.4; padding: 8px 4px;
}

/* ── Tap zone (flashcard/cloze) ───────────────────────────────── */
.tap-zone {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  flex-shrink: 0; cursor: pointer;
  padding: 8px 0;
}

.tap-hint {
  color: var(--text-muted); font-size: 13px;
  padding: 8px 16px; border-radius: 20px;
  background: var(--surface2);
  transition: background 0.2s;
}
.tap-zone:active .tap-hint { background: var(--surface3); }

/* ── Hint ─────────────────────────────────────────────────────── */
.hint-btn { align-self: center; }

.hint-text {
  background: rgba(250,204,21,0.1);
  border: 1px solid rgba(250,204,21,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px; color: var(--zluta);
  text-align: center;
  animation: slideUp 0.22s ease;
}

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

/* ── Recall zone ──────────────────────────────────────────────── */
.recall-area {
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px; gap: 12px; text-align: center;
  min-height: 80px;
}

.recall-prompt { color: var(--text-muted); font-size: 14px; }

.recall-timer {
  font-size: 30px; font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.reveal-btn { flex-shrink: 0; margin-top: 8px; }

/* ── MCQ options ──────────────────────────────────────────────── */
.mcq-options {
  display: flex; flex-direction: column;
  gap: 9px; flex: 1; justify-content: center;
}

.mcq-option {
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  text-align: left;
  font-size: 15px; font-family: var(--font); color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.12s;
  display: flex; align-items: center; gap: 12px;
}
.mcq-option:active:not(:disabled) { transform: scale(0.98); }
.mcq-option:disabled { cursor: default; }
.mcq-option.correct { border-color: var(--zelena); background: rgba(74,222,128,0.1); }
.mcq-option.wrong   { border-color: var(--cervena); background: rgba(248,113,113,0.1); }

.mcq-letter {
  min-width: 26px; height: 26px;
  background: var(--surface3);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}
.mcq-option.correct .mcq-letter { background: var(--zelena); color: #111; }
.mcq-option.wrong   .mcq-letter { background: var(--cervena); color: #fff; }
.mcq-text { flex: 1; }

/* ── Cloze ────────────────────────────────────────────────────── */
.cloze-blank {
  display: inline-block;
  min-width: 72px; border-bottom: 2.5px solid var(--accent);
  color: transparent;
  transition: color 0.35s ease;
  font-weight: 700; vertical-align: bottom;
}
.cloze-blank.filled { color: var(--zelena); }

/* ── Card back (answer) ───────────────────────────────────────── */
.card-back {
  font-size: 17px; line-height: 1.65;
  overflow-y: auto; max-height: 38vh;
  padding: 14px 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
  pointer-events: none;
  display: none;
}
.card-back.revealed {
  transform: translateY(0); opacity: 1;
  pointer-events: auto; display: block;
}

/* ── Rating zone ──────────────────────────────────────────────── */
.card-rating {
  display: none; flex-direction: column;
  gap: 8px; flex-shrink: 0;
}
.card-rating.visible { display: flex; }

.rating-row {
  display: flex; gap: 8px;
}

.rate-btn {
  flex: 1; border: none; border-radius: var(--radius-sm);
  padding: 12px 6px;
  font-size: 13px; font-weight: 700; font-family: var(--font);
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s;
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  -webkit-tap-highlight-color: transparent;
}
.rate-btn:active { transform: scale(0.94); opacity: 0.8; }
.rate-btn span    { font-size: 11px; font-weight: 600; }
.rate-wrong  { background: rgba(248,113,113,0.18); color: var(--cervena); }
.rate-almost { background: rgba(250,204,21,0.15);  color: var(--zluta);   }
.rate-correct{ background: rgba(74,222,128,0.15);  color: var(--zelena);  }

/* Honesty tip */
.honesty-tip {
  background: rgba(108,99,255,0.12);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 36px 10px 14px;
  font-size: 12px; color: var(--text-muted);
  position: relative; line-height: 1.5;
}
.tip-close {
  position: absolute; top: 6px; right: 10px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px;
}

/* Swipe / keyboard hint */
.kb-hint {
  text-align: center; font-size: 11px;
  color: var(--surface3); margin-top: 2px;
  letter-spacing: 0.3px;
}

/* ── Review header ────────────────────────────────────────────── */
.review-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 12px 18px 6px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* When review-header is present, feed-container is inline */
#view-review { display: none; flex-direction: column; }
#view-review.active { display: flex; }

.review-count-pill {
  background: var(--accent);
  color: #fff; border-radius: 20px;
  padding: 2px 10px; font-size: 13px; font-weight: 700;
  min-width: 26px; text-align: center;
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 16px; padding: 32px;
  text-align: center;
}
.empty-emoji { font-size: 60px; }
.empty-state h2 { font-size: 22px; font-weight: 800; }
.empty-state p  { color: var(--text-muted); font-size: 15px; line-height: 1.5; }
.countdown { font-size: 22px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--surface3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

select, input[type=text], input[type=number], textarea {
  background: var(--surface2); color: var(--text);
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 15px; font-family: var(--font);
  width: 100%; transition: border-color 0.2s;
  -webkit-appearance: none;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }

.radio-group { display: flex; gap: 8px; }
.radio-option {
  flex: 1; background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 6px; text-align: center; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
  border: 2px solid transparent; user-select: none;
}
.radio-option.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Exam ─────────────────────────────────────────────────────── */
.exam-setup {
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.exam-setup h2 { font-size: 20px; font-weight: 800; }

.exam-screen {
  display: flex; flex-direction: column;
  height: 100%; padding: 14px; gap: 10px;
}

.exam-top { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.exam-counter { font-size: 12px; color: var(--text-muted); text-align: center; }

.exam-progress-bar-wrap {
  height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden;
}
.exam-progress-bar {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.4s ease;
}

.exam-timer-bar {
  height: 5px; background: var(--surface3); border-radius: 3px; overflow: hidden;
}
.exam-timer-bar-fill {
  height: 100%; background: var(--zelena); border-radius: 3px;
  transition: width 0.1s linear, background 0.3s;
}
.exam-timer-bar-fill.urgent { background: var(--cervena); }

.exam-question {
  flex: 1; font-size: 22px; font-weight: 700;
  text-align: center; line-height: 1.4;
  display: flex; align-items: center; justify-content: center;
  padding: 10px 0;
}

.exam-timer {
  font-size: 36px; font-weight: 800; color: var(--accent);
  text-align: center; font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.exam-reflection {
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px;
  color: var(--text-muted); text-align: center;
  flex-shrink: 0;
}

/* ── Exam results ─────────────────────────────────────────────── */
.exam-results { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.results-score { text-align: center; font-size: 56px; font-weight: 800; }
.results-meta  { display: flex; gap: 10px; }
.results-meta-item {
  flex: 1; background: var(--surface); border-radius: var(--radius-sm);
  padding: 14px 10px; text-align: center;
}
.results-meta-item .val { font-size: 18px; font-weight: 700; }
.results-meta-item .lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.wrong-card {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 14px; border-left: 3px solid var(--cervena);
  margin-bottom: 8px;
}
.wrong-card .wc-front { font-weight: 700; margin-bottom: 6px; }
.wrong-card .wc-back  { font-size: 14px; color: var(--text-muted); }

/* ── Stats ────────────────────────────────────────────────────── */
.stats-view { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.stats-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stats-card h3 {
  font-size: 11px; font-weight: 800;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 14px;
}

.stats-row { display: flex; gap: 12px; }
.stat-item { flex: 1; text-align: center; }
.stat-item .sv { font-size: 26px; font-weight: 800; }
.stat-item .sl { font-size: 11px; color: var(--text-muted); }

.spr-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}

.subject-progress-row { margin-bottom: 14px; }
.subject-progress-row:last-child { margin-bottom: 0; }
.spr-header {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 5px; font-weight: 500;
}
.spr-bar-wrap { height: 7px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.spr-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 2px; }

/* Heatmap */
.heatmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 4px; }
.heat-cell { aspect-ratio: 1; border-radius: 4px; background: var(--surface2); cursor: default; }
.heat-cell[data-level="1"] { background: rgba(108,99,255,0.28); }
.heat-cell[data-level="2"] { background: rgba(108,99,255,0.6); }
.heat-cell[data-level="3"] { background: var(--accent); }

/* Weak cards */
.weak-card {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 8px; cursor: pointer;
  transition: background 0.2s;
  border-left: 3px solid transparent;
}
.weak-card:last-child { margin-bottom: 0; }
.weak-card:active { background: var(--surface3); }
.wc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.wc-lapses { font-size: 12px; color: var(--cervena); font-weight: 800; margin-left: auto; }

.wc-back-reveal {
  font-size: 14px; color: var(--text-muted);
  border-top: 1px solid var(--surface); padding-top: 10px;
  margin-top: 8px; display: none; line-height: 1.5;
}
.wc-back-reveal.open { display: block; }

/* ── Import ───────────────────────────────────────────────────── */
.import-view { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.import-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.import-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

.result-banner {
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 14px; font-weight: 600; display: none; margin-top: 8px;
}
.result-banner.ok  { background: rgba(74,222,128,0.12); color: var(--zelena); display: block; }
.result-banner.err { background: rgba(248,113,113,0.12); color: var(--cervena); display: block; }

.subject-manage-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--surface2);
}
.subject-manage-row:last-child { border-bottom: none; }
.smr-info .smr-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; }
.smr-info .smr-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; margin-left: 14px; }
.smr-del { background: none; border: none; color: var(--cervena); font-size: 18px; cursor: pointer; padding: 6px 4px; }
.smr-del:active { transform: scale(0.88); }

.mcq-fields { display: none; flex-direction: column; gap: 8px; margin-top: 4px; }
.mcq-fields.visible { display: flex; }
.mcq-field-row { display: flex; align-items: center; gap: 10px; }
.mcq-field-row input[type=text] { flex: 1; }
.mcq-correct-radio { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }

/* ── Toasts ───────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse;
  gap: 8px; z-index: 999;
  max-width: 360px; width: calc(100% - 32px);
  pointer-events: none;
}

.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: #fff;
  animation: toastIn 0.22s ease; pointer-events: auto;
  text-align: center; backdrop-filter: blur(8px);
}
.toast.success { background: rgba(74,222,128,0.92); color: #111; }
.toast.error   { background: rgba(248,113,113,0.95); }
.toast.info    { background: rgba(108,99,255,0.92); }
.toast.leaving { animation: toastOut 0.22s ease forwards; }

@keyframes toastIn  { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Utility ──────────────────────────────────────────────────── */
.mt8  { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.text-muted   { color: var(--text-muted); font-size: 14px; }
.text-center  { text-align: center; }
