: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);
}
.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 ── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 22px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 28px;
}

/* ── Chat ── */
.chat {
  display: flex; flex-direction: column;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Höhe wird vom Grid (align-items:stretch) an das Kurzprofil daneben
     angeglichen; der Floor verhindert nur ein Kollabieren bei wenig Inhalt. */
  min-height: 420px;
}
.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 { justify-content: 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;
}

/* 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 textarea {
  flex: 1; resize: none;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 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;
}
/* 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; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .doc { position: static; order: -1; }
  .chat { min-height: 56vh; }
  .slots { grid-template-columns: repeat(3, 1fr); }
}
