:root {
  --bg: #120d17;
  --card: rgba(18, 13, 24, .78);
  --track: rgba(255, 255, 255, .055);
  --line: rgba(255, 255, 255, .09);
  --text: #eeeaf3;
  --muted: #aaa3b4;
  --dim: #716a7c;
  --red: #ef5b5b;
  --yellow: #f2c14e;
  --green: #5bd68a;
  --r: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(110% 55% at 0% 0%, #4b1c35 0%, transparent 60%),
    radial-gradient(90% 55% at 100% 8%, #29194a 0%, transparent 62%),
    radial-gradient(120% 70% at 50% 110%, #1b1130 0%, transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 1em; height: 1em; vertical-align: -0.14em; fill: currentColor; flex: none; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: #b38cff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Kopfzeile & Navigation ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(24, 19, 30, .86);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 19px; flex: 1; min-width: 0; }
.brand svg { font-size: 24px; }
.updated { font-size: 12px; color: var(--dim); white-space: nowrap; }
.icon-btn { background: none; border: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.icon-btn:active, .icon-btn:hover { background: var(--track); color: var(--text); }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 1100px; margin: 6px auto 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 10px 14px 12px; color: var(--muted); font-weight: 500;
  white-space: nowrap; border-bottom: 3px solid transparent; display: flex; align-items: center; gap: 8px;
}
.tab .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.tab.on { color: var(--text); border-bottom-color: var(--c, #fff); }

main { max-width: 1100px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.sec-title { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 500; margin: 26px 4px 14px; }
.sec-title:first-child { margin-top: 6px; }
.sec-title svg { font-size: 24px; }
.sec-title .sub { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 400; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card.tint { border: 2px solid color-mix(in srgb, var(--c) 45%, transparent); }
.empty { color: var(--muted); display: flex; align-items: center; gap: 12px; padding: 6px 4px; }
.empty svg { font-size: 26px; color: var(--green); }
.err { background: rgba(239, 91, 91, .12); border: 1px solid rgba(239, 91, 91, .35); color: #ffb4b4; border-radius: 14px; padding: 10px 14px; font-size: 14px; margin: 8px 0; }

/* ---------- Übersicht: Schulzeiten ---------- */
.day + .day { margin-top: 20px; }
.day-h { font-size: 15px; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px 4px; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; letter-spacing: .04em; padding: 3px 8px; border-radius: 99px; background: rgba(255, 255, 255, .1); color: var(--text); font-weight: 600; }
.badge.today { background: #b38cff; color: #1a1020; }
.row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 10px; margin-top: 8px; }
.row .who { font-size: 14px; font-weight: 700; letter-spacing: .05em; color: var(--c); text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trk { position: relative; height: 38px; border-radius: 10px; background: var(--track); overflow: hidden; }
.trk .label { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.trk .label.bad { color: #ff9c9c; }
.bar {
  position: absolute; top: 0; bottom: 0; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 32%, #1b1622);
  border-left: 4px solid var(--c);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums;
  white-space: nowrap; padding: 0 6px; gap: 6px;
}
.flag { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 99px; background: var(--yellow); color: #241a05; z-index: 1; }
.flag.cancel { background: var(--red); color: #fff; }

/* ---------- Listen (Änderungen, Hausaufgaben, Arbeiten) ---------- */
.list { padding: 6px 18px; }
.item { border-left: 4px solid var(--c); padding: 14px 0 14px 18px; margin-left: -2px; position: relative; }
.item + .item::before { content: ""; position: absolute; left: 10px; right: 0; top: 0; border-top: 1px solid var(--line); }
.item-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-weight: 600; font-size: 17px; }
.item-h .when { font-variant-numeric: tabular-nums; }
.pill { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 5px 11px; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.tag { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 8px; }
.tag.cancelled { background: rgba(239, 91, 91, .2); color: #ff9c9c; }
.tag.changed { background: rgba(242, 193, 78, .18); color: var(--yellow); }
.tag.soon { background: rgba(179, 140, 255, .2); color: #cdb4ff; }
.item-b { margin-top: 6px; color: #d6d0de; line-height: 1.45; white-space: pre-line; font-size: 15.5px; }
.item-b .muted { color: var(--muted); }
.item.done { opacity: .5; }

/* ---------- Wochenplan je Kind ---------- */
.week-nav { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin: -4px 0 10px; }
.week-nav .range { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }
.week-nav .today-btn { white-space: nowrap; border: 1px solid var(--line); background: none; border-radius: 99px; padding: 5px 12px; font-size: 13px; color: var(--muted); margin-right: auto; }
.week { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(142px, 1fr); gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin; }
.col { scroll-snap-align: start; min-width: 0; }
.col-h { padding: 0 4px 10px; border-bottom: 2px solid var(--line); margin-bottom: 10px; }
.col-h .wd { font-size: 17px; color: var(--muted); }
.col-h .dt { font-size: 28px; font-weight: 700; margin-top: 2px; }
.col-h .dt small { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.col.today .col-h { border-bottom-color: var(--c); }
.col.today .wd { color: var(--c); font-weight: 600; }
.stack { position: relative; }
.lesson {
  position: absolute; text-align: left; border: 0; border-left: 4px solid var(--c); border-radius: 10px; padding: 7px 9px;
  background: color-mix(in srgb, var(--c) 16%, #1a1520); overflow: hidden; display: flex; flex-direction: column; gap: 3px;
}
.lesson:active { filter: brightness(1.15); }
.lesson .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson .m { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.lesson .m.chg { color: var(--yellow); }
.lesson .n { font-size: 12.5px; color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson.st-cancelled { border-left-color: var(--red); background: rgba(239, 91, 91, .13); }
.lesson.st-cancelled .t { text-decoration: line-through; color: #ff9c9c; }
.lesson.st-cancelled .n { color: #ff9c9c; }
.lesson.st-changed { box-shadow: inset 0 0 0 1px rgba(242, 193, 78, .45); }
.free { border-left: 4px solid var(--c); border-radius: 10px; background: color-mix(in srgb, var(--c) 12%, #1a1520); padding: 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; line-height: 1.35; }
.free svg { font-size: 20px; color: var(--green); }

/* ---------- Bottom-Sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.sheet-card { position: relative; width: 100%; max-width: 520px; background: #1e1826; border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 24px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-card h3 { margin: 0 0 4px; font-size: 22px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; margin-top: 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv s { color: var(--dim); }

/* ---------- Formulare / Einrichtung ---------- */
.setup { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 36px) 16px 40px; }
.setup .logo { font-size: 46px; color: #cdb4ff; }
.setup h1 { font-size: 28px; margin: 10px 0 6px; font-weight: 600; }
.setup p.lead { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps span.on { background: #b38cff; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }
input.in { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); outline: none; font-size: 16px; }
input.in:focus { border-color: #b38cff; background: rgba(255, 255, 255, .08); }
.btn { border: 0; border-radius: 14px; padding: 14px 20px; font-weight: 600; background: #b38cff; color: #1a1020; width: 100%; margin-top: 20px; font-size: 16px; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 9px 14px; margin: 0; font-size: 14px; }
.btn.danger { background: rgba(239, 91, 91, .18); color: #ff9c9c; }
.link { background: none; border: 0; color: #cdb4ff; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.results { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.school { text-align: left; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); border-radius: 14px; padding: 12px 14px; }
.school:hover { border-color: #b38cff; }
.school b { display: block; font-weight: 600; }
.school span { font-size: 13px; color: var(--muted); }
.chosen { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: rgba(179, 140, 255, .08); }
.chosen div { flex: 1; min-width: 0; }
.chosen b { display: block; }
.chosen span { font-size: 13px; color: var(--muted); }
.hint { font-size: 13px; color: var(--dim); margin-top: 14px; line-height: 1.5; }
.kid { border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-top: 10px; background: rgba(255, 255, 255, .03); }
.kid-top { display: flex; align-items: center; gap: 10px; }
.kid-top input.in { padding: 10px 12px; }
.swatches { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; background: var(--c); padding: 0; }
.sw.on { border-color: #fff; }
.toggle { position: relative; width: 46px; height: 28px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .15s; }
.toggle span::after { content: ""; position: absolute; width: 22px; height: 22px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.toggle input:checked + span { background: #b38cff; }
.toggle input:checked + span::after { transform: translateX(18px); }
.acct { display: flex; align-items: center; gap: 12px; }
.acct div { flex: 1; min-width: 0; }
.acct b { display: block; }
.acct span { font-size: 13px; color: var(--muted); }

@media (min-width: 900px) {
  .ov-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0 24px; align-items: start; }
  .row { grid-template-columns: 96px 1fr; }
}
.icon-btn.on { color: var(--text); background: var(--track); }
.today-btn:disabled { opacity: .4; }

/* ---------- Nachrichten ---------- */
.msg-btn { position: relative; }
.nbadge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.nbadge[hidden] { display: none; }
.msg-banner { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; margin: 4px 0 6px; padding: 14px 16px; border-radius: var(--r); border: 1px solid rgba(179, 140, 255, .45); background: rgba(179, 140, 255, .12); }
.msg-banner > svg:first-child { font-size: 26px; color: #cdb4ff; }
.msg-banner > svg:last-child { font-size: 22px; color: var(--muted); }
.msg-banner span { flex: 1; min-width: 0; }
.msg-banner b { display: block; font-size: 16px; }
.msg-banner small { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item.msg { cursor: pointer; }
.item.msg.read .item-h { font-weight: 500; color: #d6d0de; }
.udot { width: 9px; height: 9px; border-radius: 50%; background: #b38cff; flex: none; }
.muted-ic { color: var(--muted); }
.msg-text { margin-top: 16px; white-space: pre-line; line-height: 1.5; max-height: 50vh; overflow-y: auto; color: #e3dee9; overflow-wrap: anywhere; }
.atts { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.atts span { color: var(--muted); font-size: 14px; }
.brand .bt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand .bt small { font-size: 12px; color: var(--dim); font-weight: 400; margin-top: 2px; }
.brand .bt small:empty { display: none; }

/* ---------- Familiencode ---------- */
.codebox { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px solid rgba(179, 140, 255, .4); background: rgba(179, 140, 255, .08); border-radius: 16px; padding: 14px 16px; }
.codebox .code { flex: 1; min-width: 0; white-space: nowrap; font-size: clamp(17px, 5.4vw, 24px); font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; user-select: all; }
.codebox .code.masked { color: var(--dim); }
.codebtns { display: flex; gap: 8px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 13px; margin: 26px 0 14px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.codebox .code { flex-basis: 100%; }
