/* Schulboard – clean, minimal. Tokens nach der Vorlage (Instrument Serif + Inter, Indigo-Akzent). */

:root {
  --background: 0 0% 100%;
  --foreground: 210 14% 17%;
  --primary: 210 14% 17%;
  --primary-foreground: 0 0% 100%;
  --secondary: 0 0% 96%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 0% 96%;
  --muted-foreground: 200 5% 44%;
  --subtle: 184 5% 58%;
  --accent: 239 84% 67%;
  --accent-foreground: 0 0% 100%;
  --border: 0 0% 91%;
  --ring: 239 84% 67%;
  --good: 145 63% 32%;
  --warn: 32 92% 38%;
  --bad: 0 72% 50%;
  --radius: 0.5rem;
  --font-display: 'Instrument Serif', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-dashboard: 0 25px 80px -12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 24px -12px rgba(0, 0, 0, 0.06);
  --canvas: hsl(0 0% 96% / 0.45);   /* Hintergrund hinter den Karten */
  --check-border: 0 0% 78%;
  --hol-ink: 152 55% 28%;
  color-scheme: light;
}

/* Dark Mode – Apple-typisch: fast schwarzer Grund, dunkelgraue Karten */
:root[data-theme="dark"] {
  --background: 240 4% 11%;
  --foreground: 0 0% 96%;
  --primary: 0 0% 96%;
  --primary-foreground: 240 4% 9%;
  --secondary: 240 3% 18%;
  --secondary-foreground: 0 0% 96%;
  --muted: 240 3% 18%;
  --muted-foreground: 240 5% 68%;
  --subtle: 240 4% 52%;
  --accent: 239 84% 70%;
  --border: 240 3% 21%;
  --ring: 239 84% 70%;
  --good: 145 55% 50%;
  --warn: 36 95% 58%;
  --bad: 0 80% 64%;
  --shadow-dashboard: 0 25px 80px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --canvas: hsl(240 6% 5%);
  --check-border: 240 3% 38%;
  --hol-ink: 152 50% 62%;
  color-scheme: dark;
}
body, .main, .card, .sidebar, .topbar { transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.ico { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
.muted { color: hsl(var(--subtle)); }

/* ---------- Grundlayout ---------- */

.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  grid-template-rows: 60px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.85);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; width: 212px; text-decoration: none; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: block; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.06);
}
.top-date { flex: 1; display: flex; justify-content: center; min-width: 0; }
.date-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: hsl(var(--secondary)); color: hsl(var(--muted-foreground));
  font-size: 13px; white-space: nowrap;
}
.date-chip .sep { width: 3px; height: 3px; border-radius: 50%; background: hsl(var(--subtle)); }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 12px; font-weight: 600;
}
.avatar .ico { width: 15px; height: 15px; }
.icon-btn.menu-btn { display: none; }

.sidebar {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px 12px;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  overflow-y: auto;
}
.main { overflow-y: auto; background: var(--canvas); -webkit-overflow-scrolling: touch; }
.scrim { display: none; }

/* ---------- Sidebar ---------- */

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  color: hsl(var(--muted-foreground)); text-decoration: none; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.nav a.active { background: hsl(var(--secondary)); color: hsl(var(--foreground)); font-weight: 500; }
.nav .count {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
  font-size: 11px; text-align: center; color: hsl(var(--muted-foreground));
}

.side-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 10px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: hsl(var(--subtle));
}
.check-section { margin: 8px -4px 0; padding: 0 4px 4px; border-radius: 14px; }
.check-section.flash { animation: flash 1.2s ease; }
@keyframes flash {
  0%, 100% { background: transparent; box-shadow: none; }
  20%, 60% { background: hsl(var(--accent) / 0.06); box-shadow: 0 0 0 1px hsl(var(--accent) / 0.25); }
}
.check-add:focus-within { background: hsl(var(--secondary)); border-radius: 10px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 10px; border-radius: 10px; font-size: 14px;
}
.check-item:hover { background: hsl(var(--secondary)); }
.ci-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.check-item.done .ci-text { color: hsl(var(--subtle)); text-decoration: line-through; }
.check-item .del { opacity: 0; transition: opacity 0.15s; }
.check-item:hover .del, .check-item .del:focus-visible { opacity: 1; }
@media (hover: none) { .check-item .del { opacity: 0.6; } }
.side-empty { padding: 4px 10px; }

.check-add { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.check-add input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 16px; padding: 2px 0; color: hsl(var(--foreground));
}
.check-add input::placeholder { color: hsl(var(--subtle)); }

.side-foot { margin-top: auto; padding: 18px 10px 4px; font-size: 12px; color: hsl(var(--subtle)); }

/* Dark-Mode-Schalter (rechts = hell, links = dunkel) */
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.theme-row > span { font-size: 13px; color: hsl(var(--muted-foreground)); }
.theme-switch {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  width: 62px; height: 32px; padding: 0 9px; border: 0; border-radius: 999px; cursor: pointer;
  background: hsl(var(--secondary)); box-shadow: inset 0 0 0 1px hsl(var(--border));
  transition: background 0.25s ease;
}
.theme-switch .ico { width: 13px; height: 13px; position: relative; z-index: 1; color: hsl(var(--subtle)); transition: color 0.25s; }
.theme-knob {
  position: absolute; top: 3px; left: 33px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: left 0.28s cubic-bezier(0.3, 1.3, 0.5, 1);
}
/* Dunkel aktiv: Knopf links, Schiene in Akzentfarbe, Sonne rechts sichtbar */
.theme-switch[aria-checked="true"] { background: hsl(var(--accent)); box-shadow: none; }
.theme-switch[aria-checked="true"] .theme-knob { left: 3px; }
.theme-switch[aria-checked="true"] .ico-sun { color: rgba(255, 255, 255, 0.85); }
.theme-switch .ico { pointer-events: none; }
/* Symbol auf dem Knopf zeigt den aktuellen Modus farbig */
.theme-switch[aria-checked="false"] .ico-sun { color: hsl(36 95% 48%); }
.theme-switch[aria-checked="true"] .ico-moon { color: hsl(239 70% 58%); }
.side-foot p { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.side-foot .ico { width: 13px; height: 13px; }

/* ---------- Seiten ---------- */

.page { max-width: 1160px; margin: 0 auto; padding: 40px 32px 64px; }
.page-head { margin-bottom: 28px; }
.eyebrow { margin: 0 0 10px; font-size: 13px; color: hsl(var(--muted-foreground)); }
.display {
  margin: 0;
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(40px, 5.2vw, 60px); line-height: 0.95; letter-spacing: -0.015em;
}
.display em { font-style: normal; }
.lead { margin: 14px 0 0; max-width: 620px; font-size: 16px; color: hsl(var(--muted-foreground)); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 28px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background));
  font-size: 13px; font-weight: 500; text-decoration: none; color: hsl(var(--foreground));
  transition: background 0.15s, border-color 0.15s;
}
.pill .ico { width: 14px; height: 14px; }
.pill:hover { background: hsl(var(--secondary)); }
.pill-accent { background: hsl(var(--accent)); border-color: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.pill-accent:hover { background: hsl(var(--accent) / 0.9); }

/* ---------- Karten ---------- */

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card-flush { padding: 0; overflow: hidden; }
.card-wide { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-kicker { margin: 0 0 2px; font-size: 12px; color: hsl(var(--subtle)); }
.card-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.link-sm {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 13px; color: hsl(var(--muted-foreground)); text-decoration: none;
}
.link-sm:hover { color: hsl(var(--foreground)); }
.link-sm .ico { width: 14px; height: 14px; }
.more-link { display: inline-block; margin-top: 10px; font-size: 13px; color: hsl(var(--muted-foreground)); text-decoration: none; }
.count-chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
  background: hsl(var(--secondary)); color: hsl(var(--muted-foreground));
  font-size: 12px; font-weight: 500;
}
.count-chip .ico { width: 13px; height: 13px; }
.count-chip.good { color: hsl(var(--good)); background: hsl(var(--good) / 0.08); }
.count-chip.bad { color: hsl(var(--bad)); background: hsl(var(--bad) / 0.08); }

.empty { margin: 0; color: hsl(var(--subtle)); font-size: 14px; list-style: none; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 8px; text-align: center; color: hsl(var(--subtle)); font-size: 14px; }
.empty-state p { margin: 0; }
.empty-state .ico { width: 22px; height: 22px; }

/* Fach-Kennzeichnung: nur ein kleiner Farbpunkt */
.subj { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, hsl(var(--subtle))); flex-shrink: 0; }
/* feiner Rand, damit auch helle Farben (z. B. Weiß für Religion) sichtbar bleiben */
.dot, .lesson-bar, .dp-day i { box-shadow: inset 0 0 0 1px hsl(var(--foreground) / 0.18); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: hsl(var(--muted-foreground)); background: hsl(var(--secondary));
}
.badge .ico { width: 12px; height: 12px; }
.badge.good { color: hsl(var(--good)); background: hsl(var(--good) / 0.08); }
.badge.warn { color: hsl(var(--warn)); background: hsl(var(--warn) / 0.09); }
.badge.bad { color: hsl(var(--bad)); background: hsl(var(--bad) / 0.08); }

/* ---------- Morgen-Karte ---------- */

.tm-list { list-style: none; margin: 0; padding: 0; }
.tm-row { padding: 10px 0; border-top: 1px solid hsl(var(--border)); }
.tm-row:first-child { border-top: 0; padding-top: 0; }
.tm-head { display: flex; align-items: center; gap: 10px; }
.tm-head .subj { color: hsl(var(--foreground)); font-size: 14px; font-weight: 500; }
.tm-time { font-size: 12px; color: hsl(var(--subtle)); }
.tm-head .badge { margin-left: auto; }
.tm-hws { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 0 14px; }
.mini-hw {
  display: flex; align-items: flex-start; gap: 8px; width: 100%;
  padding: 4px 6px; margin-left: -6px; border: 0; border-radius: 8px;
  background: transparent; text-align: left; cursor: pointer; font-size: 13px;
}
.mini-hw:hover { background: hsl(var(--secondary)); }
.mini-check {
  width: 16px; height: 16px; margin-top: 1px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid hsl(var(--check-border)); display: grid; place-items: center; color: transparent;
}
.mini-check .ico { width: 11px; height: 11px; stroke-width: 3; }
.mini-hw.done .mini-check { background: hsl(var(--good)); border-color: hsl(var(--good)); color: #fff; }
.mini-hw.done .mini-text { color: hsl(var(--subtle)); text-decoration: line-through; }
.mini-hw.late .mini-check { border-color: hsl(var(--bad)); }
.mini-hw.late .mini-text::after { content: ' · überfällig'; color: hsl(var(--bad)); }

/* ---------- Heute-Karte ---------- */

.lesson-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lesson { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 12px; }
.lesson-time { width: 42px; font-size: 13px; font-variant-numeric: tabular-nums; }
.lesson-time small, .lesson-name small { display: block; font-size: 11px; color: hsl(var(--subtle)); }
.lesson-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--c); }
.lesson-name { flex: 1; font-size: 14px; font-weight: 500; }
.lesson.is-past { opacity: 0.45; }
.lesson.is-now { background: hsl(var(--accent) / 0.07); }
.now-chip {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: hsl(var(--accent)); color: hsl(var(--accent-foreground));
}

/* ---------- Zahlen ---------- */

.hero-num {
  font-size: 44px; font-weight: 600; line-height: 1.05; letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.hero-num .dec { font-size: 0.55em; font-weight: 500; color: hsl(var(--subtle)); letter-spacing: -0.02em; }
.hero-num small { margin-left: 8px; font-size: 13px; font-weight: 400; color: hsl(var(--muted-foreground)); letter-spacing: 0; }
.hero-sub { margin: 8px 0 0; font-size: 13px; color: hsl(var(--muted-foreground)); }
.kv { margin-top: 18px; border-top: 1px solid hsl(var(--border)); }
.kv-row { display: flex; align-items: center; gap: 10px; padding: 10px 0 0; font-size: 13px; }
.kv-label { width: 108px; color: hsl(var(--subtle)); }
.kv-row b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 16px; }
.stat .hero-num { font-size: 38px; margin-top: 8px; }

/* ---------- Hausaufgaben-Zeilen ---------- */

.hw-list { display: flex; flex-direction: column; }
.hw-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 14px;
  padding: 12px 0; border-top: 1px solid hsl(var(--border));
}
.hw-row:first-child { border-top: 0; padding-top: 2px; }
.hw-text { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.hw-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; }
.hw-due { text-align: right; font-size: 13px; font-weight: 500; white-space: nowrap; }
.hw-due small { display: block; font-size: 12px; font-weight: 400; color: hsl(var(--subtle)); }
.hw-row.is-done .hw-text { color: hsl(var(--subtle)); text-decoration: line-through; font-weight: 400; }
.hw-row.is-overdue .hw-due { color: hsl(var(--bad)); }

.check {
  width: 22px; height: 22px; border-radius: 7px; cursor: pointer; padding: 0;
  border: 1.5px solid hsl(var(--check-border)); background: hsl(var(--background));
  display: grid; place-items: center; color: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.check .ico { width: 13px; height: 13px; stroke-width: 3; }
.check:hover { border-color: hsl(var(--accent)); }
.check.on { background: hsl(var(--good)); border-color: hsl(var(--good)); color: #fff; }
.check.sm { width: 18px; height: 18px; border-radius: 6px; }
.check.sm .ico { width: 11px; height: 11px; }
.hw-row.is-overdue .check { border-color: hsl(var(--bad) / 0.7); }
@media (hover: none) { .check { width: 26px; height: 26px; } .check.sm { width: 22px; height: 22px; } }

/* ---------- Hausaufgaben-Seite ---------- */

.hw-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.form-card { position: sticky; top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.hw-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.field input, .field select, .field textarea, .grade-input {
  width: 100%;
  font: inherit; font-size: 16px; color: hsl(var(--foreground));
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background));
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus, .grade-input:focus {
  border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}
.hint { display: flex; align-items: flex-start; gap: 8px; margin: -4px 0 0; font-size: 12px; color: hsl(var(--accent)); }
.hint .ico { width: 14px; height: 14px; margin-top: 1px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px 18px; }
.icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: hsl(var(--muted-foreground));
}
.icon-btn:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.icon-btn.tiny { width: 24px; height: 24px; }
.icon-btn.tiny .ico { width: 13px; height: 13px; }
.icon-btn.subtle { color: hsl(var(--subtle)); }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 500;
  color: hsl(var(--subtle));
}
.link-btn:hover { color: hsl(var(--foreground)); }
.side-foot .link-btn { font-size: 12px; font-weight: 400; }

:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table, .tt { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 14px 16px; white-space: nowrap;
  font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--secondary) / 0.5);
}
.table th small { color: hsl(var(--subtle)); font-weight: 400; margin-left: 2px; }
.table td { padding: 10px 16px; border-bottom: 1px solid hsl(var(--border)); }
.table tr:last-child td { border-bottom: 0; }
.table .subj { color: hsl(var(--foreground)); font-size: 14px; font-weight: 500; }
.grades { min-width: 620px; }
.grade-input { width: 68px; padding: 7px 10px; text-align: center; border-radius: 10px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.grade-input::-webkit-outer-spin-button, .grade-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.grade-input::placeholder { color: hsl(var(--subtle)); }
.num { font-variant-numeric: tabular-nums; color: hsl(var(--muted-foreground)); }
.pts-cell { display: flex; align-items: center; gap: 8px; }
.pts { font-size: 15px; font-weight: 600; min-width: 22px; font-variant-numeric: tabular-nums; }

/* Stundenplan */
.tt { min-width: 680px; table-layout: fixed; }
.tt th, .tt td { padding: 6px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.tt thead th {
  padding: 14px 8px; text-align: left; font-size: 13px; font-weight: 600;
  background: hsl(var(--secondary) / 0.5);
}
.tt thead th small { display: block; font-size: 11px; font-weight: 400; color: hsl(var(--subtle)); }
.tt thead th:first-child { width: 96px; }
.tt tbody tr:last-child th, .tt tbody tr:last-child td { border-bottom: 0; }
.tt-period { padding-left: 16px !important; text-align: left; font-size: 13px; font-weight: 600; }
.tt-period small { display: block; font-size: 11px; font-weight: 400; color: hsl(var(--subtle)); font-variant-numeric: tabular-nums; }
.tt .is-today { background: hsl(var(--accent) / 0.045); }
.tt thead th.is-today { color: hsl(var(--accent)); }
.tt-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 10px;
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
  font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Dialog ---------- */

dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0; border: 0; border-radius: 20px;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  box-shadow: var(--shadow-dashboard), 0 30px 60px -20px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(20, 24, 28, 0.28); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 22px; }
.dialog-head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; }
.dialog-body { padding: 16px 22px 22px; }

/* ---------- Bildschirme: Laden / Login / App ---------- */

.boot, .login { display: none; }
body[data-screen="loading"] .app, body[data-screen="login"] .app { display: none; }
body[data-screen="loading"] .boot {
  display: grid; place-items: center; height: 100vh; height: 100dvh;
}
.boot .brand-mark { width: 56px; height: 56px; border-radius: 14px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; transform: scale(0.94); } }

body[data-screen="login"] .login {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
  background:
    radial-gradient(60% 50% at 50% 0%, hsl(var(--accent) / 0.08), transparent 70%),
    var(--canvas);
}
.login-card {
  width: min(400px, 100%);
  padding: 36px 32px 28px; border-radius: 24px;
  background: hsl(var(--background) / 0.85);
  border: 1px solid hsl(var(--border) / 0.6);
  box-shadow: var(--shadow-dashboard);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  text-align: center;
}
.brand-mark.lg { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 18px; }
.login-card .display { font-size: 44px; }
.login-card .lead { margin: 10px auto 24px; font-size: 14px; max-width: 300px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form .btn { margin-top: 4px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: 12px; color: hsl(var(--subtle)); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: hsl(var(--border)); }
.btn-ghost { background: hsl(var(--background)); border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn-ghost:hover { background: hsl(var(--secondary)); opacity: 1; }
.btn:disabled { opacity: 0.5; cursor: default; }
.login-msg { min-height: 18px; margin: 16px 0 0; font-size: 13px; color: hsl(var(--muted-foreground)); }
.login-msg[data-kind="error"] { color: hsl(var(--bad)); }
.login-msg[data-kind="ok"] { color: hsl(var(--good)); }

/* Sync-Status */
#syncStatus[data-state="synced"] { color: hsl(var(--good)); }
#syncStatus[data-state="offline"] { color: hsl(var(--warn)); }
.side-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Kurse ---------- */

.courses { min-width: 760px; }
.code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12px;
  padding: 3px 7px; border-radius: 6px; background: hsl(var(--secondary)); color: hsl(var(--foreground));
}
.teacher { font-weight: 500; }
.teacher small { display: block; font-size: 12px; font-weight: 400; color: hsl(var(--subtle)); }
.badge.accent { color: hsl(var(--accent)); background: hsl(var(--accent) / 0.09); }

/* ---------- Stundenplan: Kopf + Bearbeiten ---------- */

.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.pill-dark { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.pill-dark:hover { background: hsl(var(--primary) / 0.88); }
.tt-name { display: flex; flex-direction: column; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tt-name small { font-size: 11px; font-weight: 400; color: hsl(var(--subtle)); }
.tt-chip { align-items: center; }
.tt.is-editing { min-width: 820px; }
.tt-edit { display: flex; flex-direction: column; gap: 4px; }
.tt-edit select, .tt-edit input, .tt-times input {
  width: 100%; font: inherit; font-size: 14px; color: hsl(var(--foreground));
  padding: 6px 8px; border: 1px solid hsl(var(--border)); border-radius: 8px; background: hsl(var(--background));
  outline: none;
}
.tt-edit input { font-size: 12px; padding: 4px 8px; color: hsl(var(--muted-foreground)); }
.tt-edit select:focus, .tt-edit input:focus, .tt-times input:focus { border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); }
.tt-times { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tt-times input { font-size: 12px; padding: 3px 6px; font-weight: 400; }
.tt.is-editing thead th:first-child { width: 112px; }

.stat-empty { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; color: hsl(var(--muted-foreground)); font-size: 14px; }
.stat-empty p { margin: 0; }
.stat-empty .ico { width: 20px; height: 20px; color: hsl(var(--accent)); }
.empty-state .pill { margin-top: 6px; }

[hidden] { display: none !important; }

/* ---------- Kalender ---------- */

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 20px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .pill { margin-right: 6px; padding: 5px 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd { border-top: 1px solid hsl(var(--border)); background: hsl(var(--secondary) / 0.5); }
.cal-wd span { padding: 8px 10px; font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.cal-cell {
  position: relative; min-height: 104px; padding: 6px 6px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  border-top: 1px solid hsl(var(--border)); border-left: 1px solid hsl(var(--border));
  transition: background 0.12s;
}
.cal-cell:nth-child(7n + 1) { border-left: 0; }
.cal-cell:hover { background: hsl(var(--secondary) / 0.6); }
.cal-cell.wkend { background: hsl(var(--secondary) / 0.35); }
.cal-cell.hol { background: hsl(152 60% 40% / 0.07); }
.cal-cell.hol:hover { background: hsl(152 60% 40% / 0.11); }
.cal-cell.out .cal-num { color: hsl(var(--subtle) / 0.6); }
.cal-cell.out > :not(.cal-num) { opacity: 0.55; }
.cal-num {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-num { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; }
.cal-tag { font-size: 11px; line-height: 1.25; color: hsl(var(--hol-ink)); font-weight: 500; padding: 0 4px; }
.cal-tag.ft { color: hsl(var(--bad)); }
.cal-ev {
  display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0;
  padding: 3px 6px; border: 0; border-radius: 6px; cursor: pointer; text-align: left;
  font-size: 12px; font-weight: 500; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 14%, hsl(var(--background))); color: hsl(var(--foreground));
}
.cal-ev:hover { background: color-mix(in srgb, var(--c) 24%, hsl(var(--background))); }
.cal-ev.event { background: hsl(var(--secondary)); }
.cal-ev .dot { width: 6px; height: 6px; }
.cal-ev-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 20px;
  border-top: 1px solid hsl(var(--border)); font-size: 12px; color: hsl(var(--muted-foreground));
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.lg-gln { background: linear-gradient(135deg, #6366f1 0 50%, #0d9488 50%); opacity: 0.8; }
.lg-ev { background: hsl(var(--secondary)); border: 1px solid hsl(var(--border)); }
.lg-hol { background: hsl(152 60% 40% / 0.18); }
.lg-ft { background: hsl(var(--bad) / 0.25); }

.up-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.up-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 8px; margin: 0 -8px;
  border-radius: 12px; cursor: pointer;
}
.up-item:hover { background: hsl(var(--secondary)); }
.up-date {
  width: 42px; flex-shrink: 0; padding: 5px 0; border-radius: 10px; text-align: center;
  background: color-mix(in srgb, var(--c) 14%, hsl(var(--background)));
}
.up-date b { display: block; font-size: 16px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.up-date span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: hsl(var(--muted-foreground)); }
.up-main { flex: 1; min-width: 0; }
.up-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: hsl(var(--subtle)); }
.up-meta .dot { background: var(--c); }
.holiday-line {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 0; padding-top: 12px;
  border-top: 1px solid hsl(var(--border)); font-size: 13px; color: hsl(var(--muted-foreground));
}
.holiday-line .ico { color: hsl(var(--hol-ink)); }
.holiday-line b { font-weight: 600; color: hsl(var(--foreground)); }
.holiday-line small { display: block; font-size: 12px; color: hsl(var(--subtle)); }
.empty-state.compact { padding: 8px 0 4px; }

.hol-list { list-style: none; margin: 0; padding: 0; }
.hol-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid hsl(var(--border)); font-size: 13px; }
.hol-list li:first-child { border-top: 0; padding-top: 0; }
.hol-name { font-weight: 500; }
.hol-date { grid-column: 1; color: hsl(var(--subtle)); font-size: 12px; }
.hol-in { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 12px; color: hsl(var(--muted-foreground)); }

/* Segment-Schalter (GLN / Termin) */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; background: hsl(var(--secondary)); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 8px; border-radius: 9px; text-align: center; font-size: 14px; font-weight: 500; color: hsl(var(--muted-foreground)); transition: background 0.15s, color 0.15s; }
.seg input:checked + span { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.seg input:focus-visible + span { outline: 2px solid hsl(var(--ring)); }
.form-actions { display: flex; gap: 8px; }
.form-actions .btn-primary { flex: 1; padding: 12px 18px; }

/* ---------- Datumsauswahl ---------- */

.dp-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background));
  font-size: 16px; color: hsl(var(--foreground));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dp-trigger .ico { color: hsl(var(--accent)); }
.dp-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-rel {
  flex-shrink: 0; padding: 2px 9px; border-radius: 999px;
  background: hsl(var(--secondary)); color: hsl(var(--muted-foreground)); font-size: 12px; font-weight: 500;
}
.dp.open .dp-trigger, .dp-trigger:focus-visible { border-color: hsl(var(--ring)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15); outline: none; }

.dp-panel {
  margin-top: 4px; padding: 10px 10px 12px; border-radius: 16px;
  border: 1px solid hsl(var(--border)); background: hsl(var(--background));
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.18);
  animation: dpIn 0.18s ease-out;
}
@keyframes dpIn { from { opacity: 0; transform: translateY(-4px); } }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 4px 8px; }
.dp-month { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.dp-nav { display: flex; gap: 2px; }
.dp-nav .icon-btn { color: hsl(var(--accent)); }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; }
.dp-wd span { padding: 4px 0 6px; text-align: center; font-size: 11px; font-weight: 600; color: hsl(var(--subtle)); text-transform: uppercase; }
.dp-day {
  position: relative; height: 44px; padding: 0 0 4px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; font-size: 15px; color: hsl(var(--foreground));
}
.dp-day span {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-variant-numeric: tabular-nums; transition: background 0.12s, color 0.12s;
}
.dp-day:hover span { background: hsl(var(--secondary)); }
.dp-day.wkend span { color: hsl(var(--subtle)); }
.dp-day.hol span { background: hsl(152 60% 40% / 0.1); }
.dp-day.ft span { color: hsl(var(--bad)); }
.dp-day.today span { color: hsl(var(--accent)); font-weight: 700; }
.dp-day.sel span { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 600; }
.dp-day i {
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--c);
}
.dp-day.sel i { bottom: 10px; width: 4px; height: 4px; background: hsl(var(--accent-foreground)); }
.dp-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 10px; border-top: 1px solid hsl(var(--border)); }
.dp-quick .pill { padding: 5px 12px; font-size: 12px; }

/* ---------- Bestätigungsfenster (statt Browser-Popup) ---------- */

dialog.alert-dialog { width: min(340px, calc(100vw - 32px)); border-radius: 22px; text-align: center; }
dialog.alert-dialog[open] { animation: alertIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
@keyframes alertIn { from { opacity: 0; transform: scale(0.94); } }
.alert-body { padding: 28px 22px 20px; }
.alert-icon {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center;
  background: hsl(var(--accent) / 0.1); color: hsl(var(--accent));
}
.alert-icon.danger { background: hsl(var(--bad) / 0.1); color: hsl(var(--bad)); }
.alert-icon .ico { width: 22px; height: 22px; }
.alert-avatar {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 22px; font-weight: 600;
}
.alert-title { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.alert-msg { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: hsl(var(--muted-foreground)); overflow-wrap: anywhere; }
.alert-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; }
.alert-actions.single { grid-template-columns: 1fr; }
.alert-actions .btn { padding: 11px 14px; }
.btn-danger { background: hsl(var(--bad)); color: #fff; }

/* ---------- Responsiv (iPad & kleiner) ---------- */

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :first-child { grid-column: 1 / -1; }
  .hw-layout, .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .form-card { position: static; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .icon-btn.menu-btn { display: grid; margin-left: -8px; }
  .brand { width: auto; }
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; width: 280px; z-index: 30;
    transform: translateX(-105%); transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
  }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 60px 0 0 0; background: rgba(20, 24, 28, 0.2); z-index: 20; }
  .page { padding: 28px 20px 48px; }
}

@media (max-width: 680px) {
  .grid-3, .stat-row { grid-template-columns: minmax(0, 1fr); }
  .top-date { display: none; }
  .hide-sm { display: none; }
  .page { padding: 24px 16px 40px; }
  .card { padding: 16px; border-radius: 16px; }
  .hw-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .hw-row .icon-btn { grid-column: 3; justify-self: end; }
  .hero-num { font-size: 40px; }
  .cal-cell { min-height: 64px; padding: 4px 3px; gap: 2px; }
  .cal-num { width: 22px; height: 22px; font-size: 12px; }
  .cal-tag { display: none; }
  .cal-ev { width: auto; padding: 3px; background: transparent !important; }
  .cal-ev .dot { width: 8px; height: 8px; }
  .cal-ev-label { display: none; }
  .cal-cell .cal-ev { display: inline-flex; }
  .head-row { flex-wrap: wrap; align-items: flex-start; }
}
