.context-chat-launcher { position: fixed; z-index: 90; right: max(22px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 56px; height: 56px; min-height: 56px; padding: 0; border: 1px solid #bf5628; border-radius: 50%; background: #e9763e; color: #161616; box-shadow: 0 5px 20px #16161626; font-size: 1.7rem; }
.context-chat-launcher:hover { background: #f18c58; border-color: #bf5628; }
.context-chat-launcher[hidden] { display: none !important; }
.context-chat { position: fixed; z-index: 91; inset: auto 18px 18px auto; margin: 0; padding: 0; width: 430px; max-width: calc(100vw - 28px); height: min(var(--chat-h, 730px), calc(100dvh - 36px)); max-height: calc(100dvh - 36px); border: 1px solid #d9d3cd; border-top: 3px solid #e9763e; border-radius: 17px; background: #fff; color: #161616; box-shadow: 0 15px 50px #16161638; overflow: hidden; }
.context-chat[open] { display: flex; flex-direction: column; }
.context-chat [hidden] { display: none !important; }
.context-chat-top { flex: 0 0 auto; }
.context-chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 16px 8px; }
.context-chat-title { min-width: 0; padding-top: 6px; }
.context-chat-head h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
/* Griff am oberen Rand: Chat am Desktop höher oder niedriger ziehen. */
.context-chat-resize { position: absolute; z-index: 2; top: 0; left: 0; right: 0; height: 12px; cursor: ns-resize; touch-action: none; }
.context-chat-resize::after { content: ""; position: absolute; top: 4px; left: 50%; width: 44px; height: 4px; margin-left: -22px; border-radius: 2px; background: #d9d3cd; }
.context-chat-resize:hover::after, .context-chat-resize:focus-visible::after { background: #e9763e; }
.context-chat .context-chat-close { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: #161616; font-size: 1.7rem; padding: 0; }
.context-chat-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; border-bottom: 1px solid #ece7e1; }
.context-chat-context { margin: 4px 0 0; font-size: .8rem; color: #61594f; overflow-wrap: anywhere; }
.context-chat button { min-height: 44px; border-radius: 8px; font-size: .8rem; padding: 9px 12px; white-space: normal; }
.context-chat button:disabled { opacity: .5; }
.context-chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.context-chat-messages { display: grid; gap: 14px; }
.context-chat-message { min-width: 0; padding: 12px 14px; border: 1px solid #e8e3dd; border-radius: 11px; background: #faf9f7; }
.context-chat-message.is-user { margin-left: 26px; background: #fff3e9; border-color: #f2d7c5; }
.context-chat-message strong { font-size: .7rem; color: #665a50; }
.context-chat-message p, .context-chat-preview p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .88rem; line-height: 1.6; }
.context-chat-coverage { color: #6b6258; font-size: .73rem; line-height: 1.6; overflow-wrap: anywhere; }
.context-chat-status { margin: 0; padding: 8px 16px; font-size: .75rem; line-height: 1.5; color: #685647; background: #fff8f2; overflow-wrap: anywhere; flex: 0 0 auto; }
.context-chat-status:empty { display: none; }
.context-chat-composer { display: grid; gap: 10px; margin: 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid #ece7e1; background: #fff; flex: 0 0 auto; }
.context-chat label { display: grid; gap: 6px; margin: 0; font-size: .78rem; color: #4e463f; }
.context-chat input, .context-chat textarea { min-width: 0; width: 100%; max-width: 100%; padding: 10px; font-size: 1rem; border: 1px solid #ccc4bd; border-radius: 8px; background: #fff; color: #161616; }
.context-chat-composer textarea { max-height: 130px; resize: vertical; }
.context-chat-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.context-chat-chooser { display: grid; gap: 10px; }
.context-chat-chooser:empty { display: none; }
.context-chat-chooser p { font-size: .87rem; line-height: 1.6; margin: 0 0 10px; }
.context-chat-chooser .context-chat-choice { background: #fff; color: #161616; border: 1px solid #d9d1c8; text-align: left; justify-content: flex-start; }
.context-chat-proposal { display: grid; gap: 15px; }
.context-chat-proposal:empty { display: none; }
.context-chat-recovery { display: grid; gap: 12px; margin: 12px 0; font-size: .8rem; line-height: 1.6; }
.context-chat-recovery:empty { display: none; }
.context-chat-recovery p { margin: 0; overflow-wrap: anywhere; }
.context-chat-proposal fieldset { min-width: 0; margin: 14px 0 0; padding: 12px; border: 1px solid #d9d1c8; border-radius: 10px; }
.context-chat-proposal legend { font-size: .82rem; font-weight: 600; }
.context-chat-proposal label.context-chat-target, .context-chat-proposal label.context-chat-check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; line-height: 1.5; }
.context-chat-target input, .context-chat-check input { width: 20px; height: 20px; margin: 3px 0; flex: 0 0 20px; accent-color: #b34b1d; }
.context-chat-target span { display: grid; gap: 4px; overflow-wrap: anywhere; }
.context-chat-target span span { color: #6b6258; font-size: .76rem; }
.context-chat-preview { padding: 12px; background: #f8f6f2; border-radius: 9px; overflow-wrap: anywhere; }
.context-chat-preview:empty { display: none; }
.context-chat-preview h3 { margin: 0 0 8px; font-size: .9rem; }
.context-chat-preview strong { display: block; font-size: .75rem; margin-top: 10px; }
.context-chat :focus-visible, .context-chat-launcher:focus-visible { outline: 2px solid #161616; outline-offset: 3px; }
@media (max-width: 850px) { .context-chat-launcher { right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); } }

/* Chat wie ein Messenger (Wunsch Knyaz 12.11.2026): eigene Nachrichten rechts, James links, Denk-Indikator. */
.context-chat-message { max-width: 88%; justify-self: start; }
.context-chat-message.is-user { margin-left: 0; justify-self: end; }
.context-chat-message.is-pending { opacity: .75; }
.context-chat-thinking { display: inline-flex; align-items: center; gap: 10px; justify-self: start; padding: 10px 14px; border: 1px solid #e8e3dd; border-radius: 11px; background: #faf9f7; color: #6b6258; font-size: .8rem; }
.context-chat-dots { display: inline-flex; gap: 4px; }
.context-chat-dots i { width: 7px; height: 7px; border-radius: 50%; background: #e9763e; animation: context-chat-dot 1.2s infinite ease-in-out; }
.context-chat-dots i:nth-child(2) { animation-delay: .15s; }
.context-chat-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes context-chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .context-chat-dots i { animation: none; opacity: .7; } }
.context-chat-toolbar button { min-height: 36px; padding: 6px 10px; }
.context-chat-choice.is-general { font-weight: 600; border-color: #e9763e !important; }
.context-chat-choice-list { display: grid; gap: 8px; }
.context-chat-draft { margin-top: 10px; padding: 10px 12px; border: 1px dashed #e0b79c; border-radius: 9px; background: #fff; display: grid; gap: 8px; }
.context-chat-draft p { margin: 0; }
.context-chat-draft-to { font-size: .75rem !important; color: #61594f; }
.context-chat-draft .context-chat-draft-open { background: #e9763e; border-color: #bf5628; color: #161616; }
/* Notizblock über dem Chat. */
.context-chat-notepad { display: grid; gap: 8px; margin: 0 0 14px; padding: 10px 12px 12px; border: 1px solid #ece7e1; border-radius: 10px; background: #fffdf6; }
.context-chat-notepad h3 { margin: 0; font-size: .85rem; font-weight: 600; }
.context-chat-notepad > textarea { resize: vertical; max-height: 200px; }
.context-chat-toolbar button.is-active { background: #fff3e9; border-color: #e9763e; }
.context-chat-notepad-target { display: grid; gap: 8px; }
.context-chat-notepad-target:empty { display: none; }
.context-chat-notepad-target .context-chat-choice, .context-chat-other-targets .context-chat-choice { background: #fff; color: #161616; border: 1px solid #d9d1c8; text-align: left; }
.customer-picker { display: grid; gap: 6px; }
.context-chat select { min-width: 0; width: 100%; padding: 9px 10px; font-size: 1rem; border: 1px solid #ccc4bd; border-radius: 8px; background: #fff; color: #161616; }
.context-chat-other-targets > summary { cursor: pointer; padding: 8px 0; font-size: .8rem; }
.context-chat-other-targets > input { margin-bottom: 6px; }
.context-chat-notepad-target .context-chat-choice, .context-chat-chooser .context-chat-choice { justify-content: flex-start; text-align: left; }
/* Formatierbarer Notizblock. */
.rich-editor { display: grid; gap: 0; border: 1px solid #ccc4bd; border-radius: 8px; background: #fff; overflow: hidden; }
.rich-editor:focus-within { border-color: #161616; }
.rich-editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid #ece7e1; background: #faf9f7; }
.context-chat .rich-editor-btn { min-width: 34px; min-height: 34px; padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #161616; font-size: .9rem; line-height: 1; }
.context-chat .rich-editor-btn:hover { background: #f0ebe5; }
.context-chat .rich-editor-btn[aria-pressed="true"] { background: #fff3e9; border-color: #e9763e; }
.rich-editor-btn.is-bold { font-weight: 700; }
.rich-editor-btn.is-italic { font-style: italic; font-family: Georgia, serif; }
.rich-editor-btn.is-strikeThrough { text-decoration: line-through; }
.rich-editor-area { min-height: 110px; max-height: 260px; overflow-y: auto; padding: 10px 12px; font-size: 1rem; line-height: 1.55; color: #161616; outline: none; overflow-wrap: anywhere; }
.rich-editor-area p, .rich-editor-area div { margin: 0; }
.rich-editor-area ul, .rich-editor-area ol { margin: .2em 0; padding-left: 1.4em; }
.rich-editor-area.is-empty::before { content: attr(data-placeholder); color: #8a8178; pointer-events: none; float: left; height: 0; }
/* Handy (13.11.2026): Chat als Vollbild über der Seite. --chat-vh/--chat-top folgen dem sichtbaren Bereich
   (visualViewport), damit Eingabefeld und Verlauf über der Tastatur bleiben. */
@media (max-width: 850px) {
  html.context-chat-open, html.context-chat-open body { overflow: hidden; }
  .context-chat { inset: var(--chat-top, 0px) 0 auto 0; width: 100vw; max-width: 100vw; height: var(--chat-vh, 100dvh); max-height: none; border: 0; border-top: 3px solid #e9763e; border-radius: 0; box-shadow: none; }
  .context-chat-resize { display: none; }
  .context-chat-top { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid #ece7e1; }
  .context-chat-head, .context-chat-toolbar { display: contents; }
  .context-chat .context-chat-close { order: 0; font-size: 0; }
  .context-chat .context-chat-close::before { content: "\2190" / ""; font-size: 1.45rem; line-height: 1; }
  .context-chat-title { order: 1; flex: 1 1 auto; padding: 0 4px; }
  .context-chat-head h2 { font-size: 1rem; }
  .context-chat-head h2, .context-chat-context { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .context-chat-context { margin: 0; font-size: .75rem; }
  .context-chat-toolbar button { order: 2; position: relative; flex: 0 0 44px; width: 44px; min-width: 44px; min-height: 44px; padding: 0; border: 0; background: transparent; font-size: 0; }
  .context-chat-toolbar button::before { font-size: 1.3rem; line-height: 1; color: #161616; }
  .context-chat-toolbar button.is-choose::before { content: "\2630" / ""; }
  .context-chat-toolbar button.is-new::before { content: "\FF0B" / ""; }
  .context-chat-toolbar button.is-notepad::before { content: "\270E" / ""; }
  .context-chat-toolbar button.is-active { background: #fff3e9; border-radius: 10px; }
  .context-chat-toolbar button.has-draft::after { content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #e9763e; }
  .context-chat-scroll { padding: 12px; }
  .context-chat-composer { gap: 6px; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  .context-chat-composer label { gap: 0; font-size: 0; }
  .context-chat input, .context-chat textarea, .context-chat select, .rich-editor-area { font-size: 16px; }
  .context-chat-composer textarea { min-height: 44px; max-height: 120px; }
  .context-chat-actions > button.secondary:disabled { display: none; }
  .context-chat-actions > button[type="submit"] { margin-left: auto; }
  /* Notizblock als eigene Ansicht: Chat und Eingabefeld treten zurück, Formatierungsleiste sitzt unten über der Tastatur. */
  .context-chat.is-notepad .context-chat-composer, .context-chat.is-notepad .context-chat-status, .context-chat.is-notepad .context-chat-messages,
  .context-chat.is-notepad .context-chat-coverage, .context-chat.is-notepad .context-chat-chooser, .context-chat.is-notepad .context-chat-recovery,
  .context-chat.is-notepad .context-chat-proposal { display: none; }
  .context-chat.is-notepad .context-chat-scroll { display: flex; flex-direction: column; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  .context-chat.is-notepad .context-chat-notepad { display: flex; flex-direction: column; flex: 1 0 auto; min-height: 100%; box-sizing: border-box; margin: 0; padding: 0; border: 0; background: transparent; }
  .context-chat.is-notepad .context-chat-notepad h3 { display: none; }
  .context-chat.is-notepad .context-chat-notepad .context-chat-actions { order: -1; flex-wrap: nowrap; }
  .context-chat.is-notepad .context-chat-notepad .context-chat-actions button { flex: 1 1 0; }
  .context-chat.is-notepad .rich-editor { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 150px; }
  .context-chat.is-notepad .rich-editor-area { flex: 1 1 auto; min-height: 90px; max-height: none; }
  .context-chat.is-notepad .rich-editor-bar { order: 2; border-bottom: 0; border-top: 1px solid #ece7e1; }
  .context-chat.is-notepad .rich-editor-btn { min-width: 40px; min-height: 40px; }
}
