/* Verba – Karteikarten auf dem Schreibtisch */

@font-face { font-family: 'Literata'; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url(fonts/literata-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 300 800; font-display: swap;
  src: url(fonts/literata-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Literata'; font-style: italic; font-weight: 300 800; font-display: swap;
  src: url(fonts/literata-latin-wght-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC; }
@font-face { font-family: 'Literata'; font-style: italic; font-weight: 300 800; font-display: swap;
  src: url(fonts/literata-latin-ext-wght-italic.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+1E00-1E9F; }
@font-face { font-family: 'Atkinson'; font-weight: 400; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: 'Atkinson'; font-weight: 400; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+1E00-1E9F; }
@font-face { font-family: 'Atkinson'; font-weight: 700; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: 'Atkinson'; font-weight: 700; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF, U+1E00-1E9F; }

:root {
  --desk: #e2e7ed;
  --desk-2: #d4dbe4;
  --ink: #1c2a44;
  --ink-2: #4d5b74;
  --ink-3: #7c879a;
  --paper: #fdfdfb;
  --rule: #bccde6;
  --red: #c8323c;
  --ok: #2c7a4d;
  --close: #a86a12;
  --la: #e3efd9;      /* Latein: grüne Karteikarte */
  --la-ink: #3c6b2a;
  --es: #fbefbd;      /* Spanisch: gelbe Karteikarte */
  --es-ink: #8a6a07;
  --line: rgba(28, 42, 68, .14);
  --shadow: 0 1px 0 rgba(28, 42, 68, .08), 0 10px 26px -14px rgba(28, 42, 68, .45);
  --serif: 'Literata', Georgia, serif;
  --sans: 'Atkinson', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --lh: 1.9rem;
  --radius: 4px;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #151a21; --desk-2: #1d242d;
    --ink: #e7ecf3; --ink-2: #aab5c6; --ink-3: #7d889a;
    --paper: #232a33; --rule: rgba(130, 160, 210, .2);
    --red: #e05a62; --ok: #5cc28a; --close: #e0a64a;
    --la: #233026; --la-ink: #9fd08a; --es: #322e1d; --es-ink: #e6c867;
    --line: rgba(220, 230, 245, .12);
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 28px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 3px; }

.wrap { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 18px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px); }
.wrap.bare { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.875rem; line-height: 1.15; }
h2 { font-size: 1.3rem; line-height: 1.25; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 999px;
  background: var(--ink); color: var(--desk); font-weight: 700; font-size: 1rem;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.quiet { background: var(--desk-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: default; }
.iconbtn {
  appearance: none; border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center;
}
.iconbtn:active { background: var(--desk-2); }
.iconbtn svg, .btn svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- Formulare */
.field { display: block; }
.field > span { display: block; font-size: .875rem; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper);
  font-size: 1.0625rem; outline: none;
}
.input:focus { border-color: var(--ink); }
textarea.input { min-height: 180px; line-height: 1.55; font-family: var(--sans); resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.error { color: var(--red); font-size: .95rem; }

/* ---------------------------------------------------------------- Karteikarte */
.kk {
  position: relative; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  --head: 2.6rem;
  background-image:
    linear-gradient(var(--red), var(--red)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px), var(--rule) var(--lh));
  background-size: 100% 2px, 100% calc(100% - var(--head) - 2px);
  background-position: 0 var(--head), 0 calc(var(--head) + 2px);
  background-repeat: no-repeat;
}
.kk.la { background-color: var(--la); }
.kk.es { background-color: var(--es); }
.kk.plain { background-image: none; }
.kk-head { height: var(--head); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: .85rem; color: var(--ink-2); gap: 12px; }
.kk-head > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kk-body { padding: 8px 18px 18px; }

/* Lern-Karte mit Umdrehen */
.flip { perspective: 1400px; }
.flip-inner { display: grid; transition: transform .5s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.flip.turned .flip-inner { transform: rotateY(180deg); }
.flip { cursor: default; }
.flip.turned { cursor: pointer; }
.flip .face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; min-height: clamp(200px, 30dvh, 260px); display: flex; flex-direction: column; }
.flip .face.back { transform: rotateY(180deg); }
.flip .kk-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }

.headword { font-family: var(--serif); font-weight: 560; font-size: clamp(2rem, 9vw, 2.75rem); line-height: 1.12; letter-spacing: -.015em; overflow-wrap: anywhere; }
.headword.de { font-family: var(--sans); font-weight: 700; font-size: clamp(1.6rem, 7vw, 2.1rem); letter-spacing: 0; }
.subword { font-family: var(--serif); font-style: italic; color: var(--ink-2); font-size: 1.1rem; }
.answer-line { font-size: 1.35rem; font-weight: 700; }
.forms-list { display: grid; grid-template-columns: auto auto; gap: 2px 14px; justify-content: center; font-size: .98rem; margin-top: 6px; text-align: left; }
.forms-list dt { color: var(--ink-2); }
.forms-list dd { margin: 0; font-weight: 700; font-family: var(--serif); }
.note { font-family: var(--serif); font-style: italic; color: var(--ink-2); max-width: 30ch; margin-top: 8px; }

.stamp { font-weight: 700; font-size: .85rem; padding: 2px 9px; border-radius: 999px; border: 1.5px solid currentColor; }
.stamp.ok { color: var(--ok); } .stamp.close { color: var(--close); } .stamp.wrong { color: var(--red); } .stamp.new { color: var(--ink); }

/* ---------------------------------------------------------------- Lernansicht */
.learn-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress { flex: 1; height: 6px; border-radius: 3px; background: var(--desk-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ink); width: 0; transition: width .3s ease; }
.learn-count { font-family: var(--serif); font-size: .9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }

.answer-area { margin-top: 18px; }
.answer-area .input { font-size: 1.2rem; text-align: center; min-height: 54px; }
.charbar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.charbar button { appearance: none; border: 0; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); border-radius: 8px; min-width: 40px; height: 38px; font-size: 1.1rem; cursor: pointer; }
.charbar button:active { background: var(--desk-2); }

.choices { display: grid; gap: 10px; margin-top: 18px; }
.choice {
  appearance: none; border: 0; text-align: left; cursor: pointer;
  padding: 14px 16px; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 1.05rem; display: flex; gap: 12px; align-items: baseline;
}
.choice kbd { font: 700 .8rem var(--sans); color: var(--ink-3); }
.choice.is-right { box-shadow: inset 0 0 0 2px var(--ok); color: var(--ok); font-weight: 700; }
.choice.is-wrong { box-shadow: inset 0 0 0 2px var(--red); color: var(--red); text-decoration: line-through; }
.choice[disabled] { cursor: default; }

.formq { display: grid; gap: 14px; margin-top: 18px; }
.formq .lbl { font-size: .9rem; color: var(--ink-2); margin-bottom: 6px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; appearance: none; border: 0; cursor: pointer; min-height: 48px; border-radius: 10px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--line); font-size: 1.1rem; font-weight: 700; font-family: var(--serif); }
.seg button.on { background: var(--ink); color: var(--desk); box-shadow: none; }
.seg button.is-right { box-shadow: inset 0 0 0 2px var(--ok); color: var(--ok); }
.seg button.is-wrong { box-shadow: inset 0 0 0 2px var(--red); color: var(--red); background: var(--paper); }
.input.is-right { border-color: var(--ok); }
.input.is-wrong { border-color: var(--red); }
.tokfb { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; font-family: var(--serif); }
.tokfb span { padding: 1px 8px; border-radius: 6px; }
.tokfb .ok { color: var(--ok); } .tokfb .bad { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }

.feedback { margin-top: 16px; text-align: center; min-height: 1.5em; font-weight: 700; }
.feedback.ok { color: var(--ok); } .feedback.close { color: var(--close); } .feedback.wrong { color: var(--red); }
.actions { display: grid; gap: 10px; margin-top: 16px; }
.actions .row > .btn { flex: 1; }
.linkbtn { appearance: none; background: none; border: 0; padding: 6px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .95rem; }

/* ---------------------------------------------------------------- Startseite */
.hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--ink) calc(var(--p) * 1%), var(--desk-2) 0); }
.ring > div { width: 50px; height: 50px; border-radius: 50%; background: var(--desk); display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring b { font-family: var(--serif); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.ring small { font-size: .65rem; color: var(--ink-2); }
.streak { font-size: .95rem; color: var(--ink-2); margin-top: 4px; }
.streak b { color: var(--ink); }

.langcard { display: block; text-decoration: none; }
.langcard .kk-body { display: grid; gap: 14px; padding-top: 14px; }
.langcard .name { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.langcard.la .name { color: var(--la-ink); } .langcard.es .name { color: var(--es-ink); }
.figures { display: flex; gap: 22px; align-items: baseline; }
.figures div { display: grid; }
.figures b { font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; font-family: var(--serif); font-weight: 600; }
.figures span { font-size: .85rem; color: var(--ink-2); }
.levels { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--desk-2); }
.levels i { display: block; height: 100%; }
.levels .l1 { background: color-mix(in srgb, var(--red) 70%, var(--paper)); }
.levels .l2 { background: color-mix(in srgb, var(--close) 80%, var(--paper)); }
.levels .l3 { background: var(--ok); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

.exam { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.exam:last-child { border-bottom: 1px solid var(--line); }
.cal { width: 50px; flex: none; text-align: center; border-radius: 6px; overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.cal span { display: block; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 0; }
.cal b { display: block; font-family: var(--serif); font-size: 1.35rem; line-height: 1.5; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 30px 0 10px; }

/* ---------------------------------------------------------------- Listen */
.tabs { display: flex; gap: 6px; background: var(--desk-2); padding: 4px; border-radius: 999px; margin-bottom: 18px; }
.tabs a { flex: 1; text-align: center; padding: 9px 0; border-radius: 999px; text-decoration: none; font-weight: 700; color: var(--ink-2); }
.tabs a.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:last-child { border-bottom: 1px solid var(--line); }
.list a, .list button.li { display: flex; align-items: center; gap: 12px; padding: 14px 2px; text-decoration: none; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.lesson-meta { font-size: .875rem; color: var(--ink-2); }
.mini-bar { width: 64px; height: 6px; border-radius: 3px; background: var(--desk-2); overflow: hidden; flex: none; }
.mini-bar i { display: block; height: 100%; background: var(--ok); }
.chev { color: var(--ink-3); flex: none; }

.word-row .fw { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.word-row .de { color: var(--ink-2); font-size: .95rem; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.dot.l1 { background: color-mix(in srgb, var(--red) 70%, var(--paper)); box-shadow: none; }
.dot.l2 { background: color-mix(in srgb, var(--close) 80%, var(--paper)); box-shadow: none; }
.dot.l3 { background: var(--ok); box-shadow: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chip { font-size: .82rem; padding: 3px 10px; border-radius: 999px; background: var(--desk-2); color: var(--ink-2); }
.chip b { color: var(--ink); }
.chip.warn { background: color-mix(in srgb, var(--close) 16%, transparent); color: var(--close); }

.entry { padding: 16px 18px 18px; }
.entry .stack { --gap: 12px; }

.empty { text-align: center; padding: 34px 10px; }
.empty p { margin: 8px auto 18px; max-width: 34ch; }

.preview-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.preview-table td { border-top: 1px solid var(--line); padding: 8px 6px; vertical-align: top; }
.preview-table td:first-child { font-family: var(--serif); font-weight: 600; }
.preview-table tr.bad td { color: var(--red); }

/* Statistik */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bars i { display: block; background: var(--ink); border-radius: 2px 2px 0 0; min-height: 0; }
.bars i.miss { background: color-mix(in srgb, var(--red) 65%, var(--paper)); border-radius: 0; }
.bars div.today i:not(.miss) { background: var(--ok); }
.axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--ink-3); margin-top: 6px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kv div { background: var(--paper); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
.kv b { display: block; font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kv span { font-size: .8rem; color: var(--ink-2); }
.fc { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.fc div { background: var(--paper); border-radius: 8px; padding: 8px 0; }
.fc b { display: block; font-family: var(--serif); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.fc span { font-size: .72rem; color: var(--ink-2); }

/* ---------------------------------------------------------------- Tableiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--desk) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex; justify-content: center;
}
.tabbar nav { display: flex; width: 100%; max-width: 560px; }
.tabbar a { flex: 1; display: grid; place-items: center; align-content: center; gap: 2px; text-decoration: none; color: var(--ink-3); font-size: .75rem; font-weight: 700; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--ink); }

/* ---------------------------------------------------------------- Dialog & Toast */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 16, 28, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--desk); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px); animation: up .22s cubic-bezier(.2, .8, .3, 1); }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-bg { animation: none; } }
.fields-edit .frow { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; }
.fields-edit .frow .input { min-height: 42px; font-size: .98rem; padding: 8px 10px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--desk); padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .95rem; box-shadow: var(--shadow); max-width: 90vw; }

/* Anmeldung */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px; }
.login .kk { width: 100%; max-width: 400px; }
.login .kk-body { padding: 18px 22px 24px; }
.brand { font-family: var(--serif); font-size: 2.6rem; font-weight: 600; letter-spacing: -.02em; line-height: 1; }

.done-word { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.done-word span:first-child { font-family: var(--serif); font-weight: 600; }
