:root {
  --burgundy: #8B1E2D;
  --burgundy-dark: #7a1927;
  --bg: #e9e9e7;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: rgba(0, 0, 0, .1);
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 8px 28px rgba(0,0,0,.08);
}

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

/* The [hidden] attribute must win over our display: flex/grid rules below. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 60; /* über dem rechten Drawer-Panel */
}
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--ink);
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.logo svg { color: var(--burgundy); }
.secure-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.secure-badge svg { color: #2e7d32; }

/* ── Layout (einspaltig, zentriert — nur der Dialog steht im Fokus) ── */
.layout {
  flex: 1;
  display: flex;
  width: 100%;
  padding: 0;
  min-height: 0;
}
.stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* ── Chat (randlos, füllt den Viewport; Nachrichten scrollen intern) ── */
.chat {
  display: flex; flex-direction: column;
  background: var(--paper);
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.ch-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; object-position: center top;
  display: block; flex-shrink: 0;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.ch-title { font-weight: 700; font-size: 15px; }
.ch-sub { font-size: 12px; color: var(--muted); }

.messages {
  flex: 1;
  /* min-height:0 lässt den Nachrichten-Bereich unter seine Inhaltsgröße
     schrumpfen — dadurch wächst die Chat-Spalte nicht mehr nach unten,
     sondern scrollt intern. Höhe richtet sich nach dem Kurzprofil daneben. */
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}

.msg { display: flex; }
.msg .bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14.5px; line-height: 1.5;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.bot { flex-direction: column; align-items: flex-start; }
.msg.bot .bubble {
  background: #f4f1ef; color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--burgundy); color: #fff;
  border-bottom-right-radius: 5px;
}

/* Premium-Antworten: server-seitig als Markdown gerendert (siehe renderMarkdown in app.js) */
.bubble.markdown { white-space: normal; }
.bubble.markdown > *:first-child { margin-top: 0; }
.bubble.markdown > *:last-child { margin-bottom: 0; }
.bubble.markdown p { margin: 0 0 0.6em; }
.bubble.markdown h1, .bubble.markdown h2, .bubble.markdown h3,
.bubble.markdown h4, .bubble.markdown h5, .bubble.markdown h6 {
  margin: 0.8em 0 0.35em; line-height: 1.3; font-weight: 700;
}
.bubble.markdown h1 { font-size: 1.25em; }
.bubble.markdown h2 { font-size: 1.15em; }
.bubble.markdown h3 { font-size: 1.08em; }
.bubble.markdown h4, .bubble.markdown h5, .bubble.markdown h6 { font-size: 1em; }
.bubble.markdown ul, .bubble.markdown ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.bubble.markdown li { margin: 0.15em 0; }
.bubble.markdown strong { font-weight: 700; }
.bubble.markdown em { font-style: italic; }
.bubble.markdown code {
  background: rgba(0, 0, 0, .06); padding: 0.1em 0.35em; border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.92em;
}
.bubble.markdown pre {
  background: rgba(0, 0, 0, .06); padding: 10px 12px; border-radius: 8px;
  overflow-x: auto; margin: 0 0 0.6em;
}
.bubble.markdown pre code { background: none; padding: 0; }
.bubble.markdown blockquote {
  margin: 0 0 0.6em; padding-left: 0.8em; border-left: 3px solid currentColor; opacity: 0.85;
}
.bubble.markdown a { color: inherit; text-decoration: underline; }

/* Dokument-Karten im Chat: erscheinen unter der Nachricht, die sie erzeugt hat */
.msg-docs { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; width: 100%; max-width: 340px; }
.doc-card {
  display: flex; align-items: center; gap: 10px;
  background: #faf7f1; border: 1px solid #ece2cf; border-radius: 12px;
  padding: 9px 10px 9px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}
.doc-card-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #d8b863 0%, #c79a3a 55%, #b9842a 100%);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.doc-card-icon svg { width: 18px; height: 18px; }
.doc-card-info { flex: 1; min-width: 0; }
.doc-card-area { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #b58a3c; }
.doc-card-title {
  font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.doc-card-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid #ece2cf;
  background: #fff; color: var(--burgundy); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.doc-card-btn svg { width: 15px; height: 15px; }
.doc-card-btn:hover { background: var(--burgundy); color: #fff; border-color: var(--burgundy); }

/* typing indicator */
.typing .bubble { background: #f4f1ef; display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #b8b0aa;
  animation: blink 1.3s infinite ease-in-out both;
}
.typing .dot:nth-child(2) { animation-delay: .18s; }
.typing .dot:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* composer */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fafafa;
}
.composer-field { position: relative; flex: 1; display: flex; }
.composer textarea {
  flex: 1; resize: none;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 50px 18px 14px; font: inherit; font-size: 14.5px;
  max-height: 140px; background: #fff; color: var(--ink);
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;              /* Firefox: schmale Leiste, keine Pfeil-Buttons */
  scrollbar-color: rgba(0,0,0,.2) transparent;
}
.char-count {
  position: absolute; right: 10px; bottom: 5px;
  font-size: 10px; color: var(--muted); pointer-events: none;
  background: rgba(255,255,255,.85); padding: 1px 5px; border-radius: 6px;
}
.char-count.warn { color: #b9842a; font-weight: 600; }
.char-count.limit { color: var(--burgundy); font-weight: 700; }
/* Chromium/WebKit: die Hoch-/Runter-Pfeil-Buttons der Scrollleiste entfernen. */
.composer textarea::-webkit-scrollbar { width: 8px; }
.composer textarea::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
.composer textarea::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 8px; }
.composer textarea::-webkit-scrollbar-track { background: transparent; }
.composer textarea:focus { border-color: var(--burgundy); }
.composer button {
  flex-shrink: 0;
  width: 44px; height: 44px; border: none; border-radius: 12px;
  background: var(--burgundy); color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s, transform .1s;
}
.composer button:hover { background: var(--burgundy-dark); }
.composer button:active { transform: scale(.94); }
.composer button:disabled { opacity: .5; cursor: not-allowed; }

/* ── Document ── */
.doc { position: sticky; top: 22px; align-self: start; }
.doc-paper {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  position: relative;
}
.doc-paper::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 5px; border-radius: var(--radius) 0 0 var(--radius);
  background: var(--burgundy);
}
.doc-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.doc-kanzlei { font-size: 11px; letter-spacing: .14em; color: var(--burgundy); font-weight: 700; }
.doc-title { font-size: 21px; font-weight: 800; margin-top: 6px; }
.doc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.fit-badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; margin-bottom: 18px;
}
.fit-pending { background: #f0ece9; color: var(--muted); }
.fit-yes { background: #e6f4ea; color: #1e7a37; }
.fit-no  { background: #fbe9e9; color: #b3261e; }

.fields { display: flex; flex-direction: column; gap: 2px; }
.field {
  display: grid; grid-template-columns: 120px 1fr; gap: 10px;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
  align-items: baseline;
}
.field-block { grid-template-columns: 1fr; gap: 4px; }
.field dt { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field dd { font-size: 14.5px; line-height: 1.5; }
.field dd.empty { color: #c7c0bb; }
.field dd.filled { color: var(--ink); animation: pop .35s ease; }
@keyframes pop { from { background: #fff6d6; } to { background: transparent; } }

.book-btn {
  width: 100%; margin-top: 20px;
  border: none; border-radius: 14px;
  background: var(--burgundy); color: #fff; cursor: pointer;
  padding: 15px; font: inherit; font-weight: 700; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 6px 22px rgba(139,30,45,.4);
  animation: rise .4s ease;
  transition: background .15s, transform .1s;
}
.book-btn:hover:not(:disabled) { background: var(--burgundy-dark); }
.book-btn:active:not(:disabled) { transform: translateY(1px); }
.book-sub { font-size: 12px; font-weight: 500; opacity: .85; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Disabled (not yet eligible) — clearly greyed out, no shadow, not clickable. */
.book-btn:disabled {
  background: #cdc8c4;
  color: #7d7873;
  box-shadow: none;
  cursor: not-allowed;
  animation: none;
  opacity: 1;
}
.book-btn:disabled .book-sub { color: #908b86; }

/* ── Uploads ── */
.uploads { margin-top: 20px; }
.uploads-head {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; cursor: pointer;
  border: 1.5px dashed #cdc5bf; border-radius: 12px;
  padding: 18px 14px; background: #fbfafa; color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover { border-color: var(--burgundy); background: #fdf5f6; }
.dropzone.drag { border-color: var(--burgundy); background: #fbeef0; color: var(--burgundy); }
.dz-icon { color: var(--burgundy); margin-bottom: 2px; }
.dz-text { font-size: 13.5px; color: var(--ink); }
.dz-link { color: var(--burgundy); font-weight: 600; text-decoration: underline; }
.dz-hint { font-size: 11.5px; color: var(--muted); }

.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 8px 10px;
  background: #f6f4f2; border-radius: 10px;
}
.fi-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi-status { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.file-item.fi-done .fi-status { color: #1e7a37; font-weight: 700; }
.file-item.fi-error { background: #fbe9e9; }
.file-item.fi-error .fi-status { color: #b3261e; font-weight: 700; }

.doc-foot { font-size: 11.5px; color: var(--muted); margin-top: 16px; line-height: 1.5; }

/* ── Booking overlay ── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,16,16,.55);
  display: grid; place-items: center; padding: 20px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--paper); border-radius: 18px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  padding: 26px 26px 28px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.modal .sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.pkg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 6px; }
.pkg-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 16px 14px;
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.pkg-card:hover { border-color: #d6b2b7; }
.pkg-card.active { border-color: var(--burgundy); background: #fdf5f6; }
.pkg-dur { font-size: 15px; font-weight: 700; }
.pkg-price { font-size: 22px; font-weight: 800; color: var(--burgundy); margin-top: 6px; }
.pkg-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section-title { font-size: 13px; font-weight: 700; margin: 20px 0 10px; }
.dates { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.date-chip {
  flex-shrink: 0; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; cursor: pointer; text-align: center; min-width: 58px;
  background: #fff; transition: border-color .15s, background .15s;
}
.date-chip.active { border-color: var(--burgundy); background: var(--burgundy); color: #fff; }
.date-dow { font-size: 11px; text-transform: uppercase; opacity: .7; }
.date-day { font-size: 17px; font-weight: 700; }
.date-mon { font-size: 11px; opacity: .7; }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.slot {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 0;
  text-align: center; font-size: 14px; cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s;
}
.slot:hover { border-color: #d6b2b7; }
.slot.active { border-color: var(--burgundy); background: var(--burgundy); color: #fff; }
.slots-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

.bk-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.bk-form label { font-size: 12px; font-weight: 600; color: var(--muted); }
.bk-form input, .bk-form textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: 14px; background: #fff; outline: none;
}
.bk-form input:focus, .bk-form textarea:focus { border-color: var(--burgundy); }
.bk-form textarea { resize: vertical; min-height: 60px; }

.bk-submit {
  margin-top: 16px; width: 100%; border: none; border-radius: 12px;
  background: var(--burgundy); color: #fff; padding: 14px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 15px;
}
.bk-submit:hover { background: var(--burgundy-dark); }
.bk-submit:disabled { opacity: .5; cursor: not-allowed; }
.bk-error { color: #b3261e; font-size: 13px; margin-top: 10px; }

.bk-success { text-align: center; padding: 16px 0; }
.bk-success .check {
  width: 56px; height: 56px; border-radius: 50%; background: #e6f4ea; color: #1e7a37;
  display: grid; place-items: center; margin: 0 auto 14px; font-size: 30px;
}
.bk-success h2 { margin-bottom: 8px; }
.bk-success p { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ── Topbar right (badge + trash) ── */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 10px;
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--burgundy); border-color: #d6b2b7; background: #fdf5f6; }

/* ── Chat head extras ── */
.chat-head { position: relative; }
.premium-badge {
  margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: #8a5a12; background: linear-gradient(135deg, #f7e3a1, #e7c258);
  padding: 4px 10px; border-radius: 999px; box-shadow: 0 1px 4px rgba(199,154,58,.4);
}

/* ── Premium status indicator ── */
.status-bar {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; font-size: 12.5px; color: var(--muted);
  background: #faf7f3; border-top: 1px solid var(--line);
}
.status-spinner {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid #e0d4c4; border-top-color: var(--burgundy);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Chat divider ── */
.chat-divider {
  text-align: center; font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #b58a3c; margin: 6px 0;
  position: relative;
}
.chat-divider::before, .chat-divider::after {
  content: ""; position: absolute; top: 50%; width: 28%; height: 1px;
  background: linear-gradient(90deg, transparent, #e7c258);
}
.chat-divider::before { left: 0; }
.chat-divider::after { right: 0; transform: scaleX(-1); }

/* ── Composer: Büroklammer ── */
.attach-btn {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  background: #fff !important; color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  display: grid; place-items: center; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.attach-btn:hover { color: var(--burgundy) !important; border-color: #d6b2b7 !important; }

/* ── Actions (Termin + Premium) ── */
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.actions .book-btn { margin-top: 0; }

.premium-btn {
  width: 100%; border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, #d8b863 0%, #c79a3a 55%, #b9842a 100%);
  color: #3a2a08; padding: 15px; font: inherit; font-weight: 800; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  box-shadow: 0 6px 22px rgba(199,154,58,.45);
  transition: transform .1s, box-shadow .15s, filter .15s;
}
.premium-btn svg { margin-bottom: 1px; }
.premium-btn:hover { filter: brightness(1.05); box-shadow: 0 8px 26px rgba(199,154,58,.55); }
.premium-btn:active { transform: translateY(1px); }
.premium-sub { font-size: 11.5px; font-weight: 600; opacity: .8; }
.premium-btn.unlocked { filter: saturate(.7); }

/* ── Premium-Dokumente (Liste) ── */
.doc-results { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.doc-results-head {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px;
}
.doc-result-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.doc-result {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #faf7f1; border: 1px solid #ece2cf; border-radius: 11px; padding: 10px 12px;
}
.dr-area { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #b58a3c; }
.dr-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.dr-view {
  flex-shrink: 0; border: 1px solid var(--burgundy); background: #fff; color: var(--burgundy);
  border-radius: 9px; padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.dr-view:hover { background: var(--burgundy); color: #fff; }
.doc-results-note { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.5; }

/* ── Premium gate modal ── */
.premium-modal { max-width: 520px; }
.pm-head { text-align: center; margin-bottom: 18px; }
.pm-head h2 { margin: 8px 0 6px; }
.pm-lead { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.pm-paywall {
  border: 1px solid #ece2cf; background: #fbf7ef; border-radius: 14px;
  padding: 18px; margin-bottom: 16px;
}
.pm-price { text-align: center; margin-bottom: 12px; }
.pm-price-amount { font-size: 30px; font-weight: 800; color: #b9842a; }
.pm-price-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pm-features { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.pm-features li { font-size: 13.5px; padding-left: 24px; position: relative; line-height: 1.4; }
.pm-features li::before { content: "✓"; position: absolute; left: 0; color: #2e7d32; font-weight: 800; }
.pm-mock-note {
  margin-top: 12px; font-size: 12px; color: #8a5a2b;
  background: #fff3e3; border: 1px dashed #e7c79f; border-radius: 8px; padding: 8px 10px; text-align: center;
}
.pm-consent { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.pm-check { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink); cursor: pointer; }
.pm-check input { margin-top: 2px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--burgundy); }
.pm-check a { color: var(--burgundy); }
.pm-start {
  width: 100%; border: none; border-radius: 13px; cursor: pointer;
  background: linear-gradient(135deg, #d8b863, #b9842a); color: #3a2a08;
  padding: 14px; font: inherit; font-weight: 800; font-size: 15px;
  box-shadow: 0 6px 20px rgba(199,154,58,.4);
}
.pm-start:disabled { background: #d8d2cb; color: #8b857f; box-shadow: none; cursor: not-allowed; }

/* ── Document viewer modal + rendered document (kdoc-*) ── */
.doc-modal { max-width: 640px; }
.doc-viewer { font-size: 14px; color: var(--ink); }
.doc-pre { white-space: pre-wrap; font-family: inherit; font-size: 14px; line-height: 1.6; }
.kdoc { line-height: 1.6; }
.kdoc-letterhead { border-bottom: 2px solid var(--burgundy); padding-bottom: 10px; margin-bottom: 14px; }
.kdoc-kanzlei { font-size: 11px; letter-spacing: .14em; color: var(--burgundy); font-weight: 700; }
.kdoc-lawyer { font-size: 13px; color: var(--ink); margin-top: 2px; }
.kdoc-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.kdoc-subject { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.kdoc-basis { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.kdoc-body p { margin-bottom: 12px; }
.kdoc-open { background: #fff7f0; border: 1px solid #f2d9c4; border-radius: 9px; padding: 12px 14px; margin: 12px 0; font-size: 13px; color: #8a5a2b; }
.kdoc-open ul { margin: 6px 0 0 18px; }
.kdoc-sign { margin-top: 18px; }
.kdoc-disclaimer { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ── Mandanten-Kurzprofil als rechtes Panel (ein-/ausklappbar) ─────── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 16, 16, .4);
  animation: fade .2s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45;
  width: 360px; max-width: 88vw;
  background: var(--paper);
  box-shadow: -8px 0 28px rgba(0, 0, 0, .16);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: 62px; /* unter der Topbar starten */
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.drawer.open { transform: translateX(0); }

/* Pull-Tab: ragt immer am rechten Rand heraus, klappt das Panel auf/zu. */
.drawer-tab {
  position: absolute; left: -38px; top: 50%; transform: translateY(-50%);
  width: 38px; padding: 14px 0; border: none; cursor: pointer;
  background: var(--burgundy); color: #fff;
  border-radius: 12px 0 0 12px; box-shadow: -3px 0 12px rgba(139, 30, 45, .35);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font: inherit;
}
.drawer-tab:hover { background: var(--burgundy-dark); }
.dt-label { writing-mode: vertical-rl; font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.dt-caret { transition: transform .28s ease; }
.drawer.open .dt-caret { transform: rotate(180deg); }
.dt-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #7ee0a0; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(126, 224, 160, .7);
}
.drawer.pulse .dt-dot { animation: dot-pulse 1s ease 3; }
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .8); }
  100% { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); }
}

.drawer-head {
  flex-shrink: 0; padding: 14px 18px 12px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.dh-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-title { font-size: 16px; font-weight: 800; }
.drawer-close {
  background: none; border: none; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 0 2px;
}
.drawer-close:hover { color: var(--burgundy); }
.dh-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dh-status .fit-badge { margin: 0; }
.sheet-docs {
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  color: #8a5a12; background: linear-gradient(135deg, #f7e3a1, #e7c258);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom, 0px));
}
.drawer-body .fields { margin-top: 0; }
.drawer-body .doc-foot { margin-top: 14px; }

/* ── Auswahl-Modal (Termin vs. Premium) ─────────────────────────────── */
.choice-modal { max-width: 460px; text-align: center; }
.choice-head { margin-bottom: 20px; }
.choice-check {
  width: 54px; height: 54px; border-radius: 50%;
  background: #e6f4ea; color: #1e7a37;
  display: grid; place-items: center; margin: 4px auto 14px;
  animation: pop-in .35s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.choice-head h2 { font-size: 20px; font-weight: 800; line-height: 1.25; }
.choice-lead { font-size: 14px; color: var(--muted); margin-top: 6px; }
.choice-actions { display: flex; flex-direction: column; gap: 12px; }
.choice-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 14px; padding: 15px 16px;
  background: #fff; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
.choice-card:hover { border-color: var(--burgundy); background: #fdf5f6; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(139,30,45,.12); }
.choice-card:active { transform: translateY(0); }
.choice-card .cc-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; background: #f4f1ef; color: var(--burgundy);
}
.choice-card.premium .cc-icon { background: linear-gradient(135deg, #f7e3a1, #e7c258); color: #8a5a12; }
.choice-card.premium:hover { border-color: #c79a3a; background: #fdfaf1; box-shadow: 0 6px 18px rgba(199,154,58,.18); }
.cc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-title { font-size: 15.5px; font-weight: 700; }
.cc-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ── Dokument-Viewer: Leiste + Export + Bearbeitung ─────────────────── */
.doc-modal { max-width: 660px; padding-top: 0; }
.doc-modal-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 0 12px; margin-bottom: 6px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.dmb-hint {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.dmb-right { display: flex; align-items: center; gap: 10px; }
.doc-modal .modal-close { position: static; font-size: 26px; }

.export-wrap { position: relative; }
.export-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--burgundy); background: var(--burgundy); color: #fff;
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(139,30,45,.28);
}
.export-pill:hover { background: var(--burgundy-dark); }
.export-pill .ep-caret { transition: transform .18s ease; opacity: .85; }
.export-pill[aria-expanded="true"] .ep-caret { transform: rotate(180deg); }
.export-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 5;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0,0,0,.18); padding: 6px; min-width: 210px;
  animation: fade .12s ease;
}
.export-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; cursor: pointer; font: inherit; font-size: 13.5px;
  color: var(--ink); padding: 10px 12px; border-radius: 8px; text-align: left;
}
.export-menu button svg { color: var(--burgundy); flex-shrink: 0; }
.export-menu button:hover { background: #f6f2f0; }

/* Editierbarer Dokumenttext */
.doc-viewer { font-size: 14px; color: var(--ink); border-radius: 8px; outline: none; }
.doc-viewer[contenteditable="true"] {
  padding: 14px; margin: 2px; border: 1px dashed transparent;
  transition: border-color .15s, background .15s; cursor: text;
}
.doc-viewer[contenteditable="true"]:hover { border-color: #e2d6c6; background: #fffdf9; }
.doc-viewer[contenteditable="true"]:focus { border-color: var(--burgundy); background: #fffdf9; }
.doc-save-note {
  font-size: 12px; color: #1e7a37; font-weight: 600; text-align: right;
  padding: 8px 4px 0; animation: fade .15s ease;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .slots { grid-template-columns: repeat(3, 1fr); }
  .doc-modal-bar { flex-wrap: wrap; }
}

/* ── Druck (Dokument-Druckfenster nutzt eigenes Dokument) ───────────── */
@media print {
  .topbar, .composer, .status-bar, .overlay { display: none !important; }
}
