/* ================================================================
   WEBWERKSTATT – styles.css
   ================================================================ */

/* Ensure [hidden] always wins, even against display:flex class rules */
[hidden] { display: none !important; }

/* ================================================================
   Grundlagen – identisch in allen Werkzeugen (nicht ändern)
   ================================================================ */
:root{
  --grund:#faf8f4; --flaeche:#f3efe7; --karte:#ffffff;
  --text:#22262b; --leise:#5f656c; --linie:#e2ddd3;
  --inf:#1e5175; --inf-hell:#e8eef3;
  --wr:#9a4423;  --wr-hell:#f6e9e2;
  --akzent:#c8643b;
  --richtig:#2f7a4f; --richtig-hell:#e6f2ea;
  --falsch:#b3261e;  --falsch-hell:#fbe9e7;
  --hinweis:#8a6100; --hinweis-hell:#fbf3dc;
  --d1:#1e5175; --d2:#c8643b; --d3:#2f7a4f; --d4:#7a4fa0; --d5:#b08a1e; --d6:#2a8a96;
  --serif:"Iowan Old Style","Palatino Linotype",Palatino,"Book Antiqua",Georgia,serif;
  --sans:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  --mono:ui-monospace,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
  --r-klein:6px; --r:10px; --r-rund:999px;
  --schatten:0 1px 2px rgba(0,0,0,.06),0 2px 8px rgba(0,0,0,.05);
  --abstand:1rem;
}
:root[data-thema="dunkel"]{
  --grund:#16191c; --flaeche:#1c2024; --karte:#21262b;
  --text:#e8e5df; --leise:#a3a9b0; --linie:#363c43;
  --inf:#8db9d9; --inf-hell:#1f2d38;
  --wr:#e3997a;  --wr-hell:#3a261d;
  --akzent:#e08a62;
  --richtig:#7cc59a; --richtig-hell:#1c3226;
  --falsch:#f08a80;  --falsch-hell:#3a1f1c;
  --hinweis:#e2c06a; --hinweis-hell:#352c14;
  --d1:#8db9d9; --d2:#e08a62; --d3:#7cc59a; --d4:#b99be0; --d5:#e2c06a; --d6:#6cc3cc;
  --schatten:none;
}
:root[data-fach="informatik"]{ --fach:var(--inf); --fach-hell:var(--inf-hell); }
:root[data-fach="wr"]        { --fach:var(--wr);  --fach-hell:var(--wr-hell); }

html.tafel { font-size: 125%; }
.tafel-aus {} html.tafel .tafel-aus { display: none; }

/* ================================================================
   WebWerkstatt – Variablen auf Grundlagen abgebildet
   ================================================================ */
:root {
  --clr-primary:      var(--inf);
  --clr-primary-dark: #1a4568;
  --clr-secondary:    var(--leise);
  --clr-danger:       var(--falsch);
  --clr-danger-dark:  #8b1a14;
  --clr-success:      var(--richtig);
  --clr-warning:      var(--hinweis);

  --clr-bg:           var(--grund);
  --clr-surface:      var(--karte);
  --clr-border:       var(--linie);
  --clr-border-light: var(--linie);

  --clr-text:         var(--text);
  --clr-text-muted:   var(--leise);

  --header-h:         52px;
  --sidebar-left-w:   200px;
  --sidebar-right-w:  220px;
  --toolbar-h:        44px;

  --radius-sm:  var(--r-klein);
  --radius:     var(--r);
  --radius-lg:  12px;
  --shadow-sm:  var(--schatten);
  --shadow:     var(--schatten);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.18);

  --font-ui: var(--sans);
  --transition: 0.15s ease;
}

/* ── Reset / Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--clr-text);
  background: var(--clr-bg);
}

/* ── Header ─────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 14px;
  background: #1e5175; /* feste Fachfarbe Informatik, themenunabhängig */
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 100;
  position: relative;
  flex-shrink: 0;
}

/* Kopf-Links: Rücklink + Fach-Label + Name */
.kopf-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.kopf-heim {
  font-family: var(--serif);
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .82rem;
  white-space: nowrap;
}
.kopf-heim:hover { color: #fff; }
.kopf-name {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  margin-right: 4px;
}
.kopf-name small {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.65);
  font-weight: 600;
}
.kopf-name strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.1rem;
  color: #fff;
}
.kopf-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,.25);
  flex-shrink: 0;
}

/* ── Header: mode buttons ────────────────────────────────────────── */
.header-modes {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.hdr-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255,255,255,0.75);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.hdr-mode-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.hdr-mode-btn.active {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.50);
  color: #fff;
  font-weight: 600;
}

/* ── Header: action buttons ──────────────────────────────────────── */
.btn-hdr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255,255,255,0.80);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.btn-hdr:hover     { background: rgba(255,255,255,0.12); color: #fff; }
.btn-hdr-accent    { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary-dark); }
.btn-hdr-accent:hover { background: var(--clr-primary-dark); }
.btn-hdr-submit    { background: #27ae60; color: #fff; border-color: #1e8449; }
.btn-hdr-submit:hover { background: #1e8449; }
.btn-hdr-teacher   { background: #8e44ad; color: #fff; border-color: #6c3483; }
.btn-hdr-teacher:hover { background: #6c3483; }

.hdr-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.20);
  margin: 0 4px;
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon { font-size: 22px; }
.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-status {
  font-size: 12px;
  color: #a0aec0;
  margin-right: 4px;
  white-space: nowrap;
}
.save-status.saving { color: var(--clr-warning); }
.save-status.saved  { color: #68d391; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--clr-primary-dark); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
}
.btn-secondary:hover { background: rgba(255,255,255,0.25); }

.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}
.btn-danger:hover { background: var(--clr-danger-dark); }

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
}
.btn-sm:hover { background: var(--clr-bg); }
.btn-sm.btn-primary { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
.btn-sm.btn-danger   { background: var(--clr-danger);  color: #fff; border-color: var(--clr-danger); }

.btn-block { width: 100%; justify-content: center; }

/* ── App Body Layout ─────────────────────────────────────────────── */
.app-body {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Left Sidebar ────────────────────────────────────────────────── */
.sidebar-left {
  width: var(--sidebar-left-w);
  flex-shrink: 0;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-title {
  padding: 10px 12px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--clr-text-muted);
  border-bottom: 1px solid var(--clr-border-light);
}

.page-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.page-list li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  border-radius: 0;
  transition: background var(--transition);
  position: relative;
}
.page-list li:hover { background: var(--clr-bg); }
.page-list li.active {
  background: var(--fach-hell);
  color: var(--clr-primary);
  font-weight: 600;
  border-right: 3px solid var(--clr-primary);
}
.page-list li .page-icon { font-size: 12px; }
.page-list li .page-home-badge {
  font-size: 10px;
  background: var(--clr-primary);
  color: #fff;
  padding: 1px 4px;
  border-radius: 10px;
  margin-left: auto;
}

.sidebar-buttons {
  padding: 8px;
  border-top: 1px solid var(--clr-border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Editor Area ─────────────────────────────────────────────────── */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Toolbar ─────────────────────────────────────────────────────── */
.editor-toolbar {
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  padding: 4px 8px;
  flex-shrink: 0;
}

.toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 5px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--clr-text);
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.tb-btn:hover  { background: var(--clr-bg); border-color: var(--clr-border); }
.tb-btn.active { background: var(--fach-hell); border-color: var(--clr-primary); color: var(--clr-primary); }
.tb-btn.mode-btn { font-size: 12px; padding: 0 8px; }

.tb-separator {
  width: 1px;
  height: 20px;
  background: var(--clr-border);
  margin: 0 4px;
}

.tb-select {
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  color: var(--clr-text);
}
.tb-select:focus { outline: none; border-color: var(--clr-primary); }
/* ── Toolbar: font family custom dropdown ────────────────────────── */
.tb-font-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tb-font-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 120px;
  max-width: 150px;
  height: 28px;
  padding: 2px 6px;
  justify-content: space-between;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
}
.tb-font-trigger #tbFontPreview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 13px;
}
.tb-font-chevron {
  font-size: 10px;
  opacity: .6;
  flex-shrink: 0;
}
.tb-font-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.16);
  width: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-font-dropdown {
    background: #2a2a3a;
    border-color: #444;
  }
}
:root[data-theme="dark"] .tb-font-dropdown {
  background: #2a2a3a;
  border-color: #444;
}
.tbf-group-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--clr-text-muted, #888);
}
.tbf-option {
  padding: 5px 14px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--clr-text, #1a1a2e);
}
.tbf-option:hover      { background: var(--clr-bg, #f4f6fb); }
.tbf-option--active    { background: #ebf4ff; color: var(--clr-primary, #4a90d9); font-weight: 600; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tbf-option { color: #e0e0f0; }
  :root:not([data-theme="light"]) .tbf-option:hover { background: #333348; }
  :root:not([data-theme="light"]) .tbf-option--active { background: #1e3a5f; color: #7ab8f5; }
}
:root[data-theme="dark"] .tbf-option { color: #e0e0f0; }
:root[data-theme="dark"] .tbf-option:hover { background: #333348; }
:root[data-theme="dark"] .tbf-option--active { background: #1e3a5f; color: #7ab8f5; }

/* ── Toolbar: color buttons (native <input type="color">) ────────── */
/* ── Color picker wraps & panels ─────────────────────────────────── */
.tb-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.tb-color-btn {
  flex-direction: column;
  gap: 1px;
  padding: 3px 6px;
  height: 28px;
}
.tb-chevron-btn {
  padding: 0 3px;
  font-size: 10px;
  line-height: 1;
  height: 28px;
  min-width: 14px;
  color: var(--tb-text, #444);
}
.tb-color-letter {
  font-size: 13px;
  line-height: 1;
  font-family: Georgia, serif;
}
.color-bar {
  display: block;
  height: 3px;
  width: 100%;
  border-radius: 1px;
  min-width: 14px;
}
.tb-color-panel {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 300;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  padding: 8px;
  width: 148px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-color-panel {
    background: #2a2a3a;
    border-color: #444;
  }
}
:root[data-theme="dark"] .tb-color-panel {
  background: #2a2a3a;
  border-color: #444;
}
.tb-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 7px;
}
.tb-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.18);
  cursor: pointer;
  padding: 0;
  outline: none;
  transition: transform .1s, box-shadow .1s;
}
.tb-color-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  z-index: 1;
  position: relative;
}
.tb-color-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--border, #e5e5e5);
  padding-top: 7px;
}
.tb-color-black-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.25);
  cursor: pointer;
  padding: 0;
  background: #000;
  flex-shrink: 0;
  outline: none;
}
.tb-color-black-btn:hover { opacity: .8; }
.tb-color-footer-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border, #ddd);
  cursor: pointer;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  padding: 0;
  color: var(--tb-text, #444);
  flex-shrink: 0;
}
.tb-color-footer-btn:hover { background: var(--hover-bg, #f0f0f0); }
.tb-no-color-btn .tb-no-color-icon {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid #bbb;
  background:
    linear-gradient(to top left,
      transparent calc(50% - 1.5px), #e74c3c calc(50% - 1.5px),
      #e74c3c calc(50% + 1.5px),     transparent calc(50% + 1.5px)),
    #fff;
}
/* Visually hidden but reachable by JS .click() */
.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;
  opacity: 0;
  pointer-events: none;
}

/* ── Color panel: hex text input ─────────────────────────────────── */
.tb-color-hex-input {
  width: 68px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  background: var(--bg, #fff);
  color: var(--fg, #333);
  flex: 1 1 auto;
  min-width: 0;
  outline: none;
}
.tb-color-hex-input:focus { border-color: #4a90d9; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tb-color-hex-input { background: #2a2a3e; color: #ddd; border-color: #444; }
}
:root[data-theme="dark"] .tb-color-hex-input { background: #2a2a3e; color: #ddd; border-color: #444; }

/* Native color input styled as a small swatch */
.tb-color-native {
  width: 26px;
  height: 26px;
  padding: 1px;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.tb-color-custom-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}
.tb-color-custom-label:hover { background: var(--hover-bg, #f0f0f0); }

/* ── Toolbar: font-size input + A↑/A↓ buttons ────────────────────── */
.tb-font-size-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  min-width: 26px;
  line-height: 28px;
  letter-spacing: -0.5px;
}
.tb-font-size-btn .fs-arrow { font-size: 9px; vertical-align: middle; }
.tb-font-size-input {
  width: 40px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--clr-text);
  background: var(--clr-surface);
  text-align: center;
  -moz-appearance: textfield;
}
.tb-font-size-input::-webkit-inner-spin-button,
.tb-font-size-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tb-font-size-input:focus { outline: none; border-color: var(--clr-primary); }
.tb-fs-combo { position: relative; display: inline-block; }
.tb-fs-list {
  position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  background: var(--clr-surface); border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm); box-shadow: 0 4px 14px rgba(0,0,0,.18);
  z-index: 2000; min-width: 52px; max-height: 200px; overflow-y: auto;
}
.tb-fs-opt {
  display: block; width: 100%; padding: 4px 10px; text-align: center;
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: var(--clr-text); white-space: nowrap;
}
.tb-fs-opt:hover, .tb-fs-opt.active { background: var(--clr-primary); color: #fff; }

/* ── Toolbar: disabled state (HTML / Preview mode) ───────────────── */
/* Only formatting controls are greyed out; mode buttons & utility btns stay active */
.toolbar-formatting-disabled .tb-btn:not(.mode-btn):not(#btnPastePlain):not(#btnFocusMode),
.toolbar-formatting-disabled .tb-select,
.toolbar-formatting-disabled .tb-color-group,
.toolbar-formatting-disabled .tb-font-size-input,
.toolbar-formatting-disabled .tb-font-size-btn,
.toolbar-formatting-disabled .tb-separator {
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
}

/* ── Toolbar: table button wrapper ──────────────────────────────── */
.tb-table-wrap {
  position: relative;
  display: inline-flex;
}

/* ── Word-style table picker popup ──────────────────────────────── */
.table-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 1000;
  user-select: none;
}
.table-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  grid-template-rows: repeat(8, 20px);
  gap: 2px;
}
.tp-cell {
  width: 20px;
  height: 20px;
  border: 1px solid var(--clr-border-light);
  border-radius: 2px;
  background: var(--clr-surface);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.tp-cell--on {
  background: var(--fach-hell);
  border-color: var(--clr-primary);
}
.table-picker-label {
  text-align: center;
  font-size: 11px;
  color: var(--clr-text-muted);
  margin-top: 6px;
  font-weight: 500;
  min-height: 16px;
}

/* ── Table context toolbar ───────────────────────────────────────── */
.table-ctx-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 10px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 34px;
}
.tct-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-right: 4px;
  white-space: nowrap;
}
.tct-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  font-size: 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--clr-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}
.tct-btn:hover:not(:disabled) {
  background: var(--clr-bg);
  border-color: var(--clr-border);
}
.tct-btn:disabled {
  opacity: .35;
  cursor: default;
}
.tct-btn--danger { color: var(--clr-danger); }
.tct-btn--danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
}
.tct-separator {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--clr-border);
  margin: 0 4px;
  flex-shrink: 0;
}
.tct-hint {
  font-size: 11px;
  color: var(--clr-text-muted);
  font-style: italic;
  margin-left: 6px;
  white-space: nowrap;
}

/* Selected cells highlight for merge operation */
.wysiwyg-editor td.tbl-selected,
.wysiwyg-editor th.tbl-selected {
  outline: 2px solid var(--clr-primary) !important;
  background: #dbeafe !important;
}

/* ── Editor Wrapper ──────────────────────────────────────────────── */
.editor-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* WYSIWYG Editor */
.wysiwyg-editor {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  background: #fff;
  outline: none;
  font-family: Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1a1a2e;
  min-height: 100%;
}
.wysiwyg-editor:focus-visible { outline: none; }

/* Editor content styles */
.wysiwyg-editor h1 { font-size: 2em; margin: .67em 0; }
.wysiwyg-editor h2 { font-size: 1.5em; margin: .75em 0; }
.wysiwyg-editor h3 { font-size: 1.17em; margin: .83em 0; }
.wysiwyg-editor p  { margin: .5em 0; }
.wysiwyg-editor ul, .wysiwyg-editor ol { padding-left: 2em; margin: .5em 0; }
.wysiwyg-editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
}
.wysiwyg-editor td, .wysiwyg-editor th {
  border: 1px solid #ccc;
  padding: 8px 10px;
  min-width: 60px;
  vertical-align: top;
}
.wysiwyg-editor th { background: #f0f2f5; font-weight: 600; }
.wysiwyg-editor a  { color: var(--clr-primary); }
.wysiwyg-editor img { max-width: 100%; height: auto; cursor: pointer; border-radius: var(--radius-sm); }
.wysiwyg-editor blockquote {
  border-left: 4px solid var(--clr-primary);
  padding-left: 16px;
  color: var(--clr-text-muted);
  margin: 8px 0;
}
.wysiwyg-editor hr {
  border: none;
  border-top: 2px solid var(--clr-border);
  margin: 16px 0;
}

/* HTML View */
.html-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.html-view-warning {
  padding: 8px 16px;
  background: #fff9e6;
  border-bottom: 1px solid #f6d860;
  font-size: 12px;
  color: #856404;
  flex-shrink: 0;
}
.html-textarea {
  display: none; /* replaced by CodeMirror */
}

/* CodeMirror fills the html-view flex container */
.html-view .CodeMirror {
  flex: 1;
  height: 100%;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  background: #f6f8fa;
  color: #24292f;
}
.html-view .CodeMirror-scroll {
  height: 100%;
}
.html-view .CodeMirror-gutters {
  background: #eaeef2;
  border-right: 1px solid #d0d7de;
}
.html-view .CodeMirror-linenumber {
  color: #8c959f;
}
.html-view .CodeMirror-matchingtag {
  background: rgba(255, 200, 0, 0.35);
  border-radius: 2px;
  outline: 1px solid rgba(200, 150, 0, 0.5);
}

/* Preview */
.preview-view {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.preview-hint-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #e8f4fd;
  border-bottom: 1px solid #b3d4f0;
  font-size: 13px;
  color: #1e5175;
}
.preview-hint-bar span { flex: 1; }
.preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 0;
}

/* "Website herunterladen" hidden until preview mode */
#btnExportWebsite { display: none; }

/* Full-screen preview: hide sidebars and formatting toolbar */
.app-body.preview-fullscreen .sidebar-left,
.app-body.preview-fullscreen .sidebar-right {
  display: none;
}
.app-body.preview-fullscreen #editorToolbar {
  display: none;
}
.app-body.preview-fullscreen .editor-area {
  flex: 1;
}

/* ── Right Sidebar ───────────────────────────────────────────────── */
.sidebar-right {
  width: var(--sidebar-right-w);
  flex-shrink: 0;
  background: var(--clr-surface);
  border-left: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--clr-text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.panel-tab.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }
.panel-tab:hover:not(.active) { color: var(--clr-text); background: var(--clr-bg); }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Design Controls */
.design-group {
  margin-bottom: 14px;
}
.design-group-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.design-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--clr-text-muted);
  margin-bottom: 5px;
}
.design-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--clr-text);
  cursor: pointer;
}
.design-select:focus { outline: none; border-color: var(--clr-primary); }

/* Native color picker in design panel */
.design-color-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 2px 4px;
  background: var(--clr-surface);
}

/* Media Tab */
.media-upload-area {
  margin-bottom: 12px;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
  padding: 4px;
}
.media-upload-area.drag-over {
  border-color: var(--clr-primary);
  background: #ebf4ff;
}
.media-hint {
  font-size: 11px;
  color: var(--clr-text-muted);
  text-align: center;
  margin-top: 4px;
}

.media-gallery {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  background: var(--clr-surface);
}
.media-item:hover { background: var(--clr-bg); border-color: var(--clr-primary); }
.media-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.media-info {
  flex: 1;
  overflow: hidden;
}
.media-filename {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-filesize {
  font-size: 10px;
  color: var(--clr-text-muted);
}
.media-delete {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--clr-danger);
  font-size: 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition), background var(--transition);
}
.media-delete:hover { opacity: 1; background: #fce8e6; }

/* ── Modals ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 440px;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  animation: modalIn .2s ease;
}
.modal-box-sm { width: 360px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  padding: 16px 20px 12px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--clr-border-light);
}
.modal-body { padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--clr-border-light);
}
.modal-footer .btn-secondary {
  background: #f0f0f0;
  color: #333;
  border-color: #ccc;
}
.modal-footer .btn-secondary:hover { background: #e0e0e0; }

/* Form elements inside modals */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--clr-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--clr-text);
  background: var(--clr-surface);
  transition: border-color var(--transition);
}
.form-input:focus { outline: none; border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(74,144,217,.15); }

.radio-group {
  display: flex;
  gap: 16px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  color: var(--clr-text);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Confirm warning box (inside confirm modal) */
.confirm-warning {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fff9e6;
  border: 1px solid #f6d860;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #856404;
  line-height: 1.5;
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Scrollbars ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-left-w: 160px;
    --sidebar-right-w: 180px;
  }
  .wysiwyg-editor { padding: 16px 20px; }
  .header-actions .btn span { display: none; }
}

@media (max-width: 600px) {
  .sidebar-right { display: none; }
  :root { --sidebar-left-w: 140px; }
}

/* ── Custom font picker ──────────────────────────────────────────── */
.font-picker { position: relative; }

.font-picker-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--clr-text);
  transition: border-color var(--transition);
  gap: 6px;
}
.font-picker-btn:hover  { border-color: var(--clr-primary); }
.font-picker-btn:focus  { outline: none; border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(74,144,217,.15); }

.font-picker-preview {
  flex: 1;
  text-align: left;
  font-size: 14px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.font-picker-arrow {
  flex-shrink: 0;
  color: var(--clr-text-muted);
  transition: transform var(--transition);
}
.font-picker-btn[aria-expanded="true"] .font-picker-arrow { transform: rotate(180deg); }

.font-picker-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0;
}

.fp-group { padding: 2px 0; }
.fp-group + .fp-group { border-top: 1px solid var(--clr-border-light); }

.fp-group-label {
  padding: 5px 12px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--clr-text-muted);
}

.fp-option {
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--clr-text);
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-option:hover       { background: var(--clr-bg); }
.fp-option--active     { background: #ebf4ff; color: var(--clr-primary); font-weight: 600; }

/* ── Form hints ──────────────────────────────────────────────────── */
.form-hint {
  margin-top: 5px;
  font-size: 11px;
  color: var(--clr-text-muted);
  line-height: 1.5;
}
.required { color: #e74c3c; }
.optional  { color: var(--clr-text-muted); font-size: 11px; }

.form-input-code {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 16px;
  font-weight: 700;
}

/* ── Action status (inside submit / teacher modals) ──────────────── */
.action-status {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
}
.action-status--error   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.action-status--success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.action-status--info    { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }

/* ── Passwort-Wrapper mit Auge-Button ────────────────────────────── */
.pw-wrap {
  position: relative;
  display: flex;
}
.pw-wrap .form-input {
  flex: 1;
  padding-right: 38px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 5px;
  color: var(--clr-text-muted);
  font-size: 15px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--clr-text); background: var(--clr-bg); }

/* ── Passwort-Prüfzeile ──────────────────────────────────────────── */
.pw-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.pw-check-row .action-status { margin: 0; flex: 1; }

/* ── Gesperrter Formular-Bereich ─────────────────────────────────── */
#teacherLockedSection[aria-disabled="true"] {
  display: none;
}

/* ── Teacher dialog ──────────────────────────────────────────────── */
.teacher-info-box {
  background: #fff9e6;
  border: 1px solid #f6d860;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: #856404;
  margin-bottom: 14px;
  line-height: 1.6;
}
.teacher-info-box ul {
  padding-left: 18px;
  margin: 4px 0 0;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--clr-text);
  cursor: pointer;
  line-height: 1.5;
}
.checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.teacher-code-display {
  text-align: center;
  padding: 8px 0;
}
.teacher-code-label {
  font-size: 12px;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.teacher-code-value {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #1a1a2e;
  background: var(--clr-bg);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 10px;
  border: 2px dashed var(--clr-border);
}
.teacher-code-copy {
  display: inline-block;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--clr-text);
  margin-bottom: 12px;
  transition: background var(--transition);
}
.teacher-code-copy:hover { background: var(--clr-bg); }
.teacher-code-hint {
  font-size: 13px;
  color: var(--clr-text-muted);
  margin-bottom: 4px;
}
.teacher-code-expires {
  font-size: 11px;
  color: var(--clr-text-muted);
}

/* ── Utility ─────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}


/* ── Feature 2: Submit success state ────────────────────────────── */
.submit-success-state {
  text-align: center;
  padding: 18px 8px 8px;
}
.submit-success-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 12px;
}
.submit-success-msg {
  font-size: 16px;
  font-weight: 700;
  color: var(--clr-success);
  margin-bottom: 8px;
}
.submit-success-sub {
  font-size: 13px;
  color: var(--clr-text-muted);
  line-height: 1.5;
}

/* ── Feature 1: Readonly form input ─────────────────────────────── */
.form-input[readonly] {
  background: var(--clr-bg);
  color: var(--clr-text-muted);
  cursor: default;
  border-color: var(--clr-border-light);
}

/* ── Feature 5: Inline image selection wrapper ───────────────────── */
.wysiwyg-editor .img-sel {
  display: inline-block;
  position: relative;
  outline: 2px solid var(--clr-primary);
  border-radius: 2px;
  line-height: 0;
  cursor: default;
  user-select: none;
}
.wysiwyg-editor .img-sel img { display: block; }
.wysiwyg-editor .img-sel .img-resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--clr-primary);
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  z-index: 2;
  touch-action: none;
  transition: transform .1s;
}
.wysiwyg-editor .img-sel .img-resize-handle:hover { transform: scale(1.25); }
.wysiwyg-editor .img-sel .img-resize-handle[data-dir="nw"] { top: -7px; left: -7px; cursor: nw-resize; }
.wysiwyg-editor .img-sel .img-resize-handle[data-dir="ne"] { top: -7px; right: -7px; cursor: ne-resize; }
.wysiwyg-editor .img-sel .img-resize-handle[data-dir="sw"] { bottom: -7px; left: -7px; cursor: sw-resize; }
.wysiwyg-editor .img-sel .img-resize-handle[data-dir="se"] { bottom: -7px; right: -7px; cursor: se-resize; }

/* Standalone align bar */
#imgAlignBar {
  position: fixed;
  bottom: auto;
  z-index: 1500;
}

/* ================================================================
   NEUE FEATURES – CSS
   ================================================================ */

/* ── Group A: Strikethrough/Superscript/Subscript state ──────────── */
.tb-btn[data-cmd="strikeThrough"].active { background: var(--fach-hell); border-color: var(--clr-primary); color: var(--clr-primary); }
.tb-btn[data-cmd="superscript"].active   { background: var(--fach-hell); border-color: var(--clr-primary); color: var(--clr-primary); }
.tb-btn[data-cmd="subscript"].active     { background: var(--fach-hell); border-color: var(--clr-primary); color: var(--clr-primary); }

/* ── Group B: Paste plain toggle ─────────────────────────────────── */
#btnPastePlain {
  min-width: 30px;
}
#btnPastePlain.paste-plain-on {
  background: var(--fach-hell);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}
#btnPastePlain.paste-plain-off {
  opacity: 0.55;
}

/* ── Group E: Image alignment bar ───────────────────────────────── */
.img-align-bar {
  position: absolute;
  bottom: -42px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 3px;
  pointer-events: auto; /* 'all' is SVG-only */
  white-space: nowrap;
  z-index: 10;
}
.img-align-btn {
  padding: 3px 6px;
  font-size: 11px;
  font-family: var(--font-ui);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--clr-text);
  display: flex;
  align-items: center;
  transition: background var(--transition), border-color var(--transition);
}
.img-align-btn svg { display: block; }
.img-align-btn:hover {
  background: var(--clr-bg);
  border-color: var(--clr-border);
}
.img-align-btn.active {
  background: var(--fach-hell);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

/* ── Image drag-to-move drop cursor ────────────────────────────── */
.img-drop-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--clr-primary);
  vertical-align: middle;
  pointer-events: none;
}

/* ── Custom tooltip ─────────────────────────────────────────────── */
.custom-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--clr-text);
  color: var(--clr-surface);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: pre-wrap;
  max-width: 260px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  opacity: 0.95;
}
.custom-tooltip[hidden] { display: none; }

/* ── Group F: Word count bar ─────────────────────────────────────── */
.word-count-bar {
  flex-shrink: 0;
  padding: 3px 16px;
  background: var(--clr-bg);
  border-top: 1px solid var(--clr-border-light);
  font-size: 11px;
  color: var(--clr-text-muted);
  text-align: right;
  display: none; /* shown only in wysiwyg mode via JS */
}
.editor-area:not(.mode-html):not(.mode-preview) .word-count-bar {
  display: block;
}

/* ── Group G: Templates modal ────────────────────────────────────── */
.modal-box-templates {
  width: 520px;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-surface);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-family: var(--font-ui);
  gap: 6px;
  text-align: center;
}
.template-card:hover {
  border-color: var(--clr-primary);
  background: var(--fach-hell);
}
.template-icon {
  font-size: 28px;
  line-height: 1;
}
.template-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--clr-text);
}
.template-desc {
  font-size: 11px;
  color: var(--clr-text-muted);
}
.template-card-upload {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
}
.template-card-upload .template-icon {
  font-size: 22px;
}

/* ── Group H: Find & Replace bar ─────────────────────────────────── */
.find-replace-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.find-input {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  width: 140px;
  background: var(--clr-surface);
  color: var(--clr-text);
}
.find-input:focus {
  outline: none;
  border-color: var(--clr-primary);
}
.find-match-info {
  font-size: 11px;
  color: var(--clr-text-muted);
  white-space: nowrap;
}
.find-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--clr-text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.find-close-btn:hover {
  color: var(--clr-danger);
  background: #fef2f2;
}

/* CodeMirror current-search-match highlight */
.cm-search-match {
  background: rgba(255, 200, 0, 0.4);
  border-radius: 2px;
}
.cm-search-match-current {
  background: rgba(255, 130, 0, 0.55);
  border-radius: 2px;
}

/* ── Group I: Focus / Distraction-free mode ──────────────────────── */
.app-body.focus-mode .sidebar-left,
.app-body.focus-mode .sidebar-right {
  display: none;
}
.app-body.focus-mode #editorToolbar .tb-btn:not(#btnFocusMode),
.app-body.focus-mode #editorToolbar .tb-select,
.app-body.focus-mode #editorToolbar .tb-font-wrap,
.app-body.focus-mode #editorToolbar .tb-color-wrap,
.app-body.focus-mode #editorToolbar .tb-font-size-input,
.app-body.focus-mode #editorToolbar .tb-font-size-btn,
.app-body.focus-mode #editorToolbar .tb-separator,
.app-body.focus-mode #editorToolbar .tb-table-wrap,
.app-body.focus-mode #tableContextToolbar {
  display: none;
}
#btnFocusMode.focus-active {
  background: var(--fach-hell);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

/* ================================================================
   Dunkelmodus-Korrekturen für WebWerkstatt-spezifische Elemente
   ================================================================ */
[data-thema="dunkel"] .modal-footer .btn-secondary {
  background: var(--flaeche);
  color: var(--text);
  border-color: var(--linie);
}
[data-thema="dunkel"] .modal-footer .btn-secondary:hover {
  background: var(--linie);
}

[data-thema="dunkel"] .teacher-info-box {
  background: var(--flaeche);
  border-color: var(--linie);
  color: var(--text);
}

[data-thema="dunkel"] .action-status.error { background: var(--falsch-hell); color: var(--falsch); }
[data-thema="dunkel"] .action-status.success { background: var(--richtig-hell); color: var(--richtig); }

/* editor canvas bleibt immer hell – unabhängig vom Thema */
.wysiwyg-editor { color-scheme: light; }
