/* Rechenprofil 2: Gestaltung "Rechenheft"
   Ziffern sind aus der Schrift ausgenommen (Atkinson zeichnet die Null durchgestrichen)
   und erscheinen in der vertrauten Systemschrift des Geraets.
   Ruhige Flaechen, eine Tintenfarbe, Wendeplaettchen-Rot nur fuer Material.
   Die Aufgabenflaeche ist kariertes Heftpapier mit Rand. */

@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-002F, U+003A-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-002F, U+003A-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --paper: #FBFCFD;        /* Hintergrund */
  --sheet: #FFFFFF;        /* Flaechen */
  --grid: #DCE6EE;         /* Karolinie */
  --line: #D5DEE6;         /* Raender */
  --ink: #1C2B3A;          /* Text */
  --muted: #66717D;        /* Graphit */
  --primary: #2E5E9E;      /* Heftblau */
  --primary-ink: #FFFFFF;
  --primary-soft: #E7EEF7;
  --red: #D0453A;          /* Wendeplaettchen */
  --red-soft: #F7E3E1;
  --ok: #2D7A5B;
  --ok-soft: #E1F0E8;
  --warn-soft: #F7EDD8;
  --danger: #B23B32;
  --gold: #E3BE5B; --copper: #C4844F;
  --l-pp: #DDEFE6; --l-p: #E9F3DF; --l-z: #F6EFD9; --l-m: #F8E3D3; --l-mm: #F5D9D6;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', Tahoma, sans-serif;
  --scrim: rgba(28, 43, 58, .4);
  color-scheme: light;
}
/* Dunkles Design: folgt dem Geraet, solange ueber den Design-Knopf nichts fest gewaehlt ist (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --paper: #12181F; --sheet: #19212A; --grid: #222D38; --line: #2C3844;
    --ink: #E6ECF2; --muted: #9AA6B2;
    --primary: #86AEE6; --primary-ink: #0F1720; --primary-soft: #1F2D40;
    --red: #E46A5F; --red-soft: #3A2423; --ok: #6FC39E; --ok-soft: #1D3229; --warn-soft: #362D1B; --danger: #E0675D;
    --l-pp: #1E3A2D; --l-p: #29371F; --l-z: #3A3320; --l-m: #3E2C1E; --l-mm: #432423;
    --scrim: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
    --paper: #12181F; --sheet: #19212A; --grid: #222D38; --line: #2C3844;
    --ink: #E6ECF2; --muted: #9AA6B2;
    --primary: #86AEE6; --primary-ink: #0F1720; --primary-soft: #1F2D40;
    --red: #E46A5F; --red-soft: #3A2423; --ok: #6FC39E; --ok-soft: #1D3229; --warn-soft: #362D1B; --danger: #E0675D;
    --l-pp: #1E3A2D; --l-p: #29371F; --l-z: #3A3320; --l-m: #3E2C1E; --l-mm: #432423;
    --scrim: rgba(0, 0, 0, .55);
    color-scheme: dark;
}

/* Modulgruppen */
.g-orient { --g: #2E5E9E; --g-soft: #E7EEF7; }
.g-basis { --g: #A06A14; --g-soft: #F5ECDB; }
.g-rechnen { --g: #2D7A5B; --g-soft: #E1F0E8; }
.g-gv { --g: #6B57A0; --g-soft: #ECE8F5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .g-orient { --g: #86AEE6; --g-soft: #1F2D40; }
  :root:not([data-theme=light]) .g-basis { --g: #E0B062; --g-soft: #33291A; }
  :root:not([data-theme=light]) .g-rechnen { --g: #6FC39E; --g-soft: #1D3229; }
  :root:not([data-theme=light]) .g-gv { --g: #B3A2DD; --g-soft: #2A2438; }
}
:root[data-theme=dark] .g-orient { --g: #86AEE6; --g-soft: #1F2D40; }
:root[data-theme=dark] .g-basis { --g: #E0B062; --g-soft: #33291A; }
:root[data-theme=dark] .g-rechnen { --g: #6FC39E; --g-soft: #1D3229; }
:root[data-theme=dark] .g-gv { --g: #B3A2DD; --g-soft: #2A2438; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 18px/1.5 var(--font); -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { max-width: 760px; margin: 0 auto; padding: 20px 16px 56px; }
#app.wide { max-width: 1060px; }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
[dir=rtl] .icon-flip { transform: scaleX(-1); }

/* ---------- App-Leiste und Hamburger-Menue ---------- */
#chrome[hidden] { display: none; }
.appbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; direction: ltr; }
.brand { margin-left: auto; background: none; border: 0; padding: 6px 4px; font-weight: 700; font-size: 1rem; color: var(--ink); }
.bar-btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); color: var(--ink); font-weight: 700; font-size: 1rem; }
.bar-btn .icon { width: 20px; height: 20px; }
.bar-btn span { unicode-bidi: isolate; }
.menu-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); color: var(--ink); }
.menu-btn .icon { width: 24px; height: 24px; }
.menu-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }
/* Menue immer am linken Bildschirmrand, auch bei Rechts-nach-links-Sprachen */
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: min(340px, 88vw); overflow-y: auto; padding: 12px 12px 28px 16px; background: var(--sheet); border-right: 1.5px solid var(--line);
  transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
.drawer.open { transform: none; visibility: visible; transition: transform .22s ease; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; direction: ltr; }
.drawer-title { font-weight: 700; font-size: 1.1rem; unicode-bidi: isolate; }
.nav-section { margin: 14px 0 6px; padding: 14px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; font-weight: 700; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; border: 0; border-radius: 10px; padding: 12px 10px; background: none; font-weight: 700; color: var(--ink); }
.nav-item .icon { color: var(--muted); }
.nav-item:hover { background: var(--paper); }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav-item[aria-current="page"] .icon { color: var(--primary); }
body.no-scroll { overflow: hidden; }

/* ---------- Kopfzeile ---------- */
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 24px; min-height: 48px; }
.bar h2 { font-size: 1.25rem; text-align: center; }
.bar > :first-child { justify-self: start; }
.bar > :last-child { justify-self: end; }
.link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--primary); padding: 10px 4px; font-weight: 700; }

/* ---------- Schaltflaechen ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 18px; font-weight: 700; background: var(--sheet); color: var(--ink); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.big { font-size: 1.2rem; padding: 16px 32px; }
.btn.small { padding: 7px 12px; font-size: .9rem; border-radius: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.row.left { justify-content: flex-start; }

/* ---------- Startseite ---------- */
.home { padding-top: 40px; }
.home h1 { font-size: 2.6rem; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin-top: 8px; max-width: 34em; }
.home-sec { margin-top: 40px; }
.home-sec.first { margin-top: 44px; padding-top: 32px; border-top: 1px solid var(--line); }
.home-sec h2 { font-size: 1.4rem; }
.home-sec > p { margin-top: 12px; line-height: 1.6; max-width: 36em; }
.step-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 20px; }
.step-list li { display: flex; gap: 16px; align-items: flex-start; }
.step-list p { margin-top: 5px; line-height: 1.6; max-width: 34em; }
.step-no { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-family: system-ui, sans-serif; }
.facts { list-style: none; margin: 40px 0 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 640px) { .facts { grid-template-columns: 1fr 1fr; gap: 24px; } }
.facts li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); font-size: .92rem; line-height: 1.55; }
.facts .icon { width: 22px; height: 22px; margin-top: 2px; }
.home-cta { display: flex; justify-content: center; margin-top: 52px; }
.btn.cta { font-size: 1.3rem; padding: 20px 36px; border-radius: 16px; gap: 14px; }
.btn.cta .icon { width: 28px; height: 28px; }

/* ---------- Kinderauswahl und Sprache ---------- */
.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kid { border: 1.5px solid var(--line); background: var(--sheet); border-radius: 14px; padding: 22px 12px; font-size: 1.3rem; font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.langopt { display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 12px; padding: 16px 14px; font-size: 1.25rem; font-weight: 700; text-align: start; }
.langopt.sel { border-color: var(--primary); border-width: 2.5px; padding: 15px 13px; background: var(--primary-soft); }
.lvoice { color: var(--muted); display: inline-flex; }
.lvoice.off { color: var(--red); }

/* ---------- Modulmenue ---------- */
.bar-split { grid-template-columns: auto auto; justify-content: space-between; margin-bottom: 8px; }
.page-title { font-size: 2rem; margin-bottom: 6px; }
.page-sub { color: var(--muted); margin-bottom: 28px; }
.page-title + .kid-grid, .page-title + .empty { margin-top: 20px; }
.mgroup { margin-bottom: 28px; }
.mgroup h3 { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin-bottom: 12px; }
.mgroup h3::before { content: ""; width: 14px; height: 14px; border-radius: 4px; background: var(--g); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-align: start; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 14px; padding: 16px; min-height: 128px; }
.tile .ticon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--g-soft); color: var(--g); }
.tile .ticon .icon { width: 28px; height: 28px; }
.tile .tname { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.tile.is-done { background: transparent; color: var(--muted); }
.tile.is-done .ticon { background: transparent; color: var(--muted); }
.tcheck { position: absolute; top: 12px; inset-inline-end: 12px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.tcheck .icon { width: 18px; height: 18px; }
.tpart { font-size: .8rem; color: var(--g); font-weight: 700; }

/* ---------- Hinweise ---------- */
.banner { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 12px 14px; margin: 0 0 20px; background: var(--primary-soft); font-size: .95rem; }
.banner.ok { background: var(--ok-soft); justify-content: center; font-weight: 700; }
.banner.warn { background: var(--warn-soft); }

/* ---------- Aufgaben ---------- */
.task-bar { grid-template-columns: auto 1fr auto; }
.mod-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.mod-title .icon { color: var(--g); }
.count { font-weight: 700; color: var(--muted); }
.progress { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--g, var(--primary)); }

/* Die Aufgabenflaeche: kariertes Rechenheftpapier mit Rand */
.stage {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  min-height: 210px; padding: 32px 20px 32px 52px; text-align: center;
  background-color: var(--sheet);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px; background-position: -1px -1px;
  border: 1.5px solid var(--line); border-radius: 6px;
}
.stage::before { content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: 32px; width: 2px; background: var(--red); opacity: .45; }
[dir=rtl] .stage { padding: 32px 52px 32px 20px; }
.prompt { font-size: 1.45rem; font-weight: 700; max-width: 30em; }
.prompt.small { font-size: 1.05rem; color: var(--muted); font-weight: 400; }
.term { font-size: 3rem; font-weight: 700; letter-spacing: .02em; }
.hint-term { font-size: 1.15rem; color: var(--muted); }
.hint-term strong { color: var(--ink); }
.story { font-size: 1.35rem; max-width: 30em; line-height: 1.55; }
.bignum { font-size: 4.5rem; font-weight: 700; line-height: 1; }
.ready { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.opbox { display: inline-block; min-width: 1.3em; border: 2.5px dashed var(--primary); border-radius: 8px; color: var(--primary); line-height: 1.1; }
.input { margin-top: 20px; }

/* Tastenfeld */
.answerbox { display: flex; align-items: center; justify-content: center; min-height: 76px; max-width: 220px; margin: 0 auto 14px; border: 2px solid var(--primary); border-radius: 8px; background: var(--sheet); font-size: 2.6rem; font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 330px; margin: 0 auto; }
.key { display: grid; place-items: center; min-height: 64px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--sheet); font-size: 1.8rem; font-weight: 700; }
.key:active { background: var(--primary-soft); border-color: var(--primary); }
.key-ok { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-size: 1.3rem; }
.key-ok:disabled { opacity: .35; }
.key-del .icon { width: 30px; height: 30px; }
.key.small { min-height: 52px; min-width: 56px; font-size: 1.6rem; }

/* Auswahl */
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; max-width: 640px; margin: 0 auto; }
.opt { display: block; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 12px; padding: 18px 10px; font-size: 1.5rem; font-weight: 700; text-align: center; }
.opt.sel { border: 2.5px solid var(--primary); padding: 17px 9px; background: var(--primary-soft); }
.opts.ops .opt { font-size: 2.4rem; padding: 8px; }
.opts.ops .opt.sel { padding: 7px; }
.ok-btn { display: flex; margin: 18px auto 0; min-width: 170px; font-size: 1.2rem; }

/* Grafiken */
svg { max-width: 100%; height: auto; }
.dots { width: 340px; }
.dots.dice { width: 130px; }
.cellbox { fill: var(--sheet); stroke: var(--ink); stroke-opacity: .35; stroke-width: 1.5; }
.dot { fill: var(--red); }
.numline { width: 100%; max-width: 620px; }
.ln { stroke: var(--ink); stroke-width: 2.5; }
.lbl { fill: var(--ink); font-size: 14px; text-anchor: middle; font-weight: 700; font-family: var(--font); }
.mark { stroke: var(--red); stroke-width: 4; }
.arrow { fill: var(--red); }
.house { width: 220px; }
.roof { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 3; stroke-linejoin: round; }
.hbody { fill: var(--sheet); stroke: var(--primary); stroke-width: 3; }
.hline { stroke: var(--primary); stroke-width: 3; }
.hnum { fill: var(--ink); font-size: 34px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; font-family: var(--font); }
.hnum.hq { fill: var(--primary); }
.coins { width: 340px; }
.gold { fill: var(--gold); stroke: #A8862D; stroke-width: 2; }
.copper { fill: var(--copper); stroke: #8A5530; stroke-width: 2; }
.cv { fill: #2B2210; font-size: 18px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; font-family: var(--font); }
.cu { fill: #2B2210; font-size: 11px; text-anchor: middle; dominant-baseline: middle; font-family: var(--font); }

/* Zwanzigerfeld */
.field20 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; max-width: 520px; margin: 0 auto; padding: 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); }
.field20 .cell { aspect-ratio: 1; display: block; padding: 0; border: 1.5px solid var(--line); border-radius: 50%; background: var(--paper); }
.field20 .cell.gap { margin-right: 10px; }
.field20 .cell.on { background: var(--red); border-color: var(--red); }
.field20.static { max-width: 360px; }

/* Zehnerstangen und Einer */
.b-vis { display: flex; gap: 24px; align-items: flex-end; justify-content: center; flex-wrap: wrap; min-height: 190px; padding: 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); }
.tens { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.bar10 { display: grid; grid-template-rows: repeat(10, 14px); gap: 2px; padding: 3px; border-radius: 4px; background: var(--primary-soft); border: 1.5px solid var(--primary); }
.bar10 i { width: 14px; background: var(--primary); border-radius: 2px; }
.ones { display: grid; grid-template-columns: repeat(5, 18px); gap: 4px; align-content: end; }
.one { width: 18px; height: 18px; background: var(--red); border-radius: 50%; }
.b-ctrl { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.b-grp { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 12px; padding: 6px 8px 6px 14px; }
[dir=rtl] .b-grp { padding: 6px 14px 6px 8px; }
.b-grp span { font-weight: 700; min-width: 7.5em; }

/* Einfuehrung */
.intro-text { font-size: 1.2rem; line-height: 1.6; max-width: 34em; margin: 0 auto 24px; }
.example-label { font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.demo-answer { margin-top: 14px; min-height: 20px; }
.demo-answer.pop { animation: reveal .35s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Modul geschafft */
.done-view { text-align: center; padding-top: 12vh; }
.done-mark { display: inline-grid; place-items: center; width: 104px; height: 104px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); margin-bottom: 24px; }
.done-mark .icon { width: 56px; height: 56px; stroke-width: 2.4; }
.done-view h2 { font-size: 2rem; margin-bottom: 8px; }
.done-view p { color: var(--muted); margin-bottom: 28px; }

/* ---------- Bereich fuer Lehrkraefte ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; padding: 4px; border-radius: 12px; background: var(--grid); width: fit-content; max-width: 100%; }
.tab { border: 0; background: transparent; border-radius: 9px; padding: 9px 14px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--sheet); color: var(--ink); }
.card { background: var(--sheet); border: 1.5px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.card h3 { font-size: 1.1rem; margin-bottom: 12px; }
.card h4 { font-size: 1rem; margin: 18px 0 8px; }
.card p + p, .card ul + p { margin-top: 10px; }
.card ul { margin: 0; padding-inline-start: 20px; }
.card li + li { margin-top: 6px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 10px; }
input[type=text], input[type=email], input:not([type]), input[type=password], select { border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--paper); min-width: 180px; font-weight: 400; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--paper) inset; -webkit-text-fill-color: var(--ink); transition: background-color 0s; }
.small-select { min-width: 0; padding: 6px 8px; }
.hint { color: var(--muted); font-size: .88rem; margin-top: 10px; }
.err { color: var(--danger); font-weight: 700; }
.pin-form { max-width: 360px; margin: 0 auto; display: grid; gap: 12px; }
.danger-zone { border-color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.approx { background: var(--warn-soft); }
.badge.none { background: var(--red-soft); color: var(--danger); }

/* Tabellen */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl thead th { font-weight: 700; color: var(--muted); font-size: .85rem; }
.tbl.small { font-size: .86rem; }
.tbl.overview th, .tbl.overview td { text-align: center; padding: 7px 4px; }
.tbl.overview td:first-child, .tbl.overview th:first-child, .tbl.overview td:nth-child(2), .tbl.overview th:nth-child(2) { text-align: start; }
.tbl.overview .icon { width: 20px; height: 20px; }
.mini-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--g-soft); color: var(--g); vertical-align: middle; margin-inline-end: 8px; }
.mini-icon .icon { width: 18px; height: 18px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.c-pp { background: var(--l-pp); } .c-p { background: var(--l-p); } .c-z { background: var(--l-z); }
.c-m { background: var(--l-m); } .c-mm { background: var(--l-mm); } .c-open { color: var(--muted); font-size: .8rem; }
.chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.chip.none { background: var(--grid); color: var(--muted); font-weight: 400; }

/* Bericht */
.report { background: var(--sheet); border: 1.5px solid var(--line); border-radius: 12px; padding: 28px; }
.report h1 { font-size: 1.7rem; }
.report h2 { font-size: 1.2rem; margin: 32px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.report h3 { font-size: 1rem; margin: 18px 0 6px; display: flex; align-items: center; }
.meta { color: var(--muted); margin: 6px 0 16px; }
.disclaimer { background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; font-size: .92rem; }
.hyp { border-inline-start: 3px solid var(--primary); padding-inline-start: 14px; margin: 16px 0; }
.hyp h3 { margin-top: 0; }
.hyp ul { margin: 6px 0; padding-inline-start: 20px; }
.hyp p { margin: 6px 0; }

@media (max-width: 520px) {
  body { font-size: 17px; }
  .term { font-size: 2.3rem; }
  .prompt { font-size: 1.25rem; }
  .bar h2 { font-size: 1.05rem; }
  .home h1 { font-size: 2.1rem; }
  .stage { padding: 24px 14px 24px 44px; }
  [dir=rtl] .stage { padding: 24px 44px 24px 14px; }
  .stage::before { inset-inline-start: 26px; }
  .field20 { gap: 4px; padding: 8px; }
  .field20 .cell.gap { margin-right: 6px; }
  .bar10 { grid-template-rows: repeat(10, 10px); }
  .bar10 i { width: 10px; }
  .report { padding: 16px; }
}

/* Zahlen, Terme und Eingaben bleiben auch in Rechts-nach-links-Sprachen links-nach-rechts */
.term, .keypad, .answerbox, .field20, .b-vis, .bignum, .numline, .dots, .house, .coins, .count { direction: ltr; unicode-bidi: isolate; }

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

@media print {
  .noprint, .tabs, .banner, #chrome { display: none !important; }
  :root, :root[data-theme=dark], :root:not([data-theme=light]) { --paper: #fff; --sheet: #fff; --ink: #000; --line: #bbb; --muted: #444; color-scheme: light; }
  body { font-size: 11pt; }
  #app, #app.wide { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; }
  .report h2 { break-after: avoid; }
  .hyp, tr { break-inside: avoid; }
  .chip, .c-pp, .c-p, .c-z, .c-m, .c-mm, .disclaimer, .mini-icon { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Codeeingabe fuer Kinder */
.code-form { max-width: 420px; margin: 24px auto 0; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.code-form label { font-weight: 700; font-size: 1.15rem; }
.code-input { direction: ltr; text-align: center; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 2.2rem; font-weight: 700; letter-spacing: .35em; text-transform: uppercase; padding: 14px 8px 14px calc(8px + .35em); border: 2px solid var(--line); border-radius: 14px; background: var(--sheet); color: inherit; width: 100%; box-sizing: border-box; }
.code-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.code-form .err:empty { display: none; }
.code-form .btn.cta { align-self: center; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .12em; white-space: nowrap; }

/* Foto-Hintergrund (alle Seiten ausser den Testseiten) */
body.photo-bg::before {
  content: ""; position: fixed; inset: 0; z-index: -2;
  background: url("img/hintergrund.webp") center 30% / cover no-repeat;
}
body.photo-bg::after {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(251,252,253,0) 0%, rgba(251,252,253,.10) 40%, rgba(251,252,253,.45) 100%);
}
body.photo-bg { background: transparent; }
html:has(body.photo-bg) { background: var(--paper); }
body.photo-bg { height: 100vh; height: 100dvh; overflow: hidden; }
body.photo-bg #app {
  position: fixed; top: 68px; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 760px; box-sizing: border-box; margin: 0;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  background: rgba(251,252,253,.74);
  -webkit-backdrop-filter: blur(14px) saturate(1.1); backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(213,222,230,.9); border-radius: 20px;
  box-shadow: 0 10px 40px rgba(28,43,58,.18);
  padding: 24px 32px 48px;
}
body.photo-bg .appbar .bar-btn, body.photo-bg .appbar .menu-btn { background: rgba(255,255,255,.92); }
body.photo-bg .appbar .brand { background: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 10px; }
body.photo-bg #app.wide { max-width: 1060px; }
/* Startseite: Box beginnt unter der Leiste, der Text bleibt auf seiner Hoehe */
body.photo-bg.view-home .home { padding-top: 0; }
/* Breite Fenster: Box beginnt auf Hoehe der Oberkante des Menueknopfs, wenn links genug Platz fuer die Knoepfe ist */
@media (min-width: 1400px) {
  body.photo-bg #app:not(.wide) { top: 12px; padding-top: 14px; }
}
@media (min-width: 1720px) {
  body.photo-bg #app.wide { top: 12px; padding-top: 14px; }
}
@media (max-width: 640px) {
  body.photo-bg::before { background-position: 44% 20%; }
  body.photo-bg #app { top: 64px; bottom: 8px; width: calc(100% - 16px); padding: 16px 16px 32px; border-radius: 16px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) body.photo-bg::before { filter: brightness(.55) saturate(.85); }
  :root:not([data-theme=light]) body.photo-bg::after { background: linear-gradient(180deg, rgba(18,24,31,.10), rgba(18,24,31,.55)); }
  :root:not([data-theme=light]) body.photo-bg #app { background: rgba(18,24,31,.72); border-color: rgba(44,56,68,.9); box-shadow: 0 10px 40px rgba(0,0,0,.45); }
  :root:not([data-theme=light]) body.photo-bg .appbar .bar-btn, :root:not([data-theme=light]) body.photo-bg .appbar .menu-btn { background: rgba(25,33,42,.92); }
  :root:not([data-theme=light]) body.photo-bg .appbar .brand { background: rgba(25,33,42,.85); }
}
:root[data-theme=dark] body.photo-bg::before { filter: brightness(.55) saturate(.85); }
:root[data-theme=dark] body.photo-bg::after { background: linear-gradient(180deg, rgba(18,24,31,.10), rgba(18,24,31,.55)); }
:root[data-theme=dark] body.photo-bg #app { background: rgba(18,24,31,.72); border-color: rgba(44,56,68,.9); box-shadow: 0 10px 40px rgba(0,0,0,.45); }
:root[data-theme=dark] body.photo-bg .appbar .bar-btn, :root[data-theme=dark] body.photo-bg .appbar .menu-btn { background: rgba(25,33,42,.92); }
:root[data-theme=dark] body.photo-bg .appbar .brand { background: rgba(25,33,42,.85); }
@media print {
  body.photo-bg::before, body.photo-bg::after { display: none; }
  body.photo-bg { height: auto; overflow: visible; }
  body.photo-bg #app { position: static; transform: none; width: auto; max-width: none; overflow: visible; background: none; border: 0; box-shadow: none; padding: 0; margin: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

.appbar .brand { white-space: nowrap; }
@media (max-width: 420px) { .appbar .brand { display: none; } }

/* Sprachauswahl als Dropdown mit Flaggen */
.lang-dd { position: relative; }
.lang-btn .chev { width: 18px; height: 18px; margin-inline-start: -2px; transition: transform .15s; }
.lang-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.flag { display: inline-flex; width: 26px; height: 18px; flex: none; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px rgba(28,43,58,.18); }
.flag svg { width: 100%; height: 100%; display: block; }
.lang-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 240px; max-height: min(70vh, 520px); overflow-y: auto;
  margin: 0; padding: 6px; list-style: none; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(28,43,58,.22); }
.lang-menu [role=option] { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--ink); }
.lang-menu [role=option]:hover { background: var(--primary-soft); }
.lang-menu [role=option]:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
.lang-menu [role=option][aria-selected="true"] { background: var(--primary-soft); }
.lang-menu .lname { flex: 1; }
.lang-menu .lvoice.off { color: var(--muted); display: inline-flex; }
.lang-menu .lvoice .icon, .lang-menu .lcheck { width: 20px; height: 20px; }
.lang-menu .lcheck { color: var(--primary); }
@media (max-width: 420px) { .lang-menu { min-width: min(280px, calc(100vw - 32px)); } }

.appbar { position: relative; z-index: 40; }

/* Zentrale Speicherung: Kontextleiste, Listen, Ergebnisse des Kindes */
.ctx-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 4px 0 12px; }
.ctx-bar label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.ctx-bar select { min-width: 140px; }
.ctx-school { font-weight: 700; }
.plain-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li .btn { margin-inline-start: auto; }
.school-list .school-item { display: block; padding: 0; }
.school-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.school-row span { flex: 1; }
.school-list .school-item:last-child > .school-row { border-bottom: 0; }
.admin-panel { background: var(--bg); border-radius: 8px; padding: 12px 14px; margin: 2px 0 6px; }
.admin-panel-inner strong { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.admin-panel .form-row { margin-top: 10px; }
.dev-users { list-style: none; padding: 0; display: grid; gap: 8px; }
.dev-users .btn { width: 100%; justify-content: flex-start; }
.tbl.assign td { text-align: center; }
.tbl.assign input { width: 20px; height: 20px; }
.login-card .btn { margin-top: 8px; }
.bar-split { justify-content: space-between; }
.res-list { list-style: none; margin: 8px 0 20px; padding: 0; display: grid; gap: 8px; }
.res-list li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--sheet); }
.res-name { font-weight: 700; }
.res-done { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 700; }
.res-part { color: var(--muted); }
.res-open { color: var(--muted); }
.res-score { font-weight: 700; }
@media (max-width: 560px) { .res-list li { grid-template-columns: auto 1fr; } .res-list li > span:nth-child(n+3) { grid-column: 2; } }
.device-line { margin: 0; font-weight: 700; }

/* Die Leiste liegt ueber der Textbox; nur ihre Knoepfe fangen Klicks ab. */
.appbar { pointer-events: none; }
.appbar > * { pointer-events: auto; }
/* Klassenfilter ueber Kindertabelle, Klassenuebersicht und Export */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.filter-row label { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-weight: 700; margin: 0; padding: 0; }
.tbl.kids .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
