:root {
  --akzent: #3b4cca;
  --akzent-text: #fff;
  --text: #1c1d24;
  --leise: #5d6070;
  --hintergrund: #f4f5f8;
  --flaeche: #fff;
  --rand: #dfe1e8;
  --student: #e4e7fb;
  --code: #f0f1f5;
  --fehler: #b3261e;
  --gut: #1e7a3c;
  --gut-flaeche: #e3f4e8;
  --falsch-flaeche: #fbe7e5;
  --fast: #9a6200;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --akzent: #8f9cff;
    --akzent-text: #10132e;
    --text: #e8e9ee;
    --leise: #a3a6b4;
    --hintergrund: #14151a;
    --flaeche: #1e2027;
    --rand: #2f323c;
    --student: #2a2f5a;
    --code: #262931;
    --fehler: #ffb4ab;
    --gut: #7bd88f;
    --gut-flaeche: #1d3324;
    --falsch-flaeche: #3d2120;
    --fast: #f0c060;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--hintergrund);
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
a { color: var(--akzent); text-underline-offset: 2px; }
[hidden] { display: none !important; }

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.3rem; margin: .2em 0 .6em; line-height: 1.3; }
h3 { font-size: .8rem; margin: 1.4em 0 .5em; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); }

.klein { font-size: .875rem; color: var(--leise); }
.fehler { color: var(--fehler); }
.meta { margin: 0; font-size: .875rem; color: var(--leise); }

.primaer {
  border: 0;
  border-radius: 999px;
  padding: .65em 1.3em;
  background: var(--akzent);
  color: var(--akzent-text);
  font-weight: 600;
}
.breit { display: block; width: 100%; margin-top: 1rem; }
h3 + .breit { margin-top: 0; }

.sekundaer {
  border: 1px solid var(--akzent);
  border-radius: 999px;
  padding: .6em 1.3em;
  background: none;
  color: var(--akzent);
  font-weight: 600;
}

.link {
  border: 0;
  background: none;
  padding: .25em 0;
  color: var(--akzent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.symbol {
  border: 0;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: .3em .5em;
}

.ansicht {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
}

/* Anmeldung */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}
.login-karte {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-karte img { border-radius: 16px; }
.login-karte h1 { font-size: 1.8rem; margin-top: .5rem; }
.untertitel { margin: .25rem 0 2rem; color: var(--leise); }
.login-karte form { display: grid; gap: .6rem; text-align: left; }
.login-karte label { font-weight: 600; }
.login-karte input {
  padding: .7em .9em;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
}
.login-karte .primaer { margin-top: .4rem; }
.login-karte .klein { margin-top: 2rem; }

/* Startseite */

.kopf {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 56px;
  padding-top: env(safe-area-inset-top);
}
.kopf h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  margin-bottom: 1rem;
  border-radius: 999px;
  background: var(--rand);
}
.tabs button {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: .5em;
  background: none;
  font-weight: 600;
  color: var(--leise);
}
.tabs button[aria-selected="true"] { background: var(--flaeche); color: var(--text); }

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
  margin-bottom: 1rem;
}
.karte > h3:first-child { margin-top: 0; }
.karte ul { padding-left: 1.2em; margin: 0; }
.karte li + li { margin-top: .3em; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: .4em .9em;
  background: var(--flaeche);
  font-size: .9rem;
}
.chip:hover:not(:disabled) { border-color: var(--akzent); }

.themen { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.themen button {
  display: flex;
  align-items: center;
  gap: .9rem;
  width: 100%;
  padding: .8rem 1rem;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  text-align: left;
}
.themen .nr {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--student);
  font-weight: 700;
}
.themen .text { display: grid; }

.fuss { text-align: center; padding: 1rem 0; }

/* Chat */

.chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: 0;
}
.chat .kopf { flex: none; }
.chat #aufgaben {
  flex: none;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: .6rem;
  scrollbar-width: none;
}
.chat #aufgaben .chip { white-space: nowrap; }

.verlauf {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: .5rem 0 1rem;
}
.leer { color: var(--leise); text-align: center; margin: auto 0; }

.blase {
  max-width: 92%;
  padding: .6rem .9rem;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.blase.student {
  align-self: flex-end;
  background: var(--student);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.blase.tutor {
  align-self: flex-start;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-bottom-left-radius: 4px;
  width: 92%;
}
.blase > :first-child { margin-top: 0; }
.blase > :last-child { margin-bottom: 0; }
.blase p, .blase ul, .blase ol { margin: .5em 0; }
.blase ul, .blase ol { padding-left: 1.4em; }
.blase h3, .blase h4, .blase h5, .blase h6 {
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  color: inherit;
  margin: .9em 0 .3em;
}
.blase hr { border: 0; border-top: 1px solid var(--rand); margin: 1em 0; }
.blase code {
  font: .9em/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code);
  padding: .1em .3em;
  border-radius: 4px;
}

.code { margin: .7em 0; border-radius: 10px; background: var(--code); overflow: hidden; }
.code-kopf {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem .7rem;
  font-size: .75rem;
  color: var(--leise);
  border-bottom: 1px solid var(--rand);
}
.kopieren { border: 0; background: none; font-size: .75rem; color: var(--akzent); padding: .2em 0; }
.code pre { margin: 0; padding: .7rem; overflow-x: auto; }
.code code { background: none; padding: 0; }

.tabelle { overflow-x: auto; margin: .7em 0; }
.tabelle table { border-collapse: collapse; font-size: .9rem; }
.tabelle th, .tabelle td { border: 1px solid var(--rand); padding: .3em .6em; text-align: left; }

/* Interaktive Aufgaben (aufgaben.js) */

.aufgabe {
  margin: .7em 0;
  padding: .8rem .9rem;
  border: 1px solid var(--rand);
  border-radius: 12px;
  background: var(--hintergrund);
}
.aufgabe .frage { margin-top: 0; font-weight: 600; }

.optionen { display: grid; gap: .4rem; margin: .6rem 0; }
.option {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .5rem .7rem;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
  cursor: pointer;
}
.option:has(input:checked) { border-color: var(--akzent); }
.option:has(input:disabled) { cursor: default; }
.option input { margin: .3em 0 0; accent-color: var(--akzent); }
.option .buchstabe { font-weight: 700; color: var(--leise); }
.option.richtig { border-color: var(--gut); background: var(--gut-flaeche); }
.option.falsch { border-color: var(--fehler); background: var(--falsch-flaeche); }

.luecken-text { white-space: pre-wrap; line-height: 2.1; margin: .6rem 0; }
.code-text {
  padding: .7rem;
  border-radius: 10px;
  background: var(--code);
  overflow-x: auto;
  font: .9em/2.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.luecke-rahmen { white-space: nowrap; }
.luecke {
  font: inherit;
  line-height: 1.3;
  padding: .1em .35em;
  border: 1px solid var(--rand);
  border-bottom: 2px solid var(--akzent);
  border-radius: 6px;
  background: var(--flaeche);
  color: var(--text);
}
.luecke.richtig { border-color: var(--gut); background: var(--gut-flaeche); }
.luecke.fast { border-color: var(--fast); }
.luecke.falsch { border-color: var(--fehler); background: var(--falsch-flaeche); }
.luecke-loesung { margin-left: .35em; font-weight: 600; color: var(--gut); }
.luecke-loesung::before { content: "→ "; }

.aktionen { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.aktionen .sekundaer { padding: .4em 1.1em; }
.rueckmeldung { margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--rand); }
.rueckmeldung.gut strong { color: var(--gut); }
.rueckmeldung > div > :first-child, .rueckmeldung p:first-child { margin-top: 0; }
.rueckmeldung > :last-child > :last-child { margin-bottom: 0; }

/* „Fehler melden“ dezent unter jeder Tutor-Antwort, Tipp unter Code-Übungen */
.melden { margin-top: .5rem; text-align: right; font-size: .8rem; color: var(--leise); }
.melden .link { color: var(--leise); font-size: .8rem; }
.melden .link:hover { color: var(--akzent); }
.tipp { margin: .6rem 0 0; font-size: .875rem; color: var(--leise); }

#melden form { display: grid; gap: .6rem; }
#melden h2 { margin: 0 0 .2rem; }
#melden label { font-weight: 600; }
#melden .auswahl { display: grid; gap: .3rem; }
#melden .auswahl label { font-weight: normal; display: flex; gap: .5rem; align-items: center; }
#melden textarea {
  resize: vertical;
  padding: .6em .8em;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
}
#melden .knoepfe { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }

/* „Noch ein …“ unter einer Aufgabe bzw. unter der Rückmeldung des Tutors */
.nochmal { margin-top: .8rem; }
.nochmal:has(> [hidden]) { display: none; }
.nochmal .sekundaer { padding: .45em 1.1em; }

details.loesung {
  margin: .7em 0;
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: .5rem .8rem;
}
details.loesung summary { cursor: pointer; color: var(--akzent); font-weight: 600; }
details.loesung[open] summary { margin-bottom: .4rem; }

.tippt { display: flex; gap: .3rem; width: auto; padding: .9rem 1rem; }
.tippt span {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--leise);
  animation: tippen 1.2s infinite ease-in-out;
}
.tippt span:nth-child(2) { animation-delay: .15s; }
.tippt span:nth-child(3) { animation-delay: .3s; }
@keyframes tippen { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.eingabe {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .6rem 0 calc(.8rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rand);
  background: var(--hintergrund);
}
.eingabe textarea {
  flex: 1;
  resize: none;
  max-height: 200px;
  padding: .6em .9em;
  border: 1px solid var(--rand);
  border-radius: 20px;
  background: var(--flaeche);
  line-height: 1.4;
}
.eingabe .primaer { width: 2.6rem; height: 2.6rem; padding: 0; flex: none; }

/* Statistik */

.statistik form.karte { display: grid; gap: .6rem; max-width: 360px; }
.statistik label { font-weight: 600; }
.statistik input {
  padding: .7em .9em;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
}

.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kacheln .karte { margin: 0; }
.kachel p { margin: 0; }
.kachel .gross { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }

.balkenliste { display: grid; gap: .45rem; }
.balken-zeile {
  display: grid;
  grid-template-columns: minmax(0, 14rem) 1fr 3rem;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
}
.balken-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balken-spur { height: 8px; }
.balken { display: block; height: 100%; min-width: 2px; background: var(--akzent); border-radius: 0 4px 4px 0; }
.balken-wert { text-align: right; font-variant-numeric: tabular-nums; color: var(--leise); }

@media (max-width: 520px) {
  .balken-zeile { grid-template-columns: 1fr 3rem; row-gap: .15rem; }
  .balken-name { grid-column: 1 / -1; white-space: normal; }
}

.statistik .tabelle table { width: 100%; }
.statistik .tabelle th, .statistik .tabelle td { white-space: nowrap; }
.statistik .tabelle td.grund { white-space: normal; min-width: 16rem; }
.meldung { padding: .7rem 0; border-top: 1px solid var(--rand); }
.meldung:first-child { border-top: 0; padding-top: 0; }
.meldung p { margin: 0 0 .3rem; }
.meldung-text { white-space: pre-wrap; padding-left: .7rem; border-left: 3px solid var(--fehler); }
.meldung-feedback .meldung-text { border-left-color: var(--akzent); }
.meldung details { margin-top: .3rem; font-size: .875rem; }
.meldung summary { cursor: pointer; color: var(--akzent); }
.meldung pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow-y: auto; padding: .6rem; border-radius: 8px; background: var(--code); font-size: .8rem; }
.push-dozent { margin-top: 1rem; }
.karte-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.karte-kopf h3 { margin-top: 0; }
.statistik .zahl { text-align: right; font-variant-numeric: tabular-nums; }

/* Dialog */

dialog {
  max-width: min(560px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  background: var(--flaeche);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin-top: 0; }
dialog h2:focus { outline: none; }
dialog ul { padding-left: 1.2em; }
dialog li + li { margin-top: .5em; }
#datenschutz form { text-align: right; }
