/* ============================================================
   app.css – globale, seitenübergreifende Korrekturen
   Wird auf allen Seiten eingebunden. Schwerpunkt: saubere
   Darstellung auf Mobiltelefonen (kein horizontales Wackeln,
   Kopfzeilen-Knöpfe überlappen nicht).
   ============================================================ */

/* Kein horizontales Überlaufen der Seite */
html, body { max-width: 100%; overflow-x: hidden; }

/* ----- Modernere, Apple-artige Typografie (global) ----- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.011em;
  line-height: 1.5;
}
h1, h2, h3, h4 { letter-spacing: -0.022em; line-height: 1.18; }
h1 { font-weight: 700; }
button, input, select, textarea, a { font-family: inherit; }
/* Touch-freundliche Mindestgrößen für Buttons/Aktionslinks */
@media (pointer: coarse) {
  button, .btn, .akt a, .akt button { min-height: 44px; }
}

/* Erlaubt Flex-Kindern das Schrumpfen → verhindert Breiten-Überlauf */
*, *::before, *::after { min-width: 0; }

/* Kopfzeilen brechen um, statt zu überlaufen */
header { flex-wrap: wrap !important; row-gap: 8px !important; }
header nav,
header .links,
header > div {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 6px !important;
  align-items: center;
}
header a { margin-left: 0 !important; }

/* Auf schmalen Geräten Kopfzeile + Buttons kompakter */
@media (max-width: 540px) {
  header { padding: 12px 14px !important; }
  header img { height: 24px !important; }
  header a { padding: 7px 12px !important; font-size: 0.85rem !important; }
}

/* Breite Tabellen brechen auf dem Handy in gestapelte Karten um –
   so entsteht NIE ein horizontaler Scroll. Spaltennamen via data-label am <td>. */
@media (max-width: 640px) {
  table, table tbody, table tr, table td { display: block; width: 100%; }
  table thead { position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
  table tr {
    border: 1px solid var(--glas-rand, rgba(0,0,0,0.10));
    border-radius: 14px; padding: 10px 14px; margin-bottom: 12px;
    background: var(--glas-hintergrund, rgba(255,255,255,0.4));
  }
  table td {
    border: none !important; padding: 7px 0 !important;
    display: flex; gap: 14px; align-items: baseline; justify-content: space-between;
    text-align: right; white-space: normal; word-break: break-word;
  }
  table td::before {
    content: attr(data-label); font-weight: 600; color: var(--text-grau, #6b6b70);
    text-align: left; flex: 0 0 auto; white-space: nowrap;
  }
  /* Erste Zelle = Überschrift der Karte (kein Label, volle Breite) */
  table td:first-child { display: block; text-align: left; font-weight: 700; font-size: 1.08rem; padding-bottom: 9px !important; }
  table td:first-child::before { content: none; }
  /* Aktions-Zelle: Label oben, Knöpfe darunter (umbrechend) */
  table td.akt-zelle { display: block; text-align: left !important; }
  table td.akt-zelle::before { display: block; margin-bottom: 8px; }
  table td:empty { display: none; }
}

/* ===== Rich-Text-Editor (richtext.js) + Ausgabe ===== */
.rt-editor { border: 1px solid rgba(125,125,125,0.35); border-radius: 12px; overflow: hidden; background: rgba(255,255,255,0.5); }
@media (prefers-color-scheme: dark) { .rt-editor { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.16); } }
.rt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid rgba(125,125,125,0.25); background: rgba(125,125,125,0.08); }
.rt-btn { min-width: 36px; min-height: 36px; font: inherit; font-size: 0.95rem; border: 1px solid rgba(125,125,125,0.3); border-radius: 8px; background: rgba(255,255,255,0.7); color: inherit; cursor: pointer; }
@media (prefers-color-scheme: dark) { .rt-btn { background: rgba(255,255,255,0.1); } }
.rt-btn:hover { border-color: #4dba38; }
.rt-sep { width: 1px; height: 22px; background: rgba(125,125,125,0.35); margin: 0 4px; }
.rt-col { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.2); cursor: pointer; padding: 0; }
.rt-col-std { background: #fff; color: #1d1d1f; font-weight: 700; font-size: 0.8rem; line-height: 22px; }
.rt-col:hover { outline: 2px solid #4dba38; outline-offset: 1px; }
.rt-lbl { font-size: 0.95rem; line-height: 24px; opacity: 0.85; padding: 0 1px; }
.rt-mark { width: 24px; height: 24px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.2); cursor: pointer; padding: 0; }
.rt-mark-none { background: #fff; color: #1d1d1f; font-size: 0.85rem; line-height: 22px; }
.rt-mark:hover { outline: 2px solid #4dba38; outline-offset: 1px; }
.rt-area span[style*="background"], .rtf-out span[style*="background"] { padding: 0 0.12em; border-radius: 3px; }
.rt-area { min-height: 96px; padding: 11px 14px; outline: none; font-size: 0.95rem; line-height: 1.5; color: inherit; }
.rt-area:empty:before { content: attr(data-ph); color: #999; }
.rt-area ul, .rt-area ol { margin: 6px 0; padding-left: 26px; }
.rt-area li { margin: 2px 0; }
.rt-area p { margin: 0 0 6px; }
.rt-hidden { display: none !important; }

/* Feste Typografie in der Ausgabe – Schriftart/-größe immer gleich, nur Auszeichnungen */
.rtf-out { font-size: 0.95rem; line-height: 1.55; }
.rtf-out p { margin: 0 0 6px; }
.rtf-out p:last-child { margin-bottom: 0; }
.rtf-out ul, .rtf-out ol { margin: 4px 0 8px; padding-left: 24px; }
.rtf-out li { margin: 2px 0; }
.rtf-out b, .rtf-out strong { font-weight: 700; }
.rtf-out u { text-decoration: underline; }
.rtf-out em, .rtf-out i { font-style: italic; }

/* ============================================================
   Flat-Theme (globaler Schalter, data-theme="flat" am <html>)
   Frisches Apple-Design OHNE Glas: solide Karten + dezenter Schatten,
   kein Blur/keine Transparenz. Überschreibt die --glas-*-Variablen
   (höhere Spezifität als :root) → wirkt auf jeder Seite ohne Umbau.
   ============================================================ */
html[data-theme="flat"] {
  --glas-hintergrund:#ffffff;
  --glas-rand:rgba(0,0,0,0.08);
  --glas-schatten:0 4px 18px rgba(0,40,10,0.10);
  --glas-blur:none;
}
html[data-theme="flat"] body {
  background:linear-gradient(135deg,#eef6ea,#f6faf3 55%,#e9f3ee) !important;
}
html[data-theme="flat"] .glas {
  -webkit-backdrop-filter:none !important; backdrop-filter:none !important;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="flat"] {
    --glas-hintergrund:#1f211f;
    --glas-rand:rgba(255,255,255,0.10);
    --glas-schatten:0 4px 18px rgba(0,0,0,0.45);
    --glas-blur:none;
  }
  html[data-theme="flat"] body {
    background:linear-gradient(135deg,#11160f,#0f130d) !important;
  }
}
