/* style.css — Deutsch Lernen */
:root {
  color-scheme: dark;
  --bg: #0f1218;
  --bg-2: #161b24;
  --panel: #1b212c;
  --panel-2: #232b38;
  --border: #2c3543;
  --text: #e8edf5;
  --muted: #8b97ab;
  --accent: #e8b53d;       /* gold */
  --accent-2: #c9a227;
  --red: #e0413b;
  --good: #3ecf8e;
  --m: #5aa9ff;   /* der */
  --f: #ff6b8b;   /* die */
  --n: #5ed6a0;   /* das */
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f3f9;
  --border: #e2e8f0;
  --text: #1a2233;
  --muted: #64748b;
  --accent: #b8860b;
  --accent-2: #9a730a;
  --red: #d63031;
  --good: #16a06b;
  --m: #2563eb;
  --f: #db2777;
  --n: #059669;
  --shadow: 0 8px 24px rgba(15,23,42,.10);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f6fb; --bg-2: #ffffff; --panel: #ffffff; --panel-2: #f0f3f9;
    --border: #e2e8f0; --text: #1a2233; --muted: #64748b;
    --accent: #b8860b; --accent-2: #9a730a; --red: #d63031; --good: #16a06b;
    --m: #2563eb; --f: #db2777; --n: #059669;
    --shadow: 0 8px 24px rgba(15,23,42,.10);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}
body { font-size: 16px; line-height: 1.5; }

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  gap: 12px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.flag { flex: 1; }
.flag.f1 { background: #111; }
.flag.f2 { background: #d00; }
.flag.f3 { background: #ffce00; }
.brand-text h1 {
  margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
}
.tagline {
  margin: 1px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: .02em;
}
.stats { display: flex; gap: 8px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
  text-align: center;
  min-width: 56px;
}
.stat-num { display: block; font-size: 18px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px 12px 10px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .18s, color .18s;
  white-space: nowrap;
}
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active {
  background: var(--accent);
  color: #1a1300;
}

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  overflow-y: auto;
  padding: 6px 16px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  animation: fadeIn .25s ease;
}
.stage::-webkit-scrollbar { width: 6px; }
.stage::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
.hero { display: flex; flex-direction: column; gap: 18px; padding: 8px 0 4px; }
.hero-greet .wave { font-size: 34px; }
.hero-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.hero-sub { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 50ch; }

.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress-label {
  display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted);
}
.progress-label b { color: var(--text); }
.progress-bar {
  height: 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 99px; transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.progress-pct { font-size: 12px; color: var(--accent); font-weight: 700; align-self: flex-end; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mode-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: transform .15s, border-color .15s, background .15s;
  display: flex; flex-direction: column; gap: 4px;
}
.mode-card:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--panel-2); }
.mode-card:active { transform: translateY(0); }
.mode-icon { font-size: 26px; }
.mode-t { font-size: 15px; font-weight: 700; margin-top: 4px; }
.mode-d { font-size: 12px; color: var(--muted); line-height: 1.4; }
.mode-go { font-size: 12.5px; color: var(--accent); font-weight: 600; margin-top: 8px; }

.chip-wrap { display: flex; flex-direction: column; gap: 8px; }
.chip-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 12px; padding: 6px 11px; border-radius: 99px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.chip b { color: var(--text); }

/* ---------- Cards ---------- */
.filter-bar { display: flex; gap: 7px; margin: 6px 0 14px; flex-wrap: wrap; }
.fbtn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 99px; cursor: pointer;
  transition: all .15s;
}
.fbtn:hover { color: var(--text); }
.fbtn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.fbtn-m.active { background: var(--m); border-color: var(--m); color: #fff; }
.fbtn-f.active { background: var(--f); border-color: var(--f); color: #fff; }
.fbtn-n.active { background: var(--n); border-color: var(--n); color: #04210f; }

.card-counter { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; font-weight: 600; }

.card-wrap { perspective: 1400px; margin: 0 auto 16px; max-width: 460px; }
.flip-card {
  position: relative;
  width: 100%;
  height: 280px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4,.2,.2,1);
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; gap: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.flip-front {
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-2) 100%);
}
.flip-back {
  background: linear-gradient(160deg, var(--panel-2) 0%, var(--panel) 100%);
  transform: rotateY(180deg);
}
.flip-front::before, .flip-back::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 5px;
  border-radius: 20px 20px 0 0;
}
.art-m::before { background: var(--m); }
.art-f::before { background: var(--f); }
.art-n::before { background: var(--n); }

.front-art {
  font-size: 18px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 14px; border-radius: 99px;
  background: rgba(255,255,255,.06);
}
.art-m .front-art { color: var(--m); }
.art-f .front-art { color: var(--f); }
.art-n .front-art { color: var(--n); }
.front-word {
  font-size: 40px; font-weight: 800; letter-spacing: -0.02em;
  text-align: center; margin-top: 4px;
}
.front-cat { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.front-hint { position: absolute; bottom: 18px; font-size: 11.5px; color: var(--muted); }

.back-en-label, .back-pl-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.back-en { font-size: 30px; font-weight: 800; text-align: center; }
.back-pl { font-size: 18px; color: var(--accent); font-weight: 600; margin-bottom: 6px; }
.known-toggle {
  font-family: inherit; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  padding: 8px 16px; border-radius: 99px; cursor: pointer;
  transition: all .15s;
}
.known-toggle:hover { border-color: var(--good); color: var(--good); }
.known-toggle.is-known { background: var(--good); border-color: var(--good); color: #04210f; }

.card-ctrl { display: flex; gap: 8px; justify-content: center; max-width: 460px; margin: 0 auto; }
.ctrl-btn {
  flex: 1;
  font-family: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 11px 14px; border-radius: 12px; cursor: pointer;
  transition: all .15s;
}
.ctrl-btn:hover { background: var(--panel-2); }
.ctrl-btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1300; }
.ctrl-btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* ---------- Articles trainer ---------- */
.art-panel, .phr-panel, .quiz-panel { display: flex; flex-direction: column; gap: 14px; padding: 6px 0; }
.section-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.section-sub { margin: 0; color: var(--muted); font-size: 13.5px; }

.art-qcard {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 20px; text-align: center;
  box-shadow: var(--shadow);
}
.art-word-box { display: flex; flex-direction: column; gap: 6px; }
.art-qword { font-size: 34px; font-weight: 800; letter-spacing: -0.01em; }
.art-qen { font-size: 14px; color: var(--muted); }

.art-opts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.art-opt {
  font-family: inherit; cursor: pointer;
  background: var(--panel); border: 2px solid var(--border); color: var(--text);
  border-radius: 14px; padding: 18px 8px;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  transition: transform .12s, border-color .15s, background .15s;
}
.art-opt:hover:not(:disabled) { transform: translateY(-2px); }
.art-opt:disabled { cursor: default; opacity: .85; }
.art-opt-a { font-size: 22px; font-weight: 800; }
.art-opt-n { font-size: 11px; color: var(--muted); }
.art-opt-der .art-opt-a, .art-opt.der.correct { color: var(--m); }
.art-opt-die .art-opt-a { color: var(--f); }
.art-opt-das .art-opt-a { color: var(--n); }
.art-opt.correct { border-color: var(--good); background: rgba(62,207,142,.12); }
.art-opt.correct .art-opt-a { color: var(--good); }
.art-opt.wrong { border-color: var(--red); background: rgba(224,65,59,.12); }
.art-opt.wrong .art-opt-a { color: var(--red); }

.art-feedback, .quiz-fb {
  border-radius: 14px; padding: 14px 16px; font-size: 14px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.art-feedback.good, .quiz-fb.good { background: rgba(62,207,142,.12); border: 1px solid rgba(62,207,142,.35); color: var(--good); }
.art-feedback.bad, .quiz-fb.bad { background: rgba(224,65,59,.12); border: 1px solid rgba(224,65,59,.35); color: var(--red); }
.art-feedback b, .quiz-fb b { color: var(--text); }
.art-feedback .ctrl-btn, .quiz-fb .ctrl-btn { flex: 0 0 auto; align-self: stretch; text-align: center; }

.art-legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }
.leg { font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 99px; }
.leg-m { color: var(--m); background: rgba(90,169,255,.12); }
.leg-f { color: var(--f); background: rgba(255,107,139,.12); }
.leg-n { color: var(--n); background: rgba(94,214,160,.12); }

/* ---------- Phrases ---------- */
.phr-cats { display: flex; gap: 7px; flex-wrap: wrap; }
.phr-cat {
  font-family: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  padding: 7px 14px; border-radius: 99px; cursor: pointer; transition: all .15s;
}
.phr-cat:hover { color: var(--text); }
.phr-cat.active { background: var(--accent); border-color: var(--accent); color: #1a1300; }

.phr-list { display: flex; flex-direction: column; gap: 8px; }
.phr-row {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  transition: background .15s, border-color .15s;
}
.phr-row:hover { background: var(--panel-2); }
.phr-de { font-size: 16px; font-weight: 700; }
.phr-en {
  font-size: 13.5px; color: var(--muted);
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .3s, opacity .25s, margin .25s;
}
.phr-row.reveal .phr-en { max-height: 40px; opacity: 1; margin-top: 4px; }
.phr-note { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

/* ---------- Quiz ---------- */
.quiz-score {
  display: flex; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
}
.qs-cell { flex: 1; text-align: center; display: flex; flex-direction: column; }
.qs-n { font-size: 22px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.qs-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.quiz-qcard {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.quiz-q { font-size: 20px; font-weight: 700; text-align: center; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qopt {
  font-family: inherit; cursor: pointer; text-align: left;
  background: var(--panel-2); border: 2px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 13px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: transform .12s, border-color .15s, background .15s;
  min-height: 52px;
}
.qopt:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.qopt:disabled { cursor: default; }
.qopt-idx {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.qopt-a { font-size: 18px; font-weight: 800; }
.qopt-t { font-size: 15px; font-weight: 600; }
.qopt.correct { border-color: var(--good); background: rgba(62,207,142,.14); }
.qopt.correct .qopt-idx { background: var(--good); color: #04210f; border-color: var(--good); }
.qopt.wrong { border-color: var(--red); background: rgba(224,65,59,.14); }
.qopt.wrong .qopt-idx { background: var(--red); color: #fff; border-color: var(--red); }

.quiz-dots { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 99px; background: var(--border); }
.dot.good { background: var(--good); }
.dot.bad { background: var(--red); }

/* ---------- Footer ---------- */
.foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px 14px; font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0; gap: 8px;
}
.foot span:last-child { text-align: right; }

.empty { text-align: center; padding: 40px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
  .mode-grid { grid-template-columns: 1fr; }
  .quiz-opts { grid-template-columns: 1fr; }
  .art-opts { grid-template-columns: 1fr; }
  .front-word { font-size: 34px; }
  .back-en { font-size: 26px; }
  .brand-text h1 { font-size: 17px; }
  .tagline { font-size: 10.5px; }
  .stats { gap: 6px; }
  .stat { padding: 5px 9px; min-width: 48px; }
}
@media (min-width: 600px) {
  .topbar { padding: 20px 22px 12px; }
  .stage { padding: 8px 22px 22px; }
  .hero-title { font-size: 27px; }
}
