/* ==========================================================================
   Materialausgabe - Gestaltung
   Mobil zuerst: die Abholseite wird fast ausschließlich am Handy geöffnet.
   Systemschriften, damit nichts nachgeladen werden muss.
   ========================================================================== */

:root {
  /* Farbwelt nach der Schulwebseite regental-gymnasium.de:
     Laub #006128 als Akzent, Tinte #16241B als Text, Grau #5C6B63,
     Papier #FCFDFB und Minze #E9F6EE als helle Flaechen. Der Akzent
     wird zur Laufzeit von /theme.css uebersteuert (Einstellung
     "Hauptfarbe"); diese Werte sind der Rueckfall. */
  --accent: #006128;
  --accent-dark: #00471e;
  --accent-light: #e9f6ee;

  --bg: #f4f8f5;
  --surface: #fcfdfb;
  --surface-muted: #edf3ee;
  --border: #d7e2da;
  --border-strong: #b3c4b8;

  --text: #16241b;
  --text-muted: #5c6b63;
  --text-faint: #84948a;

  --ok: #14713d;
  --ok-bg: #e6f4ec;
  --warn: #8a5200;
  --warn-bg: #fdf1e0;
  --error: #a3252a;
  --error-bg: #fbeaea;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 5%);

  --space: 1rem;
  --wrap: 60rem;

  /* Der Fokusring darf NICHT von --accent abhaengen: primary_color ist im
     Admin frei einstellbar (/theme.css setzt --accent um), ein zu heller
     Wert machte den Ring unsichtbar. Tanne #00471E: 10,5:1 auf --surface-muted. */
  --link: var(--accent);
  /* Textmarker auf der Startseite - Blatt-Gruen der Schulseite */
  --marker: #a9e3c1;
  --focus: #00471e;
  --ablage-rand: #6b7a70;    /* 4,2:1 auf --surface-muted */
  --ablage-rand-aktiv: #006128;
  --ablage-bg-aktiv: var(--accent-light);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dunkelmodus in denselben Gruentoenen, Richtung Tanne-Tief #003315. */
    --bg: #121a15;
    --surface: #1a231d;
    --surface-muted: #212c25;
    --border: #32423a;
    --border-strong: #46584e;

    --text: #e8f0ea;
    --text-muted: #a2b3a8;
    --text-faint: #7c8d82;

    --ok: #6fd39b;
    --ok-bg: #16321f;
    --warn: #f0b866;
    --warn-bg: #33260f;
    --error: #f08a8a;
    --error-bg: #351a1a;

    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 12px rgb(0 0 0 / 25%);

    --marker: #235c3b;
    --focus: #94dbb2;        /* Blatt der Schulseite; 9,3:1 auf --surface */
    --ablage-rand: #8a9c90;  /* 4,6:1 auf --surface-muted */
    --ablage-rand-aktiv: #94dbb2;
    --ablage-bg-aktiv: #1e3a2a;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.125rem;
}

main.wrap { flex: 1; padding-block: 1.75rem 3rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; border-radius: var(--radius-sm); }

/* --- Kopf- und Fußzeile ------------------------------------------------ */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding-block: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}
.brand-logo { height: 2.25rem; width: auto; max-width: 8rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.0625rem; }
.brand-text small { color: var(--text-muted); font-size: 0.8125rem; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  justify-content: space-between;
}
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }

.version {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--text-faint);
}
.footer-links a { color: var(--text-muted); }

.announcement {
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  padding-block: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

/* --- Typografie --------------------------------------------------------- */

h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.0625rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1rem; }
a { color: var(--link, var(--accent)); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.lead { font-size: 1.125rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* --- Karten ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-tight { padding: 1.125rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* --- Schaltflächen ----------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.6875rem 1.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--accent-dark); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-muted); }

.btn-danger { background: var(--error); }
.btn-danger:hover { background: color-mix(in srgb, var(--error) 80%, black); }

.btn-small { min-height: 2.25rem; padding: 0.3125rem 0.75rem; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* --- Formulare ---------------------------------------------------------- */

.field { margin-bottom: 1.375rem; }
.field:last-child { margin-bottom: 0; }

.field label,
.field > .label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.field-hint {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], input[type="url"],
select, textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.625rem 0.8125rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font: inherit;
  color: var(--text);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6875rem;
  margin-bottom: 1rem;
  cursor: pointer;
}
.checkbox input { width: 1.25rem; height: 1.25rem; margin-top: 0.1875rem; flex: none; accent-color: var(--accent); }
.checkbox span { font-weight: 500; }
.checkbox .field-hint { margin-top: 0.125rem; font-weight: 400; }

.field-row { display: grid; gap: 1rem; }
@media (min-width: 34rem) {
  .field-row-2 { grid-template-columns: 1fr 1fr; }
}

fieldset { border: none; margin: 0 0 1.5rem; padding: 0; }
fieldset legend {
  font-weight: 700;
  font-size: 1.0625rem;
  padding: 0;
  margin-bottom: 0.75rem;
}

/* --- Meldungen ---------------------------------------------------------- */

.alert {
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
  font-size: 0.9375rem;
}
.alert-error { background: var(--error-bg); color: var(--error); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-info { background: var(--accent-light); color: var(--link, var(--accent-dark)); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.alert ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.alert p:last-child { margin-bottom: 0; }

/* --- Abzeichen ---------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.1875rem 0.5625rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--error-bg); color: var(--error); }

/* --- Dateiliste --------------------------------------------------------- */

.file-list { list-style: none; margin: 0; padding: 0; }

.file-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 0.875rem;
  padding: 0.9375rem 0;
  border-bottom: 1px solid var(--border);
}
.file-item:last-child { border-bottom: none; }

.file-icon {
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--link, var(--accent-dark));
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.file-info { flex: 1 1 8rem; min-width: 0; }

/* overflow-wrap statt word-break: trennt nur dort, wo es sonst überliefe -
   word-break hätte lange Namen mitten im Wort zerlegt. */
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { font-size: 0.875rem; color: var(--text-muted); }
.file-actions { flex: none; display: flex; gap: 0.5rem; align-items: center; }

/* Auf dem Handy rücken die Schaltflächen unter den Dateinamen. Nebeneinander
   bliebe für den Namen so wenig Platz, dass er zeichenweise umbräche. */
@media (max-width: 30rem) {
  /* Sinnbild und Name bleiben nebeneinander, nur die Schaltflächen
     rücken in eine eigene Zeile darunter. */
  .file-actions { flex: 1 0 100%; }
  .file-actions .btn { flex: 1; }
}

/* --- Tabellen ----------------------------------------------------------- */

.table-scroll { overflow-x: auto; margin-inline: -1.5rem; padding-inline: 1.5rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th, td { text-align: left; padding: 0.6875rem 0.75rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
tbody tr:hover { background: var(--surface-muted); }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Kennzahlen --------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
}
.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

/* --- Balkenverlauf ------------------------------------------------------ */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 7rem; margin-top: 0.75rem; }
.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  opacity: 0.85;
}
.chart-bar:hover { opacity: 1; }
.chart-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.375rem; }

/* --- QR-Darstellung ----------------------------------------------------- */

.qr-panel {
  display: grid;
  gap: 1.75rem;
  align-items: start;
}
@media (min-width: 44rem) {
  .qr-panel { grid-template-columns: 17rem 1fr; }
}

.qr-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.qr-box img { width: 100%; height: auto; display: block; }

.code-display {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--link, var(--accent));
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  text-align: center;
  margin: 0.5rem 0 0;
}

.link-box {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.5rem;
}
.link-box input {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
}

/* --- Große Codeeingabe ------------------------------------------------- */

.code-input {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.75rem;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
  min-height: 4rem;
}

.pin-input {
  font-size: 2rem;
  letter-spacing: 0.6em;
  text-align: center;
  min-height: 4rem;
  padding-left: 0.6em;
}

/* --- Startseite (Schüler zuerst) ---------------------------------------- */

.start { max-width: 42rem; margin-inline: auto; }

/* Hero: grosse, freundliche Ansage. ui-rounded greift auf Apple-Geraeten
   (dem Schuelerhandy schlechthin) und faellt sonst auf system-ui zurueck. */
.start-hero {
  position: relative;
  padding: 1.25rem 0 0.5rem;
}

.start-titel {
  font-family: ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(2.375rem, 9vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin: 0 0 1rem;
  position: relative;
  z-index: 1;
}

/* Textmarker-Strich: leicht schief, wie mit dem Leuchtstift gezogen */
.start-marker {
  background: linear-gradient(100deg,
    transparent 2%,
    var(--marker) 6%,
    var(--marker) 94%,
    transparent 98%);
  color: inherit;
  padding: 0.05em 0.18em;
  margin: 0 -0.08em;
  border-radius: 0.15em;
  transform: rotate(-1.2deg);
  display: inline-block;
}

.start-lead {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 32rem;
  margin: 0 0 1.75rem;
  position: relative;
  z-index: 1;
}

/* Angedeutetes QR-Muster, das nach unten "aufloest" - die Signatur der Seite */
.start-qrdeko {
  position: absolute;
  top: -0.5rem;
  right: -0.75rem;
  width: clamp(6.5rem, 22vw, 9.5rem);
  height: auto;
  color: var(--accent);
  opacity: 0.5;
  pointer-events: none;
}

/* Ticket-Zelle: die eine Handlung dieser Seite. Kerben links und rechts
   wie an einem Abriss-Ticket. */
.start-ticket {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.375rem 1.5rem 1.125rem;
  margin-bottom: 2rem;
}
.start-ticket::before,
.start-ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  transform: translateY(-50%);
}
.start-ticket::before { left: -0.8125rem; }
.start-ticket::after { right: -0.8125rem; }

.start-ticket-label {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: 0.625rem;
}

.start-code-zeile { display: flex; gap: 0.625rem; }
.start-code-zeile .code-input {
  flex: 1;
  min-width: 0;
  font-size: 1.5rem;
  min-height: 3.75rem;
  letter-spacing: 0.14em;
  border-width: 2px;
}
.start-los {
  min-height: 3.75rem;
  padding-inline: 1.75rem;
  flex: none;
  font-size: 1.125rem;
  border-radius: var(--radius-sm);
}

.start-ticket .field-hint { margin-top: 0.75rem; }

/* Drei Schritte als stille Leiste - der Inhalt IST eine Reihenfolge */
.start-schritte {
  display: grid;
  gap: 1rem;
  padding: 0.25rem 0.125rem;
}
@media (min-width: 38rem) {
  .start-schritte { grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
}

.start-schritt {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.start-schritt p { margin: 0; font-size: 0.9375rem; color: var(--text-muted); }
.start-schritt strong { color: var(--text); }

.start-schritt-nr {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--link, var(--accent));
  border: 2px solid var(--link, var(--accent));
  margin-top: 0.0625rem;
}

/* Gestaffeltes Erscheinen beim Laden - eine Bewegung, kein Feuerwerk */
@media (prefers-reduced-motion: no-preference) {
  .start-hero, .start-ticket, .start-schritte {
    animation: start-auftritt 0.45s ease-out backwards;
  }
  .start-ticket { animation-delay: 0.08s; }
  .start-schritte { animation-delay: 0.16s; }
}
@keyframes start-auftritt {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: none; }
}

/* --- Auswahlkacheln auf der Startseite ---------------------------------- */

.choice-grid { display: grid; gap: 1rem; margin-top: 1.5rem; }
@media (min-width: 40rem) { .choice-grid { grid-template-columns: 1fr 1fr; } }

.choice {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.choice:hover { border-color: var(--accent); transform: translateY(-2px); }
.choice h2 { margin: 0 0 0.375rem; font-size: 1.1875rem; }
.choice p { margin: 0; color: var(--text-muted); font-size: 0.9375rem; }

/* --- Admin-Navigation --------------------------------------------------- */

.admin-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
  scrollbar-width: thin;
}
.admin-nav a {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9375rem;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.admin-nav a:hover { color: var(--text); }
.admin-nav a.active { color: var(--link, var(--accent)); border-bottom-color: var(--accent); }

.tab-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.tab-nav a {
  padding: 0.5rem 0.9375rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.tab-nav a.active { background: var(--accent); color: #fff; }

/* --- Kopfzeile einer Seite ---------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin-bottom: 0.25rem; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar input, .filter-bar select { min-width: 9rem; }

.pagination { display: flex; gap: 0.5rem; align-items: center; justify-content: center; margin-top: 1.5rem; }

/* --- Zentrierte, schmale Seiten ----------------------------------------- */

.narrow { max-width: 28rem; margin-inline: auto; }
.centered { text-align: center; }

.big-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

/* --- Startpasswort-Miniformular in der Lehrkraefte-Tabelle --------------- */

.startpw-form { display: inline-flex; gap: 0.375rem; align-items: center; }
.startpw-feld {
  width: 9.5rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* --- Sammelaktionen in der Materialliste -------------------------------- */

.spalte-auswahl { width: 2.25rem; }
.spalte-auswahl input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

.sammel-leiste {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* --- Werkzeugklassen ---------------------------------------------------- */

/* Nur fuer Vorlesewerkzeuge. Bewusst kein display:none - der Text bliebe
   sonst auch aus dem Zugaenglichkeitsbaum heraus. */
.nur-vorlesen {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Ersetzt die style="margin-bottom:0"-Attribute: unter style-src 'self'
   wirken Inline-Stile im HTML ohnehin nicht. */
.mb-0 { margin-bottom: 0; }
.feld-schmal { max-width: 10rem; }

.nur-mit-js { display: none; }
.ablage--js .nur-mit-js { display: inline; }

/* --- Ablageflaeche im Upload-Formular ----------------------------------- */

.ablage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  border-radius: var(--radius-sm);
}

/* .field label ist spezifischer als eine einzelne Klasse - deshalb muss die
   Regel ueber .ablage laufen, sonst gewinnen font-weight und display der
   allgemeinen Formularregel. */
.ablage .ablage-flaeche {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 7.5rem;   /* gross genug zum Zielen, klein genug, dass die
                           Absendetaste am Handy sichtbar bleibt */
  margin-bottom: 0;
  padding: 1.25rem 1rem;
  text-align: center;
  border: 2px dashed var(--ablage-rand);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  cursor: pointer;
  font-weight: 400;
}
.ablage .ablage-symbol {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--ablage-rand);
  margin-bottom: 0.25rem;
}
.ablage--bereit .ablage-symbol,
.ablage:focus-within .ablage-symbol { color: var(--ablage-rand-aktiv); }

.ablage .ablage-titel { font-weight: 600; font-size: 1.0625rem; }
.ablage .ablage-text { color: var(--text-muted); font-size: 0.9375rem; }

/* Fokusring am Kasten, weil das Feld mit Skript nur 1px gross ist. */
.ablage:focus-within .ablage-flaeche {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--ablage-rand-aktiv);
}

/* Ohne Skript bleibt das Feld sichtbar: nur der zweite gestrichelte Rand
   stoert, deshalb durchgezogen. */
.ablage .ablage-feld { border-style: solid; }

/* Nur wenn das Skript laeuft UND input.files gesetzt werden kann. */
.ablage--js .ablage-feld {
  position: absolute;
  left: 1rem;     /* INNERHALB des Kastens: die Browsermeldung "Bitte waehlen
                     Sie eine Datei aus" haengt sich an diese Stelle */
  bottom: 0.5rem;
  width: 1px; height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;     /* nicht display/visibility/hidden: sonst ist das Feld nicht
                     mehr fokussierbar und Chrome bricht das Absenden eines
                     nicht dargestellten Pflichtfeldes kommentarlos ab */
  pointer-events: none;  /* der Klick soll immer das Label treffen, sonst
                            oeffnet sich der Dialog doppelt */
}

/* Zustand waehrend des Ziehens: statisch, nicht animiert. */
.ablage--bereit .ablage-flaeche {
  border-color: var(--ablage-rand-aktiv);
  border-style: solid;
  background: var(--ablage-bg-aktiv);
}

.datei-status {
  margin: 0.75rem 0 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  min-height: 1.4em;   /* kein Springen des Layouts beim ersten Text */
}

/* --- Beruehrziele in der Dateiliste ------------------------------------- */

.file-actions { gap: 0.75rem; }
.file-actions .btn,
.btn-entfernen {
  min-height: 2.75rem;   /* 44px - .btn-small waeren nur 36px */
  min-width: 2.75rem;
  padding: 0.5rem 1.125rem;
  font-size: 0.9375rem;
}

/* --- Dateitypen im Admin-Bereich ---------------------------------------- */

.ext-groups { display: grid; gap: 0.875rem; margin-bottom: 1.25rem; }

.ext-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  padding: 0.875rem 1rem;
}

.ext-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ext-group-title { font-weight: 700; font-size: 1rem; }
.ext-group-hint { margin: 0.25rem 0 0.625rem; }

/* Der Gruppenschalter kommt vom Server mit hidden und wird erst von app.js
   sichtbar gemacht. Ohne diese Regel schlaegt display:inline-flex aus .btn
   das hidden-Attribut und der Schalter waere auch ohne Skript zu sehen. */
.ext-toggle[hidden] { display: none; }

.ext-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.125rem 0.75rem;
}

.ext-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3125rem 0;
  min-height: 2.75rem;   /* 44px Antippflaeche, auch bei kurzem Text */
  cursor: pointer;
}
.ext-item input {
  width: 1.375rem;
  height: 1.375rem;
  margin-top: 0.375rem;
  flex: none;
  accent-color: var(--accent);
}
.ext-item:hover .ext-code { color: var(--link, var(--accent)); }

.ext-text { min-width: 0; }
.ext-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}
.ext-name {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.ext-name .badge { font-size: 0.6875rem; padding: 0.0625rem 0.4375rem; }

.ext-count { font-variant-numeric: tabular-nums; }

.ruecksetz-form { margin-bottom: 1.25rem; }

/* --- Weniger Bewegung --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Sonstiges ---------------------------------------------------------- */

.divider { height: 1px; background: var(--border); border: none; margin: 1.75rem 0; }

.inline-form { display: inline; }

details.help {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  background: var(--surface-muted);
  margin-bottom: 1.25rem;
}
details.help summary { cursor: pointer; font-weight: 600; }
details.help-klein { margin-top: 0.5rem; padding: 0.5rem 0.75rem; }
details.help-klein summary { font-weight: 500; font-size: 0.875rem; color: var(--text-muted); }
details.help > *:not(summary) { margin-top: 0.75rem; }

.copied { color: var(--ok); font-weight: 600; font-size: 0.875rem; }

@media print {
  .site-header, .site-footer, .btn, .admin-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; padding: 0; }
}
