/* ============================================================
   EXTENSIONS beyond tonarchiv.css — implementing components the
   owner's design system defines (Pocket Notes Design System.dc.html):
   Zitat-Pille, Gleichlauf-Vertrag, Sprecherzettel, Hermes-Ablage,
   Lösch-Dialog, Verarbeitung & Laden. tonarchiv.css stays untouched.
   ============================================================ */

/* ---- Zitat-Pille: inline in answer text; vermilion = cited ------------- */
.cite-pill {
  display: inline-flex; align-items: baseline; gap: 5px;
  border: 1.5px solid var(--vermilion);
  color: var(--vermilion);
  background: var(--vermilion-soft);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding: 1px 8px 2px;
  border-radius: 3px;
  vertical-align: baseline;
  white-space: nowrap;
  transition: all .12s ease;
}
.cite-pill:hover { background: var(--vermilion); color: var(--sheet); }
.cite-pill.ink { border-color: var(--ink); color: var(--ink); background: transparent; }
.cite-pill.ink:hover { background: var(--ink); color: var(--sheet); }

/* ---- Gleichlauf-Vertrag: running script row --------------------------- */
/* Room between the 3px playing mark and the timestamp (tonarchiv rows only
   carry 4px side padding). */
.script-row { padding-left: 14px; }
.script-row.is-playing {
  background: var(--vermilion-soft);
  box-shadow: inset 3px 0 0 var(--vermilion);
}
.script-row.is-playing .sr-time { color: var(--vermilion); }

/* ---- Sprecherzettel ---------------------------------------------------- */
.speaker-zettel {
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(31, 27, 22, 0.20);
  padding: 18px;
  margin-top: 10px;
  max-width: 340px;
  /* The popover sits inside the coloured .sr-speaker cell — reset the
     inherited display styles so it reads as a plain paper sheet. */
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  text-align: left;
  cursor: auto;
}
.zettel-title {
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-40); margin-bottom: 12px;
}
.zettel-person {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left;
  border: none; background: none;
  font-size: 13.5px; font-weight: 600;
  padding: 8px 6px;
  border-bottom: 1px solid var(--hairline);
  transition: background .12s ease;
}
.zettel-person:hover { background: var(--vermilion-soft); }
.zettel-person .check { color: var(--vermilion); font-weight: 700; }
.zettel-add {
  display: flex; gap: 8px; align-items: center; margin-top: 10px;
}
.zettel-add input {
  flex: 1; border: none; border-bottom: 1.5px dashed var(--rule);
  background: transparent; outline: none;
  font-family: var(--mono); font-size: 11.5px; padding: 5px 2px;
  color: var(--ink);
}
.zettel-add input:focus { border-bottom-color: var(--vermilion); }

/* ---- Hermes-Ablage ----------------------------------------------------- */
.hermes-pill {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--teal);
  border: 1.5px solid var(--teal); border-radius: 3px;
  padding: 3px 9px; white-space: nowrap;
}
.hermes-entry { padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.hermes-entry:last-of-type { border-bottom: none; }
.hermes-q-head {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-40);
}
.hermes-x {
  border: none; background: none; margin-left: auto;
  font-size: 12px; color: var(--ink-40); padding: 2px 6px;
}
.hermes-x:hover { color: var(--stamp-red); }
.hermes-question {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  margin: 4px 0 10px; letter-spacing: -0.01em;
}
.hermes-answer { font-size: 14.5px; max-width: 74ch; line-height: 1.7; }
.hermes-answer .cite-pill { margin: 0 2px; }
.hermes-ask { margin-top: 18px; display: flex; gap: 12px; flex-wrap: wrap; }
.hermes-ask input {
  flex: 1; min-width: 240px;
  border: 1.5px solid var(--ink); background: var(--sheet);
  padding: 10px 12px; font-size: 14px; outline: none;
}
.hermes-ask input:focus { box-shadow: 3px 3px 0 var(--vermilion); }
.hermes-hint {
  width: 100%; display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-40);
}
.hermes-suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Trigger: fixed 24px from bottom-right; page keeps foot padding free. */
.hermes-trigger {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  text-decoration: none;
}
body.has-hermes .foot { margin-bottom: 96px; }

/* ---- Lösch-Dialog ------------------------------------------------------ */
dialog.confirm {
  /* The stylesheet's global margin reset would pin the dialog to the top
     left — restore the native centering. */
  margin: auto;
  border: 1.5px solid var(--ink);
  background: var(--sheet);
  box-shadow: 8px 8px 0 rgba(31, 27, 22, 0.22);
  padding: 26px 30px;
  max-width: 420px;
}
dialog.confirm::backdrop { background: rgba(31, 27, 22, 0.35); }
dialog.confirm h3 { font-family: var(--serif); font-size: 22px; margin-bottom: 8px; }
dialog.confirm p { color: var(--ink-60); font-size: 14px; margin-bottom: 20px; }
dialog.confirm .actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-red {
  background: var(--stamp-red); color: var(--sheet);
  border: 1.5px solid var(--stamp-red);
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 9px 16px;
}
.btn-red:hover { background: #8F1E17; border-color: #8F1E17; }

/* ---- Verarbeitung & Laden ---------------------------------------------- */
@keyframes tickshim { 0% { background-position: -320px 0 } 100% { background-position: 320px 0 } }
.skeleton {
  height: 14px; background: var(--sheet-deep);
  background-image: linear-gradient(90deg, transparent, rgba(251,248,241,.8), transparent);
  background-size: 320px 100%;
  animation: tickshim 1.4s linear infinite;
}
.stamp.processing { animation: recpulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .skeleton, .stamp.processing { animation: none; } }

/* ---- Live region (visually hidden) ------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Floating Hermes-Zettel (Pocket-Notes-Bogen, not a messenger) ------ */
.hermes-zettel {
  position: fixed; right: 24px; bottom: 84px; z-index: 50;
  width: min(400px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  display: none; flex-direction: column;
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(31, 27, 22, 0.22);
}
.hermes-zettel.open { display: flex; }
.hz-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 3px double var(--rule);
}
.hz-head .hz-title { font-family: var(--serif); font-size: 18px; font-weight: 700; }
.hz-close {
  border: none; background: none; margin-left: auto;
  font-size: 14px; color: var(--ink-40); padding: 2px 6px; cursor: pointer;
}
.hz-close:hover { color: var(--ink); }
.hz-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.hz-body .hermes-question { font-size: 15px; margin: 0 0 8px; }
.hz-body .hermes-answer { font-size: 13.5px; }
.hz-status {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-60);
  padding: 8px 0;
}
.hz-status .hz-stop {
  border: 1.5px solid var(--ink); background: none; cursor: pointer;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 10px; margin-left: auto;
}
.hz-status .hz-stop:hover { background: var(--ink); color: var(--sheet); }
@keyframes hz-dots { 0%, 20% { content: "·" } 40% { content: "··" } 60%, 100% { content: "···" } }
.hz-working::after { content: "···"; animation: hz-dots 1.2s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .hz-working::after { animation: none; } }
.hz-error {
  border-left: 3px solid var(--stamp-red);
  background: rgba(179, 38, 30, 0.06);
  padding: 9px 12px; font-size: 13px; color: var(--ink-60);
  margin: 8px 0;
}
.hz-error .hz-retry {
  border: none; background: none; cursor: pointer; padding: 0;
  color: var(--vermilion); font-size: 13px; text-decoration: underline;
}
.hz-saved {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--teal); padding: 6px 0 0;
}
.hz-saved a { color: var(--teal); }
.hz-ask { padding: 12px 16px 14px; border-top: 1px solid var(--hairline); }
.hz-ask textarea {
  width: 100%; resize: none; min-height: 52px;
  border: 1.5px solid var(--ink); background: var(--sheet);
  padding: 9px 11px; font-size: 14px; font-family: inherit; outline: none;
}
.hz-ask textarea:focus { box-shadow: 3px 3px 0 var(--vermilion); }
.hz-ask .hermes-hint { margin-top: 6px; }
.hz-suggestions { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 8px; }
.hz-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.hermes-trigger { cursor: pointer; }
@media (max-width: 480px) {
  .hermes-zettel { right: 8px; bottom: 76px; }
}

/* ---- Toast: confirmations app-wide (saved, sent, deleted) --------------- */
.toast {
  position: fixed; left: 24px; bottom: 24px; z-index: 60;
  background: var(--ink); color: var(--sheet);
  padding: 12px 18px;
  box-shadow: 6px 6px 0 rgba(31, 27, 22, 0.25);
  font-size: 13.5px;
  display: none;
}
.toast.visible { display: block; animation: toast-in .18s ease; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .toast.visible { animation: none; } }

/* ---- Widerruf: 8 seconds undo after confirmed delete ------------------- */
.undo-toast {
  position: fixed; left: 24px; bottom: 24px; z-index: 60;
  display: none; align-items: center; gap: 14px;
  background: var(--ink); color: var(--sheet);
  padding: 12px 16px;
  box-shadow: 6px 6px 0 rgba(31, 27, 22, 0.25);
  font-size: 13.5px;
}
.undo-toast.visible { display: flex; }
.undo-toast .undo-btn {
  border: 1.5px solid var(--sheet); background: none; color: var(--sheet);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 5px 12px; cursor: pointer;
}
.undo-toast .undo-btn:hover { background: var(--sheet); color: var(--ink); }
.undo-toast .undo-count { font-family: var(--mono); font-size: 11px; opacity: 0.7; }
.entry.pending-delete, .hermes-entry.pending-delete { display: none; }

/* ---- „Ganze Antwort zeigen": clamp long Hermes answers ------------------ */
.hermes-answer.clamped {
  max-height: 8.5em; overflow: hidden; position: relative;
}
.hermes-answer.clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em;
  background: linear-gradient(rgba(251, 248, 241, 0), var(--sheet));
}
.show-full-answer {
  border: none; background: none; cursor: pointer; padding: 2px 0;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--vermilion); text-decoration: underline;
}

/* ---- Wellenzustände: processing shimmer + missing audio ----------------- */
@keyframes waveshim { 0%, 100% { opacity: 0.25 } 50% { opacity: 0.75 } }
.wave-bars.is-processing i {
  background: var(--ink-40);
  animation: waveshim 1.4s ease-in-out infinite;
}
.wave-bars.is-processing i:nth-child(3n) { animation-delay: 0.2s; }
.wave-bars.is-processing i:nth-child(3n + 1) { animation-delay: 0.45s; }
@media (prefers-reduced-motion: reduce) { .wave-bars.is-processing i { animation: none; } }
.wave-missing {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-40);
  border: 1.5px dashed var(--rule); padding: 8px 12px;
  display: inline-block;
}
.entry-progress {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--ink-60); margin: 0 0 10px;
}
.progress-track {
  height: 3px; background: var(--sheet-deep); margin: 6px 0 0; max-width: 320px;
}
.progress-fill { height: 100%; background: var(--vermilion); }

/* ---- Sprecherzettel as popover with keyboard contract ------------------- */
.zettel-details { position: relative; display: inline-block; }
/* The speaker name itself is the trigger (design: click a name to assign). */
.speaker-trigger {
  font: inherit; color: inherit; letter-spacing: inherit;
  text-transform: inherit; font-weight: inherit; text-align: left;
  border: none; background: none; cursor: pointer; padding: 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.speaker-trigger:hover, .speaker-trigger[aria-expanded="true"] {
  text-decoration-thickness: 2px;
}
/* Rarely used correction feature — deliberately quiet (owner feedback). */
.zettel-scope {
  display: flex; gap: 7px; align-items: center;
  font-size: 12px; font-weight: 400; color: var(--ink-60);
  margin-bottom: 3px;
}
.zettel-scope input[type="checkbox"] {
  width: 13px; height: 13px; accent-color: var(--ink-60); flex-shrink: 0;
  margin: 0;
}
.zettel-scope-hint {
  font-size: 10.5px; color: var(--ink-40);
  padding-bottom: 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.script-tools {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}
.zettel-details > .speaker-zettel {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  width: 340px; max-width: calc(100vw - 48px);
}
.zettel-details.flip-up > .speaker-zettel { top: auto; bottom: calc(100% + 6px); }
.zettel-person:focus, .zettel-scope input:focus, .zettel-add input:focus {
  outline: 2px solid var(--vermilion); outline-offset: 1px;
}
.zettel-live {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  color: var(--ink-60); margin-top: 10px;
}

/* ---- Inline editing (click the title / filing / a name to edit) --------- */
.inline-edit {
  cursor: text;
  border-bottom: 1px dashed transparent;
  transition: border-color .12s ease;
}
.inline-edit:hover { border-bottom-color: var(--rule); }
.inline-edit:empty::before { content: attr(data-placeholder); color: var(--ink-40); }
.inline-input {
  font: inherit; color: inherit; letter-spacing: inherit;
  border: none; border-bottom: 1.5px solid var(--vermilion);
  background: transparent; outline: none; padding: 0;
  min-width: 120px;
}
.dossier-title .inline-edit { display: block; }
.dossier-title .inline-input { width: 100%; }
.dossier-hint {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-40); margin: 4px 0 10px;
}
.filing-value { font-size: 13.5px; font-weight: 600; min-height: 20px; }
.add-plus {
  border: none; background: none; cursor: pointer;
  color: var(--vermilion); font-size: 16px; line-height: 1; padding: 0 3px;
}
.add-inline { display: inline-flex; gap: 5px; align-items: baseline; }
.add-inline input {
  border: none; border-bottom: 1.5px dashed var(--rule);
  background: transparent; outline: none;
  font-family: var(--mono); font-size: 11.5px; padding: 4px 2px;
  min-width: 110px; color: var(--ink);
}
.add-inline input:focus { border-bottom-color: var(--vermilion); }
.participants-field { grid-column: 1 / -1; }
.participant-row {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline;
  font-size: 13.5px; font-weight: 600;
}
.participant-item { display: inline-flex; align-items: baseline; gap: 2px; }
.participant-x {
  border: none; background: none; cursor: pointer;
  color: var(--ink-40); font-size: 11px; padding: 0 2px;
}
.participant-x:hover { color: var(--stamp-red); }

/* ---- Styled file picker (native control stays hidden) ------------------- */
.file-chosen {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em;
  color: var(--ink-40);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chosen.has-file { color: var(--ink); }
input[type="file"].sr-only:focus-visible + label {
  outline: 2px solid var(--vermilion); outline-offset: 2px;
}

/* ---- Archive unreachable page state ------------------------------------- */
.error-sheet {
  max-width: 520px; margin: 80px auto; text-align: center;
  border: 1.5px solid var(--stamp-red); background: var(--sheet);
  box-shadow: 8px 8px 0 rgba(31, 27, 22, 0.18);
  padding: 44px 36px;
}
.error-sheet h1 { font-family: var(--serif); font-size: 28px; margin-bottom: 10px; }
.error-sheet p { color: var(--ink-60); font-size: 14.5px; margin-bottom: 24px; }
