/* ¡Vamos! Design-System — warm, ruhig, spanisch. Ohne Webfonts, ohne Frameworks. */

:root {
  --bg: #faf6ef;
  --bg-soft: #f3ecdf;
  --card: #ffffff;
  --text: #26221c;
  --muted: #8a8375;
  --line: #eae3d4;
  --accent: #c2452d;
  --accent-deep: #a03823;
  --accent-soft: #fbe9e3;
  --gold: #e0a126;
  --gold-soft: #faf0d7;
  --green: #3e8e5f;
  --green-soft: #e4f2e9;
  --blue: #33689e;
  --blue-soft: #e7eef7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(80, 60, 30, .06), 0 4px 14px rgba(80, 60, 30, .05);
  --shadow-lift: 0 2px 6px rgba(80, 60, 30, .1), 0 10px 28px rgba(80, 60, 30, .1);
  --hero-grad: linear-gradient(135deg, #c2452d 0%, #d4622c 55%, #e0a126 130%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191611;
    --bg-soft: #14110d;
    --card: #242019;
    --text: #f0eadf;
    --muted: #a39a89;
    --line: #373126;
    --accent: #e56744;
    --accent-deep: #c94f2f;
    --accent-soft: #3c2419;
    --gold: #e5b04a;
    --gold-soft: #3a3019;
    --green: #58ab7c;
    --green-soft: #1f3328;
    --blue: #6f9fd0;
    --blue-soft: #1e2c3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .4);
    --hero-grad: linear-gradient(135deg, #a83a24 0%, #c2542a 55%, #b98a2c 130%);
  }
}
:root[data-theme="dark"] {
  --bg: #191611;
  --bg-soft: #14110d;
  --card: #242019;
  --text: #f0eadf;
  --muted: #a39a89;
  --line: #373126;
  --accent: #e56744;
  --accent-deep: #c94f2f;
  --accent-soft: #3c2419;
  --gold: #e5b04a;
  --gold-soft: #3a3019;
  --green: #58ab7c;
  --green-soft: #1f3328;
  --blue: #6f9fd0;
  --blue-soft: #1e2c3d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .4);
  --hero-grad: linear-gradient(135deg, #a83a24 0%, #c2542a 55%, #b98a2c 130%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* Globaler Button-Reset: nie UA-Weiß im Dark Mode durchscheinen lassen */
button {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

/* Stroke-Icons */
.icn {
  width: 1.15em; height: 1.15em;
  vertical-align: -0.22em;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.icn.lg { width: 1.6em; height: 1.6em; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ---------- Kopf & Navigation ---------- */

header.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 1.12rem; letter-spacing: -.01em; }
.topbar h1 a { color: var(--text); text-decoration: none; }
.topbar .gear {
  background: none; border: none; font-size: 1.25rem; padding: .25rem .45rem;
  border-radius: 10px; text-decoration: none; transition: background .15s;
}
.topbar .gear:hover { background: var(--bg-soft); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
  animation: view-in .28s ease both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: .3rem .4rem calc(.35rem + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; padding: .3rem 0 .35rem;
  text-decoration: none; color: var(--muted); font-size: .66rem; font-weight: 500;
  border-radius: 12px; transition: color .15s, background .15s;
}
.tabbar a .ico { display: block; line-height: 1.1; opacity: .75; transition: opacity .15s, transform .15s; }
.tabbar a .ico .icn { width: 1.45rem; height: 1.45rem; vertical-align: middle; }
.tabbar a.active { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.tabbar a.active .ico { opacity: 1; transform: translateY(-1px); }

/* ---------- Karten & Grundbausteine ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.1rem;
  margin-bottom: .95rem;
}
.card h2 { margin: 0 0 .45rem; font-size: 1.02rem; letter-spacing: -.01em; }
.card h3 { margin: .8rem 0 .3rem; font-size: .95rem; }
.muted { color: var(--muted); font-size: .87rem; }
.small { font-size: .8rem; }

.hero {
  background: var(--hero-grad);
  color: #fff;
  border: none;
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  padding: 1.25rem 1.2rem;
  display: flex; align-items: center; gap: 1.1rem;
}
.hero .greet { font-size: 1.28rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .15rem; }
.hero .sub { font-size: .86rem; opacity: .92; margin: 0 0 .7rem; }
.hero .btn.cta {
  background: #fff; color: var(--accent-deep); border: none;
  font-weight: 800; box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
.hero .ring-wrap { flex-shrink: 0; text-align: center; }
.ring { display: block; }
.ring .track { stroke: rgba(255,255,255,.25); }
.ring .val { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-label { font-size: .68rem; opacity: .92; margin-top: .15rem; display: block; }
.ring-num { font-size: 1.05rem; font-weight: 800; fill: #fff; }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: .58rem 1.05rem;
  text-decoration: none;
  font-weight: 650;
  font-size: .92rem;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.small { padding: .38rem .75rem; font-size: .82rem; }
.btn:active { transform: scale(.97); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: .95rem; }
.quick {
  display: block; text-align: center; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .75rem .3rem .6rem;
  transition: transform .12s, box-shadow .15s;
}
.quick:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.quick .ico { display: block; margin-bottom: .3rem; color: var(--accent); }
.quick .ico .icn { width: 1.5rem; height: 1.5rem; }
.quick .lbl { font-size: .74rem; font-weight: 650; }

.pill {
  display: inline-block; padding: .08rem .58rem; border-radius: 99px;
  font-size: .7rem; font-weight: 700; vertical-align: middle;
}
.pill.level { background: var(--blue-soft); color: var(--blue); }
.pill.phase { background: var(--accent-soft); color: var(--accent); }
.pill.done { background: var(--green-soft); color: var(--green); }

.progress {
  height: 7px; background: var(--line); border-radius: 99px; overflow: hidden;
  margin-top: .45rem;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #5fae82); border-radius: 99px; transition: width .5s ease; }
.progress > i.partial { background: linear-gradient(90deg, var(--gold), #ecc06a); }

.unit-row {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem .15rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text);
  transition: background .15s;
}
.unit-row:hover { background: var(--bg-soft); border-radius: 10px; }
.unit-row:last-child { border-bottom: none; }
.unit-row .emoji {
  font-size: 1.45rem; width: 2.6rem; height: 2.6rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); border-radius: 12px;
}
.unit-row .body { flex: 1; min-width: 0; }
.unit-row .title { font-weight: 650; font-size: .95rem; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: .95rem; }
.stat-grid .card { margin: 0; text-align: center; padding: .75rem .4rem .65rem; }
.stat-grid .num { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.stat-grid .lbl { font-size: .7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Vokabelliste ---------- */

table.vocab { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.vocab td { padding: .55rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.vocab tr:last-child td { border-bottom: none; }
table.vocab .es { font-weight: 650; }
table.vocab .ex { color: var(--muted); font-size: .8rem; }
table.vocab .speak-btn { border: none; background: none; font-size: 1.05rem; padding: .1rem .3rem; border-radius: 8px; }
table.vocab .speak-btn:hover { background: var(--bg-soft); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: .35rem; }
.dot.new { background: var(--line); }
.dot.learning { background: var(--gold); }
.dot.mastered { background: var(--green); }

/* ---------- Lernkarte ---------- */

.flashcard {
  min-height: 320px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: .5rem; padding: 1.6rem 1rem;
  animation: card-in .25s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.flashcard .emoji { font-size: 3.4rem; line-height: 1.2; }
.flashcard .word { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; }
.flashcard .answer { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.flashcard .example {
  color: var(--muted); font-size: .95rem; margin-top: .4rem;
  background: var(--bg-soft); border-radius: 12px; padding: .5rem .8rem;
}
.flashcard .tag { font-size: .72rem; color: var(--muted); font-weight: 600; }
.reveal-anim { animation: reveal-up .3s ease both; }
@keyframes reveal-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.grade-row button {
  border: none; border-radius: 12px; padding: .62rem .2rem; color: #fff; font-weight: 750;
  font-size: .88rem; transition: transform .1s, filter .15s;
}
.grade-row button:hover { filter: brightness(1.08); }
.grade-row button:active { transform: scale(.96); }
.grade-row .sub { display: block; font-weight: 450; font-size: .68rem; opacity: .85; }
.g-again { background: #bd3a2b; }
.g-hard { background: #cd8419; }
.g-good { background: #3e8e5f; }
.g-easy { background: #33689e; }
.reveal-btn { width: 100%; }

.session-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; font-size: .82rem; color: var(--muted); }
.session-progress { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: .8rem; }
.session-progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

/* ---------- Quiz ---------- */

.mc-option {
  display: block; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: .68rem .85rem; margin-bottom: .5rem; font-size: .95rem;
  transition: transform .1s, border-color .15s, background .15s;
}
.mc-option:hover { border-color: var(--muted); }
.mc-option:active { transform: scale(.99); }
.mc-option.correct { border-color: var(--green); background: var(--green-soft); font-weight: 650; }
.mc-option.wrong { border-color: var(--accent); background: var(--accent-soft); }
input.answer-input {
  width: 100%; padding: .62rem .85rem; font-size: 1.05rem;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
  transition: border-color .15s;
}
input.answer-input:focus { outline: none; border-color: var(--accent); }
.feedback { margin: .6rem 0; padding: .6rem .85rem; border-radius: 12px; font-size: .92rem; }
.feedback.ok { background: var(--green-soft); color: var(--green); }
.feedback.almost { background: var(--gold-soft); color: #8a6d1a; }
:root[data-theme="dark"] .feedback.almost { color: #e0c063; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .feedback.almost { color: #e0c063; } }
.feedback.no { background: var(--accent-soft); color: var(--accent); }

.listen-big {
  display: block; margin: .6rem auto 1rem; width: 84px; height: 84px;
  border-radius: 50%; border: none; background: var(--accent-soft); font-size: 2rem;
  transition: transform .12s, background .15s;
}
.listen-big:hover { transform: scale(1.06); }
.listen-big:active { transform: scale(.95); }

.cloze-sentence {
  font-size: 1.15rem; line-height: 1.7; margin: .4rem 0 .6rem;
}
.cloze-gap {
  display: inline-block; min-width: 4.5rem; border-bottom: 2px solid var(--accent);
  text-align: center; font-weight: 700; color: var(--accent);
}

/* ---------- Satzbau-Chips ---------- */

.chip {
  display: inline-block; padding: .4rem .75rem; margin: .18rem;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--card); color: var(--text);
  font-weight: 600; font-size: .92rem;
  transition: transform .1s, border-color .15s;
}
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(.95); }
.chip.used { opacity: .3; }
.chip.picked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.order-area {
  min-height: 3.2rem; border: 1.5px dashed var(--line); border-radius: 14px;
  padding: .35rem; margin: .6rem 0;
  display: flex; flex-wrap: wrap; align-items: center;
}

/* ---------- KI-Tutor Chat ---------- */

.chat-log { display: flex; flex-direction: column; gap: .5rem; margin: .8rem 0 0; max-height: 55vh; overflow-y: auto; }
.bubble {
  max-width: 85%; padding: .55rem .85rem; border-radius: 15px;
  font-size: .93rem; white-space: pre-wrap; line-height: 1.45;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.bubble.ai { align-self: flex-start; background: var(--bg-soft); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.err { align-self: center; background: var(--accent-soft); color: var(--accent); font-size: .84rem; }
textarea.answer-input { resize: vertical; font-family: inherit; line-height: 1.5; }

/* ---------- Suche ---------- */

.search-hit { display: flex; align-items: baseline; gap: .5rem; padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
.search-hit:last-child { border-bottom: none; }
.search-hit .es { font-weight: 650; }
.search-hit .unit { margin-left: auto; font-size: .7rem; color: var(--muted); white-space: nowrap; }

/* ---------- Grammatik ---------- */

.theory p { margin: .4rem 0; }
.theory .example {
  border-left: 3px solid var(--accent); padding: .35rem .75rem; margin: .5rem 0;
  background: var(--accent-soft); border-radius: 0 10px 10px 0; font-size: .92rem;
}
.theory .example .de { color: var(--muted); font-size: .84rem; }
.theory .tip {
  background: var(--blue-soft); border-radius: 12px; padding: .55rem .85rem;
  font-size: .9rem; margin: .5rem 0;
}
.theory table { border-collapse: collapse; margin: .5rem 0; font-size: .9rem; width: 100%; }
.theory th, .theory td { border: 1px solid var(--line); padding: .35rem .55rem; text-align: left; }
.theory th { background: var(--bg-soft); }
.theory code { background: var(--bg-soft); border-radius: 6px; padding: .05rem .35rem; font-size: .88em; }

/* ---------- Statistik ---------- */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 72px; margin-top: .5rem; }
.chart .bar { flex: 1; background: linear-gradient(180deg, #5fae82, var(--green)); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.empty { background: var(--line); }
.chart-labels { display: flex; gap: 3px; font-size: .6rem; color: var(--muted); }
.chart-labels span { flex: 1; text-align: center; }

/* ---------- Feier & Kleinkram ---------- */

.confetti-piece {
  position: fixed; top: -5vh; z-index: 60; font-size: 1.3rem; pointer-events: none;
  animation: confetti-fall 2.4s ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: .4; }
}

.toast {
  position: fixed; bottom: 4.8rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: .5rem 1.1rem; border-radius: 99px; font-size: .85rem; font-weight: 600;
  z-index: 50; opacity: 0; transition: opacity .25s; pointer-events: none;
  white-space: nowrap; box-shadow: var(--shadow-lift);
}
.toast.show { opacity: 1; }

.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty-state .big { font-size: 2.8rem; animation: pop-in .35s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(.4); }
  to { opacity: 1; transform: none; }
}

.skeleton { border-radius: var(--radius); background: var(--line); min-height: 90px; margin-bottom: .95rem; overflow: hidden; position: relative; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmer 1.1s infinite;
}
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

label.setting { display: block; margin: .85rem 0 .3rem; font-weight: 650; font-size: .9rem; }
select, input[type=number] {
  width: 100%; padding: .52rem .7rem; font-size: .95rem;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
}
select:focus, input[type=number]:focus { outline: none; border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  header.topbar, nav.tabbar, .btn, .btn-row, .speak-btn, .quick-grid, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0; }
}
