:root { --farbe: #4B5563; --ink: #1B1F24; --muted: #4A5260; --linie: #E1E4EA; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: #E4E7EC; font-size: 18px; -webkit-text-size-adjust: 100%; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, math-field:focus-within { outline: 3px solid rgba(51, 70, 200, .5); outline-offset: 2px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* Vollflächige Zustände */
.flaeche { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.flaeche.neutral { background: #E4E7EC; }
.flaeche.streifen { background: repeating-linear-gradient(135deg, rgba(255,255,255,.16) 0 26px, rgba(255,255,255,0) 26px 52px), var(--farbe); }
.flaeche.farbe { background: var(--farbe); }
.flaeche.grau { background: #5B616B; }
.karte { width: 100%; max-width: 560px; background: #fff; border-radius: 18px; padding: 32px 36px; box-shadow: 0 10px 30px rgba(20,24,30,.14); display: flex; flex-direction: column; gap: 18px; }
.karte.breit { max-width: 720px; }
.karte h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.3px; }
.klein { font-size: 15px; color: var(--muted); }
.feld label { display: block; font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feld .hilfe { font-size: 14px; color: var(--muted); margin-top: 6px; }
.eingabe { width: 100%; border: 2px solid #CDD2DA; border-radius: 10px; padding: 12px 14px; font: inherit; font-size: 20px; color: var(--ink); background: #fff; }
.eingabe:focus { border-color: #3346C8; outline: none; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px; letter-spacing: 2px; text-transform: uppercase; }
.raum { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; letter-spacing: 14px; width: 210px; }
.fehler { background: #FDECEC; border: 1px solid #F3B4B4; color: #8A1C1C; border-radius: 10px; padding: 12px 14px; font-size: 16px; line-height: 1.45; }
.gross { border: none; border-radius: 12px; padding: 14px 26px; font-size: 19px; font-weight: 700; min-height: 54px; background: var(--ink); color: #fff; }
.gross.farbig { background: var(--farbe); }
.gross:disabled { background: #E4E7EC; color: #4A5260; cursor: default; }
.leise { background: #fff; border: 1px solid #CDD2DA; border-radius: 10px; padding: 11px 18px; font-size: 16px; font-weight: 600; color: var(--ink); min-height: 46px; }
.leise:disabled { opacity: .4; cursor: default; }
.kuerzel { font-size: 22px; font-weight: 800; color: #fff; background: var(--farbe); border-radius: 10px; padding: 6px 14px; letter-spacing: .5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 15px; padding: 6px 12px; border-radius: 999px; background: #F1F3F6; }
.regeln { margin: 0; padding-left: 22px; font-size: 16px; line-height: 1.55; display: flex; flex-direction: column; gap: 4px; }
.farbhinweis { display: flex; align-items: center; gap: 10px; font-size: 15px; background: #F7F7F9; border-radius: 10px; padding: 10px 12px; }
.farbhinweis span.f { flex: 0 0 28px; height: 28px; border-radius: 8px; background: var(--farbe); }
.mitte { text-align: center; align-items: center; }
.symbol { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.quittung { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 44px; font-weight: 700; letter-spacing: 4px; padding: 10px 22px; border: 3px dashed var(--ink); border-radius: 14px; }

/* Test */
.test { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--farbe); }
.leiste { min-height: 64px; padding: 8px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; color: #fff; }
.leiste .k { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
.leiste .t { font-size: 14px; opacity: .92; }
.fort { flex: 1 1 160px; display: flex; align-items: center; gap: 10px; }
.fort .balken { flex: 1 1 auto; height: 10px; border-radius: 999px; background: rgba(255,255,255,.28); overflow: hidden; }
.fort .balken i { display: block; height: 100%; background: #fff; border-radius: 999px; }
.fort span { font-size: 14px; font-weight: 600; white-space: nowrap; }
.weg { font-size: 15px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: #fff; color: #8A1C1C; white-space: nowrap; }
.status { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.18); white-space: nowrap; }
.status.off { background: #FFE7B3; color: #6B4200; }
.uhr { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 700; padding: 4px 12px; border-radius: 10px; background: rgba(0,0,0,.22); }
.uhr.knapp { background: #fff; color: #8A1C1C; }
.rahmen { flex: 1 1 auto; min-height: 0; padding: 0 14px 14px; }
.blatt { height: 100%; background: #fff; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.reiter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 22px; border-bottom: 1px solid #E8EAEE; }
.reiter button { border: none; border-radius: 8px; padding: 8px 14px; font-size: 15px; font-weight: 600; min-height: 40px; background: #F1F3F6; color: var(--ink); }
.reiter button[aria-current="page"] { background: var(--farbe); color: #fff; }
.reiter .hinweis { margin-left: auto; font-size: 13px; color: #5A6372; }
.inhalt { flex: 1 1 auto; overflow-y: auto; padding: 22px 32px 40px; display: flex; flex-direction: column; gap: 30px; }
.fuss { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-top: 1px solid #E8EAEE; }
.fuss .mitteltext { flex: 1 1 auto; text-align: center; font-size: 14px; color: #5A6372; }
.info { font-size: 17px; line-height: 1.5; background: #F4F5F7; border-radius: 10px; padding: 12px 16px; }
.aufgabe { display: flex; flex-direction: column; gap: 12px; }
.kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.kopf h2 { margin: 0; font-size: 19px; font-weight: 800; }
.kopf .p { font-size: 14px; color: var(--muted); }
.flag { background: #fff; border: 1px solid #CDD2DA; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: #4A5260; min-height: 34px; }
.flag[aria-pressed="true"] { background: #FFF1CF; border-color: #E9B949; color: #6B4200; }
.text { font-size: 18px; line-height: 1.5; }
.optionen { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid #E1E4EA; border-radius: 10px; font-size: 19px; cursor: pointer; background: #fff; min-height: 52px; }
.opt input { width: 22px; height: 22px; flex: 0 0 auto; }
.opt.an { border-color: var(--farbe); background: #F7F6FB; }
.teile { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.teil { display: flex; flex-direction: column; gap: 6px; }
.teil .term { font-size: 21px; }
math-field.mf { display: block; width: 100%; max-width: 460px; border: 2px solid #CDD2DA; border-radius: 10px; padding: 6px 12px; font-size: 24px; min-height: 52px; background: #fff; }
math-field.mf:focus-within { border-color: #3346C8; }
math-field::part(menu-toggle), math-field::part(virtual-keyboard-toggle) { display: none; }

/* Mathe-Tastatur */
.tastatur { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(780px, calc(100% - 12px)); z-index: 30; background: #D9DDE5; border-radius: 16px 16px 0 0; padding: 8px 8px 12px; box-shadow: 0 -6px 24px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 6px; }
.treihe { display: flex; gap: 6px; }
.taste { flex: 1 1 0; min-width: 0; min-height: 50px; border: none; border-radius: 9px; background: #fff; color: var(--ink); font-size: 21px; font-weight: 500; box-shadow: 0 1px 0 rgba(0,0,0,.18); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.taste:active { background: #E8EBF2; }
.taste.op { background: #F3F4F7; font-family: 'Times New Roman', Georgia, serif; }
.taste.var { background: #EEF1FB; color: #22309A; font-family: 'Times New Roman', Georgia, serif; font-style: italic; }
.taste.nav { background: #C7CCD6; font-size: 17px; font-weight: 700; }
.taste.breit { flex-grow: 2; }
.tbruch { display: inline-flex; flex-direction: column; line-height: 1; font-size: 15px; }
.tbruch span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 2px 1px; }
body.tastatur-an .inhalt { padding-bottom: 300px; }
textarea.eingabe { font-size: 18px; line-height: 1.5; resize: vertical; min-height: 220px; }
.woerter { font-size: 14px; color: #5A6372; text-align: right; }
.vollbild { position: fixed; inset: 0; background: rgba(20,24,30,.72); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.uebersicht { border: 1px solid #E1E4EA; border-radius: 12px; overflow: hidden; }
.uebersicht div { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid #EEF0F4; }
.uebersicht b { flex: 0 0 100px; }
.uebersicht .leer { color: #9A3412; font-weight: 600; flex: 1 1 auto; }
.uebersicht .ok { flex: 1 1 auto; }
.uebersicht .mark { font-size: 13px; font-weight: 700; color: #7A4B00; background: #FFF1CF; border-radius: 999px; padding: 3px 10px; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }

/* Mathe aus dem Fit-Kern (CAS.formatHtml) */
.term i { font-family: 'Times New Roman', Georgia, serif; font-style: italic; }
.term .op { padding: 0 .18em; }
.bruch { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .9em; }
.bruch .z { border-bottom: 1.5px solid currentColor; padding: 0 .15em; }
.bruch .n { padding: 0 .15em; }

@media (max-width: 640px) {
  .karte { padding: 24px 20px; }
  .inhalt { padding: 18px 16px 32px; }
  .leiste .t { display: none; }
}

/* Neue Aufgabentypen */
.stapel-s { display: flex; flex-direction: column; gap: 10px; }
.gzeile { display: flex; flex-direction: column; gap: 4px; }
.kette { display: flex; flex-direction: column; gap: 8px; }
.kzeile { display: flex; align-items: center; gap: 8px; }
.kzeile .nr { flex: 0 0 24px; text-align: center; font-size: 20px; color: var(--muted); }
.kzeile math-field.mf { flex: 3 1 260px; max-width: 520px; }
.kzeile math-field.mf.op { flex: 1 1 110px; max-width: 170px; }
.kzeile .strich { font-size: 26px; color: var(--muted); }
.kzeile.lm { margin-top: 6px; }
.kzeile.lm math-field.mf { max-width: 360px; }
.ib { width: 40px; height: 40px; border-radius: 9px; border: 1px solid #CDD2DA; background: #fff; font-size: 18px; flex: 0 0 auto; }
.ib:disabled { opacity: .35; }
.lueckentext { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.lueckentext .formel, .lueckentext math-field.block { flex: 1 1 100%; }
math-field.luecken { border: none; background: transparent; font-size: 24px; padding: 4px 0; max-width: none; }
math-field.luecken.block { display: block; width: fit-content; max-width: 100%; margin: 2px auto; }
math-field.inline { display: inline-block; width: auto; min-width: 120px; max-width: 220px; font-size: 20px; min-height: 42px; }
.formel { text-align: center; margin: 6px 0; font-size: 20px; }
img.abb { display: block; max-width: min(100%, 520px); max-height: 360px; margin: 10px auto; }
.tikz-platzhalter { display: inline-block; padding: 8px 12px; border: 1px dashed #999; border-radius: 8px; color: #555; }

img.abb.grafik { width: min(100%, 440px); height: auto; max-height: none; }
.bogen img.abb.grafik { width: 70mm; }
