/* Layout: eine schmale Lernspalte, Karteikarte im Zentrum, Tab-Leiste unten für den Daumen */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --fg: #142039;
  --muted: #5a6680;
  --line: #d9e0ec;
  --accent: #1f4aa8;
  --accent-2: #3d6fd6;
  --accent-soft: #e3ebfa;
  --accent-fg: #ffffff;
  --ok: #1d7f53;
  --bad: #b8481a;
  --s0: #8e9ab0;
  --s1: #d9652b;
  --s2: #c99611;
  --s3: #3a7fc2;
  --s4: #1d7f53;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1322; --surface: #161e33; --fg: #e6ebf5; --muted: #9aa5be; --line: #28334f;
    --accent: #7fa3ff; --accent-2: #4f74d1; --accent-soft: #1d2a4c; --accent-fg: #0d1322;
    --ok: #4cc488; --bad: #f08b5c;
    --s0: #7c889f; --s1: #f08b5c; --s2: #e5bd47; --s3: #6eaae3; --s4: #4cc488;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1322; --surface: #161e33; --fg: #e6ebf5; --muted: #9aa5be; --line: #28334f;
  --accent: #7fa3ff; --accent-2: #4f74d1; --accent-soft: #1d2a4c; --accent-fg: #0d1322;
  --ok: #4cc488; --bad: #f08b5c;
  --s0: #7c889f; --s1: #f08b5c; --s2: #e5bd47; --s3: #6eaae3; --s4: #4cc488;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 calc(84px + env(safe-area-inset-bottom, 0px));
}
.app { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
h1, h2 { font-family: var(--font-display); text-wrap: balance; margin: 0; }

header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 18px; }
header.top h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
header.top h1 span { color: var(--accent); font-weight: 500; }
.sync { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; text-align: right; }

section { display: flex; flex-direction: column; gap: 16px; }

/* Lernstand */
.verteilung { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line); }
.verteilung i { display: block; height: 100%; }
.stufen { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.stufen::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 0.88rem; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 12px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip b { font-weight: 600; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.c0 { background: var(--s0); } .c1 { background: var(--s1); } .c2 { background: var(--s2); }
.c3 { background: var(--s3); } .c4 { background: var(--s4); } .cA { background: var(--accent); }

/* Karteikarte */
.karte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.band {
  height: 14px;
  background-color: var(--accent);
  background-image:
    radial-gradient(circle, var(--surface) 0 1.6px, transparent 2px),
    conic-gradient(from 45deg, var(--accent) 25%, var(--accent-2) 0 50%, var(--accent) 0 75%, var(--accent-2) 0);
  background-size: 14px 14px;
}
.karte-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.de { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.15; margin: 6px 0 0; overflow-wrap: anywhere; }
.satz { margin: 0; color: var(--muted); font-size: 1.05rem; }
.loesung { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; animation: auf 0.18s ease-out; }
.label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pt { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pt li { background: var(--accent-soft); color: var(--fg); font-weight: 600; font-size: 1.1rem; padding: 4px 12px; border-radius: 8px; }
.pt-satz { color: var(--fg); }
.notiz { margin: 0; font-size: 0.92rem; color: var(--muted); }
.art { display: inline-block; font-style: normal; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px; margin-right: 4px; vertical-align: 2px; }
details.zweites { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 14px; }
details.zweites summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
details.zweites[open] summary { margin-bottom: 12px; }
details.zweites .inhalt { display: flex; flex-direction: column; gap: 12px; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Fragen an Claude */
.chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-kopf { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-kopf h3 { margin: 0; font-family: var(--font-display); font-size: 1.05rem; min-width: 0; overflow-wrap: anywhere; }
.verlauf { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.msg { padding: 8px 12px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem; }
.msg.ich { align-self: flex-end; background: var(--accent); color: var(--accent-fg); }
.msg.claude { align-self: flex-start; background: var(--accent-soft); color: var(--fg); }
.msg.fehler { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.denkt { color: var(--muted); font-style: italic; }
.chat-eingabe { display: grid; grid-template-columns: 1fr; grid-auto-flow: column; grid-auto-columns: auto; gap: 8px; align-items: end; }
.chat-eingabe .btn { min-height: 44px; }
.btn.mic { width: 44px; padding: 0; }
.btn.mic svg { width: 20px; height: 20px; }
.btn.mic.an { background: var(--bad); color: var(--surface); border-color: var(--bad); animation: puls 1.2s ease-in-out infinite; }
@keyframes puls { 50% { opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .btn.mic.an { animation: none; } }
.knopfzeile { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
@keyframes auf { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  font: inherit; font-weight: 600; font-size: 1rem; min-height: 52px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.voll { grid-column: 1 / -1; }
.btn.primaer { background: var(--accent); color: var(--accent-fg); }
.btn.gut { background: var(--ok); color: var(--surface); }
.btn.schlecht { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.leise { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn.gefahr { background: var(--bad); color: var(--surface); }
.textlink { font: inherit; font-size: 0.9rem; color: var(--muted); background: none; border: 0; padding: 6px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; align-self: center; }
.tasten { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 0; }
@media (hover: none) { .tasten { display: none; } }

.leer { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 22px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.leer h2 { font-size: 1.3rem; }
.leer p { margin: 0; color: var(--muted); max-width: 40ch; }
.zahlen { display: flex; gap: 22px; font-variant-numeric: tabular-nums; }
.zahlen div { display: flex; flex-direction: column; }
.zahlen b { font-family: var(--font-display); font-size: 1.6rem; }
.zahlen span { font-size: 0.8rem; color: var(--muted); }

/* Liste */
.werkzeuge { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input, textarea, select {
  font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 64px; }
select { width: auto; }
.info { margin: 0; color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.liste { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.liste li + li { border-top: 1px solid var(--line); }
.zeile { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; }
.zeile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.zeile .w { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.zeile .p { grid-column: 1; color: var(--accent); font-size: 0.92rem; min-width: 0; overflow-wrap: anywhere; }
.zeile .s { grid-column: 1; color: var(--muted); font-size: 0.85rem; min-width: 0; }
.zeile .dot { grid-row: 1; grid-column: 2; margin-top: 7px; }

/* Formular */
form { display: flex; flex-direction: column; gap: 14px; }
.feld { display: flex; flex-direction: column; gap: 6px; }
.feld label { font-size: 0.88rem; font-weight: 600; }
.feld small { color: var(--muted); font-size: 0.8rem; }
.hinweis { margin: 0; font-size: 0.88rem; color: var(--muted); }
.warnung { margin: 0; font-size: 0.88rem; color: var(--bad); }
.vorschlaege { display: flex; flex-direction: column; gap: 10px; }
.vorschlag { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.vorschlag .b { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.vorschlag p { margin: 0; }
.vorschlag .p { color: var(--accent); font-weight: 600; }
.vorschlag .btn { min-height: 40px; font-size: 0.9rem; align-self: flex-start; }
.reihe { display: flex; flex-wrap: wrap; gap: 10px; }
.reihe .btn { flex: 1 1 140px; }
.loeschen { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.statistik { margin: 0; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Tab-Leiste */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
nav.tabs div { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
nav.tabs button { font: inherit; font-size: 0.92rem; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 10px; min-height: 48px; cursor: pointer; }
nav.tabs button[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 6;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 0.92rem;
  max-width: calc(100% - 32px);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .loesung { animation: none; } }

/* Ergänzungen der Web-App */
[hidden] { display: none !important; }
header.top .rechts { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
header.top .rechts .textlink { padding: 0; font-size: 0.85rem; }
.anmeldung { max-width: 420px; margin: 8vh auto 0; width: 100%; }
.anmeldung .karte-body { gap: 14px; }
.anmeldung h2 { font-size: 1.5rem; }
.fehlertext { margin: 0; font-size: 0.9rem; color: var(--bad); }
.konto { display: flex; flex-direction: column; gap: 22px; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.block h3 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; }
.block form { gap: 12px; }
body { margin: 0; }
a.btn { text-decoration: none; color: var(--fg); }
