/* Russisch lernen – mobile-first, hell/dunkel, Systemschrift */

:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --ink: #1e1c19;
  --ink-2: #57524b;
  --ink-3: #6b665c;
  --line: #ddd6c8;
  --accent: #1f6a55;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe4;
  --stress: #a83d27;
  --ok: #28713f;
  --ok-soft: #dff0e3;
  --bad: #b23a2e;
  --bad-soft: #f8e1dd;
  --warn: #8a5a00;
  --warn-soft: #f6ead0;
  --bs: #2f5a9e;
  --bs-soft: #e1e9f6;
  --shadow: 0 1px 2px rgb(30 28 25 / 0.06), 0 2px 8px rgb(30 28 25 / 0.04);
  --r: 14px;
  --r-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --tabs-h: 62px;
  --t: 0.15s ease;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #151716;
    --surface: #1d201f;
    --surface-2: #262a28;
    --ink: #ecebe6;
    --ink-2: #b2afa6;
    --ink-3: #9a978d;
    --line: #333836;
    --accent: #5fbf9f;
    --accent-ink: #0e1a16;
    --accent-soft: #1f3a31;
    --stress: #f08a6e;
    --ok: #6cc58a;
    --ok-soft: #1c3424;
    --bad: #f07c6e;
    --bad-soft: #3d2220;
    --warn: #e2b25a;
    --warn-soft: #3a2f1a;
    --bs: #8fb3ef;
    --bs-soft: #1f2b40;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #151716;
  --surface: #1d201f;
  --surface-2: #262a28;
  --ink: #ecebe6;
  --ink-2: #b2afa6;
  --ink-3: #9a978d;
  --line: #333836;
  --accent: #5fbf9f;
  --accent-ink: #0e1a16;
  --accent-soft: #1f3a31;
  --stress: #f08a6e;
  --ok: #6cc58a;
  --ok-soft: #1c3424;
  --bad: #f07c6e;
  --bad-soft: #3d2220;
  --warn: #e2b25a;
  --warn-soft: #3a2f1a;
  --bs: #8fb3ef;
  --bs-soft: #1f2b40;
  --shadow: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-wrap: break-word;
}
a {
  color: var(--accent);
}
h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 1.7rem;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 1rem;
}
p {
  margin: 0 0 0.7em;
}
code {
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted {
  color: var(--ink-2);
}
.small {
  font-size: 0.86rem;
}
.center {
  text-align: center;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 0.3em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ic {
  width: 22px;
  height: 22px;
  flex: none;
}

/* ---------- Gerüst ---------- */

.app {
  max-width: 640px;
  margin: 0 auto;
}
.view {
  outline: none;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}
body.is-session .view {
  padding-bottom: 0;
}
.page {
  padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
}
.page.center {
  text-align: center;
  padding-top: 20vh;
}
.page-head {
  margin: 8px 0 24px;
}
.page-head > .muted {
  margin-bottom: 0;
}

.boot {
  min-height: 80dvh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--ink-2);
}
.boot-mark {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--accent);
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabs[hidden] {
  display: none;
}
.tab {
  flex: 1;
  max-width: 128px;
  height: var(--tabs-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color var(--t);
}
.tab:focus-visible {
  outline-offset: -4px;
  border-radius: var(--r-s);
}
.tab.active {
  color: var(--accent);
  font-weight: 700;
}
.tab .ic {
  width: 24px;
  height: 24px;
}

/* ---------- Karten & Knöpfe ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin: 0 0 12px;
  box-shadow: var(--shadow);
}
.card > :last-child {
  margin-bottom: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--r-s);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--t), border-color var(--t), color var(--t), transform 0.05s;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.ghost {
  background: transparent;
}
.btn.big {
  min-height: 52px;
  font-size: 1.02rem;
}
.btn.block {
  display: flex;
  width: 100%;
}
.btn.small {
  position: relative;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.86rem;
}
/* sichtbar kompakt, Tippfläche trotzdem 44 px */
.btn.small::after {
  content: '';
  position: absolute;
  inset: -4px 0;
}
.btn.danger {
  color: var(--bad);
  border-color: var(--bad);
  background: transparent;
}
.btn small {
  font-weight: 400;
  opacity: 0.8;
}
.btn .ic {
  width: 20px;
  height: 20px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color var(--t);
}
@media (hover: hover) {
  .btn:hover:not(:disabled) {
    background: var(--surface-2);
  }
  .btn.primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--accent) 86%, var(--ink));
    border-color: color-mix(in srgb, var(--accent) 86%, var(--ink));
  }
  .btn.danger:hover:not(:disabled) {
    background: var(--bad-soft);
  }
  .icon-btn:hover {
    background: var(--surface-2);
  }
}

.chip {
  display: inline-block;
  font-size: 0.78rem;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-2);
  margin: 0 4px 4px 0;
}
.chip-accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.chips {
  margin: 6px 0;
}

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 8px 0 6px;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.bar-thin {
  height: 5px;
  margin: 6px 0 2px;
}

/* Hinweise */
.note {
  border-radius: var(--r-s);
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 0.95rem;
  border: 1px solid transparent;
}
.note > strong:first-child {
  display: block;
  margin-bottom: 2px;
}
.note p:last-child {
  margin-bottom: 0;
}
.note-bs {
  background: var(--bs-soft);
  border-color: color-mix(in srgb, var(--bs) 25%, transparent);
}
.note-bs > strong:first-child {
  color: var(--bs);
}
.note-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}
.note-warn > strong:first-child {
  color: var(--warn);
}
.note-tip,
.note-info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}
.note-tip > strong:first-child,
.note-info > strong:first-child {
  color: var(--accent);
}
.card.note {
  box-shadow: none;
}
.install {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Bosnisch-Hinweis an Wörtern */
.bs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  border-radius: var(--r-s);
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 0.93rem;
  background: var(--bs-soft);
}
.bs-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs);
}
.bs-word {
  font-weight: 600;
}
.bs-note {
  flex-basis: 100%;
  color: var(--ink-2);
}
.bs-false {
  background: var(--bad-soft);
}
.bs-false .bs-tag {
  color: var(--bad);
}
.bs-similar {
  background: var(--warn-soft);
}
.bs-similar .bs-tag {
  color: var(--warn);
}
.bs-mini {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bs-soft);
  color: var(--bs);
  flex: none;
}
.bs-mini.bs-false {
  background: var(--bad-soft);
  color: var(--bad);
}
.bs-mini.bs-similar {
  background: var(--warn-soft);
  color: var(--warn);
}

.check-badge {
  font-size: 0.8rem;
  color: var(--warn);
  margin-top: 8px;
}

/* Russisch */
.ru {
  font-feature-settings: 'kern';
}
.st {
  color: var(--stress);
}
.lat {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.95em;
  letter-spacing: 0.01em;
}

.say {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: 6px;
  vertical-align: middle;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  flex: none;
}
.say .ic {
  width: 19px;
  height: 19px;
}
/* Tippfläche auf mind. 44 px erweitern, ohne den Kreis grösser zu zeichnen */
.say::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
}
@media (hover: hover) {
  .say:hover {
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  }
}
.say.playing {
  background: var(--accent);
  color: var(--accent-ink);
}
.say-inline {
  border: 0;
  background: none;
  padding: 0 1px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  border-bottom: 1.5px dotted var(--accent);
  cursor: pointer;
}
.say-inline.playing {
  color: var(--accent);
}

/* ---------- Startseite ---------- */

.hello {
  margin: 6px 0 14px;
}
.hello-ru {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
}
.hello .muted {
  margin: 0;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow);
}
.kpi b {
  font-size: 1.45rem;
  line-height: 1.1;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.kpi b small {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-3);
}
.kpi > span:last-child {
  font-size: 0.78rem;
  color: var(--ink-2);
}
.kpi-ic {
  color: var(--accent);
  height: 22px;
}
.kpi-ic .ic {
  width: 18px;
  height: 18px;
}
.goal {
  margin: 8px 0 16px;
}
.goal .bar {
  margin: 0;
}
.plan-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 12px;
}
.plan-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
}
.plan-n {
  font-weight: 700;
  font-size: 1.3rem;
  min-width: 2.2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.plan-done h2 {
  color: var(--accent);
}

/* ---------- Kurs ---------- */

.phase {
  margin-bottom: 22px;
}
.mods {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mod {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--t);
}
@media (hover: hover) {
  a.mod:hover {
    border-color: var(--ink-3);
  }
  a.mod.mod-focus:hover {
    border-color: var(--accent);
  }
}
.mod-ic {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 0.9rem;
}
.mod-ic .ic {
  width: 18px;
  height: 18px;
}
.mod-done .mod-ic {
  background: var(--accent);
  color: var(--accent-ink);
}
.mod-focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent), var(--shadow);
}
/* Gesperrt: zurückgenommen, aber gut lesbar (Schloss-Symbol trägt die Bedeutung) */
.mod-locked,
.mod-later {
  background: transparent;
  box-shadow: none;
}
.mod-locked .mod-title,
.mod-later .mod-title {
  color: var(--ink-2);
}
.mod-locked .mod-ic,
.mod-later .mod-ic {
  background: transparent;
  border: 1px solid var(--line);
}
.mod-txt {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.mod-title {
  font-weight: 600;
}
.mod-sub {
  font-size: 0.84rem;
  color: var(--ink-2);
}

/* ---------- Modul ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding-right: 8px;
  text-decoration: none;
  font-weight: 600;
  margin: -8px 0 0 -6px;
}
.back .ic {
  width: 20px;
  height: 20px;
}
.sec {
  margin: 32px 0;
}
.sec.intro {
  margin-top: 24px;
}
.sec > h2 {
  margin-bottom: 12px;
}
.blk {
  margin: 16px 0;
}
.blk > h3 {
  margin-bottom: 8px;
}
.blk-text h3 {
  margin-top: 24px;
}
.blk-text:first-child h3 {
  margin-top: 0;
}
.blk-text p {
  font-size: 1rem;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.93rem;
  line-height: 1.4;
}
th,
td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.84rem;
  vertical-align: bottom;
}
tr:last-child td {
  border-bottom: 0;
}
/* Erste Spalte bleibt beim seitlichen Scrollen stehen */
th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: inset -1px 0 var(--line);
}
th:first-child {
  background: var(--surface-2);
}
@media (max-width: 559px) {
  table {
    font-size: 0.875rem;
  }
  th,
  td {
    padding: 8px;
  }
  th:first-child,
  td:first-child {
    padding-left: 12px;
  }
  /* Breite Tabellen: Erklärspalte nicht auf ein Wort pro Zeile zusammendrücken */
  td:nth-child(4):last-child {
    min-width: 9.5em;
  }
}
.letters {
  display: grid;
  gap: 12px;
}
.letters .card {
  margin: 0;
}
.letter-card .l-letter {
  font-size: 2.6rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 6px;
}
.vlist {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
}
.vitem + .vitem {
  border-top: 1px solid var(--line);
}
.vitem summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--t);
}
.vitem summary::-webkit-details-marker {
  display: none;
}
/* Pfeil zeigt: aufklappbar */
.vitem summary::after {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  margin: -4px 2px 0 0;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform var(--t);
}
.vitem details[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}
.vitem summary:focus-visible {
  outline-offset: -2px;
}
@media (hover: hover) {
  .vitem summary:hover {
    background: color-mix(in srgb, var(--surface-2) 50%, transparent);
  }
}
.v-ru {
  font-weight: 600;
  font-size: 1.05rem;
}
.v-ru {
  min-width: 0;
}
.v-de {
  flex: 1;
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: right;
  min-width: 0;
}
.v-more {
  padding: 0 16px 16px;
}
.v-more .chips:empty {
  display: none;
}
.v-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.v-line .say {
  margin-left: 0;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
  background: var(--line);
}
.dot-lernend {
  background: var(--warn);
}
.dot-gelernt {
  background: var(--accent);
  opacity: 0.6;
}
.dot-gefestigt {
  background: var(--accent);
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 32px;
}
.pager .btn {
  font-weight: 500;
  font-size: 0.88rem;
  min-width: 0;
  text-align: left;
}
.pager .btn:last-child:not(:first-child) {
  text-align: right;
}

/* ---------- Alphabet ---------- */

.abc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.abc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.abc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.abc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 8px 2px 6px;
  border-radius: var(--r-s);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  border-bottom-width: 3px;
  transition: border-color var(--t), background-color var(--t);
}
@media (hover: hover) {
  button.abc-tile:hover {
    background: var(--surface-2);
  }
}
.abc-tile.sel {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.abc-l {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.abc-t {
  font-size: 0.75rem;
  color: var(--ink-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.abc-tile.lvl-lernend {
  border-bottom-color: var(--warn);
}
.abc-tile.lvl-gelernt {
  border-bottom-color: color-mix(in srgb, var(--accent) 60%, transparent);
}
.abc-tile.lvl-gefestigt {
  border-bottom-color: var(--accent);
}
.abc-missing {
  opacity: 0.4;
}
.abc-detail {
  position: relative;
  scroll-margin-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
.abc-close {
  position: absolute;
  top: 4px;
  right: 4px;
}

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

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: var(--shadow);
}
.tile b {
  font-size: 1.7rem;
  line-height: 1.1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.tile b small {
  font-size: 0.9rem;
  color: var(--ink-3);
  font-weight: 500;
}
.tile span {
  font-weight: 600;
  font-size: 0.9rem;
}
.tile > small {
  color: var(--ink-2);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 2px;
}
.lvl-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.lvl-badge {
  font-size: 1.4rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--r-s);
  background: var(--accent);
  color: var(--accent-ink);
}
.lvl-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  margin-top: 12px;
}
.lvl-line > span:last-child {
  font-variant-numeric: tabular-nums;
}
.lvl-next {
  margin-bottom: 16px;
}

.tc {
  position: relative;
}
.tc-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.tc-bar {
  fill: var(--accent);
  opacity: 0.55;
}
.tc-bar.tc-goal-met {
  opacity: 1;
}
.tc-col.on .tc-bar {
  opacity: 1;
  stroke: var(--surface);
  stroke-width: 2px;
}
.tc-hit {
  fill: transparent;
}
.tc-col:focus {
  outline: none;
}
.tc-col:focus .tc-hit {
  fill: var(--surface-2);
}
.tc-base {
  stroke: var(--line);
  stroke-width: 1;
}
.tc-goalline {
  stroke: var(--ink-3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.tc-goaltext,
.tc-x {
  fill: var(--ink-3);
  font-size: 11px;
  font-family: var(--font);
}
.tc-tip {
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  max-width: 100%;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 5px 9px;
  border-radius: 7px;
  pointer-events: none;
}
.fc {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}
.fc li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
}
.fc-bar {
  width: min(70%, 32px);
  height: 56px;
  display: flex;
  align-items: flex-end;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.fc-bar span {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 0;
}
.fc-n {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.fc-d {
  color: var(--ink-2);
}
.ph-title {
  margin-top: 16px;
}
.mprog {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mprog li {
  padding: 0 0 8px;
}
.mprog a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.93rem;
}
.mprog a > span:first-child {
  min-width: 0;
}
.mprog a > span:last-child {
  flex: none;
}
.mprog .bar {
  margin: -4px 0 0;
}
@media (hover: hover) {
  .mprog a:hover > span:first-child {
    color: var(--accent);
  }
}

/* ---------- Einstellungen ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}
.field > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.93rem;
}
.field b {
  font-variant-numeric: tabular-nums;
}
select,
input[type='text'] {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  min-height: 44px;
  padding: 8px 12px;
  max-width: 100%;
  transition: border-color var(--t);
}
select {
  width: 100%;
  cursor: pointer;
}
select:focus-visible,
input[type='text']:focus-visible {
  border-color: var(--accent);
}
input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 44px;
  margin: -6px 0;
  cursor: pointer;
}
.switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 4px 0;
  padding: 10px 0;
  font-size: 0.93rem;
  cursor: pointer;
}
.switch input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex: none;
}
.radio-row {
  border: 0;
  padding: 0;
  margin: 16px 0 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
  font-size: 0.92rem;
}
.radio-row legend {
  padding: 0;
  margin-bottom: 0;
  width: 100%;
}
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
.radio-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}
.file-btn {
  position: relative;
  cursor: pointer;
}
.file-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.settings details > summary {
  display: list-item;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.checklist {
  padding-left: 18px;
  font-size: 0.93rem;
}
.checklist li {
  margin: 4px 0;
}
.danger h2 {
  color: var(--bad);
}

/* ---------- Lernrunde ---------- */

body.is-session {
  background: var(--surface);
}
.session {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.s-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 0 6px;
}
.s-bar {
  flex: 1;
}
.s-bar .bar {
  margin: 0;
  height: 7px;
}
.s-count {
  font-size: 0.82rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  min-width: 4.2em;
  text-align: right;
}
.s-title {
  font-size: 0.78rem;
  color: var(--ink-3);
  text-align: center;
  margin: 0;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ex {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ex-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 8px;
}
.ex-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 16px;
}
.ex-prompt {
  margin-bottom: 24px;
}
.ex-prompt:empty {
  display: none;
}
.ex-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
/* Bildschirmtastatur im Daumenbereich, direkt über den Knöpfen */
@media (pointer: coarse) {
  .kb-host {
    margin-top: auto;
  }
}
.ex-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px 16px max(16px, calc(8px + env(safe-area-inset-bottom)));
  background: var(--surface);
  border-top: 1px solid transparent;
}
.ex.answered .ex-foot {
  border-top-color: var(--line);
}
.ex-actions {
  display: flex;
  gap: 8px;
}
.ex-actions .btn {
  flex: 1;
}
.ex-actions .btn.ghost {
  flex: 0 1 auto;
}

.p-letter {
  font-size: 4.6rem;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
  letter-spacing: 0.04em;
  margin: 4px 0 8px;
}
.ex-intro .p-letter {
  text-align: left;
}
.p-ru {
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1.25;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.p-ru-sentence {
  font-size: 1.6rem;
}
.p-latin {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--ink-2);
  font-size: 1rem;
  margin-top: 2px;
}
.p-latin-big {
  font-size: 1.8rem;
  color: var(--ink);
  font-weight: 600;
}
.p-de {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 6px;
}
.p-de-small {
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink-2);
}
.p-hint {
  color: var(--ink-2);
  margin-top: 8px;
}
.p-audio {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0 8px;
}
.say-big,
.say-slow {
  width: auto;
  height: auto;
  margin: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 22px;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 600;
}
.say-big .ic {
  width: 34px;
  height: 34px;
}
.say-slow {
  background: var(--surface-2);
  color: var(--ink-2);
}
.say-slow .ic {
  width: 26px;
  height: 26px;
  margin: 4px 0;
}
.say-big,
.say-slow {
  min-width: 112px;
}
.say-big::after,
.say-slow::after {
  display: none;
}

.l-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 0.95rem;
}
.l-tr {
  flex-basis: 100%;
  color: var(--ink-2);
}
.l-sound {
  margin: 8px 0;
}

.opts {
  display: grid;
  gap: 8px;
}
.opts-grid {
  grid-template-columns: 1fr 1fr;
}
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  min-width: 0;
  padding: 8px 16px 8px 12px;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1.3;
  transition: border-color var(--t), background-color var(--t);
}
.opt-t {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (hover: hover) {
  .opt:hover:not(:disabled) {
    border-color: var(--ink-3);
  }
}
.opt:active:not(:disabled) {
  background: var(--surface-2);
}
.opt .ru {
  font-size: 1.2rem;
}
.opt-n {
  font-size: 0.72rem;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: none;
}
.opt:disabled {
  cursor: default;
}
.opt.is-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.opt.is-bad {
  border-color: var(--bad);
  background: var(--bad-soft);
}
/* Richtig/Falsch nicht nur über Farbe zeigen */
.opt.is-ok::after,
.opt.is-bad::after,
.syl.is-ok::after,
.syl.is-bad::after {
  flex: none;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}
.opt.is-ok::after,
.syl.is-ok::after {
  content: '✓';
  content: '✓' / '';
  color: var(--ok);
}
.opt.is-bad::after,
.syl.is-bad::after {
  content: '✕';
  content: '✕' / '';
  color: var(--bad);
}
.opt:disabled:not(.is-ok):not(.is-bad) {
  opacity: 0.55;
}

.inp-wrap {
  display: flex;
}
.inp {
  flex: 1;
  min-width: 0;
  font-size: 1.5rem !important;
  min-height: 56px !important;
  padding: 8px 16px !important;
  border-width: 1.5px !important;
}
.inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  outline: none;
}
.inp[readonly] {
  box-shadow: none;
}
.inp.is-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.inp.is-bad {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.inp-hint {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-3);
  margin: 8px 2px 8px;
}
.shake {
  animation: shake 0.35s;
}
@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Tastatur */
.kb {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 0;
  margin: 0 -8px;
}
.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.kb-key {
  flex: 1;
  min-width: 0;
  max-width: 48px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--line);
  transition: background-color 0.08s;
}
.kb-key:focus-visible {
  outline-offset: 1px;
}
@media (hover: hover) {
  .kb-key:hover {
    background: color-mix(in srgb, var(--surface-2) 70%, var(--line));
  }
}
.kb-key.down {
  background: var(--accent);
  color: var(--accent-ink);
}
.kb-row-last .kb-key {
  max-width: none;
}
.kb-fn {
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
}
.kb-space {
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.kb.kb-sys .kb-row:not(.kb-row-last) {
  display: none;
}
.kb.kb-sys [data-fn='sys'] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Lückentext */
.cloze {
  font-size: 1.5rem;
  line-height: 1.6;
  font-weight: 500;
}
.gap {
  display: inline-block;
  min-width: 3.5em;
  border-bottom: 2px solid var(--accent);
  text-align: center;
  padding: 0 4px;
  margin: 0 2px;
  color: var(--accent);
}
.gap.is-ok {
  color: var(--ok);
  border-color: var(--ok);
}
.gap.is-bad {
  color: var(--bad);
  border-color: var(--bad);
}

/* Satzbau */
/* Schreiblinien: eine Linie pro Kachelreihe (46 px Kachel + 8 px Abstand) */
.order-line {
  --rule: var(--line);
  min-height: 112px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  margin-bottom: 24px;
  background-image: linear-gradient(to bottom, transparent 52.5px, var(--rule) 52.5px);
  background-size: 100% 54px;
}
.order-line.is-ok {
  --rule: var(--ok);
}
.order-line.is-bad {
  --rule: var(--bad);
}
.order-empty {
  display: flex;
  align-items: center;
  min-height: 46px;
  color: var(--ink-3);
  font-size: 0.9rem;
}
.order-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tok {
  min-height: 46px;
  max-width: 100%;
  padding: 6px 16px;
  border: 1.5px solid var(--line);
  border-bottom-width: 3px;
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 1.2rem;
  line-height: 1.3;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: background-color var(--t), border-color var(--t);
}
@media (hover: hover) {
  .tok:hover:not(:disabled) {
    border-color: var(--ink-3);
  }
}
.tok:active:not(:disabled) {
  transform: translateY(1px);
  border-bottom-width: 2px;
  margin-bottom: 1px;
}
.tok:disabled {
  cursor: default;
}
/* Benutzte Wörter: Platzhalter bleibt sichtbar, damit nichts nachrutscht */
.tok[data-used] {
  background: var(--surface-2);
  border-color: transparent;
}
.tok[data-used] > * {
  visibility: hidden;
}
.tok-end {
  display: flex;
  align-items: center;
  min-height: 46px;
  font-size: 1.2rem;
}

/* Betonung */
.syls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 4px;
  margin: 16px 0 8px;
}
.syls + .inp-hint {
  text-align: center;
}
.syl {
  position: relative;
  min-width: 64px;
  min-height: 64px;
  padding: 6px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--t), background-color var(--t);
}
@media (hover: hover) {
  .syl:hover:not(:disabled) {
    border-color: var(--ink-3);
  }
}
.syl:active:not(:disabled) {
  background: var(--surface-2);
}
.syl:disabled {
  cursor: default;
}
.syl.is-ok::after,
.syl.is-bad::after {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.75rem;
}
.syl.is-ok {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.syl.is-bad {
  border-color: var(--bad);
  background: var(--bad-soft);
}
.syl-sep {
  color: var(--ink-3);
}
.syl:disabled:not(.is-ok):not(.is-bad) {
  opacity: 0.55;
}

/* Karteikarte */
.flash-back {
  border-top: 1px dashed var(--line);
  padding-top: 16px;
  margin-top: 0;
}
.ex-flash .ex-prompt {
  margin-bottom: 16px;
}
.grade-q {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-2);
  margin: 0 0 8px;
  width: 100%;
}
.ex-flash .ex-actions {
  flex-direction: column;
}
.grades {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.btn.grade {
  flex-direction: column;
  gap: 0;
  padding: 8px 4px;
  min-height: 56px;
  min-width: 0;
  border-color: transparent;
}
.btn.grade b {
  font-size: 0.95rem;
}
.btn.grade small {
  font-size: 0.7rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
/* Bewertung: Wort + Ton, von «Nochmal» (rot) bis «Leicht» (grün) */
.g-1 {
  color: var(--bad);
  background: var(--bad-soft);
}
.g-3 {
  color: var(--warn);
  background: var(--warn-soft);
}
.g-4 {
  color: var(--ok);
  background: var(--ok-soft);
}
.g-5 {
  color: var(--accent);
  background: var(--accent-soft);
}
@media (hover: hover) {
  .btn.grade:hover {
    border-color: currentColor;
  }
  .btn.grade.g-1:hover {
    background: var(--bad-soft);
  }
  .btn.grade.g-3:hover {
    background: var(--warn-soft);
  }
  .btn.grade.g-4:hover {
    background: var(--ok-soft);
  }
  .btn.grade.g-5:hover {
    background: var(--accent-soft);
  }
}
/* Tastenkürzel-Ziffern nur dort zeigen, wo es eine Tastatur gibt */
@media (hover: none) and (pointer: coarse) {
  .opt-n,
  .btn.grade small {
    display: none;
  }
  .opt {
    padding-left: 16px;
  }
}

/* Rückmeldung */
.fb {
  max-height: 52dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r);
  padding: 12px 16px 16px;
  margin-bottom: 12px;
}
.fb > :last-child {
  margin-bottom: 0;
}
.fb-ok {
  background: var(--ok-soft);
}
.fb-typo {
  background: var(--warn-soft);
}
.fb-bad {
  background: var(--bad-soft);
}
.fb-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.fb-title .ic {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}
.fb-ok .fb-title {
  color: var(--ok);
}
.fb-typo .fb-title {
  color: var(--warn);
}
.fb-bad .fb-title {
  color: var(--bad);
}
.fb-given,
.fb-answer {
  font-size: 0.92rem;
  margin: 0 0 8px;
}
.fb-bad .fb-given > span {
  text-decoration: line-through;
  text-decoration-color: var(--bad);
}
.fb-ru {
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.fb-latin {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.fb-de {
  margin-top: 2px;
}
.fb-note {
  font-size: 0.92rem;
  color: var(--ink-2);
  margin-top: 8px;
}
.fb .bs {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.fb-ex {
  margin-top: 8px;
  font-size: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.fb-ex > span:last-child {
  flex-basis: 100%;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.fb-ex .say {
  width: 30px;
  height: 30px;
}
.fb-ex .say::after,
.ex-ru .say::after {
  inset: -7px;
}

/* Beispiele */
.examples {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}
.examples li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.examples li:first-child {
  border-top: 0;
}
.ex-ru {
  font-size: 1.15rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.ex-ru .say {
  width: 30px;
  height: 30px;
}
.ex-lat {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.ex-de {
  color: var(--ink-2);
  font-size: 0.93rem;
}

/* Ende der Runde */
.s-done {
  flex: 1;
  padding: 40px 16px max(24px, calc(16px + env(safe-area-inset-bottom)));
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
}
.s-done h1,
.s-done p {
  margin: 0;
}
.s-done p {
  max-width: 34em;
  margin: 0 auto;
}
.s-done .row {
  justify-content: center;
}
.s-done .row > .btn {
  flex: 1 1 auto;
}
.s-done-mark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.s-done-mark .ic {
  width: 38px;
  height: 38px;
}
.done-stats {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: flex;
  justify-content: center;
  gap: 24px;
}
.done-stats b {
  font-variant-numeric: tabular-nums;
}
.done-stats li {
  display: flex;
  flex-direction: column;
}
.done-stats b {
  font-size: 1.5rem;
}
.done-stats span {
  font-size: 0.8rem;
  color: var(--ink-2);
}

/* Toast */
.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 50;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 14px;
  border-radius: var(--r-s);
  font-size: 0.92rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.toast[hidden] {
  display: none;
}
.toast .btn {
  flex: none;
}
body.is-session .toast {
  bottom: calc(env(safe-area-inset-bottom) + 90px);
}

@media (max-width: 559px) {
  /* Knopfreihen in Karten füllen die Breite – ruhiger, grössere Tippflächen */
  .card .row > .btn {
    flex: 1 1 auto;
  }
}

@media (min-width: 560px) {
  .letters {
    grid-template-columns: 1fr 1fr;
  }
  .p-letter {
    font-size: 5.4rem;
  }
}

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