@font-face {
  font-family: "Luciole";
  src:
    local("Luciole"),
    local("Luciole-Regular"),
    url("./fonts/Luciole-Regular.woff2") format("woff2"),
    url("./fonts/Luciole-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Luciole";
  src:
    local("Luciole Bold"),
    local("Luciole-Bold"),
    url("./fonts/Luciole-Bold.woff2") format("woff2"),
    url("./fonts/Luciole-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Luciole";
  src:
    local("Luciole Italic"),
    local("Luciole-Italic"),
    url("./fonts/Luciole-Italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Luciole";
  src:
    local("Luciole Bold Italic"),
    local("Luciole-Bold-Italic"),
    url("./fonts/Luciole-Bold-Italic.woff2") format("woff2"),
    url("./fonts/Luciole-Bold-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Luciole Math";
  src:
    local("Luciole Math"),
    local("Luciole-Math"),
    url("./fonts/Luciole-Math.woff2") format("woff2"),
    url("./fonts/Luciole-Math.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Luciole Math";
  src:
    local("Luciole Math Bold"),
    local("Luciole-Math-Bold"),
    url("./fonts/Luciole-Math-Bold.otf") format("opentype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  /* meinblatt / UKAAF G003 — Low-Vision-Palette, alle Werte WCAG-AA auf Weiß */
  --bg: #f6f6f6;
  --paper: #ffffff;
  --text: #111111;
  --muted: #595959;
  --border: #b8b8b8;
  --rule: #a6a6a6;
  --h1: #1F3864;
  --h2: #2E74B5;
  --h3: #2E74B5;
  --accent: #B84A47; /* Kontrast 4,7:1 auf #f6f6f6 (#C0504D hatte nur 4,3:1, WCAG 1.4.3) */
  --link: #0563C1;
  --link-visited: #954F72;
  --focus: #004f9e;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.08);

  --font: "Luciole", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --math-font: "Luciole Math", "Luciole", system-ui, sans-serif;
  --print-font: "Luciole", system-ui, sans-serif;
  --base-font-size: 14pt;
  --preview-font-size: 12pt;

  /* Aliase für bestehende Klassen */
  --fg: var(--text);
  --panel: #F2F2F2;
  --panel-2: var(--paper);
  --accent-bg: color-mix(in srgb, var(--accent) 12%, transparent);
  --error: var(--accent);
  --radius: 0.7rem;
  --status-bg: #F2F2F2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: var(--base-font-size);
  line-height: 1.5;
  hyphens: none;
  -webkit-hyphens: none;
  text-rendering: optimizeLegibility;
  text-align: left;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

input, select, button, textarea, summary, label,
h1, h2, h3, h4, h5, p, li, div, span, a, pre, code {
  font: inherit;
  font-family: var(--font);
}

.skip-nav {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}
.skip-links { display: contents; }
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.4;
}
.skip-link:focus,
.skip-link:focus-visible {
  position: static;
  width: auto;
  height: auto;
  padding: 0.15rem 0.65rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  border-radius: 999px;
  border: 1px solid var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}
body:not([data-entry-role="teacher"]) .skip-link[data-role="teacher"] { display: none; }
body[data-entry-role="teacher"] .skip-link[data-role="student"] { display: none; }
body:not(.personal-boards-mode) .skip-link[data-panel="personalboards"] { display: none; }
body:not(.teacher-boards-mode) .skip-link[data-panel="boards"] { display: none; }

.app {
  max-width: 1680px;
  margin: 0 auto;
  padding: 10px 20px 72px;
}
.titlebar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.site-title {
  font-size: 1.25rem;
  font-weight: 700;
}
.site-version {
  font-weight: 700;
  color: var(--muted);
}
/* Marken-Logo (/brand/logo.png) ersetzt den Namen, sobald es geladen ist. Das Logo ist dunkel
   auf hellem Grund gezeichnet und bekommt deshalb in jedem Layout einen weißen Träger. */
.site-logo {
  display: none;
  height: 2rem;
  width: auto;
  vertical-align: middle;
  background: #fff;
  border-radius: 0.3rem;
  padding: 0.1rem 0.35rem;
}
.site-title.has-logo .site-logo { display: inline-block; }
.site-title.has-logo .site-name { display: none; }
.overlay-panel.about-panel { width: min(30rem, calc(100vw - 24px)); }
.about-body { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; text-align: center; }
.about-logo {
  max-width: min(18rem, 100%);
  height: auto;
  background: #fff;
  border-radius: 0.4rem;
  padding: 0.4rem 0.6rem;
}
.about-claim { margin: 0; font-weight: 700; }
.about-version { margin: 0; color: var(--muted); }
/* „trusted": vertrauliche, attestierte KI-Umgebung (Privatemode). Board-Rot. */
.site-trusted {
  font-weight: 700;
  color: var(--accent);
}
.subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.2;
  margin-top: 0.1rem;
}
.titlebar-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.user-menu {
  position: relative;
}
.user-menu > button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 14rem;
}
.user-menu > button #userMenuLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu .user-menu-caret {
  font-size: 0.7em;
  opacity: 0.7;
}
.user-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  background: var(--panel-2, #fff);
  border: 1px solid var(--border, #ccc);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}
.user-menu-popover[hidden] { display: none; }
.user-menu-popover button,
.user-menu-popover .user-menu-link {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--fg, inherit);
  text-decoration: none;
  font-size: inherit;
  font-family: inherit;
  white-space: nowrap;
}
.user-menu-popover button:hover,
.user-menu-popover button:focus-visible,
.user-menu-popover .user-menu-link:hover,
.user-menu-popover .user-menu-link:focus-visible {
  background: var(--bg, #f0f0f0);
}
.user-menu-sep {
  height: 1px;
  background: var(--border, #ddd);
  margin: 4px 2px;
}
.profile-form {
  display: grid;
  gap: 12px;
}
.profile-field-row {
  display: grid;
  gap: 4px;
}
.profile-field-row label {
  font-weight: 600;
  font-size: 0.9rem;
}
.profile-field-row input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
}
/* Kontrollkästchen mit Beschriftung: Kästchen vor dem Text in einer Zeile (Sichtprüfung 21.10.2026, #941) */
.profile-field-row:has(> input[type="checkbox"]) {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
}
.profile-field-row input[type="checkbox"] {
  min-height: 0;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
}
.export-braille-form { display: grid; gap: 12px; }
.export-braille-intro { margin: 0; font-size: 0.9rem; color: var(--muted, #666); }
.export-braille-field { display: grid; gap: 4px; }
.export-braille-field label { font-weight: 600; font-size: 0.9rem; }
.export-braille-field select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.export-braille-field input[type="number"] {
  min-height: 40px;
  width: 7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
.export-braille-profiles { border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px 10px; margin: 0; }
.export-braille-profiles legend { font-weight: 600; font-size: 0.9rem; padding: 0 4px; }
.export-braille-profiles label { display: block; padding: 3px 0; font-size: 0.9rem; }
.export-braille-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.sheet-dialog-hint {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted, #666);
}
.sheet-dialog-hint[data-tone="warn"] {
  color: var(--error);
  font-weight: 600;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted, #666);
}
.profile-message {
  min-height: 1.2em;
  font-size: 0.9rem;
}
.profile-message[data-kind="error"] { color: var(--accent); }
.profile-message[data-kind="ok"] { color: #1f7a3a; }
.entry-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.1rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #eef4ff;
  color: #1f3f7a;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.split {
  display: grid;
  gap: 0;
  align-items: stretch;
  grid-template-columns: minmax(320px, 1fr) 14px minmax(320px, 1fr);
}

/* Explizites Grid-Placement, unabhängig von der DOM-Reihenfolge (Eingabe → Vorschau →
   Board-Verbindung → Board-Tools → Resizer zuletzt, für eine ungebrochene Tab-Reihenfolge) */
.split > .pane-top    { grid-row: 1; }
.split > .pane-bottom { grid-row: 2; }
.split > .pane-input  { grid-column: 1; }
.split > .pane-output { grid-column: 3; }
.split > .split-resizer { grid-column: 2; grid-row: 1 / 3; align-self: stretch; }

/* Obere und untere Hälfte derselben Spalte sehen wie eine Box aus */
.split > .pane.pane-top {
  border-radius: 0.7rem 0.7rem 0 0;
  border-bottom: none;
}
.split > .pane.pane-bottom {
  border-radius: 0 0 0.7rem 0.7rem;
}

@media (max-width: 980px) {
  .split {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .split > .pane-top,
  .split > .pane-bottom,
  .split > .pane-input,
  .split > .pane-output {
    grid-column: 1;
    grid-row: auto;
  }
  .split > .pane.pane-top {
    border-radius: 0.7rem;
    border-bottom: 1px solid var(--border);
  }
  .split > .pane.pane-bottom {
    border-radius: 0.7rem;
  }
}

/* ── Pane-Resizer ─────────────────────────────────────────────────────────── */
.split-resizer {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  border-radius: 4px;
  transition: background 0.15s;
}
.split-resizer::before {
  content: '';
  display: block;
  width: 3px;
  height: 36px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s, height 0.15s;
}
.split-resizer:hover::before,
.split-resizer:focus-visible::before {
  background: var(--accent);
  height: 56px;
}
.split-resizer:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 980px) {
  .split-resizer { display: none; }
}

.pane {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.pane > section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pane-header {
  display: flex;
  flex-wrap: wrap;
  row-gap: 6px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  min-height: 2.25rem;
}
.pane-header h1 {
  margin: 0;
  font-size: 1.14rem;
  line-height: 1.2;
}
.pane-header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  row-gap: 6px;
}
.pane-header-file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  border-left: 1px solid var(--border);
  padding-left: 0.5rem;
}
.pane-header-file-actions button {
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
  min-height: 32px;
}

#source {
  width: 100%;
  flex: 0 0 auto;
  height: clamp(420px, 68vh, 980px);
  padding: 16px;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--text);
  font-size: 1em;
  line-height: 1.5;
  resize: none;
  overflow: auto;
  white-space: pre-wrap;
  caret-color: var(--fg);
  scrollbar-gutter: stable;
}
#source[data-board-readonly] {
  cursor: text;
}
#source[data-board-offline] {
  cursor: not-allowed;
  border-left: 4px solid var(--accent);
  opacity: 0.85;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pane-input .button-row {
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: space-between;
  overflow-x: auto;
  padding: 6px;
  margin: -6px;
  scrollbar-gutter: stable;
}
.pane-input .button-row button {
  padding: 0.4rem 0.45rem;
}
.button-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.button-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.button-group + .button-group {
  margin-left: 6px;
}
.button-group-end {
  margin-left: auto;
}
button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 0.45rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }

.button-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 0.45rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.button-link:hover { border-color: var(--accent); }
/* Alle Bedienelemente der Knopfzeilen (Knöpfe, Links, Auswahlfeld) gleich hoch und so flach wie möglich */
.pane .button-row :is(button, .button-link, select) {
  box-sizing: border-box;
  height: 1.9rem;
  padding-block: 0;
  line-height: 1.2;
}
.button-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.pane-input .button-row .button-link { padding: 0.4rem 0.45rem; }
.button-danger {
  border-color: color-mix(in srgb, var(--error) 55%, var(--border));
  color: color-mix(in srgb, var(--error) 88%, black);
}
.button-danger:hover { border-color: var(--error); }
button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: default;
}
button[aria-disabled="true"]:hover { border-color: var(--border); }
.board-context-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.board-context-switch button[aria-pressed="true"]:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
  border-color: color-mix(in srgb, var(--accent) 85%, black);
}
button:focus-visible,
summary:focus-visible,
.skip-link:focus-visible,
pre:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.programmatic-focus-ring {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.fold {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel-2);
  overflow: hidden;
}
.fold > summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  list-style: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .technik-heading {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}
.fold-body { padding: 0 14px 14px; }
.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}
.rules-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.rules-grid h3 { margin: 0 0 8px; font-size: 1rem; }
.rules-grid ul { margin: 0; padding-left: 1.15rem; }
.rules-grid li { margin: 0.32rem 0; }
.rules-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 1100px) {
  .rules-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}
@media (max-width: 760px) {
  .rules-grid {
    grid-template-columns: 1fr;
  }
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.tech-grid p { margin: 0 0 6px; font-size: 1rem; }
pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 6rem;
  max-height: 18rem;
  overflow: auto;
}

.preview {
  flex: 0 0 auto;
  height: clamp(420px, 68vh, 980px);
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--paper);
  overflow-y: auto;
  overflow-x: hidden;
  cursor: text;
  user-select: text;
  outline: none;
  caret-color: var(--fg);
  scrollbar-gutter: stable;
  font-size: var(--preview-font-size);
}
.preview:focus { box-shadow: none; }
/* Eingebettete Bilder (z. B. aus dem Dokumentkonverter-Import) dürfen den
   Vorschau-Container nicht in seiner natürlichen Pixelbreite sprengen — sonst
   kann eine Grid-/Flex-Spalte mit der Vorschau ihre Nachbarspalte (z. B. den
   Eingabe-Editor im Dokumentkonverter) auf wenige Pixel zusammendrücken. */
.preview img {
  max-width: 100%;
  height: auto;
}

/* ── Math ─────────────────────────────────────────────────────────────────── */
.preview math {
  font-family: "Luciole Math", "Luciole", serif;
  font-size: 1em;
  font-style: normal;
  math-style: normal;    /* Low Vision: verhindert mfrac-Tiefenskalierung in Inline-Kontext */
}
.preview math * {
  math-depth: 0 !important;    /* Low Vision: verhindert Verkleinerung von Hoch-/Tiefstellungen */
}
/* Low Vision erlaubt trotzdem einen leichten Kontrast Basis/Exponent (sonst nicht unterscheidbar,
   z. B. x^2 oder Ableitungsstriche f'''); volle native Verkleinerung bliebe zu klein zum Lesen. */
.preview msup > *:last-child,
.preview msub > *:last-child,
.preview msubsup > *:nth-child(2),
.preview msubsup > *:nth-child(3) {
  font-size: 0.8em;
}
.preview math[display="block"] {
  display: block;
  overflow: visible;
  padding: 0.25rem 0;
  text-align: left;
  margin: 0;
}
.preview .display-math {
  margin: 0.9rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0;
  text-align: left;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}
.preview .display-math > * {
  display: inline-block;
  min-width: max-content;
  max-width: none;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.preview .display-math .tml-display,
.preview .display-math .temml-display,
.preview .display-math math[display="block"],
.preview .tml-display,
.preview .temml-display {
  display: block !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  text-align: left !important;
  justify-content: flex-start !important;
}

/* Chromium rendert <menclose> nicht nativ → CSS-Polyfill (wie Temml-Local.css) */
@supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
  menclose {
    position: relative;
    padding: 0.5ex 0;
  }
  .tml-overline {
    padding: 0.1em 0 0 0;
    border-top: 0.065em solid;
  }
  .tml-underline {
    padding: 0 0 0.1em 0;
    border-bottom: 0.065em solid;
  }
}

/* Low-Vision: Italic-Correction-Fallback für enge Superscript-Basen (Chrome) */
.preview msup > mi:first-child,
.preview msup > mrow > mi:first-child {
  margin-right: 0.02em;
}

/* ── Seitenmarke des Originals (role="doc-pagebreak") ─────────────────────── */
.preview .seitenmarke {
  margin: 1.1rem 0 0.6rem;
  font-size: 0.8em;
  opacity: 0.75;
}

/* ── Nummerierter Formelblock ─────────────────────────────────────────────── */
.preview .math-block {
  margin: 1rem 0;
  border-left: 0.35em double var(--h1);
  padding: 0.35rem 0 0.35rem 0.7rem;
  border-radius: 0;
}
.preview .math-block .display-math {
  margin: 0;
}
.preview .math-block-label {
  display: block;
  font-weight: 700;
  color: var(--h1);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}
.preview .display-math-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.preview .display-math-item .display-math {
  margin: 0.4rem 0;
}
.preview .display-math-item-label {
  flex: none;
  font-weight: 700;
}

/* ── Berechnen-Ergebniszeile ("=> ...") etwas von der Eingabeformel absetzen ── */
.preview br.calc-result-break {
  display: block;
  content: "";
  margin-top: 0.3em;
}

/* ── Vertikaler Rhythmus ───────────────────────────────────────────────────── */
.preview > :first-child { margin-top: 0; }
.preview p,
.preview ul,
.preview ol,
.preview pre,
.preview blockquote,
.preview table {
  margin: 0 0 1.1rem;
}

/* ── Überschriften (UKAAF G003 — gleiche Größe, Differenzierung über Farbe/Linien) ── */
.preview :is(h1, h2, h3, h4, h5, h6) {
  font-size: 1em;
  line-height: 1.45;
  font-weight: 700;
  break-after: avoid;
  page-break-after: avoid;
}
/* Formeln in Überschriften mitfetten - "Luciole Math" hat keine eigene fette
   Variante, daher rein CSS-synthetisches Fett; Ergebnis je nach Browser prüfen. */
.preview :is(h1, h2, h3, h4, h5, h6) math {
  font-weight: 700;
}
.preview h1 {
  color: var(--h1);
  margin: 1.6em 0 0.4em;
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--h1);
  letter-spacing: 0.02em;
}
.preview h2 {
  color: var(--h2);
  margin: 1.2em 0 0.4em;
}
.preview h3 {
  color: var(--h3);
  margin: 1em 0 0.35em;
  padding-left: 0.55em;
  border-left: 0.25em solid var(--h3);
}
.preview h4 {
  color: var(--h1);
  margin: 0.85em 0 0.3em;
}
.preview h5,
.preview h6 {
  color: var(--muted);
  margin: 0.75em 0 0.25em;
}

/* ── Hervorhebung: Kursiv = normal + rot, unabhängig von Fett; in Math/Code nie ─ */
.preview em,
.preview i {
  font-style: normal;
  color: var(--accent);
}
.preview math em,
.preview math i,
.preview code em,
.preview code i,
.preview pre em,
.preview pre i {
  font-style: normal;
  color: inherit;
}
.preview strong,
.preview b {
  font-weight: 700;
}


/* ── Listen ────────────────────────────────────────────────────────────────── */
/* Nummerierte Listen mit Klammer ("1)") statt Punkt: "7. 6x" wirkt wie die Dezimalzahl 7,6. */
@counter-style board-paren { system: extends decimal; suffix: ") "; }
.preview ol { list-style-type: board-paren; }
.preview ul,
.preview ol { padding-left: 1.6rem; }
.preview li { margin: 0.18rem 0; }
.preview ul ul,
.preview ul ol,
.preview ol ul,
.preview ol ol { margin: 0.15rem 0; }

/* ── Inline-Code ───────────────────────────────────────────────────────────── */
.preview code {
  background: #F2F2F2;
  font-family: var(--math-font);
  font-style: normal;
  font-weight: 400;
  padding: 0.05em 0.25em;
  border-radius: 0.2em;
}

/* ── Pre-Blöcke ────────────────────────────────────────────────────────────── */
.preview pre {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: #F2F2F2;
  white-space: pre-wrap;
  overflow-x: auto;
  font-family: var(--math-font);
  font-style: normal;
  font-weight: 400;
}
.preview pre code {
  background: transparent;
  padding: 0;
}

/* ── Blockquotes (UKAAF — linker grauer Balken, eingerückt) ────────────────── */
.preview blockquote {
  border-left: 0.25rem solid var(--rule);
  margin: 0.6em 0 0.6em 0;
  padding: 0.2em 0 0.2em 1rem;
  color: var(--text);
  background: transparent;
  border-radius: 0;
}

/* ── Tabellen ──────────────────────────────────────────────────────────────── */
.preview table {
  border-collapse: collapse;
  margin: 0.6em 0;
  display: block;
  overflow-x: auto;
}
.preview th,
.preview td {
  border: 1px solid var(--muted);
  padding: 0.35em 0.6em;
  text-align: left;
  vertical-align: top;
}
.preview th {
  font-weight: 700;
}

/* ── Horizontale Trennlinie: nur Abstand ───────────────────────────────────── */
/* Durchgehende Linien sind für Low Vision kein hilfreiches Gestaltungsmittel. */
.preview hr {
  border: 0;
  height: 0;
  margin: 1em 0;
}

/* ── Links ─────────────────────────────────────────────────────────────────── */
.preview a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.08em;
}
.preview a:visited {
  color: var(--link-visited);
}
.preview a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Render-Fehler & Leerstand ─────────────────────────────────────────────── */
.preview .number-reading-hint {
  display: block;
  font-size: 0.85em;
  color: var(--muted, inherit);
}

.preview .render-error {
  color: var(--error);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 1rem 0;
  display: inline-block;
}
.preview .empty { color: var(--muted); }


body.fullscreen-view {
  max-width: none;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

body.fullscreen-view #content.preview {
  height: auto;
  max-height: none;
  overflow: visible;
  border-radius: 0;
  padding: 0;
  background: transparent;
  border: none;
  scrollbar-gutter: auto;
}

body.fullscreen-view .export-credit {
  margin-top: 2.5rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.72em;
  color: var(--muted);
}

body.fullscreen-view .export-credit-logo {
  height: 1.5em;
  width: auto;
  vertical-align: -0.35em;
}

body.fullscreen-view .export-credit a {
  color: inherit;
  text-decoration: underline;
}

.statusbar {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
[aria-busy="true"] {
  cursor: progress;
}
#status[data-kind="warn"] { color: var(--error); }
#statusMeta {
  color: var(--muted);
  font-size: 0.9rem;
  opacity: 0.9;
}

body.modal-open {
  overflow: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.42);
  box-sizing: border-box;
}
.overlay[hidden] {
  display: none;
}
.overlay-panel {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0;
  background: var(--panel);
  color: var(--fg);
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlay-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.overlay-header h2 {
  margin: 0;
  font-size: 1.08rem;
}
.overlay-body {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
}
.button-row-right {
  justify-content: flex-end;
}

.connection-panel {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel-2);
  padding: 12px 14px;
  display: grid;
  gap: 12px;
  flex: 1 1 auto;
  align-content: start;
}
.connection-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.connection-header h1 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}
.connection-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
body[data-entry-role="teacher"] .connection-grid {
  grid-template-columns: minmax(180px, 1fr) auto;
}
.connection-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.connection-field span {
  font-weight: 600;
}
.connection-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--fg);
  background: var(--bg);
}
.connection-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}
.connection-actions button {
  min-height: 44px;
  border-radius: 12px;
}
.board-tools {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel-2);
  padding: 12px 14px;
  display: grid;
  gap: 12px;
}
.board-tools-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.board-tools-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}
.board-tools-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.board-tool-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 180px;
  min-width: 0;
}
.board-tool-group-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.board-tool-group input[type="text"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--fg);
  background: var(--bg);
}
.board-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.board-tool-actions button {
  min-height: 44px;
  border-radius: 12px;
}
.board-tools-grid {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.board-tool-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.board-tool-actions-group {
  display: grid;
  gap: 6px;
}
.board-tool-field input[type="text"] {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--fg);
  background: var(--bg);
}
.board-name-display {
  display: block;
  min-height: 44px;
  line-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}
@media (max-width: 900px) {
  .board-tools-grid {
    grid-template-columns: 1fr;
  }
}
.snapshot-list {
  display: grid;
  gap: 10px;
}
.snapshot-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 12px;
  display: grid;
  gap: 10px;
}
.snapshot-item-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.snapshot-item-title {
  font-weight: 700;
}
.snapshot-item-meta {
  color: var(--muted);
  font-size: 0.92rem;
}
.snapshot-empty {
  color: var(--muted);
}
.snapshot-day-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.snapshot-day-heading {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
}
.snapshot-item-preview {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.snapshot-origin-badge {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 6px;
}
/* ── Teacher-Presence-Panel ──────────────────────────────────────────────── */
body:not([data-entry-role="teacher"]) #teacherPresencePanel { display: none; }

.teacher-presence-panel {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.teacher-presence-heading {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.teacher-presence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.teacher-presence-item {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.88rem;
  color: var(--fg);
  user-select: none;
}
.teacher-presence-item > .tp-name {
  padding: 3px 10px;
}
.teacher-presence-select {
  appearance: none;
  background: transparent;
  color: inherit;
  border: 0;
  font: inherit;
  padding: 3px 10px;
  border-radius: inherit;
  cursor: pointer;
}
.teacher-presence-select:hover,
.teacher-presence-select:focus-visible {
  background: var(--panel-hover, #e0e0e0);
  outline: 2px solid var(--accent, #4a90d9);
  outline-offset: 0;
}
.teacher-presence-item.is-write-granted {
  background: var(--accent, #4a90d9);
  color: #fff;
  border-color: var(--accent, #4a90d9);
}
.teacher-presence-item.is-selected {
  border-color: var(--accent, #4a90d9);
}
.tp-line {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted, #888);
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--panel-2, #f0f0f0);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 4px;
}
.teacher-presence-item.is-write-granted .tp-line {
  background: color-mix(in srgb, #fff 20%, var(--accent, #4a90d9));
  color: #fff;
}
.source-line-indicator {
  font-size: 0.9rem;
  color: var(--muted, #888);
  font-weight: normal;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.2;
}
.tp-line[data-line-index] {
  cursor: pointer;
}
.tp-line[data-line-index]:hover {
  background: color-mix(in srgb, var(--accent, #4a90d9) 22%, var(--panel-2, #f0f0f0));
}
.teacher-presence-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.teacher-presence-actions p {
  margin: 0 6px 0 0;
  flex-basis: 100%;
}
.teacher-presence-empty {
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

@media (max-width: 900px) {
  .connection-grid {
    grid-template-columns: 1fr;
  }
  .connection-actions {
    align-items: stretch;
  }
}

.solve-overlay .overlay-panel {
  width: min(1180px, calc(100vw - 24px));
}

#quickMathDialog .overlay-panel {
  width: min(480px, calc(100vw - 24px));
}
#quickMathDialog .overlay-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quick-math-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.quick-math-field > label,
.quick-math-field-label {
  font-weight: 600;
  font-size: 0.92rem;
}
.quick-math-button-row {
  flex-wrap: nowrap;
  gap: 6px;
}
.quick-math-button-row button {
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  white-space: nowrap;
}
#quickMathInput {
  font-size: 1.05rem;
  padding: 8px 10px;
  flex: 1;
  min-width: 0;
}
.quick-math-input-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.quick-math-clear-btn {
  flex: none;
  width: 2.2rem;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}
.quick-math-preview {
  height: auto;
  min-height: 4rem;
  font-size: 1.6em;
  display: flex;
  align-items: center;
}

.notation-completion-popup {
  z-index: 1000;
  max-width: min(420px, calc(100vw - 24px));
  max-height: 260px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
}
.notation-completion-option {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 0.4rem;
  cursor: pointer;
}
.notation-completion-option.active,
.notation-completion-option:hover {
  background: var(--accent-bg);
}
.notation-completion-term {
  font-weight: 600;
}
.notation-completion-example {
  color: var(--muted);
  font-family: var(--math-font);
  white-space: nowrap;
}

.solve-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}
@media (max-width: 980px) {
  .solve-workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
.solve-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}
.solve-card {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel-2);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}
.solve-card--grow {
  flex: 1 1 auto;
}
.solve-textarea,
.solve-context-textarea {
  width: 100%;
  min-height: 0;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--fg);
  background: var(--bg);
  box-sizing: border-box;
  overflow: auto;
}
.solve-textarea {
  flex: 1 1 0;
  height: auto;
  min-height: 120px;
}
.solve-context-textarea {
  min-height: 112px;
  max-height: 28vh;
}
.solve-mode-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 12px;
  margin: 0;
  align-items: center;
}
.solve-mode-group label,
.solve-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.solve-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}
.modal-help {
  color: var(--muted);
  font-size: 0.96rem;
}

.solve-result {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  color: inherit;
  padding: 12px 14px;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  resize: vertical;
}
.solve-result::placeholder {
  color: var(--muted);
}
@media (max-width: 980px) {
  .solve-workspace {
    grid-template-columns: 1fr;
  }
  .overlay {
    padding: 8px;
  }
  .overlay-panel {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
}

/* ── Persönliches-Snapshot-Panel (Student, unterhalb Board-Verbindung) ────── */
body:not([data-entry-role="student"]) #personalSnapshotPanel { display: none; }

.personal-snapshot-panel {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.personal-snapshot-heading {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-basis: 100%;
}
.personal-snapshot-panel .board-tool-field {
  flex: 1 1 220px;
}

/* ── Umschalter Persönlich / Gemeinsam ───────────────────────────────────── */
.board-context-switch {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}
.board-context-switch button {
  padding: 4px 12px;
  font-size: 0.85rem;
  border-radius: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  min-height: 32px;
}
.board-context-switch button:first-child {
  border-radius: 999px 0 0 999px;
}
.board-context-switch button:last-child {
  border-radius: 0 999px 999px 0;
  border-left: none;
}
.board-context-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.board-context-switch button[aria-pressed="true"]:last-child {
  border-left-color: var(--accent);
}
.board-context-switch button:hover:not([aria-pressed="true"]):not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.board-context-switch button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
  position: relative;
}
.board-context-switch button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Export: Format wählen, dann „Exportieren" ────────────────────────────── */
.export-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
}

.export-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.export-field label {
  font-size: 0.9rem;
  color: var(--muted);
}

.export-field select {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.export-field select:hover { border-color: var(--accent); }

.export-field select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Export-Split-Button ──────────────────────────────────────────────────── */
.export-split {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.export-split > #exportPrimaryBtn {
  border-radius: 0.45rem 0 0 0.45rem;
}

.export-split > #exportChevronBtn {
  border-radius: 0 0.45rem 0.45rem 0;
  border-left: none;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}

.export-split:has(button:hover) > button { border-color: var(--accent); }

.export-split > button:focus-visible {
  z-index: 1;
  position: relative;
}

.export-menu-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .13);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.export-menu-popover[hidden] { display: none; }

.export-menu-popover [role="menuitem"] {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.35rem;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--fg);
  font-size: 0.9rem;
  white-space: nowrap;
  width: 100%;
}

.export-menu-popover [role="menuitem"]:hover,
.export-menu-popover [role="menuitem"]:focus-visible {
  background: var(--panel-2, #f0f0f0);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sheet-split {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.sheet-split > #sheetBtn {
  border-radius: 0.45rem 0 0 0.45rem;
}

.sheet-split > #sheetChevronBtn {
  border-radius: 0 0.45rem 0.45rem 0;
  border-left: none;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
}

.sheet-split:has(button:hover) > button { border-color: var(--accent); }

.sheet-split > button:focus-visible {
  z-index: 1;
  position: relative;
}

.sheet-menu-popover {
  position: fixed;
  min-width: 220px;
  max-width: min(440px, calc(100vw - 16px));
  max-height: min(320px, calc(100vh - 16px));
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .13);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.sheet-menu-popover[hidden] { display: none; }

.sheet-menu-popover [role="menuitem"] {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.35rem;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--fg);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  box-sizing: border-box;
}

.sheet-menu-popover [role="menuitem"]:hover,
.sheet-menu-popover [role="menuitem"]:focus-visible {
  background: var(--panel-2, #f0f0f0);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Zweispalten-Layout für Personal-Boards-Tab ───────────────────────────── */
.personal-boards-layout {
  display: contents; /* transparent by default — children flow normally */
}
.personal-boards-main {
  display: contents;
}
body.personal-boards-mode .personal-boards-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
body.personal-boards-mode .personal-boards-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 0;
  min-width: 0;
}
body.personal-boards-mode #personalBoardsPanel {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  overflow-x: clip;
  scrollbar-gutter: stable;
}
body.personal-boards-mode .board-context-switch { display: none !important; }
body.personal-boards-mode .pane-header-file-actions { display: none !important; }
body.personal-boards-mode #personalBoardsSelectedHeader { display: block !important; }
body.personal-boards-mode .pane-input .button-row { display: none !important; }
body.personal-boards-mode .connection-panel { display: none !important; }
body.personal-boards-mode .pane-output .button-row { display: none !important; }
body.personal-boards-mode #boardToolsSection { display: none !important; }
body.personal-boards-mode #technikFold { display: none !important; }
/* Panehöhe nutzt verfügbare Fensterhöhe aus; .app-Bottom-Padding reduziert */
body.personal-boards-mode .app { padding-bottom: 20px; }
body.personal-boards-mode .split { align-items: stretch; }
body.personal-boards-mode .pane-bottom { display: none !important; }
body.personal-boards-mode .pane { height: clamp(320px, calc(100dvh - 150px), 1200px); }
body.personal-boards-mode .pane > section { flex: 1 1 0; min-height: 0; }
body.personal-boards-mode #source,
body.personal-boards-mode .preview { flex: 1 1 0; height: auto; min-height: 0; }

/* ── KI-Review-Modus: In-Page-Panel statt gerenderte Ausgabe ──────────────── */
body.ki-review-mode #renderedOut { display: none !important; }
body.ki-review-mode #inlineReviewPanel { display: flex !important; }
body.ki-review-mode .pane-output .button-row > :not(.button-group-end) { display: none !important; }

.inline-review-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  min-height: 0;
  flex: 1 1 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface, transparent);
  overflow-y: auto;
}
.inline-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.inline-review-status {
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.2em;
}
.inline-review-status[data-kind="warn"] { color: var(--error); }
.inline-review-status[data-kind="ok"] { color: var(--success, #166534); }
.inline-review-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inline-review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.review-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}
.review-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface, transparent);
}
.review-item[data-severity="hint"] { border-left: 3px solid var(--accent, #3b82f6); }
.review-item[data-severity="error"] { border-left: 3px solid var(--error, #b91c1c); }
.review-item[data-applied="true"] { opacity: 0.55; }
.review-item[data-applied="missing"] { background: rgba(180, 50, 30, 0.05); }
.review-quote {
  font-family: var(--font-mono, monospace);
  font-size: 0.88rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 6px;
}
.review-correction-edit {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.4em;
  resize: vertical;
  font: inherit;
  margin-bottom: 8px;
  padding: 6px 8px;
}
.review-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.review-item-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
  min-height: 1.1em;
}
.review-item-status[data-kind="warn"] { color: var(--error); }
.review-item-status[data-kind="ok"] { color: var(--success, #166534); }

@media (max-width: 980px) {
  body.personal-boards-mode .personal-boards-layout {
    flex-direction: column;
  }
  body.personal-boards-mode #personalBoardsPanel {
    width: 100%;
    position: static;
    max-height: 280px;
  }
}

/* ── Persönliche-Boards-Panel-Inhalt ─────────────────────────────────────── */
#personalBoardsPanel {
  display: none;
}
.personal-boards-selected-header {
  display: none;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 2px 0 6px;
}
.personal-boards-selected-header strong {
  color: var(--fg);
}
.personal-boards-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.personal-boards-header h1 {
  margin: 0;
  font-size: 1.05rem;
}
.personal-boards-status {
  color: var(--muted);
  font-size: 0.85rem;
}
.personal-boards-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.personal-boards-item {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.personal-boards-item-button {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--fg);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font: inherit;
}
.personal-boards-item-button:hover {
  background: var(--panel);
}
.personal-boards-item-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.personal-boards-item--selected .personal-boards-item-button {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.personal-boards-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.personal-boards-item-name {
  font-weight: 700;
  min-width: 0;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.personal-boards-item-live {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.personal-boards-item--offline .personal-boards-item-button {
  opacity: 0.65;
}
.personal-boards-item--offline .personal-boards-item-button:hover {
  opacity: 1;
}
.personal-boards-item-remove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}
.personal-boards-item-remove:hover {
  background: var(--danger-bg, #fee2e2);
  color: var(--danger, #b91c1c);
  border-color: var(--danger, #b91c1c);
}
.personal-boards-item-remove:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.personal-boards-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Teacher-Board-Verwaltungs-Panel ─────────────────────────────────────── */
#teacherBoardsPanel {
  display: none;
}
body.teacher-boards-mode #teacherBoardsPanel {
  display: block !important;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  min-width: 0;
}
body.teacher-boards-mode .personal-boards-layout {
  display: none !important;
}
/* Shell */
.teacher-boards-shell {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.teacher-boards-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.teacher-boards-back-link {
  font-size: 0.88rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.teacher-boards-back-link:hover { text-decoration: underline; }
.teacher-boards-topbar input[type="search"] {
  flex: 1 1 10rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.9375rem;
  min-height: 2.25rem;
}
.teacher-boards-topbar input[type="search"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.teacher-boards-topbar button {
  flex: 0 0 auto;
  min-height: 2.25rem;
  padding: 0.45rem 0.9rem;
}
.teacher-boards-status {
  color: var(--muted);
  font-size: 0.85rem;
  flex: 1 0 100%;
  order: 10;
}
.teacher-boards-status:empty { display: none; }
/* List-Container — wie #view-list in Admin: selbst die Card */
.teacher-boards-list {
  background: var(--paper, var(--panel-2, #fff));
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  overflow: visible;
  min-width: 0;
}
/* Tabelle — wie #view-list table in Admin */
.teacher-boards-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.teacher-boards-table thead tr {
  border-bottom: 2px solid var(--border);
}
.teacher-boards-table th {
  text-align: left;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.teacher-boards-table th.teacher-boards-col-num,
.teacher-boards-table td.teacher-boards-col-num {
  text-align: right;
}
.teacher-boards-row {
  border-bottom: 1px solid var(--border);
}
.teacher-boards-row:last-child {
  border-bottom: none;
}
.teacher-boards-row td {
  padding: 0.3rem 0.6rem;
  vertical-align: middle;
}
.teacher-boards-row:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.teacher-boards-col-name {
  font-weight: 700;
  min-width: 6rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teacher-boards-col-num {
  white-space: nowrap;
  color: var(--muted);
  width: 1%;
}
.teacher-boards-col-date {
  white-space: nowrap;
  color: var(--muted);
}
.teacher-boards-col-actions {
  text-align: right;
  width: 1%;
}
.teacher-boards-more { position: relative; display: inline-block; text-align: left; }
.teacher-boards-more > summary {
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--panel-2, #fff);
  color: var(--fg);
}
.teacher-boards-more > summary::-webkit-details-marker { display: none; }
.teacher-boards-more > summary::after { content: " \25BE"; }
.teacher-boards-more[open] > summary::after { content: " \25B4"; }
.teacher-boards-more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.teacher-boards-more-items {
  position: absolute;
  right: 0;
  top: calc(100% + 0.2rem);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 11rem;
  padding: 0.3rem;
  background: var(--paper, #fff);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.teacher-boards-more-items button { text-align: left; white-space: nowrap; padding: 0.3rem 0.6rem; font-size: 0.85rem; min-height: 0; }
.teacher-boards-col-policy {
  white-space: nowrap;
}
.teacher-boards-col-policy button {
  margin-left: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.82rem;
}
.teacher-boards-policy-select {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--panel-2, #fff);
  color: var(--fg);
}
/* Legacy card styles – nicht entfernen (test_client_structure.mjs prüft .teacher-boards-item) */
.teacher-boards-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.teacher-boards-item-name {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teacher-boards-item-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.teacher-boards-item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}
.teacher-boards-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  padding: 1rem;
  text-align: center;
}
@media (max-width: 720px) {
  body.teacher-boards-mode #teacherBoardsPanel {
    width: 100%;
  }
  .teacher-boards-table {
    min-width: 0;
  }
}
.personal-boards-item-meta {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Student-Board-Verbindung: kompaktes Layout ──────────────────────────── */
body[data-entry-role="student"] .connection-panel {
  flex: 0 0 auto;
  gap: 10px;
}

body[data-entry-role="student"] .connection-grid {
  grid-template-columns:
    minmax(110px, 0.75fr)
    minmax(150px, 1fr)
    minmax(150px, 1fr)
    max-content;
  align-items: end;
}

body[data-entry-role="student"] .connection-actions {
  flex-wrap: nowrap;
  align-items: end;
}

@media (max-width: 1180px) {
  body[data-entry-role="student"] .connection-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  body[data-entry-role="student"] .connection-actions {
    grid-column: 1 / -1;
  }
}

/* ── Teacher-Kartenhöhe angleichen ───────────────────────────────────────── */
.connection-panel,
.board-tools {
  box-sizing: border-box;
}

body[data-entry-role="teacher"] {
  --teacher-control-card-min-height: 210px;
}

body[data-entry-role="teacher"] .connection-panel,
body[data-entry-role="teacher"] .board-tools {
  min-height: var(--teacher-control-card-min-height, 196px);
}

/* ── Print (meinblatt / UKAAF — A4, 18/16 mm Ränder, nur Inhalt sichtbar) ── */
@media print {
  @page {
    size: A4;
    margin: 18mm 16mm 18mm 16mm;
  }

  html, body {
    background: #ffffff;
    font-family: var(--print-font);
    font-size: var(--preview-font-size);
    line-height: 1.45;
  }

  .titlebar,
  .statusbar,
  .skip-nav,
  .skip-link,
  .button-row,
  .pane-input,
  .connection-panel,
  .board-tools,
  .board-context-switch,
  .overlay,
  .user-menu,
  .teacher-presence-panel,
  #personalBoardsPanel,
  #teacherBoardsPanel,
  button {
    display: none !important;
  }

  .app,
  .pane,
  .pane-output,
  .preview,
  body.fullscreen-view #content.preview {
    border: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    padding: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .preview h1,
  .preview h2,
  .preview h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .preview p,
  .preview li,
  .preview blockquote,
  .preview pre {
    orphans: 3;
    widows: 3;
  }

  .preview pre {
    white-space: pre-wrap;
    border: 0.5pt solid #999999;
    padding: 6pt;
    background: #F2F2F2;
  }

  .preview code {
    background: #F2F2F2;
  }

  .preview pre code {
    background: transparent;
  }

  .preview blockquote {
    border-left: 2pt solid #A6A6A6;
    margin: 6pt 0;
    padding: 2pt 0 2pt 8pt;
  }
}
