/* Studio: dunkle Oberfläche, helle Seiten in der Mitte, kräftiger Akzent. */
:root {
  --bg: #0e0f13;
  --panel: #15161c;
  --surface: #1d1f27;
  --surface-2: #262833;
  --surface-3: #30323f;
  --field: #101117;
  --border: #2b2e3a;
  --border-strong: #3a3d4c;
  --ink: #eceef5;
  --muted: #959aad;
  --accent: #6f7dff;
  --accent-2: #a37bff;
  --accent-grad: linear-gradient(135deg, #6f7dff 0%, #9a74ff 100%);
  --accent-soft: rgba(111, 125, 255, 0.16);
  --ok: #4ade80;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 14px;
  --touch: 48px; /* Mindestgröße für Touch-Ziele */
  --strong: #fff;                       /* Text auf gewählten Knöpfen */
  --glass: rgba(14, 15, 19, 0.7);       /* Kopfzeile */
  --glass-2: rgba(29, 31, 39, 0.82);    /* schwebende Leisten */
  --glass-3: rgba(29, 31, 39, 0.5);
  --scrim: rgba(5, 6, 10, 0.6);
  --placeholder: #6b7084;
  --danger-text: #ffb3b3;
  color-scheme: dark;
}
/* Heller Modus nach Systemeinstellung */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f8;
    --panel: #ffffff;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --surface-3: #e2e5ee;
    --field: #ffffff;
    --border: #dde0e9;
    --border-strong: #c6cad8;
    --ink: #161821;
    --muted: #555b6f;
    --accent: #4f5be8;
    --accent-soft: rgba(79, 91, 232, 0.12);
    --ok: #15803d;
    --warn: #a14a05;
    --danger: #cf2a2a;
    --strong: #161821;
    --glass: rgba(243, 244, 248, 0.82);
    --glass-2: rgba(255, 255, 255, 0.9);
    --glass-3: rgba(255, 255, 255, 0.7);
    --scrim: rgba(20, 22, 30, 0.35);
    --placeholder: #80869a;
    --danger-text: #b42318;
    color-scheme: light;
  }
}

* { 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: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

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);
  background:
    radial-gradient(900px 500px at 75% -10%, rgba(111, 125, 255, 0.14), transparent 70%),
    radial-gradient(700px 400px at 0% 110%, rgba(163, 123, 255, 0.08), transparent 70%),
    var(--bg);
  /* 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; font-size: 26px; }

.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: 1px solid var(--border);
  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: 19px; letter-spacing: -0.01em; }
.brand-icon {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent-grad);
  box-shadow: 0 6px 20px rgba(111, 125, 255, 0.35);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.tabs button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.tabs button[aria-selected="true"] {
  color: #fff;
  background: var(--accent-grad);
  box-shadow: 0 4px 16px rgba(111, 125, 255, 0.35);
}
.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: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation; /* kein Doppeltipp-Zoom */
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
button:hover { background: var(--surface-3); }
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.5; }
button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--strong); }
button.primary {
  border-color: transparent;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(111, 125, 255, 0.3);
}
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
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(--border);
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 18px; /* 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: 15px; }
.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: 15px; 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; }

.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: 14px; }
.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: 3px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 24px 70px rgba(0, 0, 0, 0.55),
    0 0 120px rgba(111, 125, 255, 0.10);
}

.floatbar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  background: var(--glass-2);
  border: 1px solid var(--border-strong);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  z-index: 5;
}
.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 */ }
/* Roter Papierkorb oben rechts im Textfeld */
.trash {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 48px;
  padding: 0;
  border-radius: 12px;
  color: #fff;
  background: #e5484d;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(229, 72, 77, 0.35);
}
.trash:hover { background: #f05b60; }
.trash:disabled { opacity: 0.35; box-shadow: none; }
#controls { display: grid; gap: 6px; }
.swatches { display: flex; gap: 12px; }
.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: 22px; }
.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: rgba(111, 125, 255, 0.04); }
.field-box {
  position: absolute;
  border: 1.5px dashed rgba(111, 125, 255, 0.65);
  border-radius: 4px;
  touch-action: none;
  cursor: move;
}
.field-box.selected { border: 2px solid var(--accent); background: rgba(111, 125, 255, 0.06); box-shadow: 0 0 0 4px rgba(111, 125, 255, 0.15); }
.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);
  color: #fff;
  font-size: 13px;
  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);
  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: 16px; 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: 15px; }
.badge-active { align-self: center; padding: 4px 10px; border-radius: 999px; background: var(--accent-grad); color: #fff; font-size: 13px; 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(320px, 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: 15px; }

/* ---------- 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: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.progress { position: sticky; top: -14px; padding: 10px 0; background: var(--panel); 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: 20px; border-width: 1.5px; }
.chip[data-status="0"] { background: var(--surface); color: var(--muted); }
.chip[data-status="1"], .chip[data-status="2"] { background: rgba(255, 181, 71, 0.14); border-color: rgba(255, 181, 71, 0.55); }
.chip[data-status="3"] { background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.5); }
.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 { display: flex; gap: 4px; padding: 4px; margin-bottom: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.mode-switch button { flex: 1; min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--muted); }
.mode-switch button[aria-pressed="true"] { background: var(--surface-3); color: var(--strong); }

.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 1px rgba(255, 255, 255, 0.06), 0 12px 36px rgba(0, 0, 0, 0.45);
}
#text-page, .box canvas { touch-action: none; /* kein Scrollen/Zoomen beim Schreiben */ }
.current-char {
  min-width: 90px;
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#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: 15px; }
.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: 14px; 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: 17px; }
  .profile-switch select { max-width: 150px; font-size: 16px; }
  .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: 12px; }
  .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; }
  .floatbar { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 16px); }
  .floatbar button { padding: 0 12px; }
  .floatbar .check, .floatbar-sep { display: none; }
  .banner { flex-wrap: wrap; justify-content: flex-start; }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Claude (Schriftbot-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 rgba(111, 125, 255, 0.3);
}
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, rgba(111, 125, 255, 0.22), rgba(163, 123, 255, 0.18));
  border: 1px solid rgba(111, 125, 255, 0.6); animation: banner-in .25s ease-out;
}
.claude-banner > .icon { color: #c9b8ff; }
.claude-banner > div { display: grid; flex: 1; min-width: 0; }
.claude-banner span { color: var(--muted); font-size: 14px; }
.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: 20px; }
.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 { border-color: transparent; background: #e5484d; color: #fff; font-weight: 600; }
.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; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--strong); }
.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: 14px; 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: 17px; 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: 14px; }
.ki-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ki-actions button { min-height: 44px; padding: 0 14px; font-size: 15px; }
.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: 15px;
  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: 14px; }

.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 rgba(111, 125, 255, 0.35); }
.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: 15px; }

.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: 17px; }
.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: 14px; }
.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: 15px; }
.ki-file small { color: var(--muted); font-size: 12px; }
.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: 20px; }
.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: 13px; } .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: 22px; }
.tour p { margin: 0; color: var(--muted); }
.tour .tour-step { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; 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: 15px; }
details.fine[open] > summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.slider-desc { grid-column: 1 / -1; font-size: 13px; color: var(--muted); opacity: 0.85; }
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: 22px; 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; }
