/* Sphinx – Deutsch (Farbpalette von Metis). Keine Inline-Stile (CSP style-src 'self'). */

:root {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --ink: #1d2a33;
  --muted: #60707b;
  --line: #d9dde0;
  --line-strong: #b8c0c6;
  --accent: #1f5f74;
  --accent-ink: #ffffff;
  --accent-soft: #e3eff2;
  --own: #fff1c9;
  --own-head: #f3d98f;
  --group-stripes: repeating-linear-gradient(135deg, #f5f0e2 0 5px, #e5dac2 5px 8px);
  --gold: #e8b04a;
  --ok: #2e7d4f;
  --warn: #b46a00;
  --bad: #b3261e;
  --sel: rgba(31, 95, 116, .16);
  --sel-line: #1f5f74;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.noscript, .loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ Kopfleiste */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem; padding-left: max(1rem, env(safe-area-inset-left));
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { border-radius: 7px; background: #fff2; }
.topnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topnav a { color: #fff; opacity: .85; text-decoration: none; padding: .35rem .7rem; border-radius: 999px; }
.topnav a:hover { opacity: 1; background: #ffffff1f; }
.topnav a.active { opacity: 1; background: #ffffff2e; font-weight: 600; }
.gottmodus-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem 1rem;
  flex-wrap: wrap;
  padding: .52rem 1rem;
  border-bottom: 1px solid #dbb765;
  background: #fff0c7;
  color: #533913;
  overflow-wrap: anywhere;
}
.gottmodus-banner button { color: inherit; border-color: #caa354; background: #fff8e5; white-space: normal; }
.gottmodus-picker { max-width: 34rem; margin: 1rem auto; }
.gottmodus-picker form { display: grid; gap: .85rem; }
.gottmodus-picker select { width: 100%; }
.gottmodus-picker [role=status] { font-size: .9rem; margin: 0; }
.gottmodus-picker [role=status]:empty { display: none; }
.gottmodus-picker .btn { justify-content: center; justify-self: start; }
.who { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.who .role { opacity: .8; }
.who button { background: #ffffff22; border: 1px solid #ffffff44; color: #fff; border-radius: 999px; padding: .3rem .8rem; cursor: pointer; }
.who button:hover { background: #ffffff38; }

.app { padding: 1.25rem; max-width: 1280px; margin: 0 auto; }
.app.wide { max-width: none; padding: .75rem 1rem 6rem; }

/* ------------------------------------------------------------ Bausteine */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line-strong); background: #fff;
  border-radius: 9px; padding: .48rem .9rem; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #e2b6b2; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #0000000a; }

label.field { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], select {
  border: 1px solid var(--line-strong); border-radius: 9px; padding: .5rem .65rem; background: #fff; min-width: 0;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .switch input:focus-visible + span { outline: 3px solid #1f5f7455; outline-offset: 1px; }

.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; background: #eef1f3; color: var(--muted); }
.pill.ok { background: #e5f3ea; color: var(--ok); }
.pill.warn { background: #fdf0db; color: var(--warn); }
.pill.bad { background: #fbe7e5; color: var(--bad); }

.notice { border-radius: 10px; padding: .75rem 1rem; background: #fdf0db; color: #6b4300; border: 1px solid #f1d7a6; }
.notice.info { background: var(--accent-soft); color: #18485a; border-color: #c4dde4; }
.notice.bad { background: #fbe7e5; color: #7c1b14; border-color: #efc2bd; }

/* Schalter */
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span.track { width: 46px; height: 26px; border-radius: 999px; background: #c5ccd1; position: relative; transition: background .15s; flex: none; }
.switch span.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: transform .15s; }
.switch input:checked + span.track { background: var(--ok); }
.switch input:checked + span.track::after { transform: translateX(20px); }
.switch.big span.track { width: 64px; height: 34px; }
.switch.big span.track::after { width: 28px; height: 28px; }
.switch.big input:checked + span.track::after { transform: translateX(30px); }

.progress { height: 8px; background: #e7eaec; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; }
.progress.done > i { background: var(--ok); }

/* ------------------------------------------------------------ Anmeldung */
.login { max-width: 420px; margin: 8vh auto; }
.login .logo { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.login .logo img { width: 52px; height: 52px; }
.login form { display: grid; gap: .8rem; margin-top: 1rem; }
.login .or { text-align: center; color: var(--muted); font-size: .9rem; margin: .5rem 0; }

/* ------------------------------------------------------------ Klassenkacheln */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: grid; gap: .5rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .08s, border-color .1s; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile .name { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; color: var(--accent); }
.tile .subj { font-size: .88rem; color: var(--muted); min-height: 1.3em; }
/* Dialog (schließt NUR über das X – Hausregel) */
.dlg-back { position: fixed; inset: 0; z-index: 90; background: #0b151b66; display: grid; place-items: center; padding: 1rem; }
.dlg { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px #0005; width: min(460px, 100%); max-height: 90vh; overflow: auto; }
.dlg header { display: flex; align-items: center; gap: .5rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.dlg header h2 { margin: 0; flex: 1; font-size: 1.05rem; }
.dlg header .x { border: 0; background: #eef1f3; width: 34px; height: 34px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; }
.dlg .body { padding: 1rem; display: grid; gap: .9rem; }
.dlg .choices { display: flex; gap: .35rem; flex-wrap: wrap; }
.dlg .choices button { width: 44px; height: 40px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; font-weight: 700; cursor: pointer; }
.dlg .choices button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Verwaltung */
.classes-admin { display: grid; gap: .5rem; }
.classrow { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.classrow.off { background: #f7f8f8; }
.classrow .cname { font-size: 1.25rem; font-weight: 800; color: var(--accent); }
.classrow.off .cname { color: #8c979e; }
.classrow details { font-size: .86rem; }
.classrow details ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.checklist { display: flex; flex-wrap: wrap; gap: .4rem; }
.checklist label { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 600; }
.checklist input { accent-color: var(--accent); }
.logo-prev { max-width: 120px; max-height: 120px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.table-scroll { overflow-x: auto; }
table.plain { border-collapse: collapse; width: 100%; font-size: .88rem; overflow-wrap: anywhere; }
table.plain th, table.plain td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }

.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; background: #1d2a33; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: 0 8px 30px #0004; max-width: min(420px, 90vw); }
.toast.bad { background: var(--bad); }

kbd { font-family: var(--mono); font-size: .8em; padding: .05rem .35rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: #fff; }
.help { font-size: .85rem; color: var(--muted); }
.help summary { cursor: pointer; }
.help ul { margin: .4rem 0; padding-left: 1.2rem; }

/* Anmeldung mit Illustration */
body:has(.app > .login-layout) {
  background: #0b3541;
}
.app:has(> .login-layout) {
  --login-gutter: clamp(1rem, 3vw, 2.5rem);
  display: grid;
  place-items: center;
  min-height: 100svh;
  max-width: none;
  padding:
    max(var(--login-gutter), env(safe-area-inset-top))
    max(var(--login-gutter), env(safe-area-inset-right))
    max(var(--login-gutter), env(safe-area-inset-bottom))
    max(var(--login-gutter), env(safe-area-inset-left));
}
.login-layout {
  --login-ink: #104b60;
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  width: 100%;
  max-width: min(88.4rem, calc(170svh - 5rem));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: clamp(1.2rem, 2.3vw, 2.25rem);
  background: #fffdfa;
  box-shadow: 0 1rem 2rem #0010175c;
  font-family: Georgia, "Times New Roman", serif;
}
.login-pane {
  display: grid;
  align-items: center;
  min-width: 0;
}
.login-form {
  padding: clamp(1.5rem, min(4.8vw, 7.2svh), 4.625rem);
  color: var(--login-ink);
}
.login-form .logo {
  display: flex;
  align-items: center;
  gap: clamp(.75rem, 1.25vw, 1.25rem);
  margin-bottom: clamp(1.6rem, 4.5svh, 3rem);
  font-size: clamp(1.9rem, min(3.4vw, 5.1svh), 3.25rem);
  font-weight: 700;
  line-height: 1;
}
.login-form .logo img {
  width: clamp(3.25rem, min(6vw, 9svh), 5.75rem);
  height: auto;
  flex: none;
}
.login-form .logo span {
  display: block;
  margin-top: .17em;
  font-size: .59em;
}
.login-form h1 {
  margin: 0;
  font-size: clamp(2.5rem, min(4.15vw, 6.25svh), 4rem);
  line-height: 1.05;
}
.login-form .school-fixed {
  margin: .42em 0 0;
  color: #596268;
  font-size: clamp(1.08rem, 1.9vw, 1.8rem);
}
.login-form form {
  display: grid;
  gap: clamp(.95rem, 2.2svh, 1.4rem);
  margin-top: clamp(1.2rem, 3svh, 2rem);
}
.login-form .field {
  gap: .43em;
  color: #102c37;
  font-size: clamp(1rem, min(1.72vw, 2.6svh), 1.65rem);
  font-weight: 700;
}
.login-form input, .login-form select {
  width: 100%;
  min-height: clamp(2.75rem, 5.3svh, 3.4rem);
  border-color: #929a9f;
  color: #102c37;
  font: 1rem/1.4 var(--font);
}
.login-form :is(input, select, .btn):focus-visible {
  outline: 2px solid var(--login-ink);
  outline-offset: 3px;
}
.login-form .hint {
  margin: 0;
  color: #505d65;
  font-size: clamp(1rem, min(1.45vw, 2.2svh), 1.375rem);
  line-height: 1.25;
}
.login-form .btn.primary {
  justify-content: center;
  min-height: clamp(2.75rem, 6.2svh, 4rem);
  margin-top: clamp(.15rem, 1.4svh, .9rem);
  background: #105469;
  border-color: #105469;
  font-size: clamp(1.1rem, min(2vw, 3svh), 1.875rem);
  font-weight: 700;
}
#login-msg:empty { display: none; }
.login-visual {
  align-self: stretch;
  position: relative;
  aspect-ratio: 768 / 832;
  background: #1e5768;
}
.login-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 85% center;
}
@media (max-width: 700px), (max-width: 1024px) and (orientation: portrait) {
  .app:has(> .login-layout) { --login-gutter: 1rem; }
  .login-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 32rem;
  }
  .login-form { padding: clamp(1.25rem, 6vw, 2.25rem); }
  .login-form .logo { margin-bottom: 1.35rem; }
  .login-visual { aspect-ratio: auto; }
  .login-visual img {
    display: block;
    position: static;
    height: auto;
    aspect-ratio: 4 / 3;
    object-position: center 25%;
  }
}
@media (min-width: 701px) and (max-width: 1024px) and (orientation: portrait) {
  .login-layout { max-width: 38rem; }
  .login-visual img { aspect-ratio: 16 / 10; object-position: center 22%; }
}
@media (min-width: 701px) and (max-width: 1194px) and (orientation: landscape) {
  .login-visual img { object-position: right center; }
}
@media (pointer: coarse) {
  .login-form :is(input, select, .btn.primary) { min-height: 48px; }
}

/* Klassenliste */
.students { width: 100%; border-collapse: collapse; font-size: .92rem; }
.students th, .students td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.students th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.students td.user { font-family: var(--mono); font-size: .88rem; }
.students input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.pwform { display: grid; gap: .7rem; }
.pwform .row input { flex: 1; min-width: 180px; }

/* Zugangszettel (Druck) */
.printsheet { display: none; }
@media print {
  body { background: #fff; }
  .topbar, .toast, .no-print, .app > :not(.printsheet) { display: none !important; }
  .app { padding: 0; max-width: none; }
  .printsheet { display: block; font: 11pt/1.35 var(--font); color: #000; }
  .printsheet h1 { font-size: 15pt; }
  .slips { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
  .slip { border: 1px dashed #888; padding: 10px 12px; break-inside: avoid; }
  .slip b { font-size: 12pt; }
  .slip .mono { font-family: var(--mono); font-size: 12pt; }
}

@media screen and (pointer: coarse) {
  .btn, .who button, .topnav a { min-height: 44px; }
  input[type=text], input[type=email], input[type=password], select { font-size: 16px; }
}
@media (max-width: 700px) {
  .app { padding: .8rem; }
  .who .role, .who .name { display: none; }
  .students .opt { display: none; }
}
.topnav { flex-wrap: nowrap; }
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: .3rem .65rem; }
  .topnav { order: 3; flex-basis: 100%; flex-wrap: wrap; }
  .who { margin-left: auto; }
}
@media screen and (max-width: 1100px) {
  .who .role { display: none; }
}
