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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1f1f1f;
  --border: #333333;
  --text: #ffffff;
  --text-muted: #a0a0a0;
  --text-dim: #d0d0d0;
  --akk: #cc0000;
  --akk-light: #ff3333;
  --akk-dark: #8b0000;
  --dat: #ffffff;
  --dat-light: #cccccc;
  --dat-dark: #999999;
  --correct: #ffffff;
  --wrong: #cc0000;
  --accent: #cc0000;
  --freq-green: #22c55e;
  --freq-yellow: #eab308;
  --freq-gray: #6b7280;
  --radius: 0px;
  --radius-sm: 0px;
  --shadow: none;

  /* ── Page shell vs. page content ──
     --shell-width : outer chrome (header, nav bar, controls bar).
                     IDENTICAL on every page so the navbar never moves
                     when navigating. Do NOT override per page.
     --site-width  : width of the page's own content. May differ per page
                     (trainer card = 860px, grammar.css widens it to 1000px).
     --site-pad    : shared horizontal gutter used by shell AND content.
  */
  --shell-width: 1000px;
  --site-width: 860px;
  --site-pad: clamp(12px, 4vw, 24px);
}

/* ── ROOT ──
   scrollbar-gutter: stable reserves space for the scrollbar EVEN when
   it isn't visible. This prevents the content from jumping left/right
   when navigating between short pages (no scrollbar) and tall pages
   (scrollbar). This is the correct fix for the "navbar shift" bug.
   We do NOT use overflow-x: hidden here because that disables scrollbar-gutter.
   Individual containers that could overflow use their own overflow rules.
*/
html {
  scrollbar-gutter: stable;
  height: 100%;
}

/* Browsers without scrollbar-gutter support (older Safari): always reserve
   the scrollbar track so short and long pages have the same viewport width. */
@supports not (scrollbar-gutter: stable) {
  html { overflow-y: scroll; }
}

/* min-height (not height): with height:100% the body box ends after one
   viewport, which makes the sticky header stop sticking on long pages
   where <header> is a direct child of <body>. */
body {
  min-height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--site-pad);
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
}

.header-inner {
  max-width: var(--shell-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  min-width: 0;
  gap: 8px;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-de {
  background: var(--akk);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 0px;
  letter-spacing: 1px;
}
.logo-text { font-weight: 600; font-size: 15px; color: var(--text-dim); }

.header-stats { display: flex; gap: 10px; }
.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 6px 14px;
  min-width: 60px;
}
.stat-badge.correct { border-color: rgba(34,197,94,0.3); }
.stat-badge.wrong   { border-color: rgba(239,68,68,0.3); }
.stat-num { font-weight: 700; font-size: 16px; }
.stat-badge.correct .stat-num { color: var(--correct); }
.stat-badge.wrong .stat-num   { color: var(--wrong); }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }

/* ── NAV BAR ── */
.nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--shell-width);
  margin: 0 auto;
  padding: 10px 0; /* horizontal padding comes from .header */
  flex-wrap: wrap;
  box-sizing: border-box;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0px;
  transition: all 0.2s ease;
}
.nav-link:hover, .nav-link.active {
  color: var(--bg);
  border-color: var(--text);
  background: var(--text);
}

/* ── CONTROLS ── */
.controls-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--site-pad);
  box-sizing: border-box;
}
.controls-inner {
  max-width: var(--shell-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
  min-width: 0;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 12px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.filter-btns { display: flex; gap: 4px; }
.filter-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 0px;
  padding: 6px 15px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: var(--text); color: var(--bg); }
.filter-btn.akk.active { background: var(--akk); border-color: var(--akk); }
.filter-btn.dat.active { background: var(--dat); border-color: var(--dat); }

.btn-restart {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 0px;
  padding: 7px 15px;
  font-size: 12px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-restart:hover { color: var(--text); }

/* ── PROGRESS ── */
.progress-wrap {
  max-width: var(--site-width);
  margin: 16px auto 0;
  padding: 0 var(--site-pad);
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  width: 100%;
}
.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--surface2);
  border-radius: 0px;
  overflow: hidden;
  position: relative;
}
.progress-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--akk);
  border-radius: 0px;
  transition: width 0.35s ease;
}
.progress-text { font-size: 12px; color: var(--text-muted); white-space: nowrap; min-width: 60px; text-align: right; }

/* ── MAIN ── */
.main {
  max-width: var(--site-width);
  margin: 0 auto;
  padding: 24px var(--site-pad) 48px;
  box-sizing: border-box;
  width: 100%;
}
.card-container {
  perspective: 1200px;
  margin-bottom: 28px;
  min-width: 0;
}

/* ── CARD ── */
.card {
  display: grid;
  width: 100%;
  min-height: 360px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  outline: none;
  border-radius: var(--radius);
}
.card.flipped { transform: rotateY(180deg); cursor: default; }
.card-front, .card-back {
  grid-area: 1 / 1;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}
.card-front {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}
.card-front:hover { border-color: var(--accent); box-shadow: none; }
.card-back {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
  transform: rotateY(180deg);
  justify-content: space-between;
  gap: 20px;
}

.card-hint {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.verb-display {
  font-size: clamp(32px, 7vw, 56px);
  font-weight: 800;
  text-align: center;
  color: var(--text);
  line-height: 1.1;
}
.card-number {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* back */
.back-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.back-verb {
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 800;
  color: var(--text);
}
.prep-kasus {
  display: flex;
  align-items: center;
  gap: 10px;
}
.prep-tag {
  background: var(--akk);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 0px;
}
.kasus-badge {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 0px;
  border: 2px solid var(--akk);
  color: var(--akk-light);
  background: transparent;
}
.kasus-badge.dat {
  border-color: var(--dat);
  color: var(--dat-light);
  background: transparent;
}
.back-extra {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.4;
  text-align: center;
}
.example-sentence {
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.65;
  font-style: italic;
  background: var(--surface2);
  border-radius: 0px;
  padding: 16px 20px;
  width: 100%;
  border-left: 4px solid var(--accent);
}

/* answer buttons */
.answer-btns {
  display: flex;
  gap: 12px;
  width: 100%;
}
.btn-wrong, .btn-correct {
  flex: 1;
  padding: 14px;
  border-radius: 0px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-wrong {
  background: rgba(239,68,68,0.12);
  color: var(--wrong);
  border: 1.5px solid rgba(239,68,68,0.3);
}
.btn-wrong:hover { background: rgba(239,68,68,0.22); }
.btn-correct {
  background: rgba(34,197,94,0.12);
  color: var(--correct);
  border: 1.5px solid rgba(34,197,94,0.3);
}
.btn-correct:hover { background: rgba(34,197,94,0.22); }

/* ── SECONDARY NAV BUTTONS ── */
.nav-btns,
.card-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.filter-select {
  background: var(--surface);
  border: none;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 0px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}
.filter-select:focus {
  outline: none;
}
.filter-select option {
  background: var(--bg);
  color: var(--text);
}

.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 12px 28px;
  border-radius: 0px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--text); }
.nav-btn.primary {
  background: var(--akk);
  border-color: transparent;
  color: #fff;
}
.nav-btn.primary:hover { opacity: 0.88; }

/* ── DONE SCREEN ── */
.done-screen {
  position: fixed;
  inset: 0;
  background: rgba(14,15,20,0.92);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.done-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: none;
}
.done-emoji { font-size: 56px; margin-bottom: 16px; }
.done-card h2 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.done-card p { color: var(--text-muted); margin-bottom: 28px; }
.done-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 32px;
}
.done-stat {
  flex: 1;
  background: var(--surface2);
  border-radius: 0px;
  padding: 16px;
  border: 1px solid var(--border);
}
.done-stat span { font-size: 28px; font-weight: 800; display: block; }
.done-stat small { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.done-stat.correct span { color: var(--correct); }
.done-stat.wrong span   { color: var(--wrong); }
.done-stat.pct span     { color: var(--akk-light); }
.btn-restart.big {
  display: block;
  width: 100%;
  background: var(--akk);
  border: none;
  color: #fff;
  padding: 14px;
  border-radius: 0px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity 0.18s;
}
.btn-restart.big:hover { opacity: 0.88; }
.btn-wrong-only {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid var(--wrong);
  color: var(--wrong);
  padding: 12px;
  border-radius: 0px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-wrong-only:hover { background: rgba(239,68,68,0.2); }

/* ── RESPONSIVE ── */
@media (max-width: 540px) {
  .card-front, .card-back { padding: 28px 16px; }
  .header-inner { gap: 8px; }
  .logo-text { display: none; }
  .controls-inner { gap: 8px; }
  .filter-btn { padding: 6px 10px; font-size: 11px; }
  .stat-badge { padding: 5px 10px; min-width: 50px; }
}

@media (max-width: 390px) {
  .card-front, .card-back { padding: 20px 12px; }
  .header-stats { gap: 6px; }
  .stat-badge { padding: 4px 8px; min-width: 44px; }
  .stat-num { font-size: 14px; }
  .stat-label { font-size: 9px; }
}
