/* DeineSchrift – Papier & Tinte. Ruhige Werkzeug-Oberfläche nach Apples Human Interface Guidelines:
   Systemschrift, Systemgrau, ein Akzent (Tintenblau), durchscheinende Leisten, Tippflächen ab 44 pt. */
/* Farben „Petrol“: kühles Hellgrau als Schreibtisch, weiße Flächen, ein Akzent in Petrol.
   Dunkel nur über den Schalter in der Kopfzeile (html[data-theme="dark"]), kein reines Schwarz. */
:root {
  --bg: #f3f6f7;                         /* Grund hinter Karten (Profil, Aufnahme, Ausfüllen) */
  --desk: #e8edf0;                       /* Schreibtisch hinter dem Papier */
  --panel: #ffffff;                      /* Kopfzeile, Seitenleisten, Menüs */
  --surface: #ffffff;
  --surface-2: rgba(23, 33, 38, 0.07);   /* Füllung für graue Knöpfe */
  --surface-3: rgba(23, 33, 38, 0.12);
  --field: #ffffff;
  --border: rgba(23, 33, 38, 0.12);
  --border-strong: rgba(23, 33, 38, 0.22);
  --ink: #172126;
  --muted: #53646d;                      /* 5,9:1 auf Weiß */
  --accent: #0b6464;                     /* Petrol: Text, Symbole (6,9:1 auf Weiß) */
  --accent-fill: #0e6b6b;                /* gefüllte Knöpfe mit weißer Schrift (6,4:1) */
  --accent-2: var(--accent);
  --accent-grad: var(--accent-fill);
  --accent-soft: rgba(14, 107, 107, 0.11);
  --on-accent: #ffffff;
  --ok: #1f7a35;
  --warn: #a34a00;
  --danger: #c8102e;
  --danger-fill: #c8102e;
  --field-edge: #7f8c92;                 /* Rand von Eingabefeldern, mind. 3:1 */
  --radius: 14px;
  --touch: 44px;
  --strong: #172126;
  --glass: rgba(255, 255, 255, 0.86);
  --glass-2: rgba(255, 255, 255, 0.9);
  --glass-3: rgba(255, 255, 255, 0.7);
  --scrim: rgba(20, 30, 35, 0.35);
  --placeholder: #7b898f;
  --danger-text: #b3001b;
  --shadow-1: 0 1px 2px rgba(20, 40, 50, 0.08), 0 2px 8px rgba(20, 40, 50, 0.06);
  --shadow-2: 0 10px 34px rgba(20, 40, 50, 0.16), 0 1px 3px rgba(20, 40, 50, 0.08);
  --paper-shadow: 0 1px 2px rgba(20, 40, 50, 0.1), 0 14px 36px rgba(20, 40, 50, 0.14);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);  /* wie Apples Federkurven */
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);  /* leichtes Überschwingen */
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1a1f22;
  --desk: #161a1c;
  --panel: #23292c;
  --surface: #23292c;
  --surface-2: rgba(233, 238, 240, 0.08);
  --surface-3: rgba(233, 238, 240, 0.14);
  --field: #2c3337;
  --border: rgba(233, 238, 240, 0.1);
  --border-strong: rgba(233, 238, 240, 0.2);
  --ink: #e9eef0;
  --muted: #a2b1b8;
  --accent: #5cc2bb;
  --accent-fill: #5cc2bb;
  --accent-soft: rgba(92, 194, 187, 0.16);
  --on-accent: #0b1a1a;
  --ok: #4cd07d;
  --warn: #ffb04a;
  --danger: #ff6b61;
  --danger-fill: #c8102e;
  --field-edge: #7d8a90;
  --strong: #ffffff;
  --glass: rgba(35, 41, 44, 0.86);
  --glass-2: rgba(35, 41, 44, 0.9);
  --glass-3: rgba(35, 41, 44, 0.7);
  --scrim: rgba(0, 0, 0, 0.55);
  --placeholder: #87959b;
  --danger-text: #ff8a80;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.5);
  --paper-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 18px 48px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
/* „Kontrast erhöhen“ am iPad: kräftigere Linien, Flächen und Grautexte */
@media (prefers-contrast: more) {
  :root {
    --border: rgba(23, 33, 38, 0.36);
    --border-strong: #7f8c92;
    --surface-2: rgba(23, 33, 38, 0.14);
    --surface-3: rgba(23, 33, 38, 0.22);
    --muted: #3c4a51;
    --placeholder: #5b686e;
    --field-edge: #5b686e;
  }
  :root[data-theme="dark"] {
    --border: rgba(233, 238, 240, 0.4);
    --border-strong: #8e9ba1;
    --surface-2: rgba(233, 238, 240, 0.16);
    --surface-3: rgba(233, 238, 240, 0.26);
    --muted: #c9d3d8;
    --placeholder: #aab6bb;
    --field-edge: #a2b1b8;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* sonst gewinnt z. B. display: inline-flex der Knöpfe */

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
/* Textgröße folgt der Einstellung am iPad (Dynamic Type); alle Schriftgrößen unten sind rem, 1rem = 17 px bei Standardgröße */
html { font-size: 17px; }
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) { /* nur iPad/iPhone: am Mac wäre das 13 px */
  html { font: -apple-system-body; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; line-height: 1.45; }
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* Kein Doppeltipp-Zoom und keine Textauswahl in der ganzen App: der Pencil markiert sonst beim Schreiben Text. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }

h1, h2, h3 { letter-spacing: -0.01em; }
.view h2 { margin: 0 0 16px; }

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 0.5px solid var(--border-strong);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 700; font-size: 1.176rem; letter-spacing: -0.02em; }
.brand b { color: var(--accent); font-weight: 700; }
.brand-icon { width: 34px; height: 34px; padding: 7px; border-radius: 9px; color: var(--on-accent); background: var(--accent-fill); }

/* Tab-Leiste wie in iPadOS: Kapsel, gewählter Bereich hebt sich als helle Pille ab */
.tabs { position: relative; display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.tabs button {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; background: transparent; color: var(--ink); font-weight: 600; font-size: 0.941rem;
  transition: color .25s var(--ease-out);
}
.tabs button .icon { color: var(--muted); transition: color .25s var(--ease-out); }
.tabs button:hover { background: transparent; }
.tabs button[aria-selected="true"] .icon { color: var(--accent); }
.tab-indicator {
  position: absolute; z-index: 0; top: 3px; left: 0; height: calc(100% - 6px); width: 0; border-radius: 999px;
  background: var(--panel); box-shadow: var(--shadow-1);
  transition: transform .45s var(--ease-spring), width .45s var(--ease-spring);
}

.tabs button.badge::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Bedienelemente ---------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  touch-action: manipulation; /* kein Doppeltipp-Zoom */
  transition: background .2s, color .2s, transform .45s var(--ease-pop), box-shadow .2s;
}
button:hover { background: var(--surface-3); }
button:active { transform: scale(0.94); transition: transform .08s ease-out; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Deaktiviert: grau gefüllt, graue Schrift, kein Zeiger (nicht nur blasser) */
button:disabled, button.primary:disabled, button.danger-solid:disabled, .trash:disabled {
  background: var(--surface-2); color: var(--placeholder); cursor: default; filter: none; box-shadow: none;
}
button:disabled:active { transform: none; }
button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
button.primary { background: var(--accent-fill); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.06); background: var(--accent-fill); }
button.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
button.wide { width: 100%; }

textarea, input[type="text"], input[type="url"], input[type="password"], input:not([type]), select {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid var(--field-edge);
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: max(16px, 1.059rem); /* unter 16px zoomt Safari beim Antippen */
}
textarea { line-height: 1.5; resize: none; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
::placeholder { color: var(--placeholder); }

.field { display: grid; gap: 6px; color: var(--muted); font-size: 0.882rem; }
.field[hidden] { display: none; }
.field input, .field select { color: var(--ink); }

.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; font-size: 0.882rem; color: var(--muted); }
.slider output { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.slider input { grid-column: 1 / -1; width: 100%; height: 40px; accent-color: var(--accent); }
.slider input:disabled { opacity: 0.45; filter: grayscale(1); cursor: default; }

.check { display: flex; align-items: center; gap: 12px; min-height: var(--touch); }
.check input { flex-shrink: 0; width: 24px; height: 24px; accent-color: var(--accent); }

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > button { flex: 1 1 auto; white-space: nowrap; }
.hint { color: var(--muted); }
.hint.small { font-size: 0.824rem; }
.status { margin: 4px 0; }
.status:empty { display: none; }
.status.warn { color: var(--warn); font-weight: 600; }
.status.ok { color: var(--ok); }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}
.banner[hidden] { display: none; }

/* ---------- Grundgerüst ---------- */
main { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.view { flex: 1; padding: 24px; }

.panel {
  flex-shrink: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

/* Bühne: dunkle Fläche, auf der die Seiten hell liegen; Leiste schwebt darüber */
.stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px 28px 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.pages[hidden] { display: none; }
.page, .sheet-page {
  flex-shrink: 0;
  background: #fff;
  border-radius: 2px;
  box-shadow: var(--paper-shadow);
}

.floatbar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass-2);
  border: 0.5px solid var(--border-strong);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-2);
  white-space: nowrap;
  z-index: 5;
}
.floatbar button { border-radius: 999px; }
.floatbar .check { padding: 0 10px 0 4px; color: var(--muted); }
.floatbar-sep { width: 1px; align-self: stretch; margin: 6px 2px; background: var(--border-strong); }

details.settings { display: grid; gap: 12px; padding: 4px 16px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
details.settings[open] { padding-bottom: 16px; }
.settings summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.settings[open] summary::after { transform: rotate(-135deg); }
.settings summary .icon { color: var(--accent-2); }

/* ---------- Schreiben ---------- */
.view-schreiben:not([hidden]), .view-blatt:not([hidden]) { display: flex; min-height: 0; padding: 0; }
.editor {
  width: 38%;
  min-width: 300px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.text-wrap { position: relative; display: flex; flex: 1 0 200px; min-height: 200px; }
.text-wrap textarea { flex: 1; padding-right: 64px; /* Platz für den Papierkorb */ }
/* Papierkorb oben rechts im Textfeld: rot getönt, deckend (liegt über dem Text) */
.trash {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 48px;
  padding: 0;
  border-radius: 10px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, var(--field));
}
.trash:hover { background: color-mix(in srgb, var(--danger) 22%, var(--field)); }
#controls { display: grid; gap: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 4px 8px; } /* Platz für Auswahlring und Vergrößerung */
.swatch {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid var(--panel);
  background: var(--c);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.swatch:hover { background: var(--c); }
.swatch[data-ink="eigen"] { background: conic-gradient(from 0deg, #e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935); }
.swatch[data-ink="eigen"][aria-pressed="true"] { background: var(--c); }

/* Stil-Werte als abgesetzte Gruppe */
.group { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--border); }
.group:empty { display: none; }

/* Farbton-Regler mit Regenbogen-Spur */
.hue input {
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  margin: 13px 0;
  border-radius: 7px;
  background: linear-gradient(90deg, hsl(0 72% 40%), hsl(60 72% 40%), hsl(120 72% 36%), hsl(180 72% 36%), hsl(240 72% 40%), hsl(300 72% 40%), hsl(359 72% 40%));
}
.hue input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border-strong), 0 2px 8px rgba(0, 0, 0, 0.5);
}
.hue input::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--panel); }
.swatch[aria-pressed="true"] { background: var(--c); border-color: var(--surface); box-shadow: 0 0 0 3px var(--accent); }

/* ---------- Arbeitsblatt ---------- */
.inspector { width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.panel-head h2 { margin: 0; font-size: 1.294rem; }
.panel-head p { margin: 2px 0 0; overflow-wrap: anywhere; }
.subcard { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.subcard[hidden] { display: none; }
.view-blatt:not(.has-sheet) .needs-sheet { display: none; }
#field-title { color: var(--accent); }

.empty {
  margin: auto;
  max-width: 460px;
  padding: 40px 28px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 22px;
  background: var(--glass-3);
}
.empty[hidden] { display: none; }
.empty h2 { margin: 12px 0 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }
.empty-icon { width: 56px; height: 56px; color: var(--accent); stroke-width: 1.5; }

.sheet-page { position: relative; width: min(100%, 900px); }
.sheet-page canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }
.sheet-overlay { position: absolute; inset: 0; touch-action: pan-y pinch-zoom; }
.sheet-overlay.drawing { touch-action: none; cursor: crosshair; background: color-mix(in srgb, var(--accent) 4%, transparent); }
.field-box {
  position: absolute;
  border: 1.5px dashed color-mix(in srgb, var(--accent-fill) 65%, transparent);
  border-radius: 4px;
  touch-action: none;
  cursor: move;
}
.field-box.selected { border: 2px solid var(--accent-fill); background: color-mix(in srgb, var(--accent) 6%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.field-box.overflow { border-color: var(--warn); }
/* Nummer links neben dem Feld (im Seitenrand), damit sie keinen Aufgabentext verdeckt */
.field-tag {
  position: absolute;
  right: calc(100% + 6px);
  top: 0;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--accent-fill); /* liegt immer auf weißem Papier, auch im Dunkelmodus */
  color: var(--on-accent);
  font-size: 0.765rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
.field-box.overflow .field-tag { background: var(--warn); color: #1b1300; }
.field-handle {
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: nwse-resize;
}
.field-handle::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-fill);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.field-box:not(.selected) .field-handle { display: none; }

/* ---------- Profile ---------- */
.topbar-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.profile-switch { position: relative; display: flex; align-items: center; color: var(--muted); }
.profile-switch .icon { position: absolute; left: 12px; pointer-events: none; }
.profile-switch select { width: auto; max-width: 240px; min-height: 44px; padding: 0 14px 0 40px; border-radius: 14px; background: var(--surface); font-size: max(16px, 0.941rem); font-weight: 600; }
.card-wide { grid-column: 1 / -1; }
.profile-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.profile-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--field); border: 1px solid var(--border); }
.profile-item.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.profile-item > div:first-child { display: grid; flex: 1; min-width: 0; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.profile-actions button { min-height: 44px; padding: 0 12px; font-size: 0.882rem; }
.badge-active { align-self: center; padding: 4px 10px; border-radius: 999px; background: var(--accent-grad); color: #fff; font-size: 0.765rem; font-weight: 700; }
#profile-new { max-width: 520px; }

/* ---------- Profil ---------- */
.view-profil { overflow-y: auto; }
.cards { display: grid; align-items: start; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; max-width: 1100px; }
.card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.card h3 { margin: 0; }
.card .hint { margin: 0; font-size: 0.882rem; }

/* ---------- Aufnahme ---------- */
.view-aufnahme:not([hidden]) { display: flex; height: 100%; padding: 0; }

.charlist { width: 300px; padding: 14px 14px 24px; }
.charlist h3 { margin: 18px 0 8px; font-size: 0.882rem; font-weight: 600; color: var(--muted); }

.progress { position: sticky; top: -14px; padding: 10px 0; background: var(--bg); z-index: 1; }
.progress progress { width: 100%; height: 8px; accent-color: var(--accent); }

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chip { min-width: 0; padding: 0; font-size: 1.176rem; }
.chip[data-status="0"] { background: var(--surface); color: var(--muted); }
.chip[data-status="1"], .chip[data-status="2"] { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.chip[data-status="3"] { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.chip[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: 2px; color: var(--strong); }
.chip-wide { grid-column: span 2; }

.pair-form { display: grid; gap: 8px; }

.recorder { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px 22px 12px; }
.recorder[hidden] { display: none; }
.recorder-head { display: flex; align-items: center; gap: 10px; }

.mode-switch { margin-bottom: 6px; }

.text-info { min-width: 130px; text-align: center; font-weight: 600; color: var(--accent); }
#text-commit { margin-left: auto; }
.text-page-wrap { flex: 1; min-height: 0; overflow: hidden; }
/* Feste Höhe: sonst ändert ein längerer Hinweis die Seitenaufteilung */
#text-hint { height: 2.9em; overflow-y: auto; }
/* Zeichenflächen bleiben hell wie Papier */
#text-page, .box canvas, #char-preview {
  display: block;
  background: #fff;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 0 0 0.5px var(--border-strong), var(--shadow-1);
}
#text-page, .box canvas { touch-action: none; /* kein Scrollen/Zoomen beim Schreiben */ }
.current-char { min-width: 90px; text-align: center; font-size: 2.353rem; font-weight: 700; color: var(--accent); }
#next-missing { margin-left: auto; }
.recorder .hint { margin: 8px 0 12px; min-height: 1.45em; }

.boxes { flex: 1; min-height: 0; overflow: hidden; display: grid; gap: 18px; align-content: start; justify-content: center; }
.fit-boxes { width: 100%; margin: 4px 0 8px; padding: 6px 10px; font-size: 0.882rem; }
.char-preview { flex-shrink: 0; margin-top: 10px; }
#char-preview { width: 100%; height: 96px; margin-top: 6px; }
.box-actions { display: flex; gap: 6px; margin-top: 8px; width: 0; min-width: 100%; } /* so breit wie das Kästchen, nicht breiter */
.box-actions button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 6px; gap: 5px; font-size: 0.824rem; white-space: nowrap; overflow: hidden; }

/* ---------- Schmale Bildschirme (iPad hochkant / Split View) ---------- */
@media (max-width: 1000px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 14px; }
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tabs { justify-self: center; }
  .tabs button { padding: 0 12px; }
  .profile-switch select { max-width: 170px; }
  .inspector { width: 300px; }
}
/* Handy: Tabs als Leiste unten (mit Namen), oben nur Logo, Profil und Hilfe */
@media (max-width: 700px) {
  /* backdrop-filter würde die feste Tab-Leiste an der Kopfzeile festhalten */
  .topbar { grid-template-columns: auto 1fr; background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .profile-item { flex-direction: column; align-items: stretch; }
  .profile-actions { flex-wrap: wrap; }
  .brand span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: 1rem; }
  .profile-switch select { max-width: min(150px, 100vw - 220px); font-size: max(16px, 0.941rem); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-self: stretch; justify-content: space-around; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); border-radius: 0; border: 0; border-top: 1px solid var(--border);
    background: var(--glass-2); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; min-height: 52px; padding: 4px 2px; font-size: 0.706rem; }
  .tabs button[aria-selected="true"] { box-shadow: none; }
  .tabs button.badge::after { right: calc(50% - 20px); }
  main { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .view { padding: 16px; }
  .view-schreiben:not([hidden]), .view-blatt:not([hidden]), .view-aufnahme:not([hidden]) { flex-direction: column; height: auto; }
  .editor, .inspector, .charlist { width: 100%; max-width: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .pages { padding: 16px 16px 110px; }
  /* Klebt nur über der Vorschau, nicht über den Einstellungen */
  .floatbar { position: sticky; left: auto; transform: none; align-self: center; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); margin: -76px 0 20px; max-width: calc(100% - 16px); }
  .floatbar button { padding: 0 12px; }
  .floatbar .check, .floatbar-sep { display: none; }
  .write-empty:not([hidden]) ~ .floatbar { display: none; } /* sonst verdeckt sie „Eigene Schrift aufnehmen“ */
  .banner { flex-wrap: wrap; justify-content: flex-start; }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Claude (DeineSchrift-Assistent) ---------- */
.claude-row > * { flex: 1 1 auto; }
a.btn-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 18px; border-radius: 12px; text-decoration: none; white-space: nowrap;
  font-weight: 600; color: #fff; background: var(--accent-grad); box-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 30%, transparent);
}
a.btn-link:active { transform: scale(0.97); }
a.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.claude-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); animation: banner-in .25s ease-out;
}
.claude-banner > .icon { color: var(--accent); }
.claude-banner > div { display: grid; flex: 1; min-width: 0; }
.claude-banner span { color: var(--muted); font-size: 0.824rem; }
.claude-banner button.ghost { min-width: 40px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
@keyframes banner-in { from { transform: translateY(-6px); opacity: 0; } }

.sheet-bg { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; justify-items: center; background: var(--scrim); }
.sheet {
  width: min(640px, 100%); max-height: 88%; overflow: auto; display: grid; gap: 14px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0; background: var(--panel); border: 1px solid var(--border-strong); border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5); animation: sheet-in .22s ease-out;
}
.sheet h2 { margin: 0; font-size: 1.176rem; }
.sheet .hint { margin: 0; }
.sheet .row > button { flex: 1 1 auto; }
.sheet-preview {
  max-height: 12em; overflow: auto; padding: 12px 14px; border-radius: 12px; white-space: pre-wrap;
  background: #fbfaf6; color: #1d2a5c; border: 1px solid var(--border);
}
.sheet-text { min-height: 160px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  max-width: min(520px, calc(100% - 32px)); padding: 12px 16px; border-radius: 14px;
  background: var(--surface-3); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
@media (prefers-reduced-motion: reduce) { .claude-banner, .sheet { animation: none; } }

/* ---------- Dialoge ---------- */
.sheet-msg { margin: 0; white-space: pre-line; line-height: 1.5; }
button.danger-solid { background: var(--danger-fill); color: var(--on-accent); }
.sheet input[type="text"] { width: 100%; }

/* ---------- KI ---------- */
.view-ki:not([hidden]) { display: flex; min-height: 0; padding: 0; }
.ki-shell { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 20px; }
.ki-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 6px; flex-wrap: wrap; }
.ghost-btn { background: transparent; border-color: transparent; color: var(--muted); }
.ghost-btn:hover { color: var(--ink); background: var(--surface); }

.ki-log { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 22px; padding: 18px 2px 24px; }
.ki-log:empty { display: none; }
.ki-msg { display: flex; gap: 12px; }
.ki-msg.user { flex-direction: column; align-items: flex-end; }
.ki-bubble { max-width: min(80%, 620px); padding: 12px 16px; border-radius: 20px 20px 6px 20px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 8px; }
.ki-bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ki-ctx { color: var(--muted); }
.ki-msg-files { display: flex; flex-wrap: wrap; gap: 6px; }
.ki-msg-file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--field); font-size: 0.824rem; color: var(--muted); }
.ki-msg-file .icon { width: 16px; height: 16px; }
.ki-avatar { flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-grad); color: #fff; }
.ki-avatar .icon { width: 18px; height: 18px; }
.ki-body { flex: 1; min-width: 0; display: grid; gap: 10px; }
.ki-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 1rem; padding-top: 4px; }
.ki-text.thinking { color: var(--muted); }
.ki-text.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: ki-dots 1.2s steps(4) infinite; }
@keyframes ki-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.ki-note { margin: 0; color: var(--warn); font-size: 0.824rem; }
.ki-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ki-actions button { min-height: 44px; padding: 0 14px; font-size: 0.882rem; }
.ki-actions .icon { width: 18px; height: 18px; }
.ki-error { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 0.882rem;
  background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.4); color: var(--danger-text); }
.ki-msg.user .ki-error { max-width: min(80%, 620px); }
.ki-error button { min-height: 38px; padding: 0 12px; font-size: 0.824rem; }

.ki-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px 0; }
.ki-empty[hidden] { display: none; }
.ki-empty h2 { margin: 0; font-size: clamp(24px, 3.4vw, 32px); text-wrap: balance; }
.ki-empty .hint { max-width: 520px; margin: 0; }
.ki-hello { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-grad); color: #fff; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent); }
.ki-hello .icon { width: 28px; height: 28px; }
.ki-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; max-width: 640px; }
.ki-suggestion { min-height: 44px; border-radius: 14px; background: var(--surface); font-size: 0.882rem; }

.ki-composer { position: relative; margin: 0 0 18px; padding: 10px 10px 8px 14px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border-strong);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); display: grid; gap: 6px; }
.ki-composer:focus-within { border-color: var(--accent); }
.ki-composer.drop { border-style: dashed; border-color: var(--accent); }
.ki-composer.off { opacity: 0.5; pointer-events: none; }
.ki-composer textarea { min-height: 28px; max-height: 240px; padding: 8px 2px; border: 0; background: transparent; box-shadow: none; resize: none; font-size: max(16px, 1rem); }
.ki-composer textarea:focus { box-shadow: none; }
.ki-bar { display: flex; align-items: center; gap: 8px; }
.ki-icon-btn { width: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: transparent; border-color: transparent; color: var(--muted); }
.ki-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.ki-ctx-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.824rem; }
.ki-ctx-toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.ki-send, .ki-stop { width: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; border: 0; color: #fff; background: var(--accent-grad); }
.ki-send:disabled { background: var(--surface-3); color: var(--muted); opacity: 1; }
.ki-stop { background: var(--surface-3); }
.ki-stop span { width: 14px; height: 14px; border-radius: 3px; background: #fff; }
.ki-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.ki-file { display: flex; align-items: center; gap: 10px; max-width: 280px; padding: 8px 6px 8px 10px; border-radius: 14px; background: var(--field); border: 1px solid var(--border); }
.ki-file > div { display: grid; min-width: 0; }
.ki-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.882rem; }
.ki-file small { color: var(--muted); font-size: 0.706rem; }
.ki-file.error { border-color: rgba(255, 107, 107, 0.5); }
.ki-file.error small { color: var(--danger-text); white-space: normal; }
.ki-file-x { min-width: 32px; min-height: 32px; width: 32px; padding: 0; border-radius: 50%; background: transparent; border: 0; color: var(--muted); font-size: 1.176rem; }
.ki-unavailable { margin: 24px 0; padding: 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 12px; justify-items: start; }
.ki-unavailable h2 { margin: 0; }
.ki-unavailable p { margin: 0; color: var(--muted); }
@media (max-width: 700px) { .ki-ctx-toggle { font-size: 0.765rem; } .ki-bubble { max-width: 92%; } }
@media (prefers-reduced-motion: reduce) { .ki-text.thinking::after { animation: none; content: '…'; } }


/* ---------- Kleine Symbol-Knöpfe ---------- */
.icon-btn { padding: 0; min-width: 44px; min-height: 44px; border-radius: 12px; }
.icon-btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
#help-btn { background: var(--surface); }

/* ---------- Hinweise oben (Home-Bildschirm, Sicherung) ---------- */
.banner.safety { justify-content: flex-start; gap: 12px; padding: 8px 12px 8px 16px; background: rgba(255, 181, 71, 0.12); }
.banner.safety > .icon { color: var(--warn); }
.banner.safety > span { flex: 1; min-width: 200px; }

/* ---------- Demo-Schrift ---------- */
.view-aufnahme.is-demo > :not(#demo-note) { display: none !important; }
.view-aufnahme.is-demo:not([hidden]) { display: flex; align-items: center; justify-content: center; }
.demo-note { max-width: 520px; margin: auto; padding: 32px; text-align: center; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.demo-note h2 { margin: 12px 0 8px; }
.demo-note p { color: var(--muted); }

/* ---------- Einführung ---------- */
.tour-bg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
.tour {
  width: min(480px, 100%); max-height: calc(100% - 32px); overflow: auto; display: grid; gap: 10px; padding: 24px;
  border-radius: 22px; background: var(--panel); border: 1px solid var(--border-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); animation: sheet-in .22s ease-out;
}
.tour h2 { margin: 0; font-size: 1.294rem; }
.tour p { margin: 0; color: var(--muted); }
.tour .tour-step { font-size: 0.882rem; font-weight: 600; color: var(--accent); }
.tour a { color: var(--accent); font-weight: 600; }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin: 6px 0 2px; }
.tour-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.tour-dots span.on { width: 22px; border-radius: 4px; background: var(--accent); }
.tour .row { display: flex; gap: 8px; flex-wrap: wrap; }
.tour .row > button:first-child { margin-right: auto; background: transparent; border-color: transparent; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .tour { animation: none; } }

/* ---------- Feineinstellungen, Erweitert ---------- */
details.fine { border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; }
details.fine > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 0.882rem; }
details.fine[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.slider-desc { grid-column: 1 / -1; font-size: 0.765rem; color: var(--muted); }
details.more > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary h3 { margin: 0; }
details.more > summary::after { content: '+'; margin-left: auto; font-size: 1.294rem; color: var(--muted); }
details.more[open] > summary::after { content: '–'; }

/* ---------- Fußzeile im Profil ---------- */
.app-footer { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.app-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.noscript { padding: 24px; }
.noscript a { color: var(--accent); }

/* Größere Tippflächen für kleine Kästchen */
.ki-ctx-toggle { min-height: 44px; }
.ki-ctx-toggle input { width: 22px; height: 22px; }

/* =====================================================================
   Redesign „Papier & Tinte“ – überschreibt die älteren Regeln oben.
   ===================================================================== */
.view h2 { font-size: 1.647rem; letter-spacing: -0.02em; } /* steht bewusst hier: gilt auch für die Hinweis-Karten */
.icon-btn, #help-btn { background: var(--surface-2); color: var(--accent); }
a.btn-link { background: var(--accent-fill); box-shadow: none; }

.profile-switch select { background: var(--surface-2); border: 0; font-weight: 600; }

/* Seitenleisten im Stil gruppierter Listen: Grau als Grund, weiße Karten darauf */
.panel { background: var(--bg); border-right: 0.5px solid var(--border-strong); }
details.settings, .subcard, .card, .group, .demo-note { border: 0; box-shadow: none; background: var(--surface); }
.group { background: var(--bg); }
:root[data-theme="dark"] .group { background: var(--field); }
details.fine { border: 0.5px solid var(--border-strong); }
.text-wrap textarea { box-shadow: var(--shadow-1); }
.text-wrap textarea:focus { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1); }

/* Bühne: Papier liegt auf einem ruhigen „Schreibtisch“ */
.stage { background: var(--desk); }
.page.transparent {
  background-color: #fff;
  background-image: conic-gradient(#e6e6ea 25%, #fff 0 50%, #e6e6ea 0 75%, #fff 0);
  background-size: 16px 16px;
}

/* Segment-Schalter (Apple „Segmented Control“) */
.seg, .mode-switch { display: flex; gap: 2px; padding: 2px; border: 0; border-radius: 10px; background: var(--surface-2); }
.seg button, .mode-switch button { flex: 1; min-height: 44px; padding: 0 12px; border-radius: 8px; background: transparent; color: var(--ink); font-size: 0.882rem; font-weight: 600; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"], .mode-switch button[aria-pressed="true"] {
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-1);
}
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .seg button[aria-checked="true"], :root[data-theme="dark"] .mode-switch button[aria-pressed="true"] { background: var(--surface-3); }
#export-bg + .hint { display: block; margin-top: 4px; }

/* Papier-Auswahl mit Vorschaubildern */
.paper-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.paper-opt { display: grid; justify-items: center; gap: 6px; min-height: 0; padding: 6px 2px 8px; border-radius: 12px; background: transparent; color: var(--muted); font-size: 0.706rem; font-weight: 600; line-height: 1.2; text-align: center; }
.paper-opt:hover { background: var(--surface-2); }
.paper-opt canvas { display: block; width: 100% !important; max-width: 64px; height: auto !important; aspect-ratio: 210 / 297; border-radius: 4px; box-shadow: 0 0 0 0.5px var(--border-strong), var(--shadow-1); transition: transform .45s var(--ease-pop), box-shadow .2s; }
.paper-opt[aria-checked="true"] { color: var(--accent); }
.paper-opt[aria-checked="true"] canvas { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow-1); transform: translateY(-2px); }

/* Farbfelder */
.swatch { transition: transform .45s var(--ease-pop), box-shadow .2s; }
.swatch[aria-pressed="true"] { transform: scale(1.08); }

/* Noch keine Schrift: Hinweis über der Vorschau */
.write-empty { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--desk) 55%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.write-empty-card { max-width: 420px; display: grid; justify-items: center; gap: 10px; padding: 28px; text-align: center; border-radius: 22px; background: var(--panel); box-shadow: var(--shadow-2); }
.write-empty-card h2 { margin: 0; font-size: 1.294rem; }
.write-empty-card p { margin: 0 0 6px; color: var(--muted); }

/* Ausfüllen: Erklärung mit Grafik und drei Schritten */
.fill-intro { max-width: 560px; border: 0; background: transparent; padding: 24px 20px; }
.fill-intro h2 { font-size: 1.412rem; text-wrap: balance; }
.fill-demo { width: min(100%, 300px); height: auto; overflow: visible; }
.fd-sheet { fill: #fff; stroke: var(--border-strong); stroke-width: 0.6; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.12)); }
.fd-q { fill: #d9dbe2; }
.fd-line { stroke: #c8ccd6; stroke-width: 0.8; fill: none; }
.fd-typed { font: 600 11px -apple-system, "Segoe UI", sans-serif; fill: #1d5ff2; }
.fd-ink { fill: none; stroke: #1f3f9e; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 260; stroke-dashoffset: 260; }
.fill-steps { list-style: none; counter-reset: s; display: grid; gap: 12px; margin: 4px 0 22px; padding: 0; text-align: left; }
.fill-steps li { counter-increment: s; position: relative; display: grid; gap: 2px; padding: 12px 14px 12px 52px; border-radius: 14px; background: var(--surface); }
.fill-steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.882rem; }
.fill-steps span { color: var(--muted); font-size: 0.882rem; }

/* Aufnahme */

/* Profil */
.profile-item { border: 0; background: var(--surface); }
.profile-item.active { box-shadow: 0 0 0 2px var(--accent); }
.badge-active { background: var(--accent-soft); color: var(--accent); }

/* Dialoge, Hinweise, Einführung */
.sheet { border: 0; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-2); }
.sheet::before { content: ''; justify-self: center; width: 36px; height: 5px; margin: -10px 0 2px; border-radius: 3px; background: var(--border-strong); }
.toast { border: 0; box-shadow: var(--shadow-2); background: var(--panel); border-radius: 999px; }
.tour { border: 0; box-shadow: var(--shadow-2); border-radius: 24px; }
.banner { border-bottom: 0.5px solid var(--border-strong); }
.banner.safety { background: color-mix(in srgb, var(--warn) 12%, var(--bg)); }
.empty { border: 0; background: transparent; }

@media (max-width: 1000px) {
  .tabs button { padding: 0 12px; font-size: 0.882rem; }
}
/* Handy: Tab-Leiste unten wie in iOS (Symbol + Name, gewählter Bereich in Tintenblau) */
@media (max-width: 700px) {
  .tabs button { flex: 1; min-width: 0; flex-direction: column; gap: 2px; padding: 4px 2px; border-radius: 10px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-self: stretch; justify-content: space-around; gap: 0;
    -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
    border-radius: 0; background: var(--glass-2); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); border-top: 0.5px solid var(--border-strong); }
  .tabs button { min-height: 50px; font-size: 0.647rem; font-weight: 600; color: var(--muted); }
  .tabs button[aria-selected="true"] { color: var(--accent); background: transparent; }
  .tab-indicator { display: none; }
  .paper-grid { gap: 4px; }
}

/* =====================================================================
   Bewegung: kurze, federnde Übergänge; bei „Bewegung reduzieren“ aus
   ===================================================================== */
@keyframes view-in { from { opacity: 0; transform: translateY(10px) scale(0.995); } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(0.9); } 60% { opacity: 1; transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes nib-bob { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(1px, -2px) rotate(-4deg); } }
@keyframes typed-cycle { 0%, 18% { opacity: 1; } 28%, 88% { opacity: 0; } 100% { opacity: 1; } }
@keyframes ink-cycle { 0%, 24% { stroke-dashoffset: 260; opacity: 1; } 62%, 88% { stroke-dashoffset: 0; opacity: 1; } 96% { opacity: 0; stroke-dashoffset: 0; } 100% { stroke-dashoffset: 260; opacity: 0; } }

.view.view-enter { animation: view-in .42s var(--ease-spring) both; }
.page { animation: rise-in .5s var(--ease-spring) both; }
.tour { animation: pop-in .45s var(--ease-spring) both; }
.tour-dots span { transition: width .35s var(--ease-spring), background .25s; }
.sheet { animation: sheet-up .42s var(--ease-spring) both; }
.toast { animation: rise-in .35s var(--ease-spring) both; }
.write-empty-card, .demo-note { animation: pop-in .5s var(--ease-spring) both; }
.fill-steps li { animation: rise-in .5s var(--ease-spring) both; }
.fill-steps li:nth-child(2) { animation-delay: .08s; }
.fill-steps li:nth-child(3) { animation-delay: .16s; }
.banner:not([hidden]) { animation: rise-in .35s var(--ease-spring) both; }
/* Die Feder wippt kurz zur Begrüßung und hält dann still (keine Dauerbewegung) */
.brand-icon { animation: nib-bob 1.6s ease-in-out 1s 2; transform-origin: 30% 70%; }
.write-empty-card .empty-icon, .demo-note .empty-icon { animation: nib-bob 2.4s ease-in-out 3; }
.fd-typed { animation: typed-cycle 6s var(--ease-out) infinite; }
.fd-ink { animation: ink-cycle 6s var(--ease-out) infinite; }
.fd-typed2, .fd-ink2 { animation-delay: .6s; }
.pop { animation: pop-in .4s var(--ease-pop); }
details[open] > :not(summary) { animation: rise-in .3s var(--ease-spring) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .fd-ink { stroke-dashoffset: 0; }
  .fd-typed { opacity: 0; }
  button:active { transform: none; }
}

/* =====================================================================
   Layout „B2“: Text links, Seite groß rechts, Leiste „Aussehen“ über der Seite,
   Blättern und Zoom darunter, ein Knopf „Exportieren“ oben rechts.
   ===================================================================== */
.topbar { min-height: 64px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--border); -webkit-backdrop-filter: none; backdrop-filter: none; }
.brand b { color: inherit; }
.brand-icon { border-radius: 50%; }
.topbar-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.topbar .icon-btn.round { border-radius: 999px; background: var(--panel); border: 1px solid var(--border-strong); color: var(--ink); }
.topbar .icon-btn.round:hover { background: var(--surface-2); }
button.pill { border-radius: 999px; }

/* Bereiche als Text mit Unterstrich (ab iPad-Breite) */
@media (min-width: 701px) {
  .tabs { align-self: stretch; gap: 22px; padding: 0; border-radius: 0; background: transparent; }
  .tabs button { min-height: 64px; padding: 0 2px; border-radius: 0; color: var(--muted); font-weight: 500; }
  .tabs button .icon { display: none; }
  .tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
  .tab-indicator { top: auto; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent-fill); box-shadow: none; }
}
@media (min-width: 701px) and (max-width: 1000px) { .tabs { gap: 14px; } }

/* Text links */
.view-schreiben .editor {
  width: 360px; min-width: 280px; max-width: 34%; flex-shrink: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; padding: 20px;
  background: var(--panel); border-right: 1px solid var(--border);
}
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.editor-head label { font-size: 1.059rem; font-weight: 600; color: var(--ink); }
button.small { padding: 0 10px; font-size: 0.882rem; font-weight: 500; }
#text-delete { color: var(--muted); }
#text-delete:not(:disabled):hover { color: var(--danger-text); background: color-mix(in srgb, var(--danger) 10%, transparent); }
#text-delete:disabled { background: transparent; }
#text-input { flex: 1 1 auto; min-height: 200px; padding: 14px 16px; border-radius: 14px; border-color: var(--border-strong); line-height: 1.6; box-shadow: none; }
#text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.view-schreiben .editor .status { margin: 0; font-size: 0.824rem; color: var(--muted); }
.view-schreiben .editor .status.warn { color: var(--warn); }

/* Bühne mit schwebender Leiste */
.view-schreiben .stage { overflow: hidden; background: var(--desk); }
.view-schreiben .pages { padding: 92px 32px 88px; align-items: safe center; gap: 32px; }
.lookbar-wrap { position: absolute; top: 16px; left: 0; right: 0; z-index: 6; display: flex; justify-content: center; padding: 0 12px; pointer-events: none; }
.lookbar {
  pointer-events: auto; display: flex; align-items: center; gap: 4px; max-width: 100%; padding: 6px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.lookbar::-webkit-scrollbar { display: none; }
.lb-sep { flex-shrink: 0; width: 1px; height: 24px; margin: 0 4px; background: var(--border-strong); }
.lb-font { display: flex; align-items: center; gap: 4px; padding-left: 8px; color: var(--muted); font-size: 0.882rem; font-weight: 500; }
.lb-font select { width: auto; max-width: 190px; min-height: 44px; padding: 0 6px; border: 0; background: transparent; color: var(--ink); font-weight: 600; box-shadow: none; }
.lb-font select:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.lookbar .seg { flex-shrink: 0; padding: 2px; border-radius: 11px; }
.lookbar .seg button { min-height: 40px; min-width: 0; padding: 0 12px; border-radius: 9px; font-weight: 500; color: var(--muted); }
.lookbar .seg button[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.lb-btn { flex-shrink: 0; gap: 6px; padding: 0 12px; border-radius: 11px; background: transparent; font-weight: 500; }
.lb-btn .icon { width: 16px; height: 16px; color: var(--muted); }
.lb-btn[aria-label] { padding: 0; }
.lb-btn[aria-label] .icon { width: 19px; height: 19px; color: var(--ink); }
.lb-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.lb-btn[aria-expanded="true"] .icon { color: var(--accent); }
.ink-dot { width: 16px; height: 16px; border-radius: 50%; background: #1b1b1b; box-shadow: 0 0 0 1px var(--border-strong); }

/* Aufklapp-Menüs unter der Leiste */
.pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 7; pointer-events: auto;
  width: 360px; max-width: calc(100% - 16px); display: grid; gap: 14px; padding: 16px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  animation: rise-in .28s var(--ease-spring) both;
}
.pop-wide { width: 420px; max-height: calc(100vh - 240px); overflow-y: auto; }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.882rem; }
.pop .swatches { padding: 4px; gap: 10px; }
.pop .row > button { flex: 1 1 auto; }
.swatch { border-color: var(--panel); }

/* Blättern und Zoom */
.pagebar {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-2);
}
.pagebar .icon-btn.ghost, .pagebar .ghost { color: var(--ink); font-size: 1.176rem; font-weight: 500; }
.pagebar button:disabled { background: transparent; }
.page-info { padding: 0 6px; font-size: 0.882rem; font-variant-numeric: tabular-nums; }
.pagebar .zoom-val { min-width: 64px; padding: 0 6px; font-size: 0.882rem; font-variant-numeric: tabular-nums; }
.share-again { position: absolute; right: 20px; bottom: 16px; z-index: 6; border-radius: 999px; box-shadow: var(--shadow-2); }

/* Export-Fenster */
.export-dlg {
  width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 24px; border: 0; border-radius: 22px;
  background: var(--panel); color: var(--ink); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}
.export-dlg[open] { animation: pop-in .4s var(--ease-spring) both; }
.export-dlg::backdrop { background: var(--scrim); }
.export-form { display: grid; gap: 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.view .export-dlg h2 { margin: 0; font-size: 1.294rem; }
.dlg-label { display: block; margin-bottom: 8px; font-size: 0.824rem; font-weight: 600; color: var(--muted); }
.fmt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fmt-grid button {
  display: grid; justify-items: start; align-content: start; gap: 2px; min-height: 96px; padding: 14px;
  border-radius: 14px; background: var(--field); border: 1px solid var(--border-strong); text-align: left;
}
.fmt-grid button .icon { margin-bottom: 6px; color: var(--accent); }
.fmt-grid button span { font-size: 0.765rem; font-weight: 400; color: var(--muted); }
.fmt-grid button[aria-checked="true"] { border: 2px solid var(--accent-fill); background: var(--accent-soft); padding: 13px; }
.export-dlg #export-bg-hint { display: block; margin-top: 6px; }
.export-dlg #export-summary { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }

/* iPad hochkant / kleine Fenster */
@media (max-width: 1000px) {
  .view-schreiben .editor { width: 300px; padding: 16px; }
  .lb-font > span { display: none; }
  .lb-font select { max-width: 220px; }
  .view-schreiben .pages { padding-left: 20px; padding-right: 20px; }
}
/* Handy: Text oben, darunter Leiste, Seite und Blättern im Fluss */
@media (max-width: 700px) {
  .topbar { grid-template-columns: auto 1fr; padding: 8px 12px; min-height: 56px; }
  .topbar-end { gap: 6px; }
  #export-open { padding: 0 14px; }
  .view-schreiben .editor { width: 100%; max-width: none; min-width: 0; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  #text-input { flex: none; min-height: 170px; height: 30vh; }
  .view-schreiben .stage { overflow: visible; }
  .lookbar-wrap { position: relative; top: auto; justify-content: flex-start; padding: 12px 12px 0; }
  .pop { left: 8px !important; right: 8px; width: auto; max-width: none; }
  .pop-wide { max-height: 60vh; }
  .view-schreiben .pages { flex: none; overflow: visible; padding: 16px 16px 8px; }
  .pagebar { position: static; transform: none; align-self: center; margin: 0 0 16px; }
  .share-again { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 420px) {
  #export-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #export-open { padding: 0; min-width: 44px; }
  .fmt-grid { grid-template-columns: 1fr; }
  .fmt-grid button { min-height: 0; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
  .fmt-grid button .icon { grid-row: span 2; margin: 0; }
}
/* Leiste bricht um, statt Knöpfe seitlich zu verstecken; Hilfe-Knopf wie der Design-Schalter */
.topbar #help-btn { background: var(--panel); color: var(--ink); }
.topbar #help-btn:hover { background: var(--surface-2); }
@media (max-width: 1000px) {
  .lookbar { flex-wrap: wrap; justify-content: center; overflow: visible; white-space: normal; row-gap: 2px; }
  .lookbar .lb-sep { display: none; }
}
