/*
 * VEYRA – Designsystem der Oberfläche (ADR 0059, Farben seit ADR 0161).
 * Wald bei Nacht – fast schwarz mit grünem Stich – als Grund, zartes Limettengrün als einziger Akzent, Geist als Schrift
 * (mitgeliefert, OFL).
 * Tiefe entsteht aus Flächenstufen und feinen Konturen, nicht aus Leuchten. Alles läuft über die Tokens unten –
 * Ansichten erfinden keine eigenen Farben, Abstände oder Radien.
 */

@font-face {
  font-family: "Geist";
  src: url("/vendor/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/vendor/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ================================================================== Tokens */

:root {
  color-scheme: dark;

  /* Flächen – von der tiefsten zur höchsten. Seit 21.10.2026 grünlich wie ein Wald bei Nacht (Tobis Wunsch, in der
     Stimmung von Trademania – eigene Werte, nichts übernommen) */
  --bg: #060a08;
  --bg-sunken: #040706;
  --surface-1: #0a100d;
  --surface-2: #0e1612;
  --surface-3: #141e19;
  --surface-4: #1b2720;
  /* für Felder, die halb durchsichtig über Grafiken schweben (Chart-Legende, Lupe, Gehirn) – ohne Unschärfe (ADR 0223) */
  --surface-1-rgb: 10 16 13;
  --overlay: rgb(3 6 4 / 74%);

  /* Konturen – hell mit einem Hauch Grün */
  --line-1: rgb(214 255 220 / 6%);
  --line-2: rgb(214 255 220 / 10%);
  --line-3: rgb(214 255 220 / 16%);

  /* Text */
  --text-1: #edf3ef;
  --text-2: #a7b4ac;
  --text-3: #6d7b73;
  --text-4: #49564f;

  /* Akzent: helles Limettengrün mit dunkler Schrift */
  --accent-rgb: 207 246 169;
  --accent: #cff6a9;
  --accent-strong: #b6ec82;
  --accent-text: #0a1505;
  --accent-soft: rgb(var(--accent-rgb) / 10%);
  --accent-line: rgb(var(--accent-rgb) / 36%);

  /* Kerzen: Mint und Koralle */
  --candle-up: #3ee6b4;
  --candle-down: #f45b6e;

  /* Diagramme in Blatt (ADR 0231, Stufe 13): Reihen in fester Reihenfolge – geprüft gegen die dunkle Fläche (Helligkeit,
     Sättigung, Farbsehschwächen benachbarter Reihen, Kontrast 3:1); auf Papier eigene Stufen (blatt-diagramm.js) */
  --chart-1: #3987e5;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-6: #008300;
  --chart-7: #9085e9;
  --chart-8: #e66767;

  /* Börsenzeiten (ADR 0230): je Sitzung eine Datenfarbe – Bänder im Chart, LEDs der Leiste, Streifen */
  --session-sydney: #5ec4d6;
  --session-tokio: #f08bb0;
  --session-frankfurt: #d9b45a;
  --session-london: #9aa8ff;
  --session-newyork: #7fe0a8;

  /* Zustände */
  --ok: #62dd9f;
  --ok-soft: rgb(98 221 159 / 12%);
  --warn: #e7b556;
  --warn-soft: rgb(231 181 86 / 12%);
  --danger: #f2756d;
  --danger-soft: rgb(242 117 109 / 12%);
  --violet: #a898ff;

  /* Form */
  --r-xs: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  /* Knopf-Höhen (ADR 0223): klein, mittel, groß */
  --btn-h-s: 26px;
  --btn-h-m: 32px;
  --btn-h-l: 40px;

  /* Fokus (ADR 0223): eine Kontur, die nichts verschlucken kann */
  --focus-color: var(--accent);
  --focus-width: 2px;
  --focus-offset: 2px;

  /* Tasten (ADR 0223): gewölbte Kappe, helle Kante oben, 2 px Rand nach unten */
  --key-top: #1f2c25;
  --key-bottom: #16211b;
  --key-top-hover: #24332b;
  --key-latched-top: #111a15;
  --key-latched-bottom: #18231d;
  --key-skirt: #020403;
  --key-side: rgb(214 255 220 / 9%);
  --key-gloss: rgb(255 255 255 / 5%);
  --key-shade: rgb(0 0 0 / 60%);
  --lime-top: #e2fbc6;
  --lime-top-hover: #ebfcd6;
  --lime-bottom: #c3ef95;
  --lime-skirt: #5d8838;
  --lime-edge: rgb(255 255 255 / 55%);
  --lime-side: rgb(10 21 5 / 30%);
  --key-raise: 0 2px 0 var(--key-skirt), 0 3px 8px -3px var(--key-shade), inset 0 1px 0 var(--key-gloss);
  --key-raise-hover: 0 3px 0 var(--key-skirt), 0 5px 10px -3px var(--key-shade), inset 0 1px 0 var(--key-gloss);
  --key-down: 0 0 0 var(--key-skirt), 0 1px 2px -1px var(--key-shade), inset 0 2px 4px var(--key-shade);
  --key-latched: 0 1px 0 var(--key-skirt), inset 0 1px 3px var(--key-shade);
  /* Mulde der ruhigen Knöpfe und Symbolknöpfe */
  --well: inset 0 1px 3px var(--key-shade), inset 0 0 0 1px var(--line-1);
  --well-deep: inset 0 2px 5px var(--key-shade), inset 0 0 0 1px var(--line-1);
  /* Hover bei flachen Einträgen: ein Hauch, nie die Fläche der Auswahl */
  --hover-wash: rgb(214 255 220 / 3.5%);
  /* LED: aus ein dunkler Sockel, an Limette mit Schein; geht schnell an und glimmt langsam aus */
  --led-off: #0a110d;
  --led-ring: rgb(214 255 220 / 14%);
  --led-glow: 0 0 0 1px rgb(var(--accent-rgb) / 35%), 0 0 8px 1px rgb(var(--accent-rgb) / 70%);
  /* Hub in 40 ms, Rückfedern mit der Feder */
  --key-press-time: 40ms;
  --key-release-time: 260ms;

  /* Raster: 4 px */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* Schrift */
  --font: "Geist", system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  /* Tiefe */
  --highlight: inset 0 1px 0 rgb(255 255 255 / 3.5%);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 12px 32px rgb(0 0 0 / 45%), 0 2px 6px rgb(0 0 0 / 30%);
  --shadow-3: 0 28px 70px rgb(0 0 0 / 60%), 0 0 0 1px var(--line-2);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px rgb(var(--accent-rgb) / 55%);

  /* Bewegung (ADR 0193): Erscheinen rollt kräftig aus, Verschwinden ist kurz und beschleunigt; nichts über 300 ms außer Warten */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in: cubic-bezier(0.3, 0, 0.8, 0.15);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  /* Feder mit kaum sichtbarem Nachschwingen (Ersatz ohne linear() unten bei @supports) */
  --spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --fast: 120ms;
  --med: 200ms;
  --slow: 320ms;

  /* Maße */
  --sidebar-w: 248px;
  --topbar-h: 52px;
  --content-w: 760px;
  --page-w: 1080px;
  /* Lesespalte (ADR 0225): Gespräch, Gedächtnis, System und der einfache Modus bleiben so breit; Daten gehen bis zum Rand */
  --read-w: 1080px;

  /* Altnamen – chart.js, brain.js und die SVG-Grafiken lesen sie */
  --text: var(--text-1);
  --muted: var(--text-2);
  --border: var(--line-2);
  --panel: var(--surface-2);
  --local: var(--ok);
  --external: var(--warn);
}

/* echte Feder, wo der Browser linear() kann: schnell am Ziel, 4 % drüber, ruhig zurück */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.06 2.4%, 0.236 5.3%, 0.471 8.8%, 0.7 12.8%, 0.86 16.6%, 0.959 20.7%, 1.014 25.1%, 1.038 29.6%, 1.04 33.5%, 1.03 38.4%, 1.012 45.1%, 0.999 54.1%, 0.996 63.2%, 1 82%, 1);
  }
}

/* ================================================================== Grundlagen */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font: 400 var(--fs-md) / 1.55 var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* keine einsamen Reste am Zeilenende (etwa „%“ allein in der nächsten Zeile) */
  text-wrap: pretty;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.25;
}

a {
  color: var(--accent);
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    text-decoration: underline;
  }
}

::selection {
  background: rgb(var(--accent-rgb) / 28%);
}

/* Fokus (ADR 0223): eine Kontur statt eines Schattens. Ein box-shadow-Ring wurde von jeder Regel mit „box-shadow: none“
   verschluckt (Hauptknopf, Navigation, Symbolknöpfe, Reiter …) und verschwindet im Windows-Kontrastmodus ganz. Die Kontur
   folgt den Ecken und bleibt dort sichtbar. Mausklicks zeigen sie nicht. */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

code,
kbd,
pre {
  font-family: var(--mono);
}

code {
  font-size: 0.88em;
  background: var(--surface-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-xs);
  padding: 0.08em 0.36em;
}

kbd {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-width: 18px;
  height: 18px;
  padding: 0 var(--s-1);
  border-radius: var(--r-xs);
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  line-height: 1;
}

.icon {
  flex: none;
  display: block;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: var(--fs-sm);
}

.error {
  color: var(--danger);
}

.num,
.tabular {
  font-variant-numeric: tabular-nums;
}

.num {
  text-align: right;
}

/* Schlanke Scrollleisten */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-4) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border: 3px solid transparent;
  border-radius: var(--r-full);
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/*
 * Spielmodus (ADR 0223): Neben einem Spiel kostet jede Animation Grafikleistung. Ist er an (app.js setzt die Klasse),
 * gilt dasselbe wie bei „Bewegung reduzieren“ – auch die Ersatz-Regeln der einzelnen Bausteine. Wer einen neuen Block
 * für „Bewegung reduzieren“ anlegt, ergänzt ihn hier.
 */
html.spielmodus *,
html.spielmodus *::before,
html.spielmodus *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

html.spielmodus .busy-comet {
  animation: none;
  width: 30%;
  transform: none;
}

html.spielmodus .busy-track::after {
  display: none;
}

html.spielmodus .busy-blocks i:first-child {
  border-color: var(--accent);
  background: var(--accent);
}

html.spielmodus :is(.release-lock-spin, .incident-chip .icon, .chart-reload.busy .icon, #refresh-all.busy .icon, .research-log .log-live) {
  animation: none;
}

/* ================================================================== Schaltflächen (ADR 0223) */

/*
 * Fünf Familien mit je eigener Antwort auf Darüberfahren, Drücken, Einrasten und Fokus:
 *   Sekundär    <button> ohne Familienklasse (auch .danger: Sekundär mit Warnschrift)
 *   Primär      .primary
 *   Ruhig       .ghost, .link
 *   Symbol      .icon-button
 *   Umschalter  aria-pressed (dazu .segmented und die Zeitrahmen der Grafiken)
 * Drei Höhen: klein 26 px (.small), mittel 32 px, groß 40 px (Fragen, Senden).
 * Was eine Familie zeigt, steht in den --btn-*-Werten. Bausteine mit eigenem Look (Navigation, Reiter, Zeilen,
 * Werkzeuge) stehen in der Liste „flach“ und setzen Schatten, Heben und Hub dort zurück – neue Knöpfe nehmen eine
 * Familie und bauen keine eigenen Rezepte.
 */

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  /* Sekundär: eine dunkle Taste */
  --btn-bg: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  --btn-bg-hover: linear-gradient(180deg, var(--key-top-hover), var(--key-bottom));
  --btn-border: var(--key-side);
  --btn-border-hover: var(--line-2);
  --btn-text: var(--text-1);
  --btn-text-hover: var(--btn-text);
  --btn-shadow: var(--key-raise);
  --btn-shadow-hover: var(--key-raise-hover);
  --btn-shadow-down: var(--key-down);
  /* Darüberfahren hebt um --btn-lift, Drücken senkt um --btn-travel und staucht auf --btn-press */
  --btn-lift: -1px;
  --btn-travel: 2px;
  --btn-press: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--btn-h-m);
  padding: 0 var(--s-3);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  /* Loslassen federt (--spring), Drücken setzt unten die kurze Zeit */
  transition:
    background var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease),
    opacity var(--fast) var(--ease),
    box-shadow var(--med) var(--ease-out),
    translate var(--key-release-time) var(--spring),
    scale var(--key-release-time) var(--spring);
}

@media (hover: hover) and (pointer: fine) {
  /* nicht beim Drücken: Mit der Maus ist eine gedrückte Taste immer auch „darüber“ – die Hover-Regel wiegt mehr als die
     Druck-Regel und hielt die Taste oben (Nachtrag 09.11.2026, ADR 0223). :where hält das Gewicht gleich. */
  button:hover:where(:not(:active)) {
    border-color: var(--btn-border-hover);
    background: var(--btn-bg-hover);
    box-shadow: var(--btn-shadow-hover);
    translate: 0 var(--btn-lift);
  }

  :is(.icon-button, button.link, button.ghost):hover {
    color: var(--btn-text-hover);
  }
}

/* Drücken: 2 px Hub nach unten in 40 ms (translate statt transform – sonst kämen sich Positionierungen in die Quere).
   .is-pressed hält den Zustand bei einem schnellen Tipp am iPhone mindestens 90 ms sichtbar (motion.js) */
button:where(:active, .is-pressed):where(:not(:disabled)) {
  scale: var(--btn-press);
  translate: 0 var(--btn-travel);
  box-shadow: var(--btn-shadow-down);
  transition-duration: var(--key-press-time);
  transition-timing-function: var(--ease-out);
}

/* Gesperrt: die Taste liegt flach im Rahmen, ohne Kante */
button:disabled {
  --btn-bg: var(--surface-1);
  --btn-border: var(--line-1);
  --btn-shadow: none;
  --btn-text: var(--text-3);
  opacity: 0.55;
  cursor: default;
}

/* die gewählte Möglichkeit ist gesperrt, weil sie schon gilt – sie soll gewählt aussehen, nicht ausgegraut (29.10.2026) */
button[aria-pressed="true"]:disabled {
  opacity: 1;
}

/* Primär: die Limetten-Taste */
button.primary {
  --btn-bg: linear-gradient(180deg, var(--lime-top), var(--lime-bottom));
  --btn-bg-hover: linear-gradient(180deg, var(--lime-top-hover), var(--lime-bottom));
  --btn-border: var(--lime-side);
  --btn-border-hover: var(--lime-side);
  --btn-text: var(--accent-text);
  --btn-shadow: 0 2px 0 var(--lime-skirt), 0 4px 10px -4px var(--key-shade), inset 0 1px 0 var(--lime-edge);
  --btn-shadow-hover: 0 3px 0 var(--lime-skirt), 0 6px 12px -4px var(--key-shade), inset 0 1px 0 var(--lime-edge);
  --btn-shadow-down: 0 0 0 var(--lime-skirt), inset 0 2px 4px var(--lime-side);
  font-weight: 600;
}

/* Sekundär mit Warnschrift */
button.danger {
  --btn-border: rgb(242 117 109 / 30%);
  --btn-border-hover: rgb(242 117 109 / 45%);
  --btn-text: var(--danger);
}

/* Ruhig und Symbol: keine Kappe – mit der Maus zeigt sich eine Mulde, beim Drücken wird sie tiefer */
button.ghost,
button.link,
.icon-button {
  --btn-bg: transparent;
  --btn-bg-hover: var(--bg-sunken);
  --btn-border: transparent;
  --btn-border-hover: transparent;
  --btn-shadow: none;
  --btn-shadow-hover: var(--well);
  --btn-shadow-down: var(--well-deep);
  --btn-lift: 0px;
  --btn-travel: 1px;
}

button.ghost {
  --btn-text: var(--text-1);
}

button.link {
  --btn-bg-hover: transparent;
  --btn-shadow-hover: none;
  --btn-shadow-down: none;
  --btn-travel: 0px;
  --btn-text: var(--text-2);
  --btn-text-hover: var(--text-1);
  height: auto;
  padding: 0;
  font-weight: 400;
}

@media (hover: hover) and (pointer: fine) {
  button.link:hover {
    text-decoration: underline;
  }
}

.icon-button {
  --btn-text: var(--text-2);
  --btn-text-hover: var(--text-1);
  width: var(--btn-h-m);
  padding: 0;
}

/* Umschalter: Was gilt, rastet ein – die Taste bleibt unten, die Schrift leuchtet. Wird ein anderer gewählt, federt sie
   zurück. :where hält das Gewicht niedrig, damit Bausteine mit eigenem Look gewinnen */
button:where([aria-pressed="true"], .busy, [aria-busy="true"]) {
  --btn-bg: linear-gradient(180deg, var(--key-latched-top), var(--key-latched-bottom));
  --btn-bg-hover: var(--btn-bg);
  --btn-border: var(--key-side);
  --btn-border-hover: var(--key-side);
  --btn-text: var(--accent);
  --btn-shadow: var(--key-latched);
  --btn-shadow-hover: var(--key-latched);
  --btn-latch: 1px;
  --btn-lift: var(--btn-latch);
  translate: 0 var(--btn-latch);
  transition-duration: var(--key-press-time);
}

/* Symbol-Umschalter: eingerastet als Mulde mit leuchtendem Zeichen */
.icon-button[aria-pressed="true"] {
  --btn-bg: var(--bg-sunken);
  --btn-bg-hover: var(--bg-sunken);
  --btn-border: transparent;
  --btn-border-hover: transparent;
  --btn-shadow: var(--well);
  --btn-shadow-hover: var(--well);
}

/* Größen */
button.wide {
  width: 100%;
}

button.small,
.icon-button.small {
  height: var(--btn-h-s);
  padding: 0 var(--s-2);
  font-size: var(--fs-xs);
}

.icon-button.small {
  width: var(--btn-h-s);
  padding: 0;
}

/*
 * Flach: Navigation, Reiter, Zeilen, Werkzeuge und Felder-Auslöser haben ihren eigenen Look. Sie bekommen weder Schatten
 * noch Heben noch Hub der Familien; ihre Regeln weiter unten setzen Fläche und Schrift selbst.
 */
:is(
    .nav-item,
    .session,
    .place-tab,
    .tabbar-item,
    .account-item,
    .account > summary,
    .command-trigger,
    .tile-list button,
    .lang-switch button,
    .chart-now,
    .chart-tools-item,
    .chart-tool,
    .chart-sel-action,
    .chart-panel-close,
    .chart-line-menu button,
    .chart-swatch,
    .build-release,
    .term-item,
    .mic,
    .brain-top > button,
    .brain-chip,
    .blitz-tile,
    .incident-chip,
    .incident-close,
    .code .copy,
    .leute-item,
    .more-item,
    .blatt-item-open,
    .blatt-title
  ) {
  --btn-shadow: none;
  --btn-shadow-hover: none;
  --btn-shadow-down: none;
  --btn-lift: 0px;
  --btn-travel: 0px;
  --btn-latch: 0px;
}

/* ================================================================== Eingaben */

input[type="text"],
input[type="search"],
input[type="password"],
input[type="date"],
textarea,
select,
.search {
  width: 100%;
  min-height: 34px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  color: var(--text-1);
  font-size: var(--fs-md);
  transition:
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}

textarea {
  padding: var(--s-2) var(--s-3);
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}

@media (hover: hover) and (pointer: fine) {
  input:hover,
  textarea:hover,
  select:hover {
    border-color: var(--line-3);
  }
}

/* Felder zeigen den Fokus mit Rahmen und Schein; die Kontur bleibt durchsichtig und erscheint nur im Kontrastmodus */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.search:focus-visible {
  outline-color: transparent;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Häkchen, Optionsfelder und Regler haben keinen solchen Rahmen: dort die normale Kontur */
input:is([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]):focus-visible {
  outline-color: var(--accent);
  box-shadow: none;
}

input[type="date"] {
  color-scheme: dark;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
}

.field > .icon {
  position: absolute;
  left: var(--s-3);
  color: var(--text-3);
  pointer-events: none;
}

.field > input {
  padding-left: 36px;
}

/* ================================================================== Kleine Bausteine */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--s-2);
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--accent-text);
  font-size: var(--fs-2xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.badge.local,
.badge.external,
.chip {
  height: 20px;
  padding: 0 8px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  font-weight: 500;
}

.badge.local {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: rgb(79 202 142 / 22%);
}

.badge.external {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgb(231 181 86 / 22%);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--text-3);
  flex: none;
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-xs);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-full);
  color: var(--text-2);
  background: var(--surface-3);
}

.tag.sensitive {
  color: var(--warn);
  border-color: rgb(231 181 86 / 28%);
  background: var(--warn-soft);
}

.stats {
  margin: var(--s-2) 0 var(--s-4);
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.empty-note {
  margin: var(--s-4) 0;
  padding: var(--s-8) var(--s-4);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  color: var(--text-3);
  text-align: center;
  font-size: var(--fs-sm);
}

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.plain-list {
  margin: var(--s-2) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.plain-list li {
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--line-1);
}

.plain-list li:last-child {
  border-bottom: none;
}

/* Fortschritt */
.bar,
.training-progress {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-4);
  overflow: hidden;
}

.bar-fill,
.training-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--slow) var(--ease);
}

.bar-fill.warn {
  background: var(--danger);
}

/* Platzhalter beim Laden */
.skeleton {
  display: block;
  height: 12px;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-4) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.spin {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ================================================================== Bewegung (ADR 0193) */

/* Ansichtswechsel: die neue Ansicht blendet ein und rollt 8 px nach oben aus – nur beim Erscheinen, Verschwinden ist sofort */
.view:not([hidden]) {
  animation: view-in 280ms var(--ease-out);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Ladebalken ganz oben (motion.js): erst ab 160 ms Wartezeit, kriecht gegen 90 %, schießt am Ende durch und verblasst */
.top-progress {
  position: fixed;
  /* am iPhone unter der Statusleiste, nicht dahinter */
  inset: env(safe-area-inset-top, 0px) 0 auto;
  z-index: 90;
  height: 2px;
  pointer-events: none;
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, rgb(var(--accent-rgb) / 40%), var(--accent) 70%, #fff);
  box-shadow: 0 0 10px rgb(var(--accent-rgb) / 70%);
  transition:
    transform 320ms var(--ease-out),
    opacity 200ms linear;
}

.top-progress.done {
  opacity: 0;
  transition:
    transform 200ms var(--ease-out),
    opacity 300ms linear 180ms;
}

.top-progress.reset {
  transition: none;
}

/* Warte-Anzeige statt „Lade …“ (motion.js busy): Text mit wanderndem Glanz, laufender Balken, ab 2 s die Wartezeit.
   Sie erscheint erst nach 150 ms – kurze Wartezeiten flackern so nicht. */
.busy {
  display: grid;
  gap: var(--s-3);
  width: 100%;
  max-width: 520px;
  padding: var(--s-3) 0;
  animation: fade var(--med) var(--ease-out) 150ms both;
}

.busy-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  min-width: 0;
  font-size: var(--fs-sm);
}

.busy-text,
.thinking,
.tool.running .tool-name,
.turn-steps li.is-active .turn-step {
  background: linear-gradient(100deg, var(--text-3) 0%, var(--text-3) 38%, var(--text-1) 50%, var(--text-3) 62%, var(--text-3) 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shine 2.2s linear infinite;
}

@keyframes text-shine {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0% 0;
  }
}

.busy-time {
  margin-left: auto;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.busy-track {
  position: relative;
  height: 3px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--surface-4);
}

/* mit erwarteter Dauer: füllt sich gleichmäßig, darüber läuft ein heller Schimmer */
.busy-fill {
  position: absolute;
  inset: 0;
  display: none;
  border-radius: inherit;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgb(var(--accent-rgb) / 45%), var(--accent));
  transition: transform 1s linear;
}

.busy-track.has-expect .busy-fill {
  display: block;
}

/* zwei Kometen, um einen halben Lauf versetzt – so ist die Leiste nie leer und wirkt nie hängend */
.busy-comet,
.busy-track::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgb(var(--accent-rgb) / 85%) 65%, #fff 92%, transparent);
  animation: comet 1.6s var(--ease-in-out) infinite;
}

.busy-track::after {
  content: "";
  opacity: 0.55;
  animation-delay: -0.8s;
}

.busy-track.has-expect .busy-comet,
.busy-track.has-expect::after {
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 40%), transparent);
}

@keyframes comet {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(265%);
  }
}

/* Suche auf dem Bitcoin-Knoten: eine Block-Kette, die Glied für Glied durchgelesen wird */
.busy-blocks {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 22px;
}

.busy-blocks i {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-3);
  border-radius: var(--r-xs);
  background: var(--surface-3);
  animation: block-read 1.7s var(--ease-in-out) infinite;
}

.busy-blocks i:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: 10px;
  height: 1px;
  background: var(--line-3);
}

.busy-blocks i:nth-child(2) {
  animation-delay: 0.12s;
}

.busy-blocks i:nth-child(3) {
  animation-delay: 0.24s;
}

.busy-blocks i:nth-child(4) {
  animation-delay: 0.36s;
}

.busy-blocks i:nth-child(5) {
  animation-delay: 0.48s;
}

.busy-blocks i:nth-child(6) {
  animation-delay: 0.6s;
}

.busy-blocks i:nth-child(7) {
  animation-delay: 0.72s;
}

@keyframes block-read {
  0%,
  42%,
  100% {
    transform: none;
    border-color: var(--line-3);
    background: var(--surface-3);
    box-shadow: none;
  }
  14% {
    transform: translateY(-3px);
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 12px rgb(var(--accent-rgb) / 55%);
  }
}

/* in der Kette zeigt der Balken nur eine bekannte Dauer – das Laufen machen die Blöcke */
.busy-kette .busy-track:not(.has-expect) {
  display: none;
}

.busy-compact {
  gap: var(--s-2);
  padding: var(--s-1) 0;
}

.busy-compact .busy-head {
  font-size: var(--fs-xs);
}

/* Gleitender Marker (motion.js slideMarker): liegt hinter dem aktiven Eintrag und gleitet mit der Feder hinüber (ADR 0223) */
.slide-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--w, 0);
  height: var(--h, 0);
  border-radius: var(--r-md);
  background: var(--surface-3);
  pointer-events: none;
  transform: translate(var(--x, 0), var(--y, 0));
  transition:
    transform 320ms var(--spring),
    width 320ms var(--spring),
    height 320ms var(--spring);
}

/* Fokusring, der in Seitenleiste, Reitern und Umschaltern von Eintrag zu Eintrag gleitet – wie der Limettenring im
   Blitz-Menü (motion.js focusGlide, ADR 0223). Die Einträge selbst zeigen dort keine eigene Kontur. */
.focus-glide {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: calc(var(--w, 0px) + 8px);
  height: calc(var(--h, 0px) + 8px);
  border: var(--focus-width) solid var(--focus-color);
  border-radius: var(--r-lg);
  pointer-events: none;
  opacity: 0;
  transform: translate(calc(var(--x, 0px) - 4px), calc(var(--y, 0px) - 4px));
  transition:
    transform 320ms var(--spring),
    width 320ms var(--spring),
    height 320ms var(--spring),
    opacity var(--fast) var(--ease);
}

.focus-glide.show {
  opacity: 1;
}

.focus-glide.instant {
  transition: opacity var(--fast) var(--ease);
}

/* durchsichtig statt weg: im Windows-Kontrastmodus zeichnet das System die Kontur trotzdem */
.has-focus-glide > :focus-visible {
  outline-color: transparent;
}

/* Fokus mit Feder: die Kontur springt beim Erscheinen aus 5 px Abstand auf 2 px */
:is(button, a, summary, [role="tab"]):focus-visible {
  animation: focus-in 260ms var(--spring);
}

@keyframes focus-in {
  from {
    outline-offset: 5px;
    outline-color: transparent;
  }
}

.slide-marker.instant {
  transition: none;
}

/* die Einträge liegen über dem Marker – der gleitende Fokusring bleibt frei positioniert */
.has-marker > :not(.slide-marker, .focus-glide) {
  position: relative;
}

/* Inhalte, die eine Warte-Anzeige ablösen, erscheinen weich (motion.js arrive) – ohne Bewegung beim Wunsch des Systems */
@media (prefers-reduced-motion: reduce) {
  .busy-comet {
    animation: none;
    width: 30%;
    transform: none;
  }

  .busy-track::after {
    display: none;
  }

  .busy-blocks i:first-child {
    border-color: var(--accent);
    background: var(--accent);
  }
}

/* ================================================================== Dialoge, Befehlspalette, Hinweise */

/* Auf- und Zugehen (ADR 0193): wächst federnd aus 96 % heraus und blendet ein; beim Schließen kurz und beschleunigend
   zurück – display und overlay laufen diskret mit, damit der Dialog bis zum Ende sichtbar bleibt */
dialog {
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  color: var(--text-1);
  box-shadow: var(--shadow-3);
  opacity: 0;
  scale: 0.96;
  transition:
    opacity 140ms var(--ease-in),
    scale 140ms var(--ease-in),
    overlay 140ms allow-discrete,
    display 140ms allow-discrete;
}

dialog[open] {
  opacity: 1;
  scale: 1;
  transition:
    opacity 200ms var(--ease-out),
    scale 320ms var(--spring),
    overlay 320ms allow-discrete,
    display 320ms allow-discrete;
}

@starting-style {
  dialog[open] {
    opacity: 0;
    scale: 0.96;
  }
}

dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition:
    opacity 140ms var(--ease-in),
    overlay 140ms allow-discrete,
    display 140ms allow-discrete;
}

dialog[open]::backdrop {
  opacity: 1;
  transition:
    opacity 220ms var(--ease-out),
    overlay 220ms allow-discrete,
    display 220ms allow-discrete;
}

@starting-style {
  dialog[open]::backdrop {
    opacity: 0;
  }
}

.confirm {
  width: min(480px, calc(100% - 32px));
}

.confirm > div {
  padding: var(--s-6);
}

.confirm h2 {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
  font-size: var(--fs-lg);
}

.confirm h2 .icon {
  color: var(--accent);
}

.confirm[data-risk="high"] h2,
.confirm[data-risk="critical"] h2,
.confirm[data-risk="high"] h2 .icon,
.confirm[data-risk="critical"] h2 .icon {
  color: var(--danger);
}

.confirm-summary {
  max-height: 50vh;
  margin: 0 0 var(--s-3);
  padding: var(--s-3);
  overflow-y: auto;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: var(--fs-md);
}

.confirm .muted {
  font-size: var(--fs-xs);
}

.confirm .actions {
  margin-top: var(--s-5);
}

/* Eröffnungen ansagen (Nachtrag ADR 0230): je Börse eine Umschalt-Taste, darunter „Auch aufs Handy“ */
.session-announce-keys {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin: 0 0 var(--s-3);
}

.calibrate-heard {
  min-height: 1.5em;
  margin: 0 0 var(--s-3);
  padding-left: 1.4rem;
}

/* Befehlspalette (Strg+K) */
.palette {
  width: min(600px, calc(100% - 32px));
  margin-top: 14vh;
  overflow: hidden;
  /* Strg+K kommt oft und per Taste – nur ein Hauch Bewegung, sonst bremst sie */
  transition-duration: 90ms;
}

.palette[open] {
  transition-duration: 130ms;
}

.palette-input {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--line-1);
}

.palette-input .icon {
  color: var(--text-3);
}

.palette-input input {
  height: 52px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: var(--fs-lg);
  box-shadow: none !important;
}

.palette-list {
  max-height: min(420px, 55vh);
  margin: 0;
  padding: var(--s-2);
  overflow-y: auto;
  list-style: none;
}

.palette-group {
  padding: var(--s-2) var(--s-3) var(--s-1);
  color: var(--text-3);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 38px;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.palette-item .icon {
  color: var(--text-3);
}

.palette-item .hint-text {
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.palette-item[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text-1);
}

.palette-item[aria-selected="true"] .icon {
  color: var(--accent);
}

.palette-empty {
  padding: var(--s-6);
  color: var(--text-3);
  text-align: center;
  font-size: var(--fs-sm);
}

.palette-foot {
  display: flex;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--line-1);
  color: var(--text-3);
  font-size: var(--fs-2xs);
}

.palette-foot span {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

/* Kurzmeldung unten */
.toast {
  position: fixed;
  left: 50%;
  bottom: 112px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: min(560px, calc(100vw - 32px));
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--text-1);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-2);
  /* mittig über translate – transform bleibt frei für die Bewegung (ADR 0193) */
  translate: -50% 0;
  animation: toast-in 420ms var(--spring);
}

.toast.leaving {
  animation: toast-out 160ms var(--ease-in) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* Proaktive Hinweise (ADR 0044): oben rechts, bis zum Wegklicken */
.notices {
  position: fixed;
  top: calc(var(--topbar-h) + var(--s-3));
  right: var(--s-4);
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.notice {
  position: relative;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-5);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  pointer-events: auto;
  overflow: hidden;
  animation: rise var(--med) var(--ease);
}

.notice::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.notice.dringend::before {
  background: var(--danger);
}

.notice-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-1);
  font-weight: 600;
}

.notice-icon {
  display: inline-flex;
  color: var(--accent);
}

.notice.dringend .notice-icon {
  color: var(--danger);
}

.with-icon {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.with-icon .icon {
  color: var(--accent);
}

.notice-body {
  color: var(--text-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.notice-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* ================================================================== Blatt: Dokumente und Tabellen (ADR 0231) */

/*
 * Ort Dokumente: links die Liste, rechts das offene Dokument. Text als ruhige Seite in der Lesespalte, Tabelle als Raster bis
 * zum Rand. Farben nur aus Tokens; die Farben der Anwesenheit sind Datenfarben (je Person eine, von blatt vergeben).
 */
.blatt-view {
  display: flex;
  flex-direction: column;
}

#blatt-root {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: 0;
}

.blatt-side {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-height: 0;
  padding: var(--s-4) var(--s-3);
  border-right: 1px solid var(--line-1);
}

.blatt-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0 var(--s-1);
}

.blatt-side-head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

.blatt-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.blatt-item {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.blatt-item-open {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  height: auto;
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-weight: 400;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .blatt-item-open:hover:not(:disabled) {
    background: var(--hover-wash);
    color: var(--text-1);
  }
}

.blatt-item-open[aria-current="true"] {
  background: var(--surface-3);
  color: var(--text-1);
}

.blatt-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.blatt-item-title {
  overflow: hidden;
  color: var(--text-1);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blatt-item-meta {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.blatt-item-pin {
  color: var(--text-3);
}

/* Stufe 8: Auf diesem Gerät wartet noch etwas, das blatt nicht hat */
.blatt-item-local {
  color: var(--warn);
}

/* Stufe 8: Änderungen von diesem Gerät, die blatt nicht mehr annimmt – fragen statt stillschweigend */
.blatt-orphans {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.blatt-orphan {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-1) var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--warn-soft);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--text-1);
}

.blatt-orphan > svg {
  margin-top: 2px;
  color: var(--warn);
}

.blatt-orphan p {
  margin: 0;
}

.blatt-orphan-actions {
  display: flex;
  flex-wrap: wrap;
  grid-column: 2;
  gap: var(--s-2);
}

/* jemand anderes hat es gerade offen: eine LED */
.blatt-live-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: var(--led-glow);
}

.blatt-note {
  margin: var(--s-3) var(--s-2);
}

.blatt-trash-toggle {
  align-self: flex-start;
}

.blatt-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.blatt-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-8);
  color: var(--text-2);
  text-align: center;
}

.blatt-quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
}

/* Kopf des offenen Dokuments */
.blatt-doc-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--s-3);
  min-height: 52px;
  padding: var(--s-2) var(--s-5);
  border-bottom: 1px solid var(--line-1);
}

.blatt-back {
  display: none;
}

.blatt-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  height: auto;
  padding: var(--s-1) var(--s-2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.blatt-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .blatt-title:hover {
    background: var(--hover-wash);
  }
}

.blatt-title-input {
  max-width: 420px;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.blatt-peers {
  display: flex;
  margin-left: auto;
}

.blatt-peer {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: -6px;
  border: 2px solid var(--bg);
  border-radius: var(--r-full);
  background: var(--peer);
  color: var(--accent-text);
  font-size: var(--fs-2xs);
  font-weight: 700;
}

.blatt-status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.blatt-led {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--led-off);
  box-shadow: inset 0 0 0 1px var(--led-ring);
}

.blatt-led[data-state="live"] {
  background: var(--accent);
  box-shadow: var(--led-glow);
}

.blatt-led[data-state="verbinde"] {
  background: var(--warn);
  animation: blatt-blink 1.2s var(--ease-in-out) infinite;
}

.blatt-led[data-state="offline"] {
  background: var(--warn);
}

.blatt-led[data-state="zu"] {
  background: var(--danger);
}

@keyframes blatt-blink {
  50% {
    opacity: 0.35;
  }
}

.blatt-saved[data-pending="true"] {
  color: var(--text-2);
}

.blatt-doc-body {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* Stufe 6: Inhaltsverzeichnis links neben dem Dokument; am Handy als Leiste über dem Dokument */
.blatt-doc-body.has-toc {
  flex-direction: row;
}

.blatt-toc {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--s-3);
  width: 272px;
  min-height: 0;
  padding: var(--s-3) var(--s-3) var(--s-6);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line-1);
  background: var(--surface-1);
}

.blatt-toc-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-1);
}

.blatt-toc-head strong {
  flex: 1;
}

.blatt-toc-heads,
.blatt-toc-groups,
.blatt-toc-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.blatt-toc-groups {
  gap: var(--s-2);
}

.blatt-toc-item {
  justify-content: flex-start;
  width: 100%;
  height: auto;
  min-height: 32px;
  padding: var(--s-1) var(--s-2);
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: left;
  white-space: normal;
}

.blatt-toc-item[data-level="2"] {
  padding-left: var(--s-5);
}

.blatt-toc-item[data-level="3"] {
  padding-left: var(--s-8);
  color: var(--text-2);
}

.blatt-toc-group > .blatt-toc-item:first-child {
  font-weight: 650;
}

.blatt-toc-item.blatt-toc-entry {
  padding-left: var(--s-5);
  color: var(--text-2);
  font-weight: 400;
}

.blatt-toc-veyra {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line-1);
}

.blatt-toc-veyra h3 {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.blatt-toc-veyra p {
  margin: 0;
}

.blatt-toc-veyra > button {
  align-self: flex-start;
}

.blatt-toc-groups.is-live:empty {
  display: none;
}

.blatt-arrange-preview {
  max-height: min(56vh, 560px);
}

@media (max-width: 760px) {
  .blatt-toc {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 6;
    width: min(320px, 86vw);
    border-right: 1px solid var(--line-2);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 35%);
  }
}

.blatt-doc-body > .busy {
  margin: var(--s-8);
}

.blatt-editor {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* Werkzeugleiste (Text und Tabelle) */
.blatt-toolbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-5);
  border-bottom: 1px solid var(--line-1);
  background: var(--surface-1);
}

.blatt-toolbar:empty {
  display: none;
}

.blatt-tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: var(--s-2);
  border-right: 1px solid var(--line-1);
}

.blatt-tool-group:last-child {
  border-right: 0;
}

.blatt-block {
  width: auto;
  min-height: var(--btn-h-m);
  padding: 0 var(--s-2);
  font-size: var(--fs-sm);
}

.blatt-menu {
  position: absolute;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  padding: var(--s-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-3);
  box-shadow: var(--shadow-2);
}

.blatt-menu button {
  justify-content: flex-start;
  width: 100%;
}

.blatt-menu p {
  max-width: 240px;
  margin: var(--s-1) var(--s-2);
}

.blatt-new-menu {
  position: static;
  box-shadow: none;
}

/* ------------------------------------------------------------------ Text */

.blatt-paper {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--s-8) var(--s-6) var(--s-12);
}

.blatt-text {
  max-width: 820px;
  min-height: 60vh;
  margin: 0 auto;
  padding: var(--s-10) var(--s-12);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1) 240px);
  color: var(--text-1);
  font-size: var(--fs-lg);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  caret-color: var(--accent);
  outline: none;
  counter-reset: bl-ol0 bl-ol1 bl-ol2 bl-ol3;
}

.blatt-text:focus-visible {
  box-shadow: 0 0 0 1px var(--accent-line);
}

.blatt-text > * {
  margin: 0;
}

.blatt-text > p {
  min-height: 1.7em;
}

.blatt-text > h1 {
  margin: var(--s-6) 0 var(--s-3);
  font-size: var(--fs-2xl);
}

.blatt-text > h2 {
  margin: var(--s-6) 0 var(--s-2);
  font-size: var(--fs-xl);
}

.blatt-text > h3 {
  margin: var(--s-4) 0 var(--s-1);
  color: var(--text-2);
  font-size: var(--fs-lg);
}

.blatt-text > :first-child {
  margin-top: 0;
}

.blatt-text > blockquote {
  padding-left: var(--s-4);
  border-left: 3px solid var(--accent-line);
  color: var(--text-2);
}

.blatt-text > pre {
  padding: 0 var(--s-4);
  background: var(--bg-sunken);
  font-size: var(--fs-md);
  white-space: pre-wrap;
}

.blatt-text > pre:not(pre + pre) {
  padding-top: var(--s-2);
  border-top-left-radius: var(--r-md);
  border-top-right-radius: var(--r-md);
}

.blatt-text > pre:not(:has(+ pre)) {
  padding-bottom: var(--s-2);
  border-bottom-left-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
}

/* Listen: Aufzählungszeichen und Nummern ohne eigene Elemente (die Zeile bleibt reiner Text) */
.bl-li {
  position: relative;
  min-height: 1.7em;
  padding-left: calc(28px + var(--li-indent, 0px));
}

.bl-li[data-indent="1"] {
  --li-indent: 24px;
}

.bl-li[data-indent="2"] {
  --li-indent: 48px;
}

.bl-li[data-indent="3"] {
  --li-indent: 72px;
}

.bl-li::before {
  position: absolute;
  left: var(--li-indent, 0px);
  width: 22px;
  color: var(--accent);
  text-align: right;
}

.bl-ul::before {
  content: "•";
  text-align: center;
}

.bl-ul[data-indent="1"]::before,
.bl-ul[data-indent="3"]::before {
  content: "◦";
}

.blatt-text > :not(.bl-ol) {
  counter-reset: bl-ol0 bl-ol1 bl-ol2 bl-ol3;
}

.bl-ol:not([data-indent]) {
  counter-increment: bl-ol0;
  counter-reset: bl-ol1 bl-ol2 bl-ol3;
}

.bl-ol[data-indent="1"] {
  counter-increment: bl-ol1;
  counter-reset: bl-ol2 bl-ol3;
}

.bl-ol[data-indent="2"] {
  counter-increment: bl-ol2;
  counter-reset: bl-ol3;
}

.bl-ol[data-indent="3"] {
  counter-increment: bl-ol3;
}

.bl-ol:not([data-indent])::before {
  content: counter(bl-ol0) ".";
}

.bl-ol[data-indent="1"]::before {
  content: counter(bl-ol1, lower-alpha) ".";
}

.bl-ol[data-indent="2"]::before {
  content: counter(bl-ol2, lower-roman) ".";
}

.bl-ol[data-indent="3"]::before {
  content: counter(bl-ol3) ".";
}

.bl-li.bl-ol::before {
  font-variant-numeric: tabular-nums;
}

/* Checkliste: das Kästchen ist ein Pseudo-Element, ein Klick links in die Zeile hakt ab */
.bl-todo::before {
  content: "";
  top: 0.38em;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-3);
  border-radius: var(--r-xs);
  background: var(--bg-sunken);
  cursor: pointer;
}

.bl-todo.is-checked::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 16px var(--accent-text);
}

.bl-todo.is-checked {
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-color: var(--line-3);
}

.blatt-text mark {
  padding: 0 2px;
  border-radius: var(--r-xs);
  background: rgb(var(--accent-rgb) / 22%);
  color: inherit;
}

.blatt-text a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
}

.blatt-text code {
  font-size: 0.86em;
}

.bl-hr {
  padding: var(--s-3) 0;
}

.bl-hr hr {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line-2);
}

/* Tabelle im Text */
.bl-table {
  margin: var(--s-3) 0;
  white-space: normal;
}

.bl-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(80px, 1fr));
  overflow-x: auto;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
}

.bl-cell {
  min-height: 2.2em;
  padding: var(--s-1) var(--s-3);
  border-right: 1px solid var(--line-1);
  border-bottom: 1px solid var(--line-1);
  font-size: var(--fs-md);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}

.bl-cell.is-head {
  background: var(--surface-3);
  font-weight: 600;
}

.bl-cell:focus {
  box-shadow: inset 0 0 0 2px var(--accent-line);
}

.bl-table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-1);
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.bl-table:focus-within .bl-table-tools {
  opacity: 1;
}

@media (hover: none), (pointer: coarse) {
  .bl-table-tools {
    opacity: 1;
  }
}

/* Stufe 12: Bild im Text – eigene Breite höchstens die Spalte, sonst in Prozent; Leiste beim Zeigen oder Fokus */
.bl-img {
  margin: var(--s-3) 0;
  white-space: normal;
}

.bl-img figure {
  max-width: 100%;
  margin: 0;
}

.bl-img img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.bl-img figure[style] img {
  width: 100%;
}

.bl-img.is-missing figure {
  display: grid;
  place-items: center;
  min-height: 72px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}

.bl-img-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-1);
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.bl-img:focus-within .bl-img-tools {
  opacity: 1;
}

@media (hover: hover) {
  .bl-img:hover .bl-img-tools {
    opacity: 1;
  }
}

@media (hover: none), (pointer: coarse) {
  .bl-img-tools {
    opacity: 1;
  }
}

/* Stufe 13: Diagramme – im Text so breit wie die Spalte, in Tabellen als Karte über dem Raster */
.dg {
  position: relative;
  max-width: 100%;
}

.dg svg {
  display: block;
  max-width: 100%;
  height: auto;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.dg-hit {
  fill: transparent;
}

.dg-hit.is-on {
  fill: var(--accent-soft);
}

.dg-hit-slice.is-on {
  fill: rgb(255 255 255 / 12%);
}

.dg-tip {
  position: absolute;
  z-index: 4;
  min-width: 120px;
  max-width: 260px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-3);
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
  pointer-events: none;
}

.dg-tip-title {
  margin-bottom: 2px;
  color: var(--text-1);
  font-weight: 600;
}

.dg-tip-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  white-space: nowrap;
}

.dg-tip-row strong {
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

.dg-tip-key {
  flex: none;
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.bl-chart {
  margin: var(--s-3) 0;
  white-space: normal;
}

.bl-chart-box {
  margin: 0;
}

.bl-chart:focus-within .bl-img-tools {
  opacity: 1;
}

@media (hover: hover) {
  .bl-chart:hover .bl-img-tools {
    opacity: 1;
  }
}

.blatt-chart-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

.blatt-chart-card {
  position: absolute;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: 0 10px 30px rgb(0 0 0 / 35%);
  pointer-events: auto;
}

.blatt-chart-card.is-dragging {
  opacity: 0.85;
  cursor: grabbing;
}

.blatt-chart-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 32px;
  padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3);
  border-bottom: 1px solid var(--line-1);
  touch-action: none;
}

.blatt-chart-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-1);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blatt-chart-tools {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.blatt-chart-card:hover .blatt-chart-tools,
.blatt-chart-card:focus-within .blatt-chart-tools {
  opacity: 1;
}

@media (hover: none), (pointer: coarse) {
  .blatt-chart-tools {
    opacity: 1;
  }
}

.blatt-chart-missing {
  padding: var(--s-4);
}

/* Schreibmarken und Auswahl der anderen */
.blatt-carets {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.blatt-caret {
  position: absolute;
  width: 2px;
  margin-left: -1px;
  background: var(--peer);
}

.blatt-caret-name {
  position: absolute;
  bottom: 100%;
  left: -1px;
  padding: 0 var(--s-1);
  border-radius: var(--r-xs) var(--r-xs) var(--r-xs) 0;
  background: var(--peer);
  color: var(--accent-text);
  font-size: var(--fs-2xs);
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

.blatt-peer-sel {
  position: absolute;
  background: var(--peer);
  opacity: 0.18;
}

/* ------------------------------------------------------------------ Tabelle */

.blatt-formula {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-5);
  border-bottom: 1px solid var(--line-1);
}

.blatt-cellname {
  min-width: 52px;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.blatt-formula-input {
  flex: 1;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.blatt-grid-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  outline: none;
  overscroll-behavior: contain;
}

.blatt-grid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
}

.blatt-grid col.bh-col {
  width: 48px;
}

.blatt-grid th {
  position: sticky;
  z-index: 2;
  padding: 0 var(--s-2);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.blatt-grid thead th {
  top: 0;
  height: 28px;
  border-right: 1px solid var(--line-1);
  border-bottom: 1px solid var(--line-2);
}

.bh-col-head {
  position: relative;
  cursor: pointer;
}

.bh-resize {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  z-index: 3;
  width: 8px;
  cursor: col-resize;
}

.blatt-grid tbody th {
  left: 0;
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-1);
  text-align: right;
  cursor: pointer;
}

.blatt-grid thead .bh-corner {
  left: 0;
  z-index: 4;
}

/* erste Zeile fixiert: bleibt unter den Spaltenköpfen stehen */
.blatt-grid.freeze-1 tbody tr:first-child > * {
  position: sticky;
  top: 28px;
  z-index: 2;
  background: var(--surface-1);
  box-shadow: inset 0 -1px 0 var(--line-2);
}

.blatt-grid.freeze-1 tbody tr:first-child > th {
  z-index: 3;
  background: var(--surface-2);
}

.blatt-grid td.bc {
  height: 30px;
  padding: 0 var(--s-2);
  overflow: hidden;
  border-right: 1px solid var(--line-1);
  border-bottom: 1px solid var(--line-1);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: cell;
}

.bc.a-r {
  text-align: right;
}

.bc.a-c {
  text-align: center;
}

.bc.is-bold {
  color: var(--text-1);
  font-weight: 650;
}

.bc.is-error {
  color: var(--danger);
  font-size: var(--fs-sm);
}

.blatt-sel {
  position: absolute;
  z-index: 1;
  border: 2px solid var(--accent);
  border-radius: 2px;
  pointer-events: none;
}

.blatt-sel.is-range {
  background: rgb(var(--accent-rgb) / 8%);
}

.blatt-cell-edit {
  position: absolute;
  z-index: 5;
  min-height: 0;
  padding: 0 var(--s-2);
  border: 2px solid var(--accent);
  border-radius: 2px;
  background: var(--surface-1);
  font-family: var(--mono);
  font-size: var(--fs-md);
}

.blatt-peer-cells {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.blatt-peer-cell {
  position: absolute;
  border: 2px solid var(--peer);
  border-radius: 2px;
}

.blatt-peer-cell .blatt-caret-name {
  left: -2px;
}

/* Stufe 4: Zeile, die gerade jemand bearbeitet – schraffiert in seiner Farbe, Zeilenkopf mit Balken */
.blatt-peer-row {
  position: absolute;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--peer) 14%, transparent) 0 6px, transparent 6px 12px);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--peer) 45%, transparent), inset 0 -1px 0 color-mix(in srgb, var(--peer) 45%, transparent);
}

.blatt-grid tbody th.is-locked {
  box-shadow: inset 3px 0 0 var(--peer);
  color: var(--peer);
}

.blatt-link-dialog input {
  margin: var(--s-3) 0 var(--s-4);
}

/* ------------------------------------------------------------------ iPhone und schmale Fenster: Liste oder Dokument */

@media (max-width: 760px) {
  #blatt-root {
    grid-template-columns: minmax(0, 1fr);
  }

  #blatt-root[data-mode="list"] .blatt-main,
  #blatt-root[data-mode="doc"] .blatt-side {
    display: none;
  }

  .blatt-side {
    border-right: 0;
  }

  .blatt-back {
    display: inline-flex;
  }

  .blatt-doc-head {
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
  }

  .blatt-status .blatt-led-text {
    display: none;
  }

  .blatt-toolbar,
  .blatt-formula {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-inline: var(--s-3);
  }

  .blatt-paper {
    padding: var(--s-3) var(--s-2) var(--s-10);
  }

  .blatt-text {
    padding: var(--s-6) var(--s-4);
    font-size: var(--fs-md);
  }
}

/* Fingerziele 44 pt (ADR 0223) */
@media (pointer: coarse) {
  .blatt-grid td.bc {
    height: 40px;
  }

  .blatt-tool,
  .blatt-block {
    min-height: 44px;
  }

  .blatt-tool.icon-button {
    min-width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blatt-led[data-state="verbinde"] {
    animation: none;
  }
}

html.spielmodus .blatt-led[data-state="verbinde"] {
  animation: none;
}

/* Teilen und Versionen (Stufe 2): Schalter, neuer Link, Links, Gäste, Versionen – im breiteren Dialog */
.confirm.blatt-dialog {
  width: min(620px, calc(100% - 32px));
}

/* Stufe 4: Versionsverlauf – links der Stand, rechts die Zeitleiste; am Handy untereinander */
.confirm.blatt-dialog.blatt-history-dialog {
  width: min(1180px, calc(100% - 32px));
}

.blatt-history-dialog .blatt-dialog-body {
  max-height: none;
  overflow: visible;
}

.blatt-history {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--s-4);
  height: min(72vh, 780px);
}

.blatt-dialog-body .blatt-history-view,
.blatt-dialog-body .blatt-history-side {
  gap: var(--s-2);
  min-width: 0;
  min-height: 0;
}

.blatt-history-bar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
  min-height: 44px;
}

.blatt-history-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.blatt-history-actions,
.blatt-history-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.blatt-history-form {
  width: 100%;
}

.blatt-history-form input {
  flex: 1 1 220px;
  min-width: 0;
}

.blatt-history-doc {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--bg-sunken);
}

.blatt-history-doc .blatt-paper {
  padding: var(--s-4);
}

.blatt-history-doc .blatt-text {
  min-height: 0;
  padding: var(--s-6) var(--s-8);
}

.blatt-history-empty {
  margin: auto;
}

.blatt-history-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.blatt-dialog-body .blatt-history-day {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--s-3) var(--s-2) var(--s-1);
  background: var(--surface-1);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.blatt-history-entry {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s-3);
  width: 100%;
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  text-align: left;
}

.blatt-history-entry[aria-selected="true"] {
  border-color: rgb(var(--accent-rgb) / 40%);
  background: rgb(var(--accent-rgb) / 10%);
  color: var(--text-1);
}

@media (hover: hover) {
  .blatt-history-entry:hover {
    background: var(--surface-2);
  }
}

.blatt-history-entry.is-named strong {
  color: var(--accent);
}

.blatt-history-dot {
  display: grid;
  flex: none;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--peer, transparent);
  color: var(--text-3);
}

.blatt-history-entry-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.blatt-history-entry-text > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blatt-history-foot {
  flex: none;
}

/* geänderte Zeilen und Zellen in der Vorschau: in der Farbe dessen, der sie geändert hat */
.blatt-text > .is-changed {
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--peer) 16%, transparent);
  box-shadow: -6px 0 0 color-mix(in srgb, var(--peer) 16%, transparent), -9px 0 0 var(--peer);
}

.blatt-grid td.bc.is-changed {
  background: color-mix(in srgb, var(--peer) 20%, transparent);
  box-shadow: inset 0 0 0 1px var(--peer);
}

@media (max-width: 760px) {
  .blatt-history {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 40%);
    height: min(78vh, 900px);
  }
}

.blatt-dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  max-height: min(64vh, 640px);
  overflow-y: auto;
}

.blatt-dialog-body section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.blatt-dialog-body h3 {
  margin: 0;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.blatt-dialog-body p {
  margin: 0;
}

.blatt-dialog-body > button {
  align-self: flex-start;
}

.blatt-share-gate-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

.blatt-share-gate-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.blatt-share-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.blatt-seg {
  display: inline-flex;
  gap: 2px;
}

.blatt-share-label {
  flex: 1 1 160px;
  min-width: 0;
}

.blatt-share-result {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
}

.blatt-share-url-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.blatt-share-url {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: var(--fs-xs);
}

.blatt-share-warn {
  color: var(--warn);
}

.blatt-share-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.blatt-share-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.blatt-share-row[data-active="false"] {
  opacity: 0.6;
}

.blatt-share-row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.blatt-share-row-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .blatt-share-gate-row {
    flex-wrap: wrap;
  }

  .blatt-share-url-row {
    flex-wrap: wrap;
  }
}

.blatt-share-form select {
  width: auto;
}

/* Stufe 7: VEYRA für Gäste je Link – Umschalter im Formular und in jeder Zeile, darunter kurz, was das heißt */
.blatt-share-veyra {
  white-space: nowrap;
}

.blatt-share-veyra-note {
  margin: var(--s-2) 0 0;
}

/* VEYRA im Dokument (Stufe 3): Leiste unten über dem Dokument – Auftrag, Vorschläge, Vorschau, Übernehmen */
/* VEYRA im Dokument: vorne in der Leiste, gefüllt in der Akzentfarbe und mit Namen – auch am iPhone sofort zu sehen */
.blatt-assist-button {
  gap: var(--s-2);
  padding: 0 var(--s-3);
  font-size: var(--fs-sm);
  font-weight: 650;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.blatt-assist {
  position: absolute;
  bottom: var(--s-4);
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  width: min(760px, calc(100% - 32px));
  max-height: min(72%, 640px);
  padding: var(--s-4);
  overflow-y: auto;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-xl);
  background: var(--surface-2);
  box-shadow: var(--shadow-3);
  translate: -50% 0;
  animation: toast-in 320ms var(--spring);
}

.blatt-assist-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.blatt-assist-head .icon {
  color: var(--accent);
}

.blatt-assist-head .icon-button {
  margin-left: auto;
}

.blatt-assist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.blatt-assist-ask {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
}

.blatt-assist-input {
  flex: 1;
  min-width: 0;
  min-height: var(--btn-h-m);
  max-height: 160px;
  resize: none;
}

.blatt-assist-result {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.blatt-assist-result p {
  margin: 0;
}

.blatt-assist-answer {
  white-space: pre-wrap;
}

.blatt-assist-error {
  color: var(--warn);
}

/* Stufe 5: live dabei – was VEYRA gerade tut, der Vorschlag wächst mit, Abbrechen */
.blatt-assist-steps {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
}

.blatt-assist-steps li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-3);
}

.blatt-assist-steps li::before {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--line-2);
  content: "";
}

.blatt-assist-steps li.is-done::before {
  background: var(--accent-line);
}

.blatt-assist-steps li.is-active {
  color: var(--text-1);
}

.blatt-assist-steps li.is-active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: blatt-blink 1.2s ease-in-out infinite;
}

.blatt-assist-live:empty {
  display: none;
}

.blatt-assist-answer.is-live::after,
.blatt-assist-preview.is-live .blatt-text > :last-child::after {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blatt-blink 1s steps(2) infinite;
  content: "";
}

.blatt-assist-stopped {
  margin: 0;
}

/* VEYRA unter den Anwesenden: ihr Funke statt eines Buchstabens */
.blatt-peer.is-veyra {
  color: var(--accent-text);
}

/* Bereich anderer in der Tabelle (VEYRA liest oder schreibt hier) */
.blatt-peer-range {
  position: absolute;
  border: 1px dashed var(--peer);
  border-radius: 2px;
  background: color-mix(in srgb, var(--peer) 10%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .blatt-assist-steps li.is-active::before,
  .blatt-assist-answer.is-live::after,
  .blatt-assist-preview.is-live .blatt-text > :last-child::after {
    animation: none;
  }
}

.blatt-assist-preview {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--bg-sunken);
}

.blatt-assist-preview .blatt-editor {
  min-height: 0;
}

/* die Vorschau ist der Editor selbst, nur ohne Papier: kompakt und lesbar */
.blatt-assist-preview .blatt-paper {
  padding: 0;
  overflow: visible;
}

.blatt-assist-preview .blatt-text {
  max-width: none;
  min-height: 0;
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: var(--fs-md);
}

.blatt-assist-cells {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.blatt-assist-cells th,
.blatt-assist-cells td {
  padding: var(--s-1) var(--s-2);
  border-bottom: 1px solid var(--line-1);
  text-align: left;
  font-family: var(--mono);
}

.blatt-assist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

@media (max-width: 640px) {
  .blatt-assist {
    bottom: 0;
    width: 100%;
    max-height: 80%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
}


/* Stufe 10: Kommentare – Leiste rechts neben dem Dokument (am Handy darüber), Stellen im Text hell hinterlegt, Zellen mit
   einer Ecke; die Taste im Kopf zählt die offenen Fäden */
.blatt-doc-body.has-comments {
  flex-direction: row;
}

/* neben Inhalt oder Kommentaren darf der Editor schmaler werden – eine breite Tabelle scrollt in sich, nie die Seite */
.blatt-doc-body.has-comments > .blatt-editor,
.blatt-doc-body.has-toc > .blatt-editor {
  min-width: 0;
}

.blatt-comments {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: var(--s-3);
  width: 320px;
  min-height: 0;
  padding: var(--s-3) var(--s-3) var(--s-6);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line-1);
  background: var(--surface-1);
}

.blatt-comments-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.blatt-comments-head h3 {
  flex: 1;
  margin: 0;
  font-size: var(--fs-md);
}

.blatt-comments-add {
  align-self: flex-start;
}

.blatt-comments-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.blatt-thread {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
}

.blatt-thread.is-active {
  border-color: var(--warn);
}

.blatt-thread.is-done {
  opacity: 0.72;
}

.blatt-thread-ref {
  align-self: flex-start;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: var(--fs-xs);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.blatt-thread-ref:disabled,
.blatt-thread-ref.is-static {
  cursor: default;
}

@media (hover: hover) {
  .blatt-thread-ref:not(:disabled):hover {
    color: var(--text-1);
  }
}

.blatt-comment {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.blatt-comment.is-reply {
  padding-left: var(--s-3);
  border-left: 2px solid var(--line-2);
}

.blatt-comment-meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.blatt-comment-meta strong {
  overflow: hidden;
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blatt-comment-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--peer);
}

.blatt-comment-tools {
  display: flex;
  margin-left: auto;
}

.blatt-comment-body {
  margin: 0;
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.blatt-thread-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-2);
}

.blatt-thread-foot textarea,
.blatt-comment-draft textarea,
.blatt-comment textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
}

.blatt-comment-draft {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--warn-soft);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.blatt-comment-actions {
  display: flex;
  gap: var(--s-2);
}

.blatt-thread-done {
  margin: 0;
}

.blatt-comment-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.blatt-comment-mark {
  position: absolute;
  border-bottom: 2px solid var(--warn);
  background: var(--warn-soft);
}

.blatt-comment-mark.is-active {
  background: color-mix(in srgb, var(--warn) 32%, transparent);
}

.blatt-grid td.bc.has-comment {
  position: relative;
}

.blatt-grid td.bc.has-comment::after {
  position: absolute;
  top: 0;
  right: 0;
  border-top: 8px solid var(--warn);
  border-left: 8px solid transparent;
  content: "";
  pointer-events: none;
}

.blatt-grid td.bc.is-comment-active {
  box-shadow: inset 0 0 0 2px var(--warn);
}

.blatt-comment-toggle {
  position: relative;
}

.blatt-count {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--warn);
  color: var(--bg-sunken);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

@media (max-width: 760px) {
  .blatt-comments {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    width: min(340px, 90vw);
    border-left: 1px solid var(--line-2);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 35%);
  }
}

/* Stufe 11: Import – Datei auf die Liste ziehen, Blätter einer Excel-Mappe wählen */
.blatt-side.is-drop {
  outline: 2px dashed var(--accent-line);
  outline-offset: -6px;
  background: var(--accent-soft);
}

.blatt-import-sheets {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  max-height: 50vh;
  overflow-y: auto;
}

.blatt-import-sheet {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2);
  border-radius: var(--r-md);
  cursor: pointer;
}

@media (hover: hover) {
  .blatt-import-sheet:hover {
    background: var(--surface-2);
  }
}

/* Stufe 9: Druckansicht (blatt-druck.js) – auf dem Schirm unsichtbar; beim Drucken das Einzige auf der Seite. A4 hoch,
   breite Tabellen quer (benannte Seite). Farben fest auf Papier, unabhängig vom Farbschema der Oberfläche. */
#blatt-druck {
  display: none;
}

@page {
  size: A4;
  margin: 16mm 14mm;
}

@page blatt-quer {
  size: A4 landscape;
  margin: 12mm;
}

@media print {
  html,
  body {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body > :not(#blatt-druck) {
    display: none !important;
  }

  #blatt-druck {
    display: block;
    color: #161616;
    font: 11pt/1.45 var(--sans, system-ui), system-ui, sans-serif;
  }

  #blatt-druck.quer {
    page: blatt-quer;
  }

  #blatt-druck h1,
  #blatt-druck h2,
  #blatt-druck h3 {
    margin: 14pt 0 6pt;
    line-height: 1.2;
    break-after: avoid;
  }

  #blatt-druck h1 {
    font-size: 20pt;
  }

  #blatt-druck h2 {
    font-size: 15pt;
  }

  #blatt-druck h3 {
    font-size: 12.5pt;
  }

  #blatt-druck > :first-child {
    margin-top: 0;
  }

  #blatt-druck p {
    margin: 0 0 6pt;
    orphans: 3;
    widows: 3;
  }

  #blatt-druck .druck-li {
    display: flex;
    gap: 6pt;
    margin: 0 0 3pt calc(var(--ebene, 0) * 16pt + 4pt);
    break-inside: avoid;
  }

  #blatt-druck .druck-marke {
    flex: none;
    min-width: 12pt;
    text-align: right;
  }

  #blatt-druck .druck-todo.erledigt .druck-li-text {
    color: #6b6b6b;
    text-decoration: line-through;
  }

  #blatt-druck blockquote {
    margin: 0 0 6pt;
    padding-left: 10pt;
    border-left: 2pt solid #9a9a9a;
    color: #444;
    font-style: italic;
  }

  #blatt-druck pre {
    margin: 0 0 8pt;
    padding: 6pt 8pt;
    background: #f3f3f3;
    border-radius: 3pt;
    font: 9.5pt/1.4 var(--mono, ui-monospace), ui-monospace, monospace;
    white-space: pre-wrap;
    break-inside: avoid;
  }

  #blatt-druck code {
    padding: 0 2pt;
    background: #f3f3f3;
    font-family: var(--mono, ui-monospace), ui-monospace, monospace;
  }

  #blatt-druck mark {
    background: #fff1a6;
    color: inherit;
  }

  #blatt-druck a {
    color: #0b57d0;
    text-decoration: underline;
  }

  #blatt-druck hr {
    margin: 10pt 0;
    border: 0;
    border-top: 1pt solid #9a9a9a;
  }

  /* Stufe 12: Bild – nie über eine Seite getrennt, höchstens die Spalte breit und eine Seite hoch */
  #blatt-druck .druck-bild {
    max-width: 100%;
    margin: 6pt 0 10pt;
    break-inside: avoid;
  }

  #blatt-druck .druck-bild img {
    display: block;
    max-width: 100%;
    max-height: 240mm;
    height: auto;
    object-fit: contain;
  }

  #blatt-druck .druck-bild[style] img {
    width: 100%;
  }

  #blatt-druck .druck-bild-fehlt {
    color: #555;
    font-style: italic;
  }

  /* Stufe 13: Diagramm in Papierfarben, nie getrennt; Hinweis und Zeiger-Flächen gibt es auf Papier nicht */
  #blatt-druck .druck-diagramm {
    margin: 6pt 0 12pt;
    break-inside: avoid;
  }

  #blatt-druck .druck-diagramm svg {
    display: block;
    max-width: 100%;
    height: auto;
  }

  #blatt-druck .dg-tip,
  #blatt-druck .dg-hit {
    display: none;
  }

  #blatt-druck table {
    margin: 4pt 0 10pt;
    border-collapse: collapse;
  }

  #blatt-druck .druck-tabelle {
    width: 100%;
  }

  #blatt-druck th,
  #blatt-druck td {
    padding: 3pt 5pt;
    border: 0.5pt solid #b8b8b8;
    vertical-align: top;
    text-align: left;
  }

  #blatt-druck th {
    background: #f1f1f1;
    color: #161616;
    font-size: inherit;
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
  }

  #blatt-druck tr {
    break-inside: avoid;
  }

  #blatt-druck thead {
    display: table-header-group;
  }

  #blatt-druck .druck-blatt {
    table-layout: fixed;
    font-size: 9pt;
  }

  #blatt-druck .druck-blatt td,
  #blatt-druck .druck-blatt th {
    overflow: hidden;
    white-space: nowrap;
  }

  /* leere Zeilen behalten ihre Höhe wie im Editor */
  #blatt-druck .druck-blatt td:empty::before,
  #blatt-druck .druck-blatt th:empty::before {
    content: "\a0";
  }

  #blatt-druck .druck-blatt [data-align="r"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  #blatt-druck .druck-blatt [data-align="c"] {
    text-align: center;
  }

  #blatt-druck .druck-blatt .fett {
    font-weight: 700;
  }

  #blatt-druck .druck-blatt .fehler {
    color: #b3261e;
  }
}

/* ================================================================== Teilen-Seite (blatt-teilen.css) */
/*
 * Blatt (ADR 0231 §7, Stufe 2): die Teilen-Seite für Gäste. Der Server setzt dieses Stylesheet hinter die Abschnitte von
 * style.css, die die Seite braucht (Tokens, Grundlagen, Tasten, Eingaben, Bausteine, Bewegung, Dialoge, Blatt) – hier
 * steht nur der Rahmen um den Editor, das Beitreten und die Meldungen. Nur Tokens.
 */

html,
body.teilen {
  height: 100%;
}

body.teilen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
}

.teilen-root {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.teilen-noscript {
  margin: var(--s-8) var(--s-4);
  color: var(--text-2);
  text-align: center;
}

.teilen-center {
  display: grid;
  flex: 1;
  place-items: center;
  padding: var(--s-6) var(--s-4);
}

.teilen-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  width: min(440px, 100%);
  padding: var(--s-6);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
}

.teilen-card h1 {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.25;
}

.teilen-card p {
  margin: 0;
}

.teilen-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.teilen-message-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
}

.teilen-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.teilen-label {
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.teilen-error {
  color: var(--danger);
  font-size: var(--fs-sm);
}

.teilen-privacy {
  line-height: 1.5;
}

.teilen-foot {
  display: flex;
  justify-content: center;
}

/* Offenes Dokument: Kopf oben, Editor füllt den Rest */
.teilen-doc {
  /* Stufe 7: die Leiste „VEYRA fragen“ schwebt am unteren Rand */
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.teilen-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-1) var(--s-2);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.teilen-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teilen-readonly {
  flex: none;
}

/* Handy: Kopf in zwei Zeilen, Abgleich ohne Text */
@media (max-width: 640px) {
  .teilen-head {
    flex-wrap: wrap;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
  }

  .teilen-title {
    flex: 1 1 100%;
    order: -1;
  }

  .teilen-head .blatt-led-text {
    display: none;
  }

  .teilen-card {
    padding: var(--s-5);
  }
}
