/* parla
   Schwarz und Weiss, dazu Grau für Nebensächliches. Die einzige Farbe ist
   Rot, und nur für Fehler: schwach ausgesprochene Wörter, falsche Antworten,
   Fehlermeldungen. Italienisch steht in der
   Serifenschrift, Deutsch in der Grotesk: so sieht man jederzeit, welche
   Sprache man vor sich hat. */

:root {
    --ink: #000;
    --muted: #666;
    --line: #dedede;
    --accent: #000;
    --warn: #c8321e;
    --sans: system-ui, -apple-system, "Helvetica Neue", sans-serif;
    /* Iowan Old Style zuerst: auf Mac und iPhone vorinstalliert, so sieht die Schrift überall gleich aus. */
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    /* Bewegung: kräftiges Ausklingen für alles, was erscheint oder antwortet. */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
    --tabbar: 3.25rem;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: #fff;
    color: var(--ink);
    font: 400 1.0625rem/1.45 var(--sans);
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: 1.6rem; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; line-height: 1.25; font-weight: 650; }
h3 { font-size: 1.0625rem; font-weight: 650; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.it { font-family: var(--serif); }
.de { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.warn { color: var(--warn); }

#app, .screen { max-width: 34rem; margin: 0 auto; }
.pad { padding: 1.25rem 1.25rem 2rem; }
.stack > * + * { margin-top: 1.75rem; }
.stack-s > * + * { margin-top: 1rem; }
.row { display: flex; gap: 0.625rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }

/* ── Kopf und Navigation ── */
.topbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(var(--safe-t) + 0.5rem) 0.75rem 0.5rem 1.25rem;
    background: #fff;
}
.wordmark { font: 500 1.5rem/1 var(--serif); text-decoration: none; letter-spacing: -0.01em; }
.wordmark-big { font: 500 3rem/1 var(--serif); letter-spacing: -0.02em; }
#view { padding-bottom: calc(var(--tabbar) + var(--safe-b) + 1rem); }
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    display: flex; justify-content: center;
    padding-bottom: var(--safe-b);
    background: #fff; border-top: 1px solid var(--line);
}
.tab {
    flex: 0 1 11.3rem; height: var(--tabbar);
    display: grid; place-items: center;
    text-decoration: none; color: var(--muted); font-weight: 500;
}
.tab.is-active { color: var(--ink); font-weight: 650; }
.in-session .topbar, .in-session .tabbar { display: none; }
.in-session #view { padding-bottom: 0; }

/* ── Knöpfe und Felder ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    min-height: 2.875rem; padding: 0 1.1rem;
    border: 1.5px solid var(--ink); border-radius: 0.5rem; background: #fff;
    font-weight: 600; text-decoration: none; cursor: pointer;
    transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn:active { background: var(--ink); color: #fff; transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:active { background: var(--muted); border-color: var(--muted); }
.btn-small { min-height: 2.5rem; padding: 0 0.875rem; font-size: 0.9375rem; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn .done svg, .btn-icon svg { width: 1.1rem; height: 1.1rem; display: block; }
.btn .done svg { stroke-width: 2.4; }
.icon-btn {
    display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem;
    border: 0; background: none; border-radius: 50%; cursor: pointer; color: var(--ink);
}
.link { border: 0; background: none; padding: 0; text-decoration: underline; text-underline-offset: 0.15em; cursor: pointer; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: grid; gap: 0.5rem; }
.label { font-weight: 600; font-size: 0.9375rem; }
.hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="password"] {
    width: 100%; min-height: 2.875rem; padding: 0 0.75rem;
    border: 1.5px solid var(--ink); border-radius: 0.5rem; background: #fff;
    font-size: 1.0625rem;
}
input:disabled { opacity: 0.4; }
.choice { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice button {
    min-height: 2.5rem; padding: 0 0.875rem;
    border: 1.5px solid var(--line); border-radius: 0.5rem; background: #fff; cursor: pointer;
    transition: border-color 120ms var(--ease-out);
}
.choice button[aria-checked="true"] { border-color: var(--ink); font-weight: 650; box-shadow: inset 0 0 0 1px var(--ink); }
.form-error { color: var(--warn); min-height: 1.45em; }
.notice { padding: 0.75rem 0.875rem; border: 1.5px solid var(--ink); border-radius: 0.5rem; font-size: 0.9375rem; }

#view section:not(.today):not(.unit-next):not(.cards-due) > * + * { margin-top: 0.75rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.25rem; }
.facts dt { color: var(--muted); }

/* ── Anmeldung ── */
.screen { min-height: 100dvh; padding: calc(var(--safe-t) + 3rem) 1.25rem 2rem; }
.auth-form > * + * { margin-top: 1.5rem; }

/* ── Heute ── */
.today-count { font-size: 1.2rem; }
.today-count strong { font: 500 4rem/1 var(--serif); margin-right: 0.5rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.meter { height: 0.375rem; margin-top: 0.875rem; background: var(--line); border-radius: 0.2rem; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.week { display: flex; justify-content: space-between; margin: 1.25rem 0 0.875rem; }
.week li { display: grid; justify-items: center; gap: 0.3rem; font-size: 0.8125rem; color: var(--muted); }
.week-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1.5px solid var(--line); border-radius: 50%; }
.week .is-part .week-mark { border-color: var(--ink); }
.week .is-full .week-mark { border-color: var(--ink); background: var(--ink); color: #fff; }
.week-mark svg { width: 1.05rem; height: 1.05rem; stroke-width: 2.4; }
.week .is-full, .week .is-part { color: var(--ink); }
.unit-next, .cards-due { padding-top: 1.75rem; border-top: 1px solid var(--line); }
.unit-next > * + *, .cards-due > * + * { margin-top: 0.75rem; }
.unit-next .row { margin-top: 1.1rem; }
.unit-next .row .btn { padding: 0 0.8rem; }
.level { margin-left: 0.6rem; font-weight: 400; color: var(--muted); }

/* ── Pfad ── */
.level-group { border-top: 1px solid var(--line); margin-top: 0 !important; }
.level-group:last-child { border-bottom: 1px solid var(--line); }
.level-group summary {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 1rem 0; cursor: pointer; list-style: none;
}
.level-group summary::-webkit-details-marker { display: none; }
.level-name { font: 500 1.5rem/1 var(--serif); }
.unit { padding: 0.25rem 0 1.5rem; }
.unit > * + * { margin-top: 0.4rem; }
.unit .row { margin-top: 0.8rem; }

/* ── Einheit (Gespräch, Aussprache, Karten) ── */
.session { display: flex; flex-direction: column; height: 100dvh; }
.session-head {
    flex: none; display: grid; grid-template-columns: 2.75rem 1fr auto; align-items: center; gap: 0.5rem;
    padding: calc(var(--safe-t) + 0.4rem) 1.25rem 0.4rem 0.5rem;
    border-bottom: 1px solid var(--line);
}
.session-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.session-foot {
    flex: none; position: relative;
    padding: 0.875rem 1.25rem calc(var(--safe-b) + 0.875rem);
    border-top: 1px solid var(--line); background: #fff;
}
.log { flex: 1; overflow-y: auto; padding: 1.25rem 1.25rem 3rem; -webkit-overflow-scrolling: touch; }
.turn + .turn { margin-top: 1.75rem; }
.turn > * + * { margin-top: 0.5rem; }
.turn-tutor > .it { font-size: 1.4rem; line-height: 1.32; }
.turn-tools { display: flex; align-items: center; gap: 0.5rem; margin-left: -0.6rem; }
.turn-user { margin-left: 1.5rem; padding-left: 1rem; border-left: 2px solid var(--accent); }
.turn-user .it { font-size: 1.15rem; }
.fix { margin-top: 0.875rem; }
.fix > * + * { margin-top: 0.15rem; }
.fix-said { color: var(--muted); text-decoration: line-through; }
.over-note { text-align: center; margin-bottom: 0.75rem; }
.over-note .link { color: var(--ink); font-weight: 600; }
.type-toggle { position: absolute; right: 0.75rem; top: 0.875rem; color: var(--muted); }
.type-form { margin-top: 0.875rem; display: grid; gap: 0.5rem; }
.type-form .row { flex-wrap: nowrap; }

.words { font-size: 1.15rem; }
/* Aussprache: schwach = rot und unterstrichen, unsicher = gepunktet unterstrichen (ohne Farbe). */
.w-weak { color: var(--warn); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
.w-mid { text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
.w-miss { color: var(--muted); text-decoration: line-through; }

/* Aufnahmeknopf: der Ring wächst mit der Lautstärke. */
.rec-wrap { display: grid; justify-items: center; gap: 0.5rem; }
.rec {
    position: relative; width: 4.75rem; height: 4.75rem; padding: 0;
    border: 0; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer;
    transition: background-color 150ms var(--ease-out), transform 140ms var(--ease-out);
}
.rec:active:not(:disabled) { transform: scale(0.96); }
/* Aufnahme läuft: der Knopf kehrt sich um (weiss mit schwarzem Rand). */
.rec.is-on { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2.5px var(--ink); }
.rec:disabled { background: var(--line); cursor: default; }
.rec-ring {
    position: absolute; inset: 0; border-radius: 50%; background: var(--ink); opacity: 0;
    transition: transform 90ms linear;
}
.rec.is-on .rec-ring { opacity: 0.12; }
.rec-icon { position: relative; display: grid; place-items: center; height: 100%; }
.rec-icon svg { width: 1.9rem; height: 1.9rem; }
.rec-label { color: var(--muted); font-size: 0.9375rem; min-height: 1.45em; font-variant-numeric: tabular-nums; }

/* ── Aussprache ── */
.speak-body { flex: 1; overflow-y: auto; padding: 2.5rem 1.25rem 2rem; text-align: center; }
.speak-body > * + * { margin-top: 1rem; }
.speak-it { font-size: 1.9rem; line-height: 1.25; text-wrap: balance; }
.speak-result { margin-top: 2rem !important; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.speak-result:empty { display: none; }
.speak-result > * + * { margin-top: 1rem; }
.speak-result .words { font-size: 1.4rem; }
.scores { display: flex; justify-content: center; gap: 2rem; }
.scores dt { font-size: 0.8125rem; color: var(--muted); }
.scores dd { font: 500 2rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
/* Fuss der Ausspracherunde: ein Knopf in der Mitte, darunter der andere Weg als kleine Zeile. */
.next-wrap { display: grid; place-items: center; min-height: 6.7rem; }
.next-big { min-height: 3.5rem; min-width: 11rem; font-size: 1.125rem; }
.foot-alt { display: block; margin: 0.5rem auto 0; font-size: 0.875rem; }

/* ── Karten ── */
.review-body { flex: 1; display: grid; align-content: center; justify-items: center; gap: 1.5rem; padding: 2rem 1.25rem; text-align: center; }
.review-de { font-size: 1.5rem; line-height: 1.3; text-wrap: balance; }
.review-answer { display: grid; justify-items: center; gap: 0.25rem; }
.review-it { font-size: 2rem; line-height: 1.25; text-wrap: balance; }
.review-foot { display: flex; gap: 0.5rem; }
.review-foot .btn { flex: 1; padding: 0 0.5rem; }
.card-form { display: grid; gap: 0.875rem; padding: 1.25rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.card-form .btn { justify-self: start; }
.card-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.card-list .it { font-size: 1.15rem; }
.card-meta { display: grid; justify-items: end; gap: 0.15rem; flex: none; }

.summary { padding-top: calc(var(--safe-t) + 3rem); }

/* ── Hinweis ── */
#toast-root { position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 3.75rem); z-index: 20; display: grid; justify-items: center; pointer-events: none; padding: 0 1.25rem; }
.toast {
    max-width: 30rem; padding: 0.7rem 1rem; background: var(--ink); color: #fff; border-radius: 0.5rem; font-size: 0.9375rem;
    transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
    @starting-style { opacity: 0; transform: translateY(-0.4rem); }
}


/* ── Statistik ── */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 400; font-size: 0.8125rem; color: var(--muted); padding: 0 0 0.4rem; }
.table td { padding: 0.55rem 0; border-top: 1px solid var(--line); vertical-align: baseline; }
.table .n { text-align: right; padding-left: 0.75rem; white-space: nowrap; }
.table .it { font-size: 1.15rem; }
.word-btn { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.fix-list > li { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.fix-list > li > * + * { margin-top: 0.15rem; }

/* ── Hörverstehen ── */
.listen-body { flex: 1; overflow-y: auto; padding: 2rem 1.25rem; -webkit-overflow-scrolling: touch; }
.listen-body > * + * { margin-top: 1rem; }
.listen-q { font-size: 1.6rem; line-height: 1.28; }
.listen-text .it { font-size: 1.2rem; line-height: 1.45; }
.listen-text > p + p { margin-top: 0.4rem; }
.speaker { font-weight: 600; font-size: 0.9375rem; }
.listen-result { margin-top: 2rem !important; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.listen-result:empty { display: none; }
.listen-result > * + * { margin-top: 0.6rem; }
.listen-result .icon-btn { vertical-align: middle; }

/* ── Bewegung ──
   Die Welle ist das eine bewegte Zeichen der App: Sie lädt, sie zeigt, dass der
   Tutor nachdenkt, und sie läuft in der Kopfzeile, solange vorgelesen wird.
   Alles andere bewegt sich nur als Antwort auf eine Handlung. */
.wave { display: inline-flex; align-items: center; gap: 3px; height: 1.5rem; vertical-align: middle; }
.wave i {
    width: 3px; height: 100%; border-radius: 2px; background: currentColor;
    transform: scaleY(0.22);
    animation: wave 520ms var(--ease-in-out) infinite alternate;
}
.wave i:nth-child(1) { animation-delay: -900ms; }
.wave i:nth-child(2) { animation-delay: -480ms; }
.wave i:nth-child(3) { animation-delay: -120ms; }
.wave i:nth-child(4) { animation-delay: -660ms; }
.wave i:nth-child(5) { animation-delay: -300ms; }
@keyframes wave { to { transform: scaleY(1); } }

.loader { display: grid; place-items: center; min-height: 100dvh; color: var(--accent); }
body:not(.in-session) .loader { min-height: 50dvh; }
.loader .wave { height: 2.75rem; gap: 5px; }
.loader .wave i { width: 5px; border-radius: 3px; }

.thinking { margin-top: 1.75rem; color: var(--accent); }

/* Kopfzeile: Welle nur, solange vorgelesen wird. */
.head-side { display: inline-flex; align-items: center; gap: 0.6rem; }
.wave-speaking { height: 1rem; gap: 2px; color: var(--accent); opacity: 0; transition: opacity 180ms var(--ease-out); }
.wave-speaking i { width: 2px; animation-play-state: paused; }
.is-speaking .wave-speaking { opacity: 1; }
.is-speaking .wave-speaking i { animation-play-state: running; }

/* Neue Beiträge im Gespräch, Ergebnisse und Aufgedecktes erscheinen weich. */
.turn, .speak-result > *, .listen-result > *, .review-answer, .log .de, .listen-body .de, .listen-text {
    transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
    @starting-style { opacity: 0; transform: translateY(0.5rem); }
}
.turn-user + .turn-tutor { transition-delay: 70ms; }

/* Tagesziel füllt sich beim Öffnen. */
.meter span { transform-origin: left; animation: meter-in 300ms var(--ease-out) both; }
@keyframes meter-in { from { transform: scaleX(0); } }

/* Abschluss: Kreis und Haken zeichnen sich. Nur bei geschafften Einheiten. */
.done-mark svg { width: 3.5rem; height: 3.5rem; stroke: var(--accent); stroke-width: 2.5; display: block; }
.done-mark circle, .done-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 420ms var(--ease-out) 120ms forwards; }
.done-mark path { animation-duration: 300ms; animation-delay: 420ms; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Übergänge zwischen Ansichten (View Transitions, ausgelöst über swap()). */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: var(--ease-out); }
::view-transition-image-pair(root) { isolation: auto; }
/* Einheit öffnen: fährt von unten über die Übersicht. Schliessen: denselben Weg zurück. */
html[data-nav="open"]::view-transition-old(root) { animation: none; mix-blend-mode: normal; }
html[data-nav="open"]::view-transition-new(root) { animation: sheet-in 340ms var(--ease-drawer) both; mix-blend-mode: normal; }
html[data-nav="close"]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html[data-nav="close"]::view-transition-old(root) { animation: sheet-out 260ms var(--ease-drawer) both; mix-blend-mode: normal; z-index: 1; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
/* Nächster Satz, nächste Frage, nächste Karte: kommt von rechts, die alte geht nach links. */
html[data-nav="step"] .step-body { view-transition-name: step; }
html[data-nav="step"]::view-transition-old(root), html[data-nav="step"]::view-transition-new(root) { animation: none; }
::view-transition-old(step) { animation: step-out 160ms var(--ease-out) both; }
::view-transition-new(step) { animation: step-in 240ms var(--ease-out) both; }
@keyframes step-out { to { opacity: 0; transform: translateX(-1.5rem); } }
@keyframes step-in { from { opacity: 0; transform: translateX(1.5rem); } }

/* Reduzierte Bewegung: nichts verschiebt sich mehr, Zustände blenden nur noch. */
@media (prefers-reduced-motion: reduce) {
    *, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { transition-duration: 1ms !important; animation: none !important; }
    .rec-ring { display: none; }
    .wave i { animation: wave-fade 900ms ease-in-out infinite alternate !important; transform: scaleY(0.6); }
    .wave-speaking i { animation-play-state: paused !important; }
    .is-speaking .wave-speaking i { animation-play-state: running !important; }
    .done-mark circle, .done-mark path { stroke-dashoffset: 0; }
}
@keyframes wave-fade { from { opacity: 0.3; } }

/* ── Belohnungen und Meilensteine ── */
.rewards:empty { display: none; }
.rewards { padding: 0.875rem 1rem; border: 1.5px solid var(--accent); border-radius: 0.5rem; }
.rewards > * + * { margin-top: 0.4rem; }
.reward strong { font-weight: 650; }
.reward { transition: opacity 220ms var(--ease-out); @starting-style { opacity: 0; } }
.milestones li { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
