:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 0.75rem;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #818cf8;
    --brand-dark: #a5b4fc;
    --brand-light: #312e81;
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  max-width: 75rem;
  margin: 0 auto;
}

header nav a.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  margin-right: 0.5rem;
  text-decoration: none;
}

header nav a.brand svg {
  flex-shrink: 0;
}

header nav a:not(.brand) {
  color: rgba(255, 255, 255, 0.88);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

header nav a:not(.brand):hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

header nav form {
  margin: 0;
}

#nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.nav-toggle-btn {
  display: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  margin-left: auto;
  user-select: none;
}

.nav-toggle-btn::before {
  content: "☰ ";
}

.nav-toggle:checked ~ .nav-toggle-btn::before {
  content: "✕ ";
}

.nav-toggle:focus-visible ~ .nav-toggle-btn {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

header nav form button {
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

header nav form button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

main {
  padding: 1.5rem;
  max-width: 75rem;
  margin: 1.5rem auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

main h1 {
  margin-top: 0;
  color: var(--text);
  border-bottom: 3px solid var(--brand-light);
  padding-bottom: 0.5rem;
}

main h2 {
  color: var(--brand);
  font-size: 1.15rem;
}

main section + section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.hero {
  background: radial-gradient(circle at top left, var(--brand-light), transparent 60%);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: -0.5rem -0.5rem 1rem;
}

.event-countdown {
  font-weight: 600;
  color: var(--brand-dark);
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  align-items: stretch;
  gap: 1rem;
  margin-top: 1rem;
}

.hero-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hero-card h2 {
  margin: 0;
}

.hero-card p {
  margin: 0;
  flex-grow: 1;
}

.hero-card a {
  align-self: flex-start;
}

.hero-card--primary {
  border: 2px solid var(--brand);
  background: var(--brand-light);
}

.hero-card--primary a {
  background: var(--brand);
  color: #fff;
  padding: 0.55rem 1.1rem;
  border-radius: 0.5rem;
  font-weight: 600;
}

.hero-card--primary a:hover {
  background: var(--brand-dark);
  text-decoration: none;
}

footer {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 75rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1rem;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 1.5rem auto 0;
  max-width: 75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.messages li {
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border-left: 4px solid var(--text-muted);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.messages li.success {
  border-left-color: #16a34a;
  background: color-mix(in srgb, #16a34a 10%, var(--surface));
}

.messages li.error {
  border-left-color: #dc2626;
  background: color-mix(in srgb, #dc2626 10%, var(--surface));
}

.messages li.warning {
  border-left-color: #d97706;
  background: color-mix(in srgb, #d97706 10%, var(--surface));
}

.manual-check-row th,
.manual-check-row td {
  background: color-mix(in srgb, #d97706 15%, var(--surface));
}

.manual-check-flag {
  color: #d97706;
  font-weight: bold;
}

.messages li.info {
  border-left-color: #0ea5e9;
  background: color-mix(in srgb, #0ea5e9 10%, var(--surface));
}

button,
input[type="submit"] {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

button:hover,
input[type="submit"]:hover {
  background: var(--brand-dark);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

td button {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
}

input:not([type="submit"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

textarea {
  max-width: none;
  resize: vertical;
}

form p {
  margin-bottom: 1rem;
}

ul.errorlist {
  color: #dc2626;
  font-size: 0.85rem;
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}

.helptext {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-errors-summary {
  border-left: 4px solid #dc2626;
  background: color-mix(in srgb, #dc2626 10%, var(--surface));
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.form-errors-summary p {
  margin: 0 0 0.4rem;
  font-weight: 600;
}

.form-errors-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border-collapse: collapse;
  width: 100%;
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-image:
    linear-gradient(to right, var(--surface) 50%, transparent),
    linear-gradient(to left, var(--surface) 50%, transparent),
    radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0));
  background-size: 48px 100%, 48px 100%, 22px 100%, 22px 100%;
  background-position: 0 0, 100% 0, 0 0, 100% 0;
  background-attachment: local, local, scroll, scroll;
}

th, td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

thead th {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: var(--brand-light);
}

.yearbook-row-linked td {
  background: rgba(22, 163, 74, 0.08);
}

.yearbook-row-unavailable td {
  color: var(--text-muted, #888);
  opacity: 0.6;
}

#yearbook-table .yearbook-subject-input {
  width: 10rem;
  max-width: none;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable::after {
  content: "\21C5";
  display: inline-block;
  margin-left: 0.3em;
  opacity: 0.4;
  font-size: 0.8em;
}

th.sortable[data-sort-dir="asc"]::after {
  content: "\2191";
  opacity: 1;
}

th.sortable[data-sort-dir="desc"]::after {
  content: "\2193";
  opacity: 1;
}

.directory-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 1rem;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  text-align: center;
}

.gallery-card:hover {
  background: var(--brand-light);
  text-decoration: none;
}

.gallery-card img {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  object-fit: cover;
}

.gallery-placeholder {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
}

.contact-detail-photo {
  max-width: 100%;
  width: 20rem;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 1rem;
}

.home-top-row {
  display: flow-root;
}

.home-top-row > section:not(.attendance-banner) {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.attendance-banner {
  background: var(--brand-light);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.25rem;
  float: left;
  width: 320px;
  max-width: 100%;
  margin: 0 1.5rem 1.5rem 0;
}

.profile-photo {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 0.75rem;
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.avatar-option img,
.avatar-option-none {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-option-none {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
  font-size: 0.7rem;
  text-align: center;
}

.attendance-banner h2 {
  margin-top: 0;
}

.attendance-banner .attendance-locked-note {
  font-weight: 600;
  color: var(--brand-dark);
}

.attendance-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.attendance-badge.attendance-ja {
  background: color-mix(in srgb, #16a34a 15%, var(--surface));
  color: #16a34a;
}

.attendance-badge.attendance-unsicher {
  background: color-mix(in srgb, #d97706 15%, var(--surface));
  color: #d97706;
}

.attendance-badge.attendance-nein {
  background: color-mix(in srgb, #dc2626 15%, var(--surface));
  color: #dc2626;
}

.role-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.role-badge-teacher {
  background: color-mix(in srgb, #7c3aed 15%, var(--surface));
  color: #7c3aed;
}

.role-badge-student {
  background: color-mix(in srgb, #2563eb 15%, var(--surface));
  color: #2563eb;
}

.yearbook-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.yearbook-toolbar .role-filter-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.yearbook-toolbar .role-filter-btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.yearbook-toolbar input[type="search"] {
  width: auto;
  min-width: 14rem;
  margin: 0;
}

.yearbook-summary {
  font-weight: 600;
}

@media (max-width: 900px) {
  .nav-toggle-btn {
    display: inline-block;
  }

  #nav-links {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .nav-toggle:checked ~ #nav-links {
    display: flex;
  }
}

@media (max-width: 640px) {
  main {
    margin: 0.75rem;
    padding: 1rem;
  }

  header nav {
    padding: 0.6rem 0.75rem;
  }

  .home-top-row .attendance-banner {
    float: none;
    width: auto;
    margin-right: 0;
  }
}

/* Honeypot-Feld gegen Bots (Registrierungsformular): für Sehende und
   Screenreader gleichermaßen unsichtbar, aber im DOM/Tab-Fokus vorhanden,
   damit naive Bots, die Formularfelder blind befüllen, hineintappen. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
