/* ==========================================================================
   EBENE 3: EDITOR TYPOGRAPHY & BASE THEME
   Definiert das Standard-Aussehen für nutzergeneriertes HTML.
   Alle Regeln greifen nur innerhalb des Containers ".editor-content".
   ========================================================================== */

.editor-content {
    word-wrap: break-word;
    display: flow-root;
}

/* Verhindert, dass Standard-Margins nach oben oder unten aus dem Container ausbrechen, respektiert jedoch vom Autor explizit gesetzte Abstände */
.editor-content > *:first-child:not([style*="margin-top"]),
.editor-content > p:first-child:not([style*="margin-top"]),
.editor-content > h1:first-child:not([style*="margin-top"]),
.editor-content > h2:first-child:not([style*="margin-top"]),
.editor-content > h3:first-child:not([style*="margin-top"]),
.editor-content > h4:first-child:not([style*="margin-top"]),
.editor-content > h5:first-child:not([style*="margin-top"]),
.editor-content > h6:first-child:not([style*="margin-top"]) {
    margin-top: 0;
}

.editor-content > *:last-child:not([style*="margin-bottom"]),
.editor-content > p:last-child:not([style*="margin-bottom"]),
.editor-content > h1:last-child:not([style*="margin-bottom"]),
.editor-content > h2:last-child:not([style*="margin-bottom"]),
.editor-content > h3:last-child:not([style*="margin-bottom"]),
.editor-content > h4:last-child:not([style*="margin-bottom"]),
.editor-content > h5:last-child:not([style*="margin-bottom"]),
.editor-content > h6:last-child:not([style*="margin-bottom"]),
.editor-content > ul:last-child > li:last-child:not([style*="margin-bottom"]),
.editor-content > ol:last-child > li:last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}

/* Frage-Block ([data-type="question"]): Zentrale Typografie + kompakter Standard-Abstand nach unten (0.25rem statt 1em), am Container-Ende 0 */
.editor-content [data-type="question"] {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: var(--color-surface-fg);
    display: block;
    position: relative;
}
.editor-content [data-type="question"][data-variant="icon"] {
    padding-left: 2rem;
}
.editor-content [data-type="question"][data-variant="icon"]::before {
    content: attr(data-icon);
    position: absolute;
    left: 0;
    top: 2px;
    color: var(--color-primary);
    user-select: none;
}
.editor-content [data-type="question"]:not([style*="margin-top"]) {
    margin-top: 0.75rem;
}
.editor-content > [data-type="question"]:first-child:not([style*="margin-top"]) {
    margin-top: 0;
}
.editor-content [data-type="question"]:not([style*="margin-bottom"]) {
    margin-bottom: 0.25rem;
}
.editor-content > [data-type="question"]:last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}
.editor-content [data-type="question"] > p:first-child:not([style*="margin-top"]) {
    margin-top: 0;
}
.editor-content [data-type="question"] > p:not([style*="margin-bottom"]) {
    margin-bottom: 0.25rem;
}
.editor-content [data-type="question"] > p:last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}


/* --- 1. GRUNDLAGEN (Typografie) --- */
.editor-content h1 { font-size: 2em; font-weight: 700; margin: 1em 0 0.5em; line-height: 1.2; }
.editor-content h2 { font-size: 1.5em; font-weight: 700; margin: 1em 0 0.5em; line-height: 1.3; }
.editor-content h3 { font-size: 1.25em; font-weight: 700; margin: 1em 0 0.5em; line-height: 1.4; }
.editor-content h4 { font-size: 1.1em; font-weight: 700; margin: 1em 0 0.5em; line-height: 1.4; }
.editor-content h5 { font-size: 1em; font-weight: 700; margin: 0.85em 0 0.4em; line-height: 1.4; }
.editor-content h6 { font-size: 0.9em; font-weight: 700; margin: 0.85em 0 0.4em; line-height: 1.4; color: var(--color-muted-fg); }
.editor-content ul { list-style-type: disc; padding-left: 2.25rem; margin: 0; }
.editor-content ol { padding-left: 2.25rem; margin: 0; }
.editor-content ul[data-bullet-type="disc"] { list-style-type: disc; }
.editor-content ul[data-bullet-type="circle"] { list-style-type: circle; }
.editor-content ul[data-bullet-type="square"] { list-style-type: square; }
.editor-content ul[data-bullet-type="arrow"] { list-style-type: '→  '; }
.editor-content ul[data-bullet-type="heavy-arrow"] { list-style-type: '➔  '; }
.editor-content ul[data-bullet-type="triangle"] { list-style-type: '▸  '; }
.editor-content ul[data-bullet-type="dash"] { list-style-type: '–  '; }
.editor-content ul[data-bullet-type="check"] { list-style-type: '✓  '; }
.editor-content ul[data-bullet-type="cross"] { list-style-type: '✗  '; }
.editor-content li { display: list-item; margin-bottom: 0; }
.editor-content li:last-child { margin-bottom: 1em; }
.editor-content li li:last-child { margin-bottom: 0; }
:where(.editor-content) hr {
    border: none;
    border-top: 2px solid var(--color-muted);
    margin-block: var(--editor-hr-margin-y, 0.5rem);
    margin-inline: 0;
}
@layer base {
    .editor-content a { 
        color: var(--color-primary); 
        text-decoration: underline; 
        text-underline-offset: 2px; 
        cursor: pointer; 
    }
}
.editor-content p { margin-bottom: 1em; }
.editor-content li p { margin-bottom: 0; }
/* Verhindert asymmetrisches Margin-Collapsing (1em statt 0.5rem/0.25rem) vor Trennlinien und erlaubt 0pt-Abstand nach oben */
.editor-content p:where(:not([style*="margin-bottom"]):has(+ hr)),
.editor-content :where(ul, ol):where(:has(+ hr)) > li:last-child:where(:not([style*="margin-bottom"])),
.editor-content [data-type="question"]:not([style*="margin-bottom"]):where(:has(+ hr)) {
    margin-bottom: 0;
}
:where(.editor-content :is(td, th)) > hr:first-child:not([style*="margin-top"]) {
    margin-top: 0;
}
:where(.editor-content :is(td, th)) > hr:last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}
.editor-content sub,
.editor-content sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}
.editor-content sub { bottom: -0.25em; }
.editor-content sup { top: -0.5em; }
.editor-content p:empty::after {
    content: '\00A0'; /* Zwingt leere HTML-Paragraphen dazu, die Höhe exakt einer Zeile anzunehmen (Verhindert Kollabieren im Player) */
}

/* --- 2. ZITATE, HINWEIS-BOXEN (Callouts) & AKKORDEONS --- */
.editor-content blockquote {
    display: flow-root;
    border-left: 4px solid var(--color-primary);
    padding: 0.5rem 1rem; margin: 1.5rem 0; font-style: italic; color: var(--color-muted-fg);
    background: linear-gradient(90deg, var(--color-primary) 0%, transparent 15%);
    background-size: 15% 100%; background-repeat: no-repeat;
}
.editor-content blockquote > :first-child { margin-top: 0; }
.editor-content blockquote > :last-child,
.editor-content blockquote > :is(ul, ol):last-child > li:last-child { margin-bottom: 0; }
.editor-content .callout { display: block; position: relative; padding: 1rem 1rem 1rem 3rem; border-radius: 0.5rem; margin: 1.5rem 0; border-left: 4px solid; }
.editor-content .callout > :first-child:not([style*="margin-top"]),
.editor-content .callout p:first-child:not([style*="margin-top"]) { margin-top: 0; }
.editor-content .callout > :last-child:not([style*="margin-bottom"]),
.editor-content .callout p:last-child:not([style*="margin-bottom"]) { margin-bottom: 0; }
.editor-content .callout::before { position: absolute; left: 1rem; top: 1rem; font-size: 1.25rem; line-height: 1; }
.editor-content .callout-info { background-color: rgba(59, 130, 246, 0.1); border-left-color: #3b82f6; }
.editor-content .callout-info::before { content: '💡'; }
.editor-content .callout-warning { background-color: rgba(234, 179, 8, 0.1); border-left-color: #eab308; }
.editor-content .callout-warning::before { content: '⚠️'; }
.editor-content .callout-danger { background-color: rgba(239, 68, 68, 0.1); border-left-color: #ef4444; }
.editor-content .callout-danger::before { content: '🚨'; }
.editor-content .callout-success { background-color: rgba(34, 197, 94, 0.1); border-left-color: #22c55e; }
.editor-content .callout-success::before { content: '✅'; }

/* --- 2b. AKKORDEONS (Player <details> & Editor Inline-View) --- */
.editor-content details.bona-accordion,
.editor-content details:not([class]),
.editor-content .bona-accordion-editor {
    interpolate-size: allow-keywords;
    margin: 1.25rem 0;
    border-radius: 0.75rem;
    border: 1px solid var(--color-muted, #cbd5e1);
    background-color: var(--color-surface, #ffffff);
    color: var(--color-surface-fg, #0f172a);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.editor-content details.bona-accordion.bona-accordion-accent,
.editor-content .bona-accordion-editor.bona-accordion-accent {
    border-left: 4px solid var(--color-primary, #3b82f6);
}

.editor-content details.bona-accordion.bona-accordion-muted,
.editor-content .bona-accordion-editor.bona-accordion-muted {
    background-color: rgba(128, 128, 128, 0.06);
    box-shadow: none;
}

/* Player <summary> Header (Teaser / Kopfzeile) */
.editor-content details.bona-accordion > summary.bona-accordion-summary,
.editor-content details:not([class]) > summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 3rem 1rem 1.25rem;
    position: relative;
    user-select: none;
    transition: background-color 0.15s ease;
    outline: none;
    display: block;
}

.editor-content details.bona-accordion > summary.bona-accordion-summary::-webkit-details-marker,
.editor-content details:not([class]) > summary::-webkit-details-marker {
    display: none;
}

.editor-content details.bona-accordion.bona-accordion-accent > summary.bona-accordion-summary {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.06) 0%, transparent 100%);
}

.editor-content details.bona-accordion > summary.bona-accordion-summary:hover,
.editor-content details:not([class]) > summary:hover {
    background-color: rgba(128, 128, 128, 0.05);
}

.editor-content details.bona-accordion > summary.bona-accordion-summary:focus-visible,
.editor-content details:not([class]) > summary:focus-visible {
    box-shadow: inset 0 0 0 2px var(--color-primary, #3b82f6);
    border-radius: 0.75rem;
}

/* Typografie im Kopfbereich: 1. Absatz = kräftiger Titel, Folgeabsätze = lesbarer Teaser-Text */
.editor-content .bona-accordion-summary > :first-child:not([style*="margin-top"]) {
    margin-top: 0;
}
.editor-content .bona-accordion-summary > p:first-child {
    font-weight: 700;
    font-size: 1.05em;
    line-height: 1.35;
}
.editor-content .bona-accordion-summary > :first-child:not(:last-child):not([style*="margin-bottom"]) {
    margin-bottom: 0.35rem;
}
.editor-content .bona-accordion-summary > p:not(:first-child) {
    font-weight: 400;
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 0.25rem;
    color: var(--color-surface-fg, #0f172a);
}
.editor-content .bona-accordion-summary > :last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}

/* Animiertes Chevron-Icon rechts im Player-<summary> */
.editor-content details.bona-accordion > summary.bona-accordion-summary::after,
.editor-content details:not([class]) > summary::after {
    content: '';
    position: absolute;
    right: 1.25rem;
    top: 1.3rem;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid var(--color-surface-fg, #0f172a);
    border-bottom: 2px solid var(--color-surface-fg, #0f172a);
    transform: rotate(45deg);
    transition: transform 0.25s ease, border-color 0.2s ease, top 0.25s ease;
}

.editor-content details.bona-accordion[open] > summary.bona-accordion-summary::after,
.editor-content details:not([class])[open] > summary::after {
    transform: rotate(-135deg);
    top: 1.5rem;
    border-color: var(--color-primary, #3b82f6);
}

/* Aufgeklappter Inhaltsbereich im Player */
.editor-content details.bona-accordion > .bona-accordion-content {
    padding: 1rem 1.25rem 1.25rem 1.25rem;
    border-top: 1px solid var(--color-muted, #cbd5e1);
}

.editor-content .bona-accordion-content > :first-child:not([style*="margin-top"]) {
    margin-top: 0;
}
.editor-content .bona-accordion-content > :last-child:not([style*="margin-bottom"]) {
    margin-bottom: 0;
}

/* Moderne Aufklapp-Animation via ::details-content + Fallback */
.editor-content details.bona-accordion::details-content {
    block-size: 0;
    overflow: hidden;
    transition: block-size 0.25s ease, content-visibility 0.25s ease allow-discrete;
}
.editor-content details.bona-accordion[open]::details-content {
    block-size: auto;
}

/* --- Editor-spezifische Darstellung (.bona-accordion-editor) --- */
.editor-content .bona-accordion-editor {
    position: relative;
    overflow: visible;
    margin: 1.5rem 0;
}

.editor-content .bona-accordion-editor-toggle {
    position: absolute;
    left: 0.65rem;
    top: 0.95rem;
    z-index: 10;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    color: var(--color-surface-fg, #0f172a);
    background-color: rgba(128, 128, 128, 0.1);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.2s ease, color 0.15s ease;
}
.editor-content .bona-accordion-editor-toggle:hover {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--color-primary, #3b82f6);
}
.editor-content .bona-accordion-editor-toggle svg {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}
.editor-content .bona-accordion-editor[data-editor-open="false"] .bona-accordion-editor-toggle svg {
    transform: rotate(-90deg);
}

.editor-content .bona-accordion-editor .bona-accordion-summary {
    position: relative;
    padding: 1.1rem 1.25rem 0.9rem 2.65rem;
    border-top-left-radius: 0.7rem;
    border-top-right-radius: 0.7rem;
    background-color: rgba(59, 130, 246, 0.03);
}

.editor-content .bona-accordion-editor .bona-accordion-summary::before,
.editor-content .bona-accordion-editor .bona-accordion-content::before {
    content: attr(data-zone-label);
    position: absolute;
    top: -0.55rem;
    left: 2.65rem;
    padding: 0.05rem 0.45rem;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 9999px;
    background-color: var(--color-surface, #ffffff);
    border: 1px solid var(--color-muted, #cbd5e1);
    color: var(--color-surface-fg, #0f172a);
    pointer-events: none;
    user-select: none;
    line-height: 1.3;
}

.editor-content .bona-accordion-editor .bona-accordion-content {
    position: relative;
    padding: 1.15rem 1.25rem 1rem 1.25rem;
    border-top: 1px dashed var(--color-muted, #cbd5e1);
}
.editor-content .bona-accordion-editor .bona-accordion-content::before {
    left: 1.25rem;
}

.editor-content .bona-accordion-editor[data-editor-open="false"] .bona-accordion-content {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .editor-content details.bona-accordion,
    .editor-content details.bona-accordion::details-content,
    .editor-content details.bona-accordion > summary.bona-accordion-summary::after,
    .editor-content .bona-accordion-editor-toggle,
    .editor-content .bona-accordion-editor-toggle svg {
        transition: none !important;
    }
}

/* --- 3. TABELLEN (Smart Responsive) --- */
.editor-content .tableWrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    padding: 1px;
    -webkit-overflow-scrolling: touch;
    margin: 0.75rem 0;
    /* Deine Schatten-Styles bleiben erhalten: */
    background: linear-gradient(to right, var(--color-surface) 30%, rgba(255,255,255,0)), linear-gradient(to right, rgba(255,255,255,0), var(--color-surface) 70%) 0 100%, radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.1), rgba(0,0,0,0)), radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.1), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: var(--color-surface);
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

/* Feedback Tabellen (z.B. Matrix) sollen diesen generischen 24px-Abstand nicht haben */
.editor-content .feedback-comparison:has(> .feedback-table):not(:has(.tableWrapper, .feedback-table-wrapper)),
.editor-content .feedback-comparison .tableWrapper,
.editor-content .feedback-comparison .feedback-table-wrapper,
.editor-content .tableWrapper:has(.feedback-table),
.editor-content .feedback-table-wrapper {
    margin: 0.25rem 0;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1px;
    background: transparent;
    -webkit-overflow-scrolling: touch;
}

/* Verhindert doppelte Scroll-Container bei bereits gespeicherten Feedback-Tabellen mit innerem .tableWrapper */
.editor-content .feedback-table-wrapper:has(> .tableWrapper) {
    overflow: visible;
    padding: 0;
    margin: 0;
}

/* Reduziert den Abstand zwischen vorangestelltem Text (z.B. Fragestellung) und der Tabelle */
.editor-content p:has(+ .tableWrapper),
.editor-content p:has(+ .feedback-table-wrapper),
.editor-content p:has(+ .feedback-comparison) {
    margin-bottom: 0.25rem;
}


.editor-content table {
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0; 
    max-width: none;
}

.editor-content table[style*="width: auto"],
.editor-content table[style*="width:auto"] {
    table-layout: auto;
}

/* Tabellen mit Formeln: Inhaltsbasiertes Spaltenlayout, damit Formelspalten mit der Formel wachsen
   und niemals in Nachbarspalten ragen (der äußere .tableWrapper übernimmt das horizontale Scrollen). */
.editor-content table:not(.feedback-table):has(:is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) {
    table-layout: auto;
}

.editor-content td, .editor-content th {
    border: 1px solid var(--color-muted);
    padding: 0.5rem;
    vertical-align: top;
    position: relative;
    min-width: 3em; /* Verhindert komplett zerquetschte Zellen */
}
.editor-content th { background-color: var(--color-muted); font-weight: 700; text-align: left; }
.editor-content table p { margin: 0; padding: 0; line-height: 1.4; }
.editor-content table p + p { margin-top: 0.5rem; }

/* Zebra-Style */
.editor-content table.table-zebra tr:nth-child(odd) > td:not([data-bg-color]):not([data-cell-bg]),
.editor-content table.table-zebra tr:nth-child(odd) > th:not([data-bg-color]):not([data-cell-bg]) {
    background-color: rgba(128, 128, 128, 0.08);
}

/* Optionen aus dem Editor */
.editor-content table[data-padding="small"] td, .editor-content table[data-padding="small"] th { padding: 0.25rem; }
.editor-content table[data-padding="large"] td, .editor-content table[data-padding="large"] th { padding: 1.25rem; }
.editor-content table[data-word-wrap="break-word"] td, .editor-content table[data-word-wrap="break-word"] th { word-break: break-all; overflow-wrap: anywhere; }
.editor-content table[data-word-wrap="nowrap"] td, .editor-content table[data-word-wrap="nowrap"] th { white-space: nowrap; }

/* Schutz für Formeln in Tabellenzellen: Volle intrinsische Formelbreite erhalten, keine interne Zerstückelung */
.editor-content table :is(td, th) :is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex) {
    max-width: none;
    overflow: visible;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}
.editor-content table :is(td, th) :is(mjx-container, .katex, .katex-display) * {
    word-break: normal;
    overflow-wrap: normal;
}
.editor-content mjx-container mjx-break:not([newline]) {
    white-space: nowrap !important;
}
.editor-content [data-type="math-component"][data-break-mode="fit"] mjx-container mjx-break:not([newline]),
.editor-content[data-device="tablet"] [data-type="math-component"][data-break-mode="tablet"] mjx-container mjx-break:not([newline]),
.editor-content[data-device="mobile"] [data-type="math-component"][data-break-mode="tablet"] mjx-container mjx-break:not([newline]),
.editor-content[data-device="mobile"] [data-type="math-component"][data-break-mode="mobile"] mjx-container mjx-break:not([newline]) {
    white-space: normal !important;
}

/* Tabellen-Grundraster (Grid Styles) */
.editor-content table[data-grid="horizontal"] :where(td, th) {
    border-inline: none;
}
.editor-content table[data-grid="booktabs"] {
    border-top: 1.5px solid var(--color-surface-fg);
    border-bottom: 1.5px solid var(--color-surface-fg);
}
.editor-content table[data-grid="booktabs"] :where(td, th) {
    border: none;
}
.editor-content table[data-grid="booktabs"] tr:first-child > :where(td, th) {
    border-top: 1.5px solid var(--color-surface-fg);
}
.editor-content table[data-grid="booktabs"] tr:last-child > :where(td, th) {
    border-bottom: 1.5px solid var(--color-surface-fg);
}
.editor-content table[data-grid="booktabs"] tr:not(:has(> td)) + tr:has(> td) > :where(td, th) {
    border-top: 1px solid var(--color-surface-fg);
}
.editor-content table[data-grid="none"] :where(td, th) {
    border: none;
}

/* Vertikale Zellausrichtung */
.editor-content table :is(td, th)[data-valign="top"] { vertical-align: top; }
.editor-content table :is(td, th)[data-valign="middle"] { vertical-align: middle; }
.editor-content table :is(td, th)[data-valign="bottom"] { vertical-align: bottom; }

/* Semantische Zell-Hintergrundfarben (Light, Dark & High-Contrast kompatibel) */
.editor-content table :is(td, th)[data-cell-bg="none"] {
    background-color: transparent;
}
.editor-content table :is(td, th)[data-cell-bg="muted"] {
    background-color: color-mix(in srgb, var(--color-surface-fg) 10%, var(--color-surface));
}
.editor-content table :is(td, th)[data-cell-bg="primary"] {
    background-color: color-mix(in srgb, var(--color-primary) 14%, var(--color-surface));
}
.editor-content table :is(td, th)[data-cell-bg="secondary"] {
    background-color: color-mix(in srgb, var(--color-secondary) 14%, var(--color-surface));
}
.editor-content table :is(td, th)[data-cell-bg="success"] {
    background-color: color-mix(in srgb, var(--color-success, #22c55e) 14%, var(--color-surface));
}
.editor-content table :is(td, th)[data-cell-bg="warning"] {
    background-color: color-mix(in srgb, #eab308 16%, var(--color-surface));
}
.editor-content table :is(td, th)[data-cell-bg="danger"] {
    background-color: color-mix(in srgb, var(--color-danger, #ef4444) 14%, var(--color-surface));
}

/* Individuelle Zellrahmen pro Kante (überschreiben das Tabellen-Grundraster) */
.editor-content table :is(td, th)[data-bt="none"] { border-top: 0 hidden transparent; }
.editor-content table :is(td, th)[data-bt="thin"] { border-top: 1px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bt="medium"] { border-top: 2px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bt="thick"] { border-top: 3px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bt="double"] { border-top: 3px double var(--color-surface-fg); }

.editor-content table :is(td, th)[data-br="none"] { border-right: 0 hidden transparent; }
.editor-content table :is(td, th)[data-br="thin"] { border-right: 1px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-br="medium"] { border-right: 2px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-br="thick"] { border-right: 3px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-br="double"] { border-right: 3px double var(--color-surface-fg); }

.editor-content table :is(td, th)[data-bb="none"] { border-bottom: 0 hidden transparent; }
.editor-content table :is(td, th)[data-bb="thin"] { border-bottom: 1px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bb="medium"] { border-bottom: 2px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bb="thick"] { border-bottom: 3px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bb="double"] { border-bottom: 3px double var(--color-surface-fg); }

.editor-content table :is(td, th)[data-bl="none"] { border-left: 0 hidden transparent; }
.editor-content table :is(td, th)[data-bl="thin"] { border-left: 1px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bl="medium"] { border-left: 2px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bl="thick"] { border-left: 3px solid var(--color-surface-fg); }
.editor-content table :is(td, th)[data-bl="double"] { border-left: 3px double var(--color-surface-fg); }

/* --- NEU: HIGH CONTRAST FIX FÜR TABELLEN --- */
.high-contrast .editor-content table,
.high-contrast .editor-content th,
.high-contrast .editor-content td {
    border-color: var(--color-surface-fg) !important;
}
.high-contrast .editor-content hr,
.high-contrast .editor-content details.bona-accordion,
.high-contrast .editor-content details.bona-accordion > .bona-accordion-content,
.high-contrast .editor-content .bona-accordion-editor,
.high-contrast .editor-content .bona-accordion-editor .bona-accordion-content {
    border-color: var(--color-surface-fg) !important;
}
.high-contrast .editor-content:not(.force-light, .force-light *) blockquote {
    border-color: var(--color-surface-fg) !important;
    background: none;
}

/* --- 4. MEDIEN (Bilder, Videos, Audio) --- */
.editor-content figure {
    display: flex;
    flex-direction: column;
    margin: 1.5rem auto;
    position: relative;
    align-items: center; 
    clear: both; /* Verhindert Float-Bugs */
}
.editor-content figure[style*="float: left"] { float: left; margin: 0.5rem 1.5rem 1rem 0; align-items: flex-start; clear: none; }
.editor-content figure[style*="float: right"] { float: right; margin: 0.5rem 0 1rem 1.5rem; align-items: flex-end; clear: none; }
.editor-content figure img, .editor-content figure video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0.25rem;
}
.editor-content:not(.ProseMirror) figure.image-wrapper[data-zoomable="true"] img {
    cursor: zoom-in;
}
.editor-content figcaption { text-align: center; font-size: 0.75rem; color: var(--color-muted-fg); width: 100%; }

/* Tiptap Media Responsive CSS:
   Reagiert per JS (useItemBreakpoints) evaluiertem data-device Attribut dynamisch
   auf die reale Container-Breite statt starrer Viewport-@media-Queries. */
.editor-content[data-device="tablet"] figure.image-wrapper[style*="--tw-media-tablet"],
.editor-content[data-device="tablet"] figure.video-wrapper[style*="--tw-media-tablet"],
.editor-content[data-device="tablet"] figure.audio-wrapper[style*="--tw-media-tablet"] {
    width: var(--tw-media-tablet) !important;
    max-width: 100% !important;
}

.editor-content[data-device="mobile"] figure.image-wrapper[style*="--tw-media-mobile"],
.editor-content[data-device="mobile"] figure.video-wrapper[style*="--tw-media-mobile"],
.editor-content[data-device="mobile"] figure.audio-wrapper[style*="--tw-media-mobile"] {
    width: var(--tw-media-mobile) !important;
    max-width: 100% !important;
}

/* Auto-Center für Mobile: Hebt das Umfließen von Text (float) auf */
.editor-content[data-device="mobile"] figure.image-wrapper,
.editor-content[data-device="mobile"] figure.video-wrapper,
.editor-content[data-device="mobile"] figure.audio-wrapper {
    float: none !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* --- 5. FEEDBACK MATRIX TEMPLATES --- */
.editor-content .feedback-stimulus { border-left: 4px solid var(--color-primary); padding-left: 1rem; color: var(--color-muted-fg); margin-bottom: 1.5rem; }
.editor-content .feedback-box { background: var(--color-surface, #ffffff); padding: 1rem; border: 1px solid var(--color-muted, #cbd5e1); border-radius: 8px; margin-bottom: 1.5rem; }
.editor-content .feedback-header { display: flex; gap: 1rem; margin-bottom: 0.5rem; color: var(--color-muted-fg, #64748b); font-size: 0.7em; font-weight: bold; text-transform: uppercase; }
.editor-content .feedback-header-label { width: 40%; }
.editor-content .feedback-header-track { flex: 1; display: flex; text-align: center; }
.editor-content .feedback-header-col { flex: 1; font-size: 0.7em; color: var(--color-muted-fg); line-height: 1.1; margin-top: 4px; }
.editor-content .feedback-legend { margin-top: 1rem; font-size: 0.8em; display: flex; gap: 1rem; justify-content: flex-end; }
.editor-content .feedback-legend-item { display: flex; align-items: center; gap: 6px; }
.editor-content .feedback-correct-text { color: var(--color-success, #22c55e); font-weight: bold; }

/* --- 5a. ISOLIERTE MATRIX-PROFILLINIE (CSS Grid + Subgrid, Option A Mobile-Header) --- */
.editor-content:not(.ProseMirror) .feedback-profile-scroller {
    container: profile-scroller / inline-size;
    width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; margin: 0; padding: 0; background: transparent; -webkit-overflow-scrolling: touch;
}
@media (max-width: 480px) {
    .editor-content:not(.ProseMirror) .feedback-box:has(.feedback-profile-scroller) { padding: 0.75rem; }
}
.editor-content:not(.ProseMirror) .feedback-profile-chart {
    --profile-label-col-min: 112px;
    --profile-label-col-max: 34%;
    --profile-wm-vert: vertical-rl;
    --profile-rot-vert: rotate(180deg);
    position: relative; display: grid; width: 100%; box-sizing: border-box;
    min-width: calc(var(--profile-label-col-min) + var(--profile-cols, 2) * var(--profile-col-min, 21px));
    grid-template-columns: minmax(var(--profile-label-col-min), var(--profile-label-col-max)) repeat(var(--profile-cols, 2), minmax(var(--profile-col-min, 21px), 1fr));
    grid-template-rows: auto auto;
    border: 1px solid var(--color-muted, #cbd5e1); border-radius: 0.375rem; background-color: var(--color-surface, #ffffff);
}
@supports (writing-mode: sideways-lr) {
    .editor-content:not(.ProseMirror) .feedback-profile-chart { --profile-wm-vert: sideways-lr; --profile-rot-vert: none; }
}
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-svg {
    position: absolute; inset: 0; grid-column: 2 / -1; grid-row: 2; width: 100%; height: 100%; min-width: 0; min-height: 0; display: block; pointer-events: none; z-index: 2; overflow: visible;
}
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table { display: contents; }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > colgroup { display: none; }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > thead { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: subgrid; }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > tbody { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: subgrid; grid-auto-rows: 1fr; }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > :is(thead, tbody) > tr { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table :is(th, td) {
    position: static !important; box-shadow: none !important; min-width: 0; max-width: none; width: auto; border: none; box-sizing: border-box;
}
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table :is(th, td):not(:last-child) { border-right: 1px solid color-mix(in srgb, var(--color-muted, #cbd5e1) 60%, transparent); }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table :is(th, td):first-child { border-right: 1px solid var(--color-muted, #cbd5e1); }
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > thead > tr > :is(th, td) {
    border-bottom: 1px solid var(--color-muted, #cbd5e1); background-color: var(--color-surface, #ffffff); background-color: color-mix(in srgb, var(--color-muted, #cbd5e1) 15%, var(--color-surface, #ffffff));
}
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > tbody > tr:not(:last-child) > :is(th, td) { border-bottom: 1px solid color-mix(in srgb, var(--color-muted, #cbd5e1) 60%, transparent); }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-corner {
    display: flex; align-items: flex-end; justify-content: flex-start; padding: 0.5rem 0.75rem; font-weight: 700; font-size: 0.875rem; line-height: 1.3; color: var(--color-muted-fg, #64748b); text-align: left; overflow-wrap: break-word; word-break: normal; hyphens: auto;
}
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-row-label {
    display: flex; align-items: center; justify-content: flex-start; padding: 0.5rem 0.75rem; font-weight: 400; font-size: 0.875rem; line-height: 1.35; color: var(--color-surface-fg, #0f172a); background-color: var(--color-surface, #ffffff); text-align: left; overflow-wrap: break-word; word-break: normal; hyphens: auto;
}
.editor-content:not(.ProseMirror) .feedback-profile-chart :is(.feedback-profile-corner, .feedback-profile-row-label) > * { min-width: 0; max-width: 100%; overflow-wrap: break-word; word-break: normal; hyphens: auto; }

/* Matrix-Profillinie mit Formeln in der Label-Spalte: Track 1 wächst mit der Formel, .feedback-profile-scroller scrollt das Diagramm */
.editor-content:not(.ProseMirror) .feedback-profile-chart:has(:is(.feedback-profile-corner, .feedback-profile-row-label) :is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) {
    min-width: max(min-content, calc(var(--profile-label-col-min) + var(--profile-cols, 2) * var(--profile-col-min, 21px)));
    grid-template-columns: minmax(max(var(--profile-label-col-min), min-content), var(--profile-label-col-max)) repeat(var(--profile-cols, 2), minmax(var(--profile-col-min, 21px), 1fr));
}
.editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table :is(.feedback-profile-corner, .feedback-profile-row-label):has(:is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) { min-width: min-content; }
.editor-content:not(.ProseMirror) .feedback-profile-chart :is(.feedback-profile-corner, .feedback-profile-row-label) > *:is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex),
.editor-content:not(.ProseMirror) .feedback-profile-chart :is(.feedback-profile-corner, .feedback-profile-row-label) > *:has(:is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) { min-width: min-content; max-width: none; }

.editor-content:not(.ProseMirror) .feedback-profile-chart :is(.feedback-profile-corner, .feedback-profile-row-label) p { margin: 0; line-height: inherit; }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-col-head {
    display: flex; align-items: flex-end; justify-content: center; padding: 0.5rem var(--profile-col-px, 0.25rem); font-weight: 500; font-size: 0.75rem; line-height: 1.25; color: var(--color-muted-fg, #64748b); text-align: center;
}
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-col-head.is-long-head { padding-inline: var(--profile-long-px, 0.25rem); }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-head-label { display: block; max-width: 100%; overflow-wrap: break-word; word-break: normal; hyphens: auto; }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-col-head.is-long-head > .feedback-profile-head-label {
    writing-mode: var(--profile-wm, horizontal-tb); transform: var(--profile-rot, none); max-width: var(--profile-head-mw, 100%); max-height: var(--profile-head-mh, none); line-height: var(--profile-head-lh, 1.25); text-align: var(--profile-head-align, center);
}
@container profile-scroller (max-width: 860px) { .editor-content:not(.ProseMirror) .feedback-profile-chart[data-cols-density="very-high"] { --profile-wm: var(--profile-wm-vert); --profile-rot: var(--profile-rot-vert); --profile-head-mw: none; --profile-head-mh: 12.5rem; --profile-head-lh: 1.2; --profile-head-align: start; --profile-long-px: 0.125rem; } }
@container profile-scroller (max-width: 680px) { .editor-content:not(.ProseMirror) .feedback-profile-chart[data-cols-density="high"] { --profile-wm: var(--profile-wm-vert); --profile-rot: var(--profile-rot-vert); --profile-head-mw: none; --profile-head-mh: 12.5rem; --profile-head-lh: 1.2; --profile-head-align: start; --profile-long-px: 0.125rem; } }
@container profile-scroller (max-width: 520px) { .editor-content:not(.ProseMirror) .feedback-profile-chart[data-cols-density="medium"] { --profile-wm: var(--profile-wm-vert); --profile-rot: var(--profile-rot-vert); --profile-head-mw: none; --profile-head-mh: 12.5rem; --profile-head-lh: 1.2; --profile-head-align: start; --profile-long-px: 0.125rem; } }
@container profile-scroller (max-width: 480px) {
    .editor-content:not(.ProseMirror) .feedback-profile-chart :is(.feedback-profile-corner, .feedback-profile-row-label) { padding: 0.5rem 0.625rem; font-size: 0.8125rem; }
    .editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-col-head.is-short-head { --profile-col-px: 0.125rem; }
}
@container profile-scroller (max-width: 380px) { .editor-content:not(.ProseMirror) .feedback-profile-chart[data-cols-density="low"] { --profile-wm: var(--profile-wm-vert); --profile-rot: var(--profile-rot-vert); --profile-head-mw: none; --profile-head-mh: 12.5rem; --profile-head-lh: 1.2; --profile-head-align: start; --profile-long-px: 0.125rem; } }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-cell { display: flex; align-items: center; justify-content: center; padding: 0; background-color: var(--color-surface, #ffffff); }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-track-slot { position: relative; width: 100%; min-height: 28px; height: 100%; display: flex; align-items: center; justify-content: center; }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-guide { position: absolute; top: 50%; left: 0; right: 0; height: 1px; background-color: color-mix(in srgb, var(--color-muted, #cbd5e1) 50%, transparent); z-index: 1; }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-marker-correct { position: relative; width: 13px; height: 13px; border-radius: 2.5px; background-color: var(--color-success, #22c55e); box-shadow: 0 0 0 1.5px var(--color-surface, #ffffff); flex-shrink: 0; z-index: 3; }
.editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-marker-user { position: absolute; width: 9px; height: 9px; border-radius: 50%; background-color: var(--color-primary, #3b82f6); box-shadow: 0 0 0 1.5px var(--color-surface, #ffffff); flex-shrink: 0; z-index: 4; }
.editor-content .feedback-profile-legend { margin-top: 0.875rem; font-size: 0.8125rem; line-height: 1.3; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; justify-content: flex-end; align-items: center; }
@media (max-width: 520px) { .editor-content .feedback-profile-legend { justify-content: flex-start; } }
.editor-content .feedback-profile-legend-item { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
.editor-content .feedback-profile-legend-icon { flex-shrink: 0; display: block; }
.high-contrast .editor-content:not(.ProseMirror) .feedback-profile-chart { border-color: var(--color-surface-fg) !important; }
.high-contrast .editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table :is(th, td):not(:last-child),
.high-contrast .editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > thead > tr > :is(th, td),
.high-contrast .editor-content:not(.ProseMirror) .feedback-profile-chart > .feedback-profile-table > tbody > tr:not(:last-child) > :is(th, td) { border-color: var(--color-surface-fg) !important; }
/* --- NEUE MATRIX LAYOUT KLASSEN --- */

/* 1. Unified Grid für das Profil (Löst das Umbruch-Problem) */
.editor-content .feedback-matrix-profile {
    display: grid;
    grid-template-columns: fit-content(40%) 1fr; /* Links max 40%, Rest für die Linien */
    grid-auto-rows: 1fr; /* Alle Zeilen werden exakt gleich hoch (wichtig für SVG Y-Achse!) */
    align-items: stretch;
    position: relative;
    gap: 0 1rem;
}

/* 2. SVG Wrapper (Legt sich exakt über die rechte Grid-Spalte) */
.editor-content .feedback-matrix-svg-wrapper {
    grid-column: 2;
    grid-row: 1 / -1; /* Umspannt alle Zeilen von oben bis unten */
    position: relative;
}

/* 3. Label-Zellen (Links) */
.editor-content .feedback-matrix-label {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9em;
    word-break: break-word; /* Sanfter Umbruch bei extrem langen Texten */
    border-bottom: 1px dashed rgba(128, 128, 128, 0.2);
}

/* 4. Flex-Track & Spalten (Erzwingt EXAKT gleiche Breiten) */
.editor-content .feedback-matrix-track {
    display: flex;
    width: 100%;
    align-items: center;
    border-bottom: 1px dashed rgba(128, 128, 128, 0.2);
}
.editor-content .feedback-matrix-col {
    flex: 1 1 0%; /* Das ist der Trick! Keine Spalte darf breiter sein als die andere */
    position: relative;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Profillinie (Raster) */
.editor-content .feedback-profile-grid { display: flex; gap: 1rem; position: relative; }
.editor-content .feedback-profile-labels { width: 40%; display: flex; flex-direction: column; }
.editor-content .feedback-profile-tracks { flex: 1; display: flex; flex-direction: column; position: relative; }

/* Flex: 1 sorgt dafür, dass alle Zeilen exakt gleich hoch sind! */
.editor-content .feedback-profile-label-cell { flex: 1; display: flex; align-items: center; min-height: 40px; border-bottom: 1px dashed rgba(128, 128, 128, 0.2); font-size: 0.9em; font-weight: 500; padding: 0.5rem 0; }
.editor-content .feedback-profile-track-cell { flex: 1; display: flex; position: relative; border-bottom: 1px dashed rgba(128, 128, 128, 0.2); min-height: 40px; }
.editor-content .feedback-profile-cell { flex: 1; position: relative; }

/* Z-Index und Barrierefreie Formen */
.editor-content .feedback-profile-line { position: absolute; top: 50%; left: 0; right: 0; height: 2px; background: var(--color-muted, #cbd5e1); z-index: 1; }
.editor-content .feedback-profile-dot-correct { width: 14px; height: 14px; border-radius: 2px; background: var(--color-success, #22c55e); border: 2px solid var(--color-surface, #ffffff); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; } /* QUADRAT */
.editor-content .feedback-profile-dot-user { width: 12px; height: 12px; border-radius: 50%; background: var(--color-primary, #3b82f6); border: 2px solid var(--color-surface, #ffffff); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 4; transition: opacity 0.2s ease; } /* KREIS */

/* Balkendiagramme */
.editor-content .feedback-chart-title { font-weight: bold; margin-bottom: 1rem; }
.editor-content .feedback-chart-track { position: relative; height: 120px; margin-bottom: 0.5rem; display: flex; gap: 8px; }
.editor-content .feedback-chart-zero-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--color-muted, #cbd5e1); z-index: 1; }
.editor-content .feedback-chart-col { flex: 1; position: relative; height: 100%; }

/* Basis-Balken: Ruhig und neutral, visualisiert nur die Punkte */
.editor-content .feedback-chart-bar-bg { position: absolute; left: 50%; transform: translateX(-50%); width: 100%; max-width: 40px; background: rgba(128, 128, 128, 0.15); border-radius: 4px; box-sizing: border-box; }

/* User-Antwort: Gestrichelter Rahmen, bläulich transparent */
.editor-content .feedback-chart-bar-user { 
    position: absolute; left: 50%; transform: translateX(-50%); width: 100%; max-width: 40px; z-index: 2; transition: opacity 0.2s ease; box-sizing: border-box; 
    background-color: rgba(59, 130, 246, 0.2); 
    border: 2px dashed var(--color-primary, #3b82f6); 
    border-radius: 4px;
}

.editor-content .feedback-chart-score { position: absolute; left: 50%; transform: translateX(-50%); font-size: 0.75em; font-weight: bold; color: var(--color-muted-fg, #64748b); z-index: 3; line-height: 1; text-align: center; }
.editor-content .feedback-chart-info { font-size: 0.85em; display: flex; justify-content: space-between; background: rgba(128, 128, 128, 0.05); padding: 8px; border-radius: 4px; margin-bottom: 1rem; }

/* Semantische Sichtbarkeit (State-Klassen) */
.editor-content .is-visible-0 { display: none !important; }
.editor-content .is-visible-1 { opacity: 1 !important; }

/* --- 6. FEEDBACK HOTSPOT TEMPLATES --- */
.editor-content .feedback-hotspot-empty { padding: 1rem; background: rgba(128, 128, 128, 0.05); border-radius: 8px; text-align: center; font-style: italic; color: var(--color-muted-fg, #64748b); }
.editor-content .feedback-hotspot-container { position: relative; display: inline-block; max-width: 100%; border-radius: 8px; overflow: hidden; border: 1px solid var(--color-muted, #cbd5e1); }
.editor-content .feedback-hotspot-image { max-width: 100%; height: auto; display: block; }
.editor-content .feedback-hotspot-spot { position: absolute; transform: translate(-50%, -50%); border-style: solid; border-width: 2px; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); }
.editor-content .feedback-hotspot-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: var(--color-surface, #ffffff); border: 1px solid var(--color-muted, #cbd5e1); padding: 2px 6px; font-size: 11px; font-weight: bold; color: var(--color-surface-fg, #0f172a); white-space: nowrap; margin-top: 6px; border-radius: 4px; box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1); }

/* --- 7. LÜCKENTEXT FEEDBACK (Golden Standard) --- */
.editor-content .feedback-gap-box {
    line-height: 1.6;
    padding: 1rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-muted);
    border-radius: 4px;
}
/* FIX: Margins restlos entfernt, da Leerzeichen im Text ausreichen */
.editor-content .feedback-gap-user {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: var(--color-muted-fg);
    text-underline-offset: 3px;
}
.editor-content .feedback-gap-solution,
.editor-content .feedback-gap-correct {
    color: var(--color-success, #16a34a);
    font-weight: 600;
}
.editor-content .feedback-gap-wrong {
    color: var(--color-danger, #dc2626);
}
.editor-content .feedback-gap-wrapper {
    white-space: nowrap;
}
.editor-content .inline-gap-text {
    line-height: 1.65;
}

/* --- 8. FEEDBACK TABELLEN (Golden Standard für Formula etc.) --- */
/* Smart Table Defaults - Überschreibbar via CSS-Tab (Niedrige Spezifität via :where) */
:where(.editor-content) .feedback-table {
    --ft-min-w-default: 80px;                /* Smarte Mindestbreite für normale Spalten (55px Content-Box: Mehrwort-Header brechen um, normale Wörter bleiben ganz) */
    --ft-max-w-default: min(400px, 70vw);    /* Maximale Breite, bevor Text umbricht (auf Mobile max. 70% Viewport) */
    --ft-max-w-first: min(240px, 45vw);      /* Maximale Breite für die angepinnte erste Spalte auf schmalen Viewports */
    --ft-w-icon: 5.25rem;                    /* Feste Breite für Icon/Result-Spalten (84px bei 16px Basis, skaliert mit Schriftgröße) */
    --ft-sticky-header: sticky; /* 'sticky' oder 'static' für Mobile Header */
    --ft-sticky-col: sticky;    /* 'sticky' oder 'static' für erste Spalte auf Mobile */
}
.editor-content .feedback-table {
    width: auto; /* Tabelle schrumpft auf den nötigen Inhalt */
    min-width: 40%; /* Sieht nicht zu winzig aus, wenn nur ein Zeichen drinsteht */
    margin: 0 auto; /* Zentriert die Tabelle elegant im Container ohne zusätzlichen oberen Abstand */
    border-collapse: collapse;
    table-layout: auto;
}
.editor-content .feedback-table th {
    border: 1px solid var(--color-muted);
    background-color: var(--color-surface);
    background-color: color-mix(in srgb, var(--color-muted) 15%, var(--color-surface));
    padding: 0.25rem 0.75rem; /* Höhe deutlich reduziert, Seitenabstand behalten */
    text-align: left;
    font-weight: bold;
    color: var(--color-muted-fg);
    min-width: var(--ft-min-w-default);
    max-width: var(--ft-max-w-default);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
}
.editor-content .feedback-table td {
    border: 1px solid var(--color-muted);
    background-color: var(--color-surface);
    padding: 0.25rem 0.75rem; /* Höhe deutlich reduziert */
    vertical-align: middle;
    text-align: left;
    min-width: var(--ft-min-w-default);
    max-width: var(--ft-max-w-default);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
}
.editor-content .feedback-table :where(th, td):is(.text-center, .col-result) {
    text-align: center;
}
.editor-content .feedback-table :where(th, td).text-right {
    text-align: right;
}
.editor-content .feedback-table .col-result {
    min-width: var(--ft-w-icon);
    max-width: var(--ft-w-icon);
    width: var(--ft-w-icon);
    padding-inline: 0.375rem;
    white-space: nowrap;
    word-wrap: normal;
    overflow-wrap: normal;
    hyphens: none;
}
.editor-content .feedback-table :where(pre, code, mjx-container, .katex, svg) {
    hyphens: none;
}
/* Sticky Header & Sticky First Column */
.editor-content :has(> svg) .feedback-table {
    --ft-sticky-col: static;
    --ft-min-w-default: 0px;
    --ft-max-w-default: none;
    --ft-max-w-first: none;
}
.editor-content :has(> svg) > .tableWrapper {
    margin: 0;
    padding: 0;
    overflow: visible !important;
    background: transparent;
}
.editor-content .feedback-table > :where(thead, tbody:not(thead ~ tbody)) > tr:first-child > th {
    position: var(--ft-sticky-header);
    inset-block-start: 0;
    z-index: 10;
    background-color: var(--color-surface);
    background-color: color-mix(in srgb, var(--color-muted) 15%, var(--color-surface));
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.editor-content .feedback-table :where(td, th):first-child {
    max-width: var(--ft-max-w-first);
    position: var(--ft-sticky-col);
    inset-inline-start: 0;
    z-index: 11;
    background-color: var(--color-surface);
    box-shadow: -1px 0 0 var(--color-surface), 1px 0 2px rgba(0, 0, 0, 0.05);
}
/* Überschneidung oben links (Eckzelle bleibt vertikal & horizontal verankert) */
.editor-content .feedback-table > :where(thead, tbody:not(thead ~ tbody)) > tr:first-child > th:first-child {
    position: var(--ft-sticky-col);
    inset-block-start: 0;
    inset-inline-start: 0;
    z-index: 20;
    background-color: var(--color-surface);
    background-color: color-mix(in srgb, var(--color-muted) 15%, var(--color-surface));
    box-shadow: -1px 0 0 color-mix(in srgb, var(--color-muted) 15%, var(--color-surface)), 1px 1px 2px rgba(0, 0, 0, 0.05);
}
.editor-content :has(> svg) .feedback-table :where(td, th):first-child {
    box-shadow: none;
}
/* Feedback-Tabellen mit Formeln: Betroffene Formelzellen wachsen mit, bei Formel in Spalte 1 entfällt Sticky-Verdeckung */
.editor-content .feedback-table:not(.feedback-profile-table) :is(th, td):has(:is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) {
    max-width: none;
}
.editor-content .feedback-table:not(.feedback-profile-table):has(:where(td, th):first-child :is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) {
    --ft-max-w-first: none;
    --ft-sticky-col: static;
}
.editor-content .feedback-table:not(.feedback-profile-table):has(:where(td, th):first-child :is(mjx-container, .katex, .katex-display, [data-type="math-component"], .math-node, .math-tex)) :where(td, th):first-child {
    box-shadow: none;
}
.editor-content .feedback-result-icon {
    position: relative;
    width: 20px; /* Leicht verkleinert für kompaktere Optik */
    height: 20px;
    margin: 0 auto;
}
.editor-content .feedback-result-icon > * {
    position: absolute;
    top: 0;
    left: 0;
}

/* Steuerbare Optionsbilder im Feedback (Choice etc.) - Überschreibbar via CSS-Tab */
.editor-content .feedback-option-image-list {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    vertical-align: middle;
}
:where(.editor-content) .feedback-option-image {
    display: inline-block;
    vertical-align: middle;
    max-width: var(--fb-opt-img-max-w, 80px);
    max-height: var(--fb-opt-img-max-h, 56px);
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0;
    padding: 2px;
    box-sizing: border-box;
    border-radius: 0.25rem;
    border: 1px solid color-mix(in srgb, var(--color-surface-fg, #0f172a) 18%, transparent);
    background-color: var(--color-surface, #ffffff);
}
.high-contrast .editor-content .feedback-option-image {
    border-color: var(--color-surface-fg);
}

/* Mobile Overrides (zwingt Floats und Pixelbreiten in die Knie) */
@media (max-width: 768px) {
    .editor-content figure[data-mobile-full="true"] {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* --- 9. FEEDBACK CODE TEMPLATE CLASSES --- */
.editor-content .feedback-code-stacked > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }

.editor-content .feedback-code-label { 
    display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; 
    letter-spacing: 0.05em; color: var(--color-muted-fg, #64748b); margin-bottom: 0.5rem; 
}
.editor-content .feedback-code-label.has-mt { margin-top: 1rem; }
.editor-content .feedback-code-label.is-success { color: var(--color-success, #16a34a); }

.editor-content .feedback-code-block { 
    background-color: rgba(128, 128, 128, 0.1); border-radius: 0.5rem; 
    padding: 1rem; overflow-x: auto; border: 1px solid rgba(128, 128, 128, 0.5); 
}
.editor-content .feedback-code-block.is-success { 
    background-color: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.3); 
}
.editor-content .feedback-code-block.is-sm { padding: 0.75rem; border-radius: 0.25rem; }
.editor-content .feedback-code-block.h-24 { height: 6rem; }
.editor-content .feedback-code-block.h-32 { height: 8rem; }

.editor-content .feedback-code-pre { 
    margin: 0; font-family: monospace; font-size: 0.875rem; color: var(--color-surface-fg, #0f172a); 
}
.editor-content .feedback-code-pre.is-sm { font-size: 0.75rem; }
.editor-content .feedback-code-pre.is-success { color: var(--color-surface-fg, #0f172a); }

.editor-content .feedback-code-grid { 
    display: grid; gap: 1rem; grid-template-columns: repeat(1, minmax(0, 1fr)); 
}
@media (min-width: 768px) { 
    .editor-content .feedback-code-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } 
}

/* --- 10. DRUCK- & PDF-EXPORT OPTIMIERUNGEN (@media print & .print-container) --- */
.print-container .editor-content details.bona-accordion::details-content,
.print-container .editor-content details::details-content {
    block-size: auto !important;
    content-visibility: visible !important;
    overflow: visible !important;
}

.print-container .editor-content .feedback-comparison,
.print-container .editor-content .tableWrapper,
.print-container .editor-content .feedback-table-wrapper,
.print-container .editor-content .feedback-comparison .tableWrapper,
.print-container .editor-content .feedback-comparison .feedback-table-wrapper {
    overflow: visible !important;
    background: transparent !important;
}

.print-container .editor-content .feedback-table-wrapper > div[style*="min-width"] {
    min-width: 0 !important;
    width: 100% !important;
}

.print-container .editor-content .feedback-table {
    --ft-min-w-default: 0px;
    --ft-max-w-default: none;
    --ft-max-w-first: none;
    --ft-w-icon: 56px;
    --ft-sticky-header: static;
    --ft-sticky-col: static;
    width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
    font-size: 0.82em;
}

.print-container .editor-content .feedback-table th,
.print-container .editor-content .feedback-table td {
    min-width: 0 !important;
    max-width: none !important;
    padding: 0.25rem 0.4rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    position: static !important;
    box-shadow: none !important;
}

.print-container .editor-content:not(.ProseMirror) .feedback-profile-chart {
    --profile-label-col-min: 96px;
    --profile-col-min: 0px !important;
    min-width: 0 !important;
    width: 100% !important;
}
.print-container .editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-cell { padding: 0; }

.print-container .editor-content .feedback-table .col-result {
    min-width: 52px !important;
    max-width: 64px !important;
    width: 56px !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}

.print-container .editor-content table:not(.feedback-table) {
    width: 100% !important;
    max-width: 100% !important;
}

.print-container .editor-content table:not(.feedback-table) th,
.print-container .editor-content table:not(.feedback-table) td {
    min-width: 0 !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media print {
    .editor-content details.bona-accordion::details-content,
    .editor-content details::details-content {
        block-size: auto !important;
        content-visibility: visible !important;
        overflow: visible !important;
    }

    .editor-content .feedback-comparison,
    .editor-content .tableWrapper,
    .editor-content .feedback-table-wrapper,
    .editor-content .feedback-comparison .tableWrapper,
    .editor-content .feedback-comparison .feedback-table-wrapper {
        overflow: visible !important;
        background: transparent !important;
    }

    .editor-content .feedback-table-wrapper > div[style*="min-width"] {
        min-width: 0 !important;
        width: 100% !important;
    }

    .editor-content .feedback-table {
        --ft-min-w-default: 0px;
        --ft-max-w-default: none;
        --ft-max-w-first: none;
        --ft-w-icon: 56px;
        --ft-sticky-header: static;
        --ft-sticky-col: static;
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto !important;
        font-size: 0.82em;
    }

    .editor-content .feedback-table th,
    .editor-content .feedback-table td {
        min-width: 0 !important;
        max-width: none !important;
        padding: 0.25rem 0.4rem;
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal;
        position: static !important;
        box-shadow: none !important;
    }

    .editor-content:not(.ProseMirror) .feedback-profile-chart {
        --profile-label-col-min: 96px;
        --profile-col-min: 0px !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    .editor-content:not(.ProseMirror) .feedback-profile-chart .feedback-profile-cell { padding: 0; }

    .editor-content .feedback-table .col-result {
        min-width: 52px !important;
        max-width: 64px !important;
        width: 56px !important;
        white-space: nowrap !important;
        overflow-wrap: normal !important;
        word-break: normal !important;
    }

    .editor-content table:not(.feedback-table) {
        width: 100% !important;
        max-width: 100% !important;
    }

    .editor-content table:not(.feedback-table) th,
    .editor-content table:not(.feedback-table) td {
        min-width: 0 !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}
