/* LOCAL-FONT-START – Schrift liegt auf dem eigenen Server (keine Verbindung zu Google) */
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/fraunces-500.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 600 700; font-display: swap; src: url('fonts/fraunces-600.woff2') format('woff2'); }
/* LOCAL-FONT-END */

:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efebe3;
  --text: #1d231f;
  --muted: #5f675f;
  --line: #e1dcd1;
  --accent: #2f7d4f;          /* Basilikum-Grün */
  --accent-ink: #ffffff;
  --accent-soft: #e2f0e6;
  --red: #c8412f;             /* Tomate */
  --red-soft: #f8e3df;
  --amber: #b7791f;
  --amber-soft: #f7ecd8;
  --blue: #2f6aa8;
  --blue-soft: #e1ebf6;
  --g-m: #2f6aa8;
  --g-f: #b83d74;
  --g-mf: #7a57b0;
  --shadow: 0 1px 2px rgba(30,35,30,.06), 0 8px 24px rgba(30,35,30,.07);
  --radius: 18px;
  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2320;
    --surface-2: #262d29;
    --text: #eef1ec;
    --muted: #a3ada5;
    --line: #313a35;
    --accent: #5dbb82;
    --accent-ink: #0d1510;
    --accent-soft: #1f3528;
    --red: #ec7a67;
    --red-soft: #3a2420;
    --amber: #e0a64a;
    --amber-soft: #3a2f1c;
    --blue: #7fb1e6;
    --blue-soft: #1e2d3d;
    --g-m: #86b6ea;
    --g-f: #ec8fb8;
    --g-mf: #b89ce6;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body::before { /* feine Tricolore oben */
  content: ''; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50;
  background: linear-gradient(90deg, #2f7d4f 0 33.3%, #f4f1ea 33.3% 66.6%, #c8412f 66.6%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

/* ---------- Boot ---------- */
.boot { display: grid; place-items: center; min-height: 70dvh; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand h1 { font-family: var(--serif); font-weight: 600; font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
.streak-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--amber-soft); color: var(--amber); font-weight: 600; font-size: .92rem;
}

/* ---------- Karten / Flächen ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.stack > * + * { margin-top: 14px; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------- Hero auf Startseite ---------- */
.hero h2 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -.01em; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.stat {
  background: var(--surface-2); border-radius: 14px; padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 1.55rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.stat.due b { color: var(--blue); }
.stat.new b { color: var(--accent); }
.stat.done b { color: var(--amber); }

.goal-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600;
  background: var(--surface-2); color: var(--text); transition: transform .08s ease, filter .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: .9rem; border-radius: 10px; }
.btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ---------- Segmented control & Chips ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 14px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12), inset 0 0 0 1px var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px;
  font-size: .9rem; font-weight: 600; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Lernkarte ---------- */
.learn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.learn-head .goal-bar { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 1.1rem; flex: none;
}
.counter { font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--muted); min-width: 52px; text-align: right; }

.flash {
  position: relative; min-height: 340px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 28px 22px; cursor: pointer; user-select: none;
}
.flash .meta { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }
.tag { background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-weight: 600; }
.tag.new { background: var(--accent-soft); color: var(--accent); }
.tag.own { background: var(--blue-soft); color: var(--blue); }
.flash .lang { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.flash .word { font-family: var(--serif); font-weight: 500; font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.15; overflow-wrap: anywhere; }
.flash .divider { width: 48px; height: 2px; background: var(--line); margin: 22px auto; border-radius: 2px; }
.flash .answer { font-size: clamp(1.2rem, 5vw, 1.5rem); font-weight: 600; overflow-wrap: anywhere; animation: fadeUp .25s ease; }
.flash .hint { margin-top: 26px; font-size: .88rem; color: var(--muted); }
.speak { margin-top: 14px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.grade { border: 0; border-radius: 14px; padding: 10px 4px; font-weight: 600; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.grade small { font-weight: 500; font-size: .74rem; opacity: .8; }
.grade.g0 { background: var(--red-soft); color: var(--red); }
.grade.g1 { background: var(--amber-soft); color: var(--amber); }
.grade.g2 { background: var(--accent-soft); color: var(--accent); }
.grade.g3 { background: var(--blue-soft); color: var(--blue); }
.grade:active { transform: scale(.97); }
.kbd-hint { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 10px; }
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------- Fun-Fact ---------- */
.funfact { text-align: center; padding: 30px 22px; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.funfact .emoji { font-size: 3rem; line-height: 1; }
.funfact h3 { font-family: var(--serif); font-size: 1.35rem; margin: 12px 0 4px; }
.funfact .milestone { color: var(--accent); font-weight: 600; font-size: .9rem; }
.funfact p.fact { font-size: 1.08rem; margin: 16px 0 22px; }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

/* ---------- Session-Ende ---------- */
.done-card { text-align: center; padding: 30px 20px; }
.done-card .big { font-size: 3rem; }
.done-card h2 { font-family: var(--serif); margin: 10px 0 6px; }

/* ---------- Listen ---------- */
.search { display: flex; gap: 8px; }
.input, .search input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .it { font-weight: 600; }
.list .de { color: var(--muted); font-size: .92rem; }
.list .grow { flex: 1; min-width: 0; }
.list .lvl { width: 4px; height: 30px; border-radius: 2px; flex: none; background: var(--line); }
.lvl.l1 { background: var(--red); } .lvl.l2 { background: var(--amber); } .lvl.l3 { background: var(--accent); } .lvl.l4 { background: var(--blue); }

/* ---------- Statistik ---------- */
.lesson-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lesson-row:last-child { border-bottom: 0; }
.lesson-row .lname { font-weight: 700; }
.stackbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.stackbar i { display: block; height: 100%; }
.stackbar .b-new { background: var(--line); }
.stackbar .b-learn { background: var(--amber); }
.stackbar .b-known { background: var(--accent); }
.stackbar .b-master { background: var(--blue); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal i { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); }
.cal i.on1 { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.cal i.on2 { background: color-mix(in srgb, var(--accent) 65%, var(--surface-2)); }
.cal i.on3 { background: var(--accent); }
.cal i.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.tabbar nav { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; border-radius: 12px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* ---------- Login ---------- */
.login { min-height: 82dvh; display: flex; flex-direction: column; justify-content: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.login h1 { font-family: var(--serif); font-size: 2.2rem; margin: 0 0 6px; letter-spacing: -.02em; }
.login form { margin-top: 26px; }
.login label { display: block; font-weight: 600; margin-bottom: 8px; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 1.4rem; font-variant-numeric: tabular-nums; }

/* ---------- Dialog & Toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10,14,12,.45); }
dialog form { padding: 20px; }
dialog h3 { margin: 0 0 14px; font-family: var(--serif); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 86px); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.guest-hint { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; box-shadow: none; background: var(--surface-2); }
.guest-hint span { flex: 1; }
.guest-hint .icon-btn { width: 32px; height: 32px; font-size: .9rem; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.admin-badge { font-size: .72rem; background: var(--blue-soft); color: var(--blue); padding: 2px 8px; border-radius: 6px; font-weight: 700; }

/* ---------- Genus & Artikel ---------- */
.art { font-weight: 600; }
.art.g-m { color: var(--g-m); } .art.g-f { color: var(--g-f); } .art.g-mf { color: var(--g-mf); }
.gdot { display: inline-block; width: .38em; height: .38em; border-radius: 50%; margin-right: .32em; vertical-align: .18em; }
.gdot.g-m { background: var(--g-m); } .gdot.g-f { background: var(--g-f); } .gdot.g-mf { background: var(--g-mf); }
.gnote { font-size: .55em; color: var(--muted); font-family: var(--sans); font-weight: 500; white-space: nowrap; }
.list .gnote { font-size: .8em; }
.glegend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--muted); }
.glegend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Karte: Umdrehen & Wischen ---------- */
.card-stage { perspective: 1200px; }
.flash { touch-action: pan-y; transition: transform .22s ease, opacity .22s ease; will-change: transform; overflow: hidden; }
.flash.flip-out { transform: rotateY(90deg); transition: transform .15s ease-in; }
.flash.flip-in { animation: flipIn .2s ease-out; }
.flash.card-in { animation: cardIn .22s ease-out; }
@keyframes flipIn { from { transform: rotateY(-90deg); } to { transform: none; } }
@keyframes cardIn { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.stamp {
  position: absolute; top: 44px; padding: 4px 12px; border: 3px solid currentColor; border-radius: 10px;
  font-weight: 800; font-size: 1.1rem; letter-spacing: .06em; text-transform: uppercase; opacity: 0; pointer-events: none;
}
.stamp-yes { left: 16px; color: var(--accent); transform: rotate(-12deg); }
.stamp-no { right: 16px; color: var(--red); transform: rotate(12deg); }
.flash.swipe-yes { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.flash.swipe-no { box-shadow: 0 0 0 3px var(--red), var(--shadow); }
.swipe-hint { text-align: center; font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
@media (hover: hover) and (pointer: fine) { .swipe-hint { display: none; } }

/* ---------- Beispielsatz ---------- */
.ex-btn {
  margin-top: 22px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font-size: .85rem; font-weight: 600;
}
.ex-btn:hover { color: var(--text); }
.example { margin-top: 20px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; text-align: left; max-width: 34em; animation: fadeUp .2s ease; }
.example p { margin: 0; }
.example p[lang="it"] { font-family: var(--serif); font-size: 1.05rem; }
.example .ex-de { color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* ---------- Konjugation ---------- */
.ex-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.example + .ex-row .ex-btn { margin-top: 14px; }
.conj { padding: 20px; }
.conj h3 { font-size: 1.35rem; }
.conj-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 14px; }
.conj-tab { flex: 1 1 28%; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: .85rem; padding: 8px 6px; border-radius: 9px; cursor: pointer; line-height: 1.2; }
.conj-tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.conj-table { width: 100%; border-collapse: collapse; }
.conj-table th, .conj-table td { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.conj-table tr:last-child th, .conj-table tr:last-child td { border-bottom: 0; }
.conj-table th { width: 5.5em; color: var(--muted); font-weight: 500; font-size: .9rem; }
.conj-table td { font-family: var(--serif); font-size: 1.08rem; overflow-wrap: anywhere; }
.conj-info { margin: 12px 0 0; }
.conj-badge { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; font-weight: 600; }
.conj-note { margin: 6px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
dialog form.conj-other { padding: 0; margin-top: 16px; display: flex; gap: 8px; }
.conj-other .input { flex: 1; min-width: 0; }
.conj-rule { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font-size: .88rem; }
.conj-rule summary { cursor: pointer; font-weight: 600; padding: 10px 0; list-style-position: inside; }
.conj-rule[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.conj-rule ul { margin: 8px 0 12px; padding-left: 18px; }
.conj-rule li { margin: 5px 0; line-height: 1.45; }
.conj-rule i { font-family: var(--serif); font-style: normal; font-size: 1.02em; }
.conj-rule .nw { white-space: nowrap; }
.conj-this { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.conj-this p { margin: 3px 0; line-height: 1.45; }
.list .conj-mini { font-size: .75rem; padding: 4px 8px; flex: 0 0 auto; }

/* ---------- Einführung ---------- */
.intro { text-align: center; }
.intro .big { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.intro h3 { font-family: var(--serif); font-size: 1.35rem; margin: 6px 0 8px; }
.intro p { color: var(--muted); margin: 0 auto; max-width: 30em; }
.intro .dots { display: flex; gap: 6px; justify-content: center; margin: 18px 0 4px; }
.intro .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.intro .dots i.on { background: var(--accent); }
.intro .demo { display: flex; justify-content: center; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.intro .demo span { padding: 6px 12px; border-radius: 10px; font-weight: 700; font-size: .9rem; }

.legal h2 { font-family: var(--serif); font-size: 1.4rem; margin: 22px 0 6px; }
.legal h3 { font-size: 1rem; margin: 18px 0 4px; }
.legal p { margin: 6px 0; max-width: 65ch; }
.legal mark { background: var(--amber-soft); color: var(--amber); border-radius: 4px; padding: 0 4px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
