/* KI-Ready Lern-Webseite — Grundgerüst der Oberfläche.
   Reihenfolge je Seite: tokens.css → app.css → nachtglas.css → rueckgrat-r1.css.
   Token kommen aus tokens.css (Skill edles-dunkel-design), die Bauteile aus
   nachtglas.css und rueckgrat-r1.css (wörtlich). Hier steht nur, was diese
   App an Aufbau braucht: Seite, Kopfzeile mit Marke, Karten, Knöpfe, Felder,
   Tabelle, Dialog, Meldung, Lernpfad-Kacheln — ohne Farbwerte, nur Token.
   16 px Seitenrand, kein waagerechtes Scrollen bei 390 px. */

*, *::before, *::after { box-sizing: border-box; }
/* `hidden` gewinnt gegen jedes display der Bauteile (Overlay-Falle, Formulare). */
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100vh;
  font-size: var(--fs-ui);
  line-height: 1.45;
}
/* Kopfschrift der Tabelle: dunkel eine aufgehellte Modulfarbe (trägt auf der
   16-%-Tönung), hell die Modulfarbe selbst (schon dunkel genug gerechnet). */
html.nacht { --m-hell: color-mix(in srgb, var(--m) 72%, var(--m-misch)); }
html:not(.nacht) { --m-hell: var(--m); }

main.seite {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding: 0 16px 40px;
  min-width: 0;
}
.page[hidden] { display: none; }
.page > h1 { font-size: var(--fs-page); font-weight: 700; margin: 0 0 6px; }
.page > p.sub { color: var(--glas-leise); margin: 0 0 18px; }
h2 { font-size: var(--fs-card); margin: 0 0 6px; }
.leise { color: var(--glas-leise); }
.hinweis { color: var(--glas-text); margin: 10px 0 0; font-size: var(--fs-body); }
.hinweis.warn { color: var(--bernstein); font-weight: 700; }
.hinweis.rot { color: var(--rot-nacht); font-weight: 700; }

/* ------------------------------------------------------------ Kopfzeile
   Bauteil aus nachtglas.css §5 (nur Symbole rechts); links die Marke als
   Schriftzug in Tinos — die eine Ausnahme von „keine Wörter“, weil die
   Lern-Webseite keine Seitenleiste mit Marke hat. */
.kopfzeile { position: sticky; top: 0; display: flex; align-items: center; gap: 5px; min-height: 52px; }
.kopf-marke {
  display: inline-flex; align-items: center; gap: 10px;
  margin-right: 10px; min-width: 0;
  font-size: var(--fs-card); font-weight: 700; letter-spacing: 0.01em;
  color: var(--glas-text); text-decoration: none; white-space: nowrap;
}
.kopf-marke img { width: 26px; height: 26px; flex: 0 0 auto; }
.kopf-marke .marke-zusatz { color: var(--glas-leise); font-weight: 400; }
.kopf-marke .marke-punkt { color: var(--m); }
@media (max-width: 479.98px) { .kopf-marke .marke-zusatz, .kopf-marke .marke-punkt { display: none; } }
/* Ohne Seitenleiste gibt es den Menü-Knopf nicht — die Lücke aus nachtglas.css
   (54 px für ☰ unter 900 px) fällt weg. */
@media (max-width: 899.98px) {
  html.edel .kopfzeile.kiready-kopf { padding: 6px 2px; min-height: 52px; }
}
.kopf-liste[hidden] { display: none; }
.kopf-sprache .kopf-liste { min-width: 160px; }

/* ------------------------------------------------------------ Karten */
.card {
  position: relative;
  margin-top: 18px;
  padding: 20px;
  background: var(--glas);
  border: 1px solid var(--glas-rand);
  border-radius: var(--r-kachel);
  box-shadow: inset 0 1px 0 var(--glas-kante);
  color: var(--glas-text);
  min-width: 0;
}
.card > h2 { display: flex; align-items: center; gap: 8px; }
.card > h2 [data-icon] { display: inline-flex; color: var(--m); }
.card > h2 svg { width: 18px; height: 18px; }
.card-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
/* k1 (P1.1b): Symbol im Kartenkopf mit Abstand zum Titel, gleiche Größe wie in .card > h2. */
.card-kopf h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.card-kopf h2 [data-icon] { display: inline-flex; color: var(--m); }
.card-kopf h2 svg { width: 18px; height: 18px; }
.card-kopf .stand { color: var(--m); font-weight: 700; font-size: var(--fs-body); }
.card-kopf .stand.ok { color: var(--status-gruen); }
.card-kopf .stand.warn { color: var(--bernstein); }
.card > p.sub { color: var(--glas-leise); margin: 4px 0 14px; font-size: var(--fs-body); }
.karten-raster { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .karten-raster.zwei { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------ Knöpfe
   Nebenaktion = Glas; Hauptaktion (.primary) aus rueckgrat-r1.css;
   Löschen rot umrandet; .linklike nur Schrift. Knöpfe erben die Schrift. */
button, .knopf {
  font: inherit;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: var(--r-knopf);
  border: 1px solid var(--glas-rand);
  background: var(--glas);
  color: var(--glas-text);
  box-shadow: inset 0 1px 0 var(--glas-kante);
  cursor: pointer;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
button [data-icon], .knopf [data-icon] { display: inline-flex; align-items: center; }
button svg, .knopf svg { width: 16px; height: 16px; }
@media (hover: hover) {
  button:enabled:hover, .knopf:hover {
    border-color: var(--m);
    box-shadow: inset 0 1px 0 var(--glas-kante),
                0 0 var(--leucht-glas-weite) color-mix(in srgb, var(--m) var(--leucht-glas), transparent);
  }
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--m); outline-offset: 2px;
}
html.zeiger button:focus-visible, html.zeiger a:focus-visible { outline: none; }
button.danger {
  background: transparent; border-color: var(--rot-nacht); color: var(--rot-nacht); box-shadow: none;
}
button.danger:enabled:hover { background: color-mix(in srgb, var(--rot-nacht) 10%, transparent); border-color: var(--rot-nacht); box-shadow: none; }
button.linklike, button.linklike:enabled:hover {
  background: none; border-color: transparent; box-shadow: none;
  color: var(--glas-leise); padding: 4px 8px; min-height: 0; font-weight: 400;
}
button.linklike:enabled:hover { color: var(--glas-text); }
button.klein { min-height: 32px; padding: 4px 11px; font-size: var(--fs-body); }
.knopf-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }

/* ------------------------------------------------------------ Felder */
label { display: block; margin: 12px 0 5px; color: var(--glas-leise); font-size: var(--fs-body); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  font: inherit;
  padding: 8px 12px;
  background: var(--feld-grund);
  border: 1px solid var(--glas-rand);
  border-radius: var(--r-feld);
  color: var(--glas-text);
  min-width: 0;
  max-width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input::placeholder, textarea::placeholder { color: var(--glas-leise); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--m);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--m) var(--leucht-fokus), transparent);
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--rot-nacht);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rot-nacht) 18%, transparent);
}
.feld-fehler { display: block; color: var(--rot-nacht); font-size: var(--fs-small); margin-top: 4px; }
.feld-hilfe { display: block; color: var(--glas-leise); font-size: var(--fs-small); margin-top: 4px; }
html.edel select { color-scheme: dark; }
html.edel:not(.nacht) select { color-scheme: light; }
html.edel select option { background: var(--grund-inhalt-2); color: var(--glas-text); }
.form-zeile { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-zeile.zwei { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------ Tabelle ohne Raster (§5) */
.table-wrap {
  margin-top: 12px;
  border: 1px solid var(--glas-rand);
  border-radius: var(--r-tabelle);
  background: var(--glas);
  overflow: auto;
  max-width: 100%;
}
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
table.data th, table.data td { text-align: left; padding: 10px 12px; vertical-align: middle; white-space: nowrap; }
table.data th {
  position: sticky; top: 0;
  color: var(--m-hell);
  font-weight: 700;
  font-size: var(--fs-tabelle-kopf);
  background: color-mix(in srgb, var(--m) 16%, var(--grund-inhalt-2));
  box-shadow: inset 0 -0.5px 0 var(--m);
}
table.data td { border-bottom: 0.5px solid var(--linie-haar); color: var(--glas-text); }
table.data tr:last-child td { border-bottom: 0; }
@media (hover: hover) {
  table.data tbody tr:hover td { background: color-mix(in srgb, var(--m) 9%, transparent); }
}
table.data td.aktion, table.data th.aktion { text-align: right; }   /* k4: Kopf über seinen Knöpfen */
table.data td.aktion button { margin-left: 6px; }
/* Zustände nur als farbige Schrift (Grundsatz 6) */
.z-offen { color: var(--glas-leise); }
.z-begonnen { color: var(--m); font-weight: 700; }
.z-abgeschlossen { color: var(--status-gruen); font-weight: 700; }
.z-inaktiv { color: var(--glas-leise); font-style: italic; }
.z-eingeladen { color: var(--bernstein); font-weight: 700; }
.z-eingeloest { color: var(--status-gruen); font-weight: 700; }
.leer-zustand { color: var(--glas-text); padding: 8px 0 0; }

/* ------------------------------------------------------------ Lernpfad-Kacheln
   Glaskachel mit Lichtfleck (nachtglas.css §6, Klasse nd-glas für effekte.js). */
/* M5 (P1.1b): Kacheln in Modul-Gruppen mit Zwischenüberschrift; genau eine Kachel
   trägt die Hauptaktion („Als Nächstes“), alle anderen einen Nebenknopf. */
.lp-raster { margin-top: 18px; }
.lp-gruppe + .lp-gruppe { margin-top: 26px; }
.lp-gruppe-titel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 12px; font-size: var(--fs-card); }
.lp-gruppe-titel .lp-gruppe-stand { color: var(--glas-leise); font-size: var(--fs-body); font-weight: 400; }
.lp-gruppe-raster { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lp-naechstes { color: var(--m); font-weight: 700; font-size: var(--fs-small); letter-spacing: 0.04em; text-transform: uppercase; }
.lp-kachel.card.lp-naechste { border-color: var(--m); }
.lp-kachel.card {
  --nd-farbe: var(--m);
  margin-top: 0;
  display: flex; flex-direction: column; gap: 6px;
  background-color: transparent;
  background-image:
    radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%),
                    color-mix(in srgb, var(--nd-farbe) var(--nd-licht), transparent), transparent 70%),
    linear-gradient(var(--glas), var(--glas));
  box-shadow: inset 0 1px 0 var(--glas-kante), 0 10px 30px var(--schatten-kachel);
  overflow: hidden;
  transition: --nd-licht 0.25s ease, transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
@media (hover: hover) {
  .lp-kachel.card:hover { --nd-licht: var(--leucht-fleck); transform: translateY(-4px); }
}
.lp-modul { font-size: var(--fs-small); color: var(--glas-leise); letter-spacing: 0.04em; text-transform: uppercase; }
.lp-titel { font-size: var(--fs-card); font-weight: 700; margin: 0; }
.lp-zeit { font-size: var(--fs-body); color: var(--glas-leise); }
.lp-zustand { font-size: var(--fs-body); margin-top: 2px; }
.lp-fuss { margin-top: auto; padding-top: 12px; display: flex; justify-content: flex-end; }
.lp-stand { color: var(--m); font-weight: 700; margin: 0 0 4px; }

/* ------------------------------------------------------------ Dialog (§10) */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.overlay[hidden] { display: none; }
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--glas-fenster);
  border: 1px solid var(--glas-rand);
  border-radius: var(--r-kachel);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 8px; }
.modal-head h2 { margin: 0; font-size: var(--fs-card); }
.modal-head .linklike { min-height: 30px; padding: 0 8px; border-radius: 50%; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 20px 12px; }
.modal-body label:first-child { margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--linie-haar); }
.link-feld { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-feld input { flex: 1 1 200px; font-size: var(--fs-body); }
.link-feld button { white-space: nowrap; flex: 0 0 auto; }

/* ------------------------------------------------------------ Meldung (§11) */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  max-width: min(420px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border: 0.5px solid var(--status-gruen);
  border-radius: var(--r-feld);
  background: color-mix(in srgb, var(--status-gruen) 8%, var(--grund-inhalt-2));
  color: var(--glas-text);
  font-size: var(--fs-body);
  box-shadow: 0 12px 30px var(--schatten-toast);
}
.toast[hidden] { display: none; }
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--status-gruen); margin-top: 2px; }
.toast.error { border-color: var(--rot-nacht); background: color-mix(in srgb, var(--rot-nacht) 8%, var(--grund-inhalt-2)); }
.toast.error svg { color: var(--rot-nacht); }

/* ------------------------------------------------------------ Lektion (Platzhalter-Seite) */
.lektion-karte { max-width: 640px; margin: 24px auto 0; text-align: center; padding: 32px 24px; }
.lektion-karte h1 { font-size: var(--fs-page); margin: 0 0 8px; }
.lektion-karte p { color: var(--glas-text); margin: 0 0 18px; }
.lektion-karte .lp-modul { display: block; margin-bottom: 6px; }

/* ------------------------------------------------------------ Anmeldung / Einladung (§8)
   Grundlagen, die nachtglas.css voraussetzt (Nexus app.css). */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.login-wrap { width: 100%; max-width: 340px; margin: auto; }
.login-card { display: flex; flex-direction: column; gap: 8px; }
.login-card form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.login-card form label { margin: 6px 0 0; }
.login-card form button { margin-top: 8px; justify-content: center; }
.login-card h2 { font-size: var(--fs-card); margin: 6px 0 0; }
.login-card p { margin: 0; }
.login-error { color: var(--rot-nacht); font-size: var(--fs-body); margin: 2px 0 0; }
.login-error[hidden] { display: none; }
.login-card .infoblatt {
  margin-top: 6px; padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--m) 50%, transparent);
  border-radius: var(--r-kachel);
  font-size: var(--fs-body);
}
.login-card .infoblatt h2 { font-size: var(--fs-body); margin: 0 0 6px; }
.login-card .infoblatt p { margin: 0 0 6px; }
.login-card .infoblatt .vermerk { color: var(--bernstein); font-weight: 700; margin: 0; }
/* k18 (P1.1b): die Einladung ist breiter (420 px), damit der Knopftext in einer Zeile steht. */
/* Vorrang über nachtglas.css (html.edel .login-card: 300 px, .login-wrap: 340 px). */
html.edel .login-card.einladung-card { width: 420px; max-width: 100%; }
html.edel .login-wrap:has(.einladung-card) { max-width: 420px; width: 100%; }
.einladung-card .knopf-zeile { margin-top: 16px; }
.einladung-card .knopf-zeile button { white-space: nowrap; }
#einl-gelesen-hinweis { margin-top: 10px; }
/* k6 (P1.1b): Link „Probe-Lektion ansehen“ in der Modulfarbe statt Browser-Blau. */
.login-probe a, .einladung-card a:not(.knopf) { color: var(--m); text-decoration: none; font-weight: 600; }
.login-probe a:hover { text-decoration: underline; text-underline-offset: 3px; }
.nd-marke { width: 76px; height: 76px; flex: 0 0 auto; }

/* ------------------------------------------------------------ Ruhe */
@media (prefers-reduced-motion: reduce) {
  .lp-kachel.card:hover { transform: none; }
}
