/* Study — Oberfläche im Stil von iOS (Farben, Schrift und Abstände nach Apples Human Interface Guidelines).
   Hell/Dunkel: folgt dem Gerät; unter ⚙︎ „Darstellung“ fest einstellbar (data-theme auf <html>, thema.js). */
:root {
  color-scheme: light;
  --hg: #f2f2f7;                       /* systemGroupedBackground */
  --karte: #ffffff;                    /* secondarySystemGroupedBackground */
  --karte-2: #f2f2f7;                  /* tertiär: Felder in Karten */
  --text: #000000;
  --leise: rgba(60, 60, 67, .6);       /* secondaryLabel */
  --rand: rgba(60, 60, 67, .18);       /* separator */
  --fuellung: rgba(118, 118, 128, .12);/* tertiarySystemFill */
  --segment: #ffffff;
  --haupt: #007aff; --haupt-text: #ffffff; --haupt-zart: rgba(0, 122, 255, .12);
  --gut: #34c759; --schlecht: #ff3b30;
  --leiste: rgba(249, 249, 249, .8);
  --blatt: #f2f2f7;
  --schatten-segment: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --hg: #000000; --karte: #1c1c1e; --karte-2: #2c2c2e; --text: #ffffff;
  --leise: rgba(235, 235, 245, .6); --rand: rgba(84, 84, 88, .65); --fuellung: rgba(118, 118, 128, .24);
  --segment: #636366; --haupt: #0a84ff; --haupt-zart: rgba(10, 132, 255, .2);
  --gut: #30d158; --schlecht: #ff453a; --leiste: rgba(29, 29, 31, .8); --blatt: #1c1c1e;
  --schatten-segment: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --hg: #000000; --karte: #1c1c1e; --karte-2: #2c2c2e; --text: #ffffff;
    --leise: rgba(235, 235, 245, .6); --rand: rgba(84, 84, 88, .65); --fuellung: rgba(118, 118, 128, .24);
    --segment: #636366; --haupt: #0a84ff; --haupt-zart: rgba(10, 132, 255, .2);
    --gut: #30d158; --schlecht: #ff453a; --leiste: rgba(29, 29, 31, .8); --blatt: #1c1c1e;
    --schatten-segment: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--hg); }
body {
  margin: 0; background: var(--hg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  letter-spacing: -.01em; -webkit-font-smoothing: antialiased;
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
[hidden] { display: none !important; }
h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 8px; letter-spacing: -.02em; }
.leise { color: var(--leise); font-size: 15px; }
.fehler { color: var(--schlecht); font-size: 15px; }

.ansicht { min-height: 100vh; min-height: 100dvh; }
.inhalt { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); }

/* Anmelden */
.mitte { max-width: 420px; margin: 0 auto; padding: calc(14vh + env(safe-area-inset-top)) 16px 32px; text-align: center; }
.mitte h1 { font-size: 34px; font-weight: 700; letter-spacing: .01em; }
.mitte > .leise { margin: 4px 0 28px; }
.mitte .karte { text-align: left; }
.mitte button.haupt { width: 100%; margin-top: 4px; }
.mitte .logo { width: 76px; height: 76px; border-radius: 17px; margin: 0 auto 16px; display: block;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15); }

/* Navigationsleiste (durchscheinend wie in iOS) */
.leiste {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
  min-height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 4px 0;
  background: var(--leiste); border-bottom: .5px solid var(--rand);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.leiste > button:first-child { justify-self: start; }
.leiste > :last-child { justify-self: end; grid-column: 3; grid-row: 1; }
.leiste > h1, .leiste > .titel { grid-column: 2; grid-row: 1; justify-self: stretch; text-align: center; }
.leiste .titel { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.leiste .titel strong { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leiste .titel .leise { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.symbol { background: none; border: none; font-size: 28px; line-height: 1; padding: 0 10px; color: var(--haupt);
  min-width: 44px; min-height: 44px; border-radius: 0; font-weight: 400; }
.symbol:active { opacity: .4; }
.uhr { grid-column: 3; grid-row: 1; justify-self: end; margin-right: 48px; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 15px; padding: 3px 9px; border-radius: 8px; background: var(--fuellung); }
.uhr.knapp { color: var(--schlecht); }

/* Große Überschrift der Fächerliste */
.gross { font-size: 34px; font-weight: 700; letter-spacing: .01em; margin: 4px 4px 14px; }

/* Karten = gruppierte Abschnitte (inset grouped) */
.karte { display: block; width: 100%; background: var(--karte); border: none; border-radius: 12px; padding: 14px 16px;
  margin: 0 0 16px; color: inherit; font: inherit; text-align: left; }
button.karte { cursor: pointer; min-height: 0; }
button.karte:active { background: var(--karte-2); }
.karte.weiter { background: var(--haupt); color: #fff; }
.karte.weiter .leise { color: rgba(255, 255, 255, .8); }
.karte.weiter:active { opacity: .85; background: var(--haupt); }
.karte h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--leise); margin: 0 0 10px; }

/* Fächerliste als Liste mit Trennlinien und Pfeil */
#fach-liste { background: var(--karte); border-radius: 12px; overflow: hidden; margin: 0 0 16px; }
#fach-liste:empty { display: none; }
.fach-karte { position: relative; border-radius: 0; margin: 0; padding: 11px 36px 11px 16px; }
.fach-karte + .fach-karte::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--rand); }
.fach-karte::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -5px;
  border: solid var(--leise); border-width: 2px 2px 0 0; transform: rotate(45deg); opacity: .6; }
.fach-karte .zeile { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.fach-karte strong { font-weight: 400; }

/* Eingaben */
label { display: block; margin: 0 0 14px; font-size: 15px; color: var(--leise); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 17px; color: var(--text);
  background: var(--karte-2); border: none; border-radius: 10px; padding: 11px 12px; outline: none;
  -webkit-appearance: none; appearance: none;
}
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--karte-2); }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 2px var(--haupt-zart), inset 0 0 0 1px var(--haupt); }
select { background-image: linear-gradient(45deg, transparent 50%, var(--leise) 50%), linear-gradient(135deg, var(--leise) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
.karte textarea, #eingabe textarea { background: var(--karte); margin: 0 0 12px; }
::placeholder { color: var(--leise); opacity: .8; }
label.wahl { display: flex; gap: 12px; align-items: flex-start; color: var(--text); font-size: 17px; padding: 6px 0; }
label.wahl input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; border-radius: 50%; padding: 0;
  background: transparent; box-shadow: inset 0 0 0 2px var(--rand); }
label.wahl input:checked { box-shadow: inset 0 0 0 7px var(--haupt); }
label.wahl .leise { font-size: 13px; }

/* Knöpfe */
button { font: inherit; font-size: 17px; border-radius: 12px; border: none; background: var(--fuellung); color: var(--haupt);
  padding: 12px 16px; min-height: 50px; cursor: pointer; font-weight: 500; transition: opacity .15s, transform .1s; }
button:active { opacity: .6; }
button.haupt { background: var(--haupt); color: var(--haupt-text); font-weight: 600; }
button.gut { background: var(--gut); color: #fff; font-weight: 600; }
button.schlecht { background: var(--schlecht); color: #fff; font-weight: 600; }
button:disabled { opacity: .35; }
button.link { background: none; color: var(--haupt); padding: 4px 0; min-height: 0; font-weight: 400; }
#abmelden { color: var(--schlecht); width: 100%; background: var(--karte); }
.reihe { display: flex; flex-wrap: wrap; gap: 10px; }
.reihe > button { flex: 1 1 auto; }
.reihe:empty { display: none; }
#eingabe > .reihe { margin-bottom: 10px; }
.voll { width: 100%; }
.stapel { display: grid; gap: 10px; }

/* Text des Trainers */
.text { overflow-wrap: anywhere; line-height: 1.45; }
.text > :first-child, .rueckmeldung > :first-child { margin-top: 0; }
.text > :last-child, .rueckmeldung > :last-child { margin-bottom: 0; }
.text hr, .rueckmeldung hr { border: none; border-top: .5px solid var(--rand); margin: 14px 0; }
.text table, .rueckmeldung table, .zusatz table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 15px; margin: 8px 0; }
.text th, .text td, .rueckmeldung th, .rueckmeldung td, .zusatz th, .zusatz td { border: .5px solid var(--rand); padding: 5px 8px; vertical-align: top; }
.text blockquote, .rueckmeldung blockquote, .zusatz blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--rand); color: var(--leise); }
.math.block { overflow-x: auto; }
.rueckmeldung { box-shadow: inset 4px 0 0 var(--haupt); }
.zusatz { box-shadow: inset 4px 0 0 var(--gut); }
.zusatz h3 { font-size: 13px; font-weight: 400; margin: 0 0 6px; color: var(--leise); text-transform: uppercase; letter-spacing: .02em; }

/* Antwortoptionen */
.optionen { display: grid; gap: 10px; margin: 0 0 14px; }
.option { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 13px 14px; border-radius: 12px;
  background: var(--karte); color: var(--text); font-weight: 400; min-height: 0; box-shadow: inset 0 0 0 2px transparent; }
.option:active { opacity: 1; background: var(--karte-2); }
.option .nr { flex: none; width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--rand);
  display: grid; place-items: center; font-weight: 600; font-size: 15px; color: var(--leise); }
.option .ot p { margin: 0; }
.option.gewaehlt { background: var(--haupt-zart); box-shadow: inset 0 0 0 2px var(--haupt); }
.option.gewaehlt .nr { background: var(--haupt); box-shadow: none; color: #fff; }

.punkte { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 22px; margin: 6px 0 12px; }
.punkte button { width: 52px; font-size: 24px; padding: 0; }
.punkte input { width: 84px; text-align: center; display: inline-block; margin: 0; }

/* Blatt (Sheet von unten, mit Griff) */
.blatt-hg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; animation: einblenden .2s ease-out; }
.blatt { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 90vh; overflow-y: auto; background: var(--blatt);
  border-radius: 14px 14px 0 0; padding: 22px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 680px; margin: 0 auto;
  animation: hochfahren .32s cubic-bezier(.2, .9, .3, 1); }
.blatt::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px;
  border-radius: 3px; background: var(--leise); opacity: .5; }
.blatt h2 { margin-bottom: 2px; font-size: 22px; font-weight: 700; }
.blatt .stapel > button:not(.haupt) { background: var(--karte); }
.blatt .gruppe { margin: 18px 0 0; }
.blatt .gruppe > .leise { margin: 0 0 6px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
.blatt select { background-color: var(--karte); }
.blatt .gruppe > .voll { background: var(--karte); }
@keyframes hochfahren { from { transform: translateY(100%); } to { transform: none; } }
@keyframes einblenden { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .blatt, .blatt-hg { animation: none; } }

/* Segment-Umschalter (wie UISegmentedControl) */
.chips { display: flex; gap: 2px; margin: 0 0 8px; padding: 2px; border-radius: 9px; background: var(--fuellung); }
.chips button { flex: 1; min-height: 32px; padding: 5px 8px; border-radius: 7px; background: transparent; color: var(--text);
  font-size: 13px; font-weight: 500; }
.chips button:active { opacity: .6; }
.chips button.an { background: var(--segment); font-weight: 600; box-shadow: var(--schatten-segment); }

.laden { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--leiste); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 999px;
  padding: 4px 16px; font-size: 15px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); }
.hinweis { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--leiste); color: var(--text); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: 14px; padding: 13px 16px; max-width: 640px; margin: 0 auto; font-size: 15px; box-shadow: 0 8px 30px rgba(0, 0, 0, .2); }
#zusatz input + button { margin-top: 10px; }
