/* Nora: one history, one manual speaking control. Use the shared app palette. */
dialog.blatt.erzaehlen-blatt,
body.nw dialog.blatt.erzaehlen-blatt {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--karte, Canvas);
  color: var(--tinte, CanvasText);
  box-shadow: none;
  transition: none;
}
.erzaehlen-blatt[open] { animation: none; }
.erzaehlen-blatt::backdrop { background: var(--karte, Canvas); backdrop-filter: none; }
.erzaehlen-innen {
  height: 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--tinte, CanvasText);
  background: var(--karte, Canvas);
}
.erzaehlen-innen [hidden] { display: none !important; }
.erzaehlen-innen :is(h2, h3, p) { margin: 0; }
.erzaehlen-innen p { line-height: 1.55; overflow-wrap: anywhere; }
.erzaehlen-innen button {
  font: inherit;
  min-height: 44px;
  max-width: 100%;
  white-space: normal;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.erzaehlen-innen button:disabled { cursor: default; }

/* Header and messages share a quiet, readable desktop column. */
.erzaehlen-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  padding: max(16px, env(safe-area-inset-top)) max(24px, calc((100% - 960px)/2), env(safe-area-inset-right)) 16px max(24px, calc((100% - 960px)/2), env(safe-area-inset-left));
  border-bottom: 1px solid var(--linie, #888);
}
.erzaehlen-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.erzaehlen-person img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
.erzaehlen-person h2 { font-size: 1.1rem; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; }
.erzaehlen-person p { font-size: .75rem; color: var(--tinte-2, currentColor); margin-top: 3px; }
.erzaehlen-blatt .erzaehlen-kopf .erzaehlen-schliessen {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--tinte-2, currentColor);
}
.erzaehlen-schliessen .erzaehlen-icon,
.erzaehlen-schliessen svg { display: block; width: 20px; height: 20px; }

.erzaehlen-gespraech { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }
.erzaehlen-verlauf {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 32px max(24px, calc((100% - 960px)/2), env(safe-area-inset-right)) 32px max(24px, calc((100% - 960px)/2), env(safe-area-inset-left));
  scrollbar-gutter: stable;
}
.erzaehlen-beitrag {
  box-sizing: border-box;
  max-width: min(85%, 680px);
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid var(--linie, #888);
  border-radius: 16px 16px 16px 4px;
  align-self: flex-start;
  background: var(--karte, Canvas);
  color: var(--tinte, CanvasText);
  overflow-wrap: anywhere;
}
.erzaehlen-beitrag[data-sprecher=du] {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  background: var(--flaeche, Canvas);
}
.erzaehlen-beitrag[data-aktiv=true] { border-color: var(--linie-2, currentColor); }
.erzaehlen-beitrag-kopf { margin-bottom: 7px; min-width: 0; }
.erzaehlen-beitrag-kopf strong { font-size: .75rem; font-weight: 650; color: var(--tinte-2, currentColor); overflow-wrap: anywhere; }
.erzaehlen-beitrag p { white-space: pre-wrap; font-size: 1rem; line-height: 1.65; }
.erzaehlen-aelter,
.erzaehlen-neu { align-self: center; flex-shrink: 0; font-size: .78rem; padding: 5px 14px; margin: 2px 12px; color: var(--tinte-2, currentColor); }

/* Fixed control size: recording waves never move the icon or label. */
.erzaehlen-steuerung {
  box-sizing: border-box;
  flex-shrink: 0;
  display: grid;
  gap: 12px;
  max-height: 58dvh;
  overflow: auto;
  padding: 20px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--linie, #888);
  background: var(--karte, Canvas);
  text-align: center;
}
.erzaehlen-zustand { min-width: 0; max-width: 680px; justify-self: center; }
.erzaehlen-zustand:has([data-phase-detail][hidden]) { display: none; }
.erzaehlen-zustand [data-phase-detail] { font-size: .82rem; color: var(--tinte-2, currentColor); }
.erzaehlen-aktionen { display: flex; align-items: center; justify-content: center; min-width: 0; width: 100%; }
.erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 8px;
  width: clamp(132px, 8.25rem, 240px);
  height: clamp(132px, 8.25rem, 240px);
  max-width: 100%;
  min-height: 132px;
  padding: 18px 12px 28px;
  border: 1px solid var(--tinte, CanvasText);
  border-radius: 50% !important;
  background: var(--tinte, CanvasText);
  color: var(--karte, Canvas);
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.25;
  transition: background-color .18s, color .18s, border-color .18s, transform .15s;
}
.erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion:disabled {
  background: var(--flaeche, Canvas);
  color: var(--tinte, CanvasText);
  border-color: var(--linie, #888);
  opacity: 1;
}
.erzaehlen-hauptaktion .erzaehlen-icon { display: flex; align-items: center; justify-content: center; flex: none; }
.erzaehlen-hauptaktion .erzaehlen-icon svg { display: block; width: clamp(28px, 1.8rem, 42px); height: clamp(28px, 1.8rem, 42px); }
.erzaehlen-hauptaktion [data-hauptlabel] { max-width: 100%; overflow-wrap: anywhere; }
.erzaehlen-blatt[data-phase=zuhoeren] .erzaehlen-hauptaktion { outline: 2px solid var(--tinte, CanvasText); outline-offset: 4px; }
.erzaehlen-hauptaktion .erzaehlen-wave {
  position: absolute;
  bottom: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 18px;
  gap: 2px;
  overflow: hidden;
  color: inherit;
  pointer-events: none;
}
.erzaehlen-wave > span { display: block; flex: 0 0 2px; height: 18px; border-radius: 2px; background: currentColor; transform: scaleY(.03846); transform-origin: center; will-change: transform; }
.erzaehlen-hauptaktion[aria-busy=true] .erzaehlen-icon { animation: nora-status-pulse 1.4s ease-in-out infinite; }
@keyframes nora-status-pulse { 50% { opacity: .4; } }
.erzaehlen-innen .erzaehlen-hinweis { font-size: .78rem; line-height: 1.5; }
.erzaehlen-gespraech > .erzaehlen-hinweis { flex-shrink: 0; padding: 5px 16px; text-align: center; }
.erzaehlen-hinweis:empty { display: none; }
.erzaehlen-innen button:focus-visible,
.erzaehlen-verlauf:focus-visible { outline: 2px solid var(--sw-focus, currentColor); outline-offset: 4px; scroll-margin-block: 10px; }
.erzaehlen-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Shared book-workshop question excerpt, outside the conversation dialog. */
.ghostwriter-rueckfrage { border-left: 3px solid var(--tinte, #333); padding: 3px 0 3px 12px; min-width: 0; }
.ghostwriter-rueckfrage h3 { font: inherit; font-size: .75rem; font-weight: 600; margin: 0 0 6px; }
.ghostwriter-rueckfrage p { line-height: 1.55; overflow-wrap: anywhere; white-space: pre-line; margin: 0; }

@media (hover: hover) {
  .erzaehlen-blatt .erzaehlen-kopf .erzaehlen-schliessen:hover { background: var(--flaeche, Canvas); color: var(--tinte, CanvasText); }
  .erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion:not(:disabled):hover { background: var(--gw-weiss-hover, var(--tinte, CanvasText)); color: var(--karte, Canvas); }
}
.erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion:not(:disabled):active { transform: scale(.97); }
@media (max-width: 480px) {
  .erzaehlen-kopf { gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  .erzaehlen-person { gap: 10px; }
  .erzaehlen-person img { width: 38px; height: 38px; }
  .erzaehlen-person p { font-size: .7rem; }
  .erzaehlen-verlauf { gap: 16px; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
  .erzaehlen-beitrag { max-width: 94%; padding: 13px 15px; }
  .erzaehlen-beitrag p { font-size: .96rem; }
  .erzaehlen-steuerung { padding-top: 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
@media (max-height: 480px) and (min-width: 481px) {
  .erzaehlen-kopf { padding-block: max(8px, env(safe-area-inset-top)) 8px; }
  .erzaehlen-steuerung { padding-block: 10px max(12px, env(safe-area-inset-bottom)); }
  .erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion { width: 108px; height: 108px; min-height: 108px; padding-block: 12px 22px; gap: 5px; }
  .erzaehlen-hauptaktion .erzaehlen-wave { bottom: 10px; height: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .erzaehlen-blatt .erzaehlen-innen .erzaehlen-hauptaktion { transition: none; }
  .erzaehlen-hauptaktion[aria-busy=true] .erzaehlen-icon { animation: none; }
}

/* Recovery controls exist only for explicitly rejected or separately retained originals. */
.erzaehlen-blatt [hidden] { display: none !important; }
.erzaehlen-wiederherstellung { min-width: 0; width: 100%; max-width: 680px; justify-self: center; text-align: left; }
.erzaehlen-wiederherstellung h3 { margin: 0 0 12px; font-size: 1.05rem; }
.erzaehlen-wiederherstellung p { font-size: .82rem; line-height: 1.5; overflow-wrap: anywhere; }
.erzaehlen-wiederherstellung [role=status]:empty { display: none; }
.erzaehlen-rettungsliste { padding-left: 1.15rem; }
.erzaehlen-rettungsliste li { padding-block: 8px; min-width: 0; }
.erzaehlen-rettungsliste a { display: block; width: fit-content; max-width: 100%; padding-block: 9px; font-size: .82rem; overflow-wrap: anywhere; text-decoration: underline; }
.erzaehlen-rettungsaktionen { display: flex; flex-wrap: wrap; gap: 10px; }
.erzaehlen-rettungsaktionen button { min-height: 44px; white-space: normal; overflow-wrap: anywhere; text-align: left; font-size: .82rem; }
.erzaehlen-aufbewahrt { justify-self: center; max-width: 100%; min-height: 44px; font-size: .78rem; white-space: normal; }

/* Vor der Eingabe erreichbar, auch bei geringer Displayhöhe. */
.buch-datenschutzhinweis { min-width: 0; max-width: 680px; font-size: .82rem; line-height: 1.55; overflow-wrap: anywhere; }
.buch-datenschutzhinweis p { margin: 0 0 8px; }
.buch-datenschutzhinweis a { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; color: inherit; text-underline-offset: 3px; }
.erzaehlen-datenschutz { flex: 0 0 auto; min-height: 44px; max-height: min(30dvh, 230px); overflow: auto; padding-inline: max(16px, calc((100% - 960px)/2)); border-bottom: 1px solid var(--linie, #888); }
.erzaehlen-datenschutz summary { box-sizing: border-box; min-height: 44px; padding-block: 12px; font-size: .78rem; cursor: pointer; }
.erzaehlen-datenschutz .buch-datenschutzhinweis { padding-bottom: 8px; }
.erzaehlen-datenschutz :is(summary,a):focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }

.erzaehlen-textbereich {
  width: min(100%, 680px);
  min-width: 0;
  justify-self: center;
  text-align: left;
}
.erzaehlen-textbereich > summary {
  width: fit-content;
  margin-inline: auto;
  min-height: 44px;
  padding: 12px;
  box-sizing: border-box;
  cursor: pointer;
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.erzaehlen-textformular {
  display: grid;
  gap: 10px;
  padding-top: 6px;
}
.erzaehlen-textformular label { font-size: .85rem; font-weight: 600; }
.erzaehlen-textformular textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 90px;
  max-height: 24dvh;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--linie, #888);
  border-radius: 8px;
  background: var(--flaeche, Canvas);
  color: var(--tinte, CanvasText);
  font: inherit;
  line-height: 1.5;
}
.erzaehlen-textformular button { justify-self: end; }
.erzaehlen-textformular [data-textfehler]:empty { display: none; }
