/* ==========================================================================
   Schulmanager – Design
   ========================================================================== */
:root {
  --bg: #f4f5fb; --card: #ffffff; --card-2: #f8f9fd; --text: #1c2233; --muted: #687086; --line: #e4e7f0;
  --pri: #5b5bd6; --pri-h: #4a49c2; --pri-soft: #ecedfd; --on-pri: #fff;
  --ok: #1a8f58; --ok-soft: #e1f5ea; --warn: #b26a00; --warn-soft: #fdf0d9;
  --bad: #cf3b48; --bad-soft: #fde7e9; --info: #2474cc; --info-soft: #e2eefb;
  --ev-ferien: #2fa567; --ev-feiertag: #e5484d; --ev-pruefung: #f08a1c; --ev-ausflug: #2f8fe8; --ev-sonstiges: #8b8fa3;
  --radius: 16px; --radius-s: 10px;
  --shadow: 0 1px 2px rgba(22, 28, 60, .05), 0 8px 24px rgba(22, 28, 60, .06);
  --side-w: 248px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #11131b; --card: #1a1d29; --card-2: #212536; --text: #e9ebf3; --muted: #9aa2b8; --line: #2c3144;
  --pri: #8a8af2; --pri-h: #a0a0f6; --pri-soft: #272a4d; --on-pri: #12142a;
  --ok: #4fd08f; --ok-soft: #163526; --warn: #f1b04c; --warn-soft: #3a2c12;
  --bad: #ff7b86; --bad-soft: #401c21; --info: #6db3f7; --info-soft: #172c44;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -.02em; text-wrap: balance; }
h3 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
a { color: var(--pri); }
code { background: var(--card-2); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
.ic { width: 1.25em; height: 1.25em; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: .6rem 0; }

/* ---------- Formularelemente ---------- */
input, select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--card); min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
input:disabled { opacity: .5; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--pri); }
input[type="color"] { width: 44px; height: 36px; min-height: 0; padding: 2px; }
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; min-height: 42px; min-width: 0; max-width: 100%; line-height: 1.4; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.4em; }
label { min-width: 0; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { font-weight: 400; color: var(--text); font-size: 15px; }
label.check { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; color: var(--text); }
label.inline { flex-direction: row; align-items: center; gap: .6rem; }
label.inline select { width: auto; min-width: 180px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.field > label { margin-bottom: .3rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw:hover { transform: scale(1.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem .95rem;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); color: var(--text);
  font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--pri) 40%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
.btn.pri:hover { background: var(--pri-h); border-color: var(--pri-h); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: transparent; }
.btn.danger.ghost:hover { background: var(--bad-soft); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none; border: 1px solid transparent; border-radius: var(--radius-s);
  background: transparent; color: var(--muted); padding: 0;
}
.icon-btn:hover { background: var(--pri-soft); color: var(--pri); }
.icon-gap { width: 38px; flex: none; }

.badge {
  display: inline-flex; align-items: center; padding: .15rem .6rem; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--line); color: var(--muted); font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge.ok, .seg-b.ok.on, .m-c.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn, .seg-b.warn.on, .m-c.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad, .seg-b.bad.on, .m-c.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info, .seg-b.info.on, .m-c.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2.4rem; padding: .15rem .5rem; border-radius: 8px; flex: none;
  font-size: .78rem; font-weight: 700; color: color-mix(in srgb, var(--c) 75%, var(--text)); background: color-mix(in srgb, var(--c) 16%, var(--card));
}
.av {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; color: #fff;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em;
}
.av.sm { width: 28px; height: 28px; font-size: .68rem; }
.av.xl { width: 84px; height: 84px; font-size: 1.7rem; }
.note { padding: .7rem .9rem; border-radius: var(--radius-s); font-size: .92rem; margin-bottom: .8rem; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.inset { margin: 0 1rem .8rem; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; display: inline-block; background: var(--ev-sonstiges); }
.dot.ferien { background: var(--ev-ferien); } .dot.feiertag { background: var(--ev-feiertag); }
.dot.pruefung { background: var(--ev-pruefung); } .dot.ausflug { background: var(--ev-ausflug); }

/* ---------- Grundlayout ---------- */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }
#side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem .8rem;
  background: var(--card); border-right: 1px solid var(--line); z-index: 30; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .5rem .6rem; }
.brand strong { display: block; line-height: 1.2; }
.brand span { font-size: .8rem; color: var(--muted); }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .6rem .75rem; border: 0; border-radius: var(--radius-s);
  background: transparent; color: var(--muted); font-weight: 600; text-decoration: none; text-align: left;
}
.nav-item:hover { background: var(--card-2); color: var(--text); }
.nav-item.on { background: var(--pri-soft); color: var(--pri); }
.nav-item span:empty { display: none; }
.nav-item > span:first-child:not(:last-child) { display: inline-flex; }
.side-foot { border-top: 1px solid var(--line); padding-top: .6rem; display: flex; flex-direction: column; gap: 2px; }
#scrim { display: none; }
#main { flex: 1; min-width: 0; margin-left: var(--side-w); }
#top { display: none; }
#view { padding: 1.8rem clamp(1rem, 3vw, 2.4rem) 3rem; max-width: 1280px; margin: 0 auto; outline: none; }
.view-in { display: flex; flex-direction: column; gap: 1.1rem; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.vh { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.vh p { color: var(--muted); margin-top: .2rem; }
.vh-act { display: flex; gap: .5rem; flex-wrap: wrap; }
.loading { height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--pri), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: load 1s linear infinite; }
@keyframes load { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem; display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card > .btn { align-self: flex-start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .7rem 1rem; flex-wrap: wrap; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.toolbar.bare { padding: 0; border: 0; }
.stepper { display: flex; align-items: center; gap: .3rem; }
.stepper input[type="date"] { width: auto; }
.step-label { min-width: 5.5rem; text-align: center; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.search { flex-direction: row; align-items: center; gap: .5rem; flex: 1; max-width: 340px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); }
.search input { border: 0; padding-left: 0; box-shadow: none !important; background: transparent; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; align-self: flex-start; }
.tab { border: 0; background: transparent; padding: .4rem 1rem; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tab.on { background: var(--pri-soft); color: var(--pri); }
.empty { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 2.2rem 1rem; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }

/* ---------- Tabellen ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .65rem 1rem; background: var(--card-2); white-space: nowrap; }
.tbl td { padding: .6rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl.click tbody tr { cursor: pointer; }
.tbl.click tbody tr:hover { background: var(--card-2); }
.tbl .num, .tbl.center th:not(:first-child), .tbl.center td:not(:first-child) { text-align: center; }
.tbl td.num:last-child, .tbl th.num:last-child { text-align: right; }
.who { display: flex; align-items: center; gap: .7rem; min-width: 0; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li + li { border-top: 1px solid var(--line); }
.ev-row, .lesson, .jr { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; }
.l-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.l-main strong { overflow-wrap: anywhere; }
.l-main small { color: var(--muted); overflow-wrap: anywhere; }
.ev-row.click, .jr { cursor: pointer; border-radius: 8px; }
.ev-row.click:hover, .jr:hover { background: var(--card-2); }
.ev-row.past { opacity: .55; }

/* ---------- Übersicht ---------- */
.hero { padding: 1.4rem 1.5rem; border-radius: var(--radius); color: #fff; background: linear-gradient(120deg, #6a5df0, #4f7be8 60%, #38a3d8); box-shadow: var(--shadow); }
.hero p { opacity: .9; margin-top: .25rem; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.tile { display: flex; flex-direction: column; gap: .1rem; padding: 1rem 1.1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--muted); font-size: .88rem; transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--pri) 45%, var(--line)); }
.tile strong { font-size: 1.7rem; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }
.tile-ic { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--pri-soft); color: var(--pri); margin-bottom: .5rem; }
.l-time { width: 3rem; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.l-bar { width: 4px; align-self: stretch; border-radius: 4px; }
.lesson.live { background: var(--pri-soft); margin: 0 -.6rem; padding-inline: .6rem; border-radius: 10px; border-top-color: transparent !important; }
.picker { align-items: center; text-align: center; }
.picker h3 { align-self: flex-start; }
.picker > .btn { align-self: center; }
.pick-stage { min-height: 150px; display: grid; place-items: center; width: 100%; }
.pick { display: flex; flex-direction: column; align-items: center; gap: .6rem; font-size: 1.2rem; }
.pick.final { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.7); } }

/* ---------- Fächer ---------- */
.subj { flex-direction: row; align-items: center; text-align: left; cursor: pointer; transition: transform .15s, border-color .15s; }
.subj:hover { transform: translateY(-2px); border-color: var(--c); }
.subj-badge { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: .85rem; color: #fff; background: var(--c); }

/* ---------- Stundenplan ---------- */
.tt { width: 100%; min-width: 660px; border-collapse: separate; border-spacing: 6px; padding: .5rem; table-layout: fixed; }
.tt thead th { font-size: .82rem; color: var(--muted); padding: .3rem; }
.tt thead th:first-child { width: 78px; }
.tt thead th.today { color: var(--pri); }
.tt-time { text-align: center; font-weight: 400; }
.tt-time b { display: block; font-size: 1.05rem; }
.tt-time span { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.tt td { padding: 0; height: 1px; }
.tt-cell {
  width: 100%; height: 100%; min-height: 64px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding: .45rem .65rem;
  border: 0; border-left: 4px solid var(--c); border-radius: 10px; background: color-mix(in srgb, var(--c) 13%, var(--card)); text-align: left; transition: filter .15s, transform .1s;
}
.tt-cell:hover { filter: brightness(.96); transform: scale(1.02); }
.tt-cell b { color: color-mix(in srgb, var(--c) 70%, var(--text)); font-size: .78rem; }
.tt-cell span { font-weight: 600; font-size: .9rem; line-height: 1.25; overflow-wrap: anywhere; }
.tt-cell small { color: var(--muted); font-size: .75rem; }
.tt-cell.empty { border: 1px dashed var(--line); background: transparent; align-items: center; color: var(--muted); }
.tt-cell.empty .tt-plus { opacity: 0; }
.tt-cell.empty:hover .tt-plus, .tt-cell.empty:focus-visible .tt-plus { opacity: 1; }
.tt tr.pause td { height: var(--h, auto); line-height: 1; text-align: center; font-size: .72rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; padding: .1rem; }

.tt tr.pause td span { display: inline-block; }
.tt tr.pause.lunch td { background: var(--card-2); border-radius: 10px; font-weight: 600; }

/* ---------- Anwesenheit ---------- */
.sum { display: flex; flex-wrap: wrap; gap: .4rem; padding: .8rem 1rem; }
.att-row { display: grid; grid-template-columns: minmax(170px, 1.2fr) auto minmax(120px, 1fr); align-items: center; gap: .8rem; padding: .55rem 1rem; border-top: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg-b { border: 0; background: transparent; padding: .4rem .7rem; font-size: .82rem; font-weight: 600; color: var(--muted); min-height: 36px; }
.seg-b + .seg-b { border-left: 1px solid var(--line); }
.seg-b:hover { background: var(--card-2); }
.seg-b .sm { display: none; }
.att-note { min-height: 36px; padding: .35rem .6rem; }
.matrix { border-collapse: collapse; width: 100%; font-size: .8rem; }
.matrix th, .matrix td { border: 1px solid var(--line); text-align: center; padding: 0; min-width: 24px; height: 30px; }
.matrix thead th { font-weight: 600; padding: .2rem 0; line-height: 1.15; background: var(--card-2); }
.matrix thead small { display: block; font-size: .62rem; color: var(--muted); font-weight: 400; }
.matrix .m-name { text-align: left; padding: 0 .7rem; white-space: nowrap; font-weight: 600; position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 150px; }
.matrix thead .m-name { background: var(--card-2); }
.matrix td button { width: 100%; height: 30px; border: 0; background: transparent; padding: 0; display: grid; place-items: center; }
.matrix td button:hover { background: var(--pri-soft); }
.matrix .we, .matrix .fr { background: var(--card-2); }
.matrix .fr { background: color-mix(in srgb, var(--ev-ferien) 12%, var(--card)); }
.matrix th.today { color: var(--pri); box-shadow: inset 0 -2px 0 var(--pri); }
.m-c { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; font-style: normal; font-weight: 700; font-size: .72rem; }
.m-sum { font-weight: 700; }
.legend .m-c { margin-right: .1rem; }

/* ---------- Sitzplan ---------- */
.seat-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1rem; }
.room { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; min-width: 0; }
.board { margin: 0 auto .6rem; width: min(60%, 420px); padding: .35rem; text-align: center; border-radius: 8px; background: #2f5d50; color: #e8f3ee; font-weight: 700; letter-spacing: .25em; text-transform: uppercase; font-size: .78rem; }
.teacher { margin: 0 auto 1.2rem; width: 150px; padding: .35rem; text-align: center; border-radius: 8px; border: 1px dashed var(--muted); color: var(--muted); font-size: .78rem; }
.teacher.links { margin-left: 0; }
.teacher.rechts { margin-right: 0; }
.room-scroll { overflow-x: auto; }
.room-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(62px, 1fr)); gap: 8px; }
.room-grid.einzel { gap: 22px 26px; }
.desk, .cell-add, .cell-none { min-height: 86px; border-radius: 12px; }
.desk { position: relative; background: var(--card); border: 2px solid var(--line); display: grid; padding: 3px; transition: border-color .12s, background .12s, transform .12s; }
.desk.over { border-color: var(--pri); background: var(--pri-soft); transform: scale(1.04); }
.seat {
  display: flex; align-items: center; gap: .45rem; padding: .3rem .45rem; border-radius: 9px; background: var(--card); min-width: 0;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; font-weight: 600; font-size: .84rem; line-height: 1.15;
}
.seat > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; }
.desk .seat { flex-direction: column; justify-content: center; gap: .25rem; padding: .35rem .15rem; text-align: center; font-size: .8rem; }
.desk .seat > span:last-child { width: 100%; }
.desk .seat:hover { background: var(--card-2); }
.seat.dragging { opacity: .35; }
.seat.ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); border: 2px solid var(--pri); cursor: grabbing; }
body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.pool { background: var(--card-2); border: 2px dashed var(--line); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .7rem; min-height: 96px; transition: border-color .12s, background .12s; }
.pool.over { border-color: var(--pri); background: var(--pri-soft); }
.pool h3 { justify-content: flex-start; }
.pool-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.pool .seat { min-width: 150px; }
.pool .seat { border: 1px solid var(--line); }
.editing .desk { cursor: pointer; border-style: dashed; }
.editing .desk:hover { border-color: var(--bad); }
.editing .seat { cursor: pointer; pointer-events: none; }
.desk-x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-size: .6rem; }
.cell-add { border: 2px dashed var(--line); background: transparent; color: var(--muted); display: grid; place-items: center; opacity: .6; }
.cell-add:hover { opacity: 1; border-color: var(--pri); color: var(--pri); }

/* ---------- Klassenbuch ---------- */
.days { display: flex; flex-direction: column; gap: .9rem; }
.day > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.day > header > div { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.day.is-today { border-color: var(--pri); }
.jr { align-items: flex-start; padding: .6rem .4rem; }
.jr-p { width: 1.6rem; flex: none; font-weight: 700; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.jr-by { align-self: center; }
.abs-line { font-size: .85rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: .6rem; }

/* ---------- Kalender ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 1.1rem; align-items: start; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.3rem 1.5rem; }
.month h4 { font-size: .92rem; margin-bottom: .4rem; }
.month h4 span { color: var(--muted); font-weight: 400; }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mgrid b { font-size: .66rem; font-weight: 600; color: var(--muted); text-align: center; padding-bottom: .15rem; }
.cd { aspect-ratio: 1; display: grid; place-items: center; border: 0; padding: 0; border-radius: 8px; background: transparent; font-size: .8rem; font-variant-numeric: tabular-nums; }
button.cd:hover { box-shadow: inset 0 0 0 2px var(--pri); }
.cd.we { color: var(--muted); }
.cd.ferien { background: color-mix(in srgb, var(--ev-ferien) 24%, var(--card)); color: var(--text); }
.cd.feiertag { background: color-mix(in srgb, var(--ev-feiertag) 24%, var(--card)); color: var(--text); }
.cd.pruefung { background: color-mix(in srgb, var(--ev-pruefung) 30%, var(--card)); color: var(--text); }
.cd.ausflug { background: color-mix(in srgb, var(--ev-ausflug) 26%, var(--card)); color: var(--text); }
.cd.sonstiges { background: color-mix(in srgb, var(--ev-sonstiges) 28%, var(--card)); color: var(--text); }
.cd.today { box-shadow: inset 0 0 0 2px var(--pri); font-weight: 800; color: var(--pri); }

/* ---------- Noten ---------- */
.grades { display: flex; flex-wrap: wrap; gap: .3rem; }
.g { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 .35rem; border-radius: 8px; border: 2px solid transparent; font-weight: 700; font-size: .88rem; background: var(--card-2); color: var(--text); }
button.g:hover { filter: brightness(.94); }
.g.heavy { border-color: currentColor; }
.g.soft { font-weight: 600; font-size: .82rem; }
.g1 { background: var(--ok-soft); color: var(--ok); }
.g2 { background: color-mix(in srgb, var(--ok-soft) 55%, var(--info-soft)); color: color-mix(in srgb, var(--ok) 55%, var(--info)); }
.g3 { background: var(--info-soft); color: var(--info); }
.g4 { background: var(--warn-soft); color: var(--warn); }
.g5, .g6 { background: var(--bad-soft); color: var(--bad); }

/* ---------- Einstellungen ---------- */
.periods { display: flex; flex-direction: column; gap: .4rem; }
.period { display: flex; align-items: center; gap: .5rem; }
.period input { max-width: 130px; }

/* ---------- Dialoge & Meldungen ---------- */
.dlg { border: 0; padding: 0; border-radius: 20px; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); box-shadow: 0 24px 70px rgba(10, 14, 40, .35); }
.dlg::backdrop { background: rgba(16, 20, 40, .5); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlg .18s ease-out; }
@keyframes dlg { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg-in { padding: 1.3rem; display: flex; flex-direction: column; gap: 1rem; }
.dlg:has(.small) { width: min(420px, calc(100vw - 1.5rem)); }
.dlg-in > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dlg-in h3 { font-size: 1.15rem; }
.dlg-in footer { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.dlg-in footer > div { display: flex; gap: .6rem; margin-left: auto; }
.dlg-in .note { margin: 0; }
.menu-list { display: flex; flex-direction: column; gap: .4rem; }
.menu-item { display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card); text-align: left; font-weight: 600; }
.menu-item:hover { border-color: var(--pri); background: var(--pri-soft); color: var(--pri); }
#toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; align-items: center; z-index: 2000; pointer-events: none; }
.toast { padding: .6rem 1.1rem; border-radius: 999px; background: #1c2233; color: #fff; font-weight: 600; font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: fade .2s ease-out; transition: opacity .3s; max-width: 90vw; text-align: center; }
.toast.bad { background: #c9323f; border-radius: 14px; }
.toast.out { opacity: 0; }

/* ---------- Anmeldung & Installation ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.2rem; background: radial-gradient(1200px 600px at 10% -10%, #dfe1ff, transparent), radial-gradient(900px 500px at 110% 110%, #d8eefb, transparent), var(--bg); }
[data-theme="dark"] .auth-page { background: var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 1.8rem; display: flex; flex-direction: column; gap: 1.1rem; }
.auth-card.wide { width: min(640px, 100%); }
.auth-card h2 { font-size: 1rem; margin-top: .6rem; }
.brand-big { display: flex; align-items: center; gap: .9rem; }
.brand-big h1 { font-size: 1.45rem; line-height: 1.2; }
.brand-big p { color: var(--muted); }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }

/* ---------- Arbeitsblätter ---------- */
.sheet-card { text-align: left; cursor: pointer; align-items: flex-start; gap: .5rem; transition: transform .15s, border-color .15s; }
.sheet-card:hover { transform: translateY(-2px); border-color: var(--pri); }
.sheet-card strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.badge.k-uebung { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.k-test { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.k-schularbeit { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.gen { background: var(--pri-soft); border-radius: var(--radius-s); padding: .7rem .8rem; }
.gen > label { color: var(--pri); }
.gen-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.gen-row select { flex: 1 1 220px; min-width: 0; }
.gen-row input { width: 76px; }
.res-list { display: flex; flex-direction: column; max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.res-row { flex-direction: row; align-items: center; gap: .7rem; padding: .35rem .7rem; font-weight: 400; color: var(--text); font-size: .95rem; }
.res-row + .res-row { border-top: 1px solid var(--line); }
.res-row > span:first-child { flex: 1; min-width: 0; }
.res-row input[type="checkbox"] { width: 18px; flex: none; }
.res-row input[type="number"] { width: 92px; min-height: 36px; padding: .3rem .5rem; }

/* Das Blatt selbst: sieht am Bildschirm und im Druck gleich aus (immer „Papier“, auch im Dunkelmodus) */
.paper {
  --muted: #667; --pri: #5b5bd6; --pri-soft: #ecedfd; color-scheme: light;
  background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow);
  padding: clamp(1rem, 4.5vw, 3rem); width: 100%; max-width: 860px; margin: 0 auto;
}
.ws { font-size: 11.5pt; line-height: 1.45; color: #111; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
.ws-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .8em; color: #444; border-bottom: 1px solid #999; padding-bottom: .3em; }
.ws h1 { font-size: 1.6em; line-height: 1.2; margin: .55em 0 .1em; letter-spacing: -.01em; }
.ws-meta { color: #333; font-size: .9em; }
.ws-name { display: flex; flex-wrap: wrap; gap: .7em 2em; margin: 1.3em 0 1.1em; }
.ws-name u, .ws-blank, .ws-gap { display: inline-block; height: 1.15em; border-bottom: 1px solid #111; text-decoration: none; vertical-align: bottom; }
.ws-name u { min-width: 15em; } .ws-name u.mid { min-width: 7em; } .ws-name u.short { min-width: 3.2em; }
.ws-intro { border: 1px solid #999; border-radius: 4px; padding: .5em .8em; margin-bottom: 1em; white-space: pre-wrap; font-size: .92em; }
.ws-empty { color: #667; text-align: center; padding: 2.5em 0; }
.ws-task { position: relative; margin: 1.25em 0; break-inside: avoid; }
.ws-task.editable { cursor: pointer; border-radius: 6px; outline: 1px dashed transparent; outline-offset: 6px; }
.ws-task.editable:hover, .ws-task.editable:focus-visible { outline-color: #5b5bd6; background: #fafaff; }
.ws-tools { position: absolute; top: -1.9em; right: -2px; z-index: 2; display: flex; gap: 1px; padding: 2px; background: #fff; border: 1px solid #d6d9e6; border-radius: 10px; box-shadow: 0 4px 14px rgba(20, 25, 50, .12); opacity: 0; pointer-events: none; transition: opacity .12s; }
.ws-task:hover .ws-tools, .ws-task:focus-within .ws-tools { opacity: 1; pointer-events: auto; }
.ws-tools .icon-btn { width: 30px; height: 30px; }
.ws-th { display: flex; gap: .5em; align-items: baseline; font-weight: 600; margin-bottom: .55em; }
.ws-th span { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-th em { font-style: normal; font-weight: 400; font-size: .88em; white-space: nowrap; }
.ws-h { display: block; font-size: 1.15em; border-bottom: 2px solid #111; padding-bottom: .15em; margin: 0; }
.ws-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-sol { color: #0b7a3e; font-weight: 700; }
.ws-calc { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 1em 1.6em; }
.ws-ci { display: flex; gap: .45em; break-inside: avoid; }
.ws-ci > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ws-l { color: #444; min-width: 1.4em; }
.ws-blank { min-width: 4.5em; }
.ws-line { height: 2em; border-bottom: 1px solid #111; }
.ws-grid, .ws-lines.kariert { border: 1px solid #9aa7b8; background-image: linear-gradient(#c9d3df 1px, transparent 1px), linear-gradient(90deg, #c9d3df 1px, transparent 1px); background-size: 5mm 5mm; background-position: -1px -1px; }
.ws-grid { margin-top: .45em; } .ws-grid.s1 { height: 20mm; } .ws-grid.s2 { height: 40mm; }
.ws-lines { height: calc(var(--n) * 9mm); }
.ws-lines.liniert { background-image: linear-gradient(transparent calc(9mm - 1px), #555 calc(9mm - 1px)); background-size: 100% 9mm; }
.ws-box { display: flex; flex-wrap: wrap; gap: .3em 1.4em; border: 1px solid #999; border-radius: 4px; padding: .4em .8em; margin-bottom: .7em; }
.ws-gaptext { line-height: 2.15; white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-gap.ws-sol { height: auto; border-bottom-color: #0b7a3e; padding: 0 .3em; }
.ws-opts { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: .4em 1.5em; }
.ws-cb { display: inline-grid; place-items: center; width: 1.15em; height: 1.15em; border: 1.5px solid #111; border-radius: 2px; margin-right: .55em; vertical-align: -.2em; font-size: .9em; font-weight: 700; line-height: 1; color: #0b7a3e; }
.ws-tf { width: 100%; border-collapse: collapse; }
.ws-tf th { font-size: .8em; font-weight: 600; width: 4.2em; text-align: center; }
.ws-tf td { padding: .35em 0; border-bottom: 1px dotted #999; }
.ws-tf td + td { text-align: center; } .ws-tf td + td .ws-cb { margin: 0; }
.ws-match { display: grid; grid-template-columns: 1fr 1fr; gap: .55em 2.5em; }
.ws-foot { margin-top: 2.2em; break-inside: avoid; }
.ws-key { border-collapse: collapse; font-size: .82em; }
.ws-key th, .ws-key td { border: 1px solid #777; padding: .25em .7em; text-align: center; font-weight: 400; }
.ws-key th:first-child, .ws-key td:first-child { font-weight: 700; text-align: left; }
.ws-sign { display: flex; gap: 2.5em; margin-top: 3em; }
.ws-sign span { flex: 1; border-top: 1px solid #111; padding-top: .3em; font-size: .8em; text-align: center; }
.fr { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; font-size: .86em; line-height: 1.12; margin: 0 .12em; }
.fr i { font-style: normal; padding: 0 .22em; } .fr i:first-child { border-bottom: 1px solid currentColor; }
@media (hover: none) {
  .ws-tools { position: static; opacity: 1; pointer-events: auto; width: max-content; margin: 0 0 .3em auto; box-shadow: none; }
}
@media (max-width: 640px) {
  .ws { font-size: 10.5pt; }
  .ws-calc { grid-template-columns: repeat(min(var(--cols), 2), minmax(0, 1fr)); }
  .ws-match { gap: .5em 1em; }
}
@media print {
  #print-area .ws { font-size: 11.5pt; }
  .p-break { break-after: page; }
}

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  #side { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  body.nav-open #side { transform: none; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; background: rgba(16, 20, 40, .45); z-index: 25; }
  #main { margin-left: 0; }
  #top { display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 20; padding: .5rem .8rem; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  #view { padding-top: 1.2rem; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  h2 { font-size: 1.3rem; }
  .hide-sm { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > * { grid-column: 1 / -1; }
  .tbl th, .tbl td { padding-inline: .7rem; }
  .att-row { grid-template-columns: 1fr auto; }
  .att-note { grid-column: 1 / -1; }
  .seg-b .lg { display: none; }
  .seg-b .sm { display: inline; }
  .seg-b { min-width: 40px; min-height: 40px; }
  .vh-act .btn span { display: none; }
  .vh-act .btn.pri span { display: inline; }
  .months { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
  .seat-wrap { padding: .6rem; }
  .room { padding: .6rem; }
  .dlg-in footer > div { flex: 1; }
  .dlg-in footer > div .btn { flex: 1; }
}
/* Touch-Geräte: ab 16px Schrift zoomt Safari beim Antippen eines Feldes nicht mehr hinein */
@media (hover: none) {
  input, select, textarea, label > input, label > select, label > textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Druck (DIN A4)
   ========================================================================== */
#print-area { display: none; }
@media print {
  html, body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; --text: #000; --muted: #444; --line: #999; --card: #fff; --card-2: #eee; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; border-bottom: 2px solid #000; padding-bottom: 3mm; margin-bottom: 5mm; }
  .p-head h1 { font-size: 17pt; line-height: 1.2; }
  .p-right { text-align: right; font-size: 9pt; }
  .p-table { width: 100%; border-collapse: collapse; }
  .p-table th, .p-table td { border: 1px solid #777; padding: 1.6mm 2.2mm; text-align: left; vertical-align: top; }
  .p-table th { background: #e9e9ee; font-size: 9pt; }
  .p-table tr { break-inside: avoid; }
  .p-table thead { display: table-header-group; }
  .p-table.checklist td { height: 8.5mm; }
  .p-table.checklist th:nth-child(n+3) { width: 7%; }
  .p-table.p-center th:not(:first-child), .p-table.p-center td:not(:first-child) { text-align: center; }
  .p-table.p-jr td { height: 8mm; }
  .p-table.p-jr th:nth-child(1) { width: 8%; } .p-table.p-jr th:nth-child(2) { width: 16%; } .p-table.p-jr th:nth-child(3) { width: 34%; }
  .p-legend { margin-top: 3mm; font-size: 9pt; color: #333; }
  .p-day { break-inside: avoid; margin-bottom: 5mm; }
  .p-day h2 { font-size: 11.5pt; margin-bottom: 1.5mm; }
  .p-sign { display: flex; justify-content: space-between; margin-top: 16mm; }
  .p-sign span { width: 42%; border-top: 1px solid #000; padding-top: 1.5mm; font-size: 9pt; text-align: center; }

  .p-tt { min-width: 0; width: 100%; border-collapse: collapse; border-spacing: 0; padding: 0; table-layout: fixed; }
  .p-tt th, .p-tt td { border: 1px solid #777; }
  .p-tt thead th { color: #000; font-size: 11pt; padding: 2.5mm; background: #e9e9ee; }
  .p-tt thead th:first-child { width: 26mm; }
  .p-tt .tt-time { padding: 1.5mm; }
  .p-tt .tt-time span { color: #000; font-size: 8.5pt; }
  .p-tt td.tt-p { height: 19mm; padding: 1.5mm 2.5mm; vertical-align: middle; }
  .p-tt td.tt-p[style] { border-left: 2.2mm solid var(--c); }
  .p-tt td.tt-p b { display: block; font-size: 8.5pt; color: #333; }
  .p-tt td.tt-p span { display: block; font-weight: 700; font-size: 11.5pt; }
  .p-tt td.tt-p small { font-size: 8.5pt; }
  .p-tt tr.pause td { height: calc(var(--h) * .75); padding: 0; font-size: 7.5pt; background: #f1f1f4; color: #333; }

  .p-matrix { font-size: 7.6pt; table-layout: auto; }
  .p-matrix th, .p-matrix td { border: 1px solid #777; min-width: 0; height: 6.6mm; }
  .p-matrix .m-name { position: static; min-width: 0; padding: 0 1.5mm; font-size: 8.5pt; background: #fff; }
  .p-matrix thead th, .p-matrix thead .m-name { background: #e9e9ee; }
  .p-matrix .we, .p-matrix .fr { background: #d9d9de !important; }
  .p-matrix .m-c { background: none !important; color: #000 !important; width: auto; height: auto; font-size: 8pt; }
  .p-matrix tr { break-inside: avoid; }

  .p-board { width: 55%; margin: 0 auto 9mm; padding: 2mm; text-align: center; border: 1.5pt solid #000; font-weight: 700; letter-spacing: .4em; }
  .p-teacher { width: 34mm; margin: -4mm auto 6mm; padding: 1.5mm; text-align: center; border: 1pt dashed #000; font-size: 9pt; }
  .p-teacher.links { margin-left: 3mm; } .p-teacher.rechts { margin-right: 3mm; }
  .p-room { width: 100%; border-collapse: separate; border-spacing: 3mm; table-layout: fixed; }
  .p-room td { height: 21mm; text-align: center; vertical-align: middle; font-size: 11pt; line-height: 1.25; overflow: hidden; }
  .p-room.einzel { border-spacing: 7mm 5mm; }
  .p-room td.p-desk { border: 1.2pt solid #000; border-radius: 2.5mm; }

  .p-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4mm 6mm; margin-bottom: 4mm; }
  .p-months .month { break-inside: avoid; }
  .p-months .month h4 { font-size: 9.5pt; margin-bottom: .8mm; }
  .p-months .mgrid { gap: .5mm; }
  .p-months .mgrid b { font-size: 6.5pt; color: #333; }
  .p-months .cd { aspect-ratio: auto; height: 5mm; font-size: 7.6pt; border-radius: 1mm; color: #000; }
  .p-months .cd.we { color: #666; }
  #print-area .legend { margin-bottom: 4mm; color: #000; font-size: 8.5pt; }
}
