/*
 * ft-friendsbot-panel.css — (W5193) FriendsBot-Chatfenster (/friendsbot_chat.php)
 * Eigenständige Seite (ohne die übrigen Friendstime-Stile). Ruhige Flächen, Friendstime-Petrol als einzige Akzentfarbe.
 * Hell/Dunkel: html[data-theme=light|dark|auto] (auto = nach dem System). Mobil/PWA: Safe-Area, Höhe folgt der Tastatur
 * (--fbp-vh aus visualViewport, sonst 100dvh). Logische Eigenschaften → Rechts-nach-links-Sprachen funktionieren.
 */
:root {
  --fbp-bg: #f6f8f8; --fbp-surface: #ffffff; --fbp-side: #edf1f1; --fbp-text: #17201f; --fbp-muted: #556362;
  --fbp-line: #d9e1e0; --fbp-accent: #006c87; --fbp-accent-strong: #00566b; --fbp-on-accent: #ffffff;
  --fbp-soft: #e1f0f3; --fbp-hover: rgba(0, 108, 135, .09); --fbp-danger: #a32626; --fbp-danger-soft: #fbeaea;
  --fbp-code: #eef2f2; --fbp-shadow: 0 1px 2px rgba(16, 32, 36, .06), 0 8px 24px rgba(16, 32, 36, .07);
  --fbp-focus: #006c87; --fbp-mark-a: #007a98; --fbp-mark-b: #5a57c9;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --fbp-bg: #111617; --fbp-surface: #192021; --fbp-side: #0c1011; --fbp-text: #e8eeed; --fbp-muted: #a3b3b1;
  --fbp-line: #2a3537; --fbp-accent: #63c6dd; --fbp-accent-strong: #8ad6e8; --fbp-on-accent: #06222a;
  --fbp-soft: #14343c; --fbp-hover: rgba(99, 198, 221, .12); --fbp-danger: #ff9d9d; --fbp-danger-soft: #3a1c1c;
  --fbp-code: #0c1112; --fbp-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  --fbp-focus: #8ad6e8; --fbp-mark-a: #1791b0; --fbp-mark-b: #6f6ce0;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --fbp-bg: #111617; --fbp-surface: #192021; --fbp-side: #0c1011; --fbp-text: #e8eeed; --fbp-muted: #a3b3b1;
    --fbp-line: #2a3537; --fbp-accent: #63c6dd; --fbp-accent-strong: #8ad6e8; --fbp-on-accent: #06222a;
    --fbp-soft: #14343c; --fbp-hover: rgba(99, 198, 221, .12); --fbp-danger: #ff9d9d; --fbp-danger-soft: #3a1c1c;
    --fbp-code: #0c1112; --fbp-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
    --fbp-focus: #8ad6e8; --fbp-mark-a: #1791b0; --fbp-mark-b: #6f6ce0;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.fbp-body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--fbp-bg); color: var(--fbp-text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
:where(.fbp-body) button, :where(.fbp-body) input, :where(.fbp-body) textarea { font: inherit; color: inherit; }
.fbp-body a { color: var(--fbp-accent-strong); text-underline-offset: 2px; }
.fbp-body [hidden] { display: none !important; }
.fbp-body :focus-visible { outline: 3px solid var(--fbp-focus); outline-offset: 2px; border-radius: 8px; }
.fbp-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.fbp-skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 50; background: var(--fbp-surface); padding: 8px 12px; border-radius: 8px; box-shadow: var(--fbp-shadow); }
.fbp-skip:focus { top: calc(8px + env(safe-area-inset-top, 0px)); }
.fbp-ico { flex: none; display: block; }

/* ── Gerüst ───────────────────────────────────────────────────────────────── */
.fbp { display: grid; grid-template-columns: 296px minmax(0, 1fr); height: 100vh; height: 100dvh; height: var(--fbp-vh, 100dvh); }
.fbp-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--fbp-bg); }
.fbp-col { width: 100%; max-width: 780px; margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.fbp-only-mobile { display: none !important; }

/* ── Seitenleiste ───────────────────────────────────────────────────────────── */
.fbp-side {
  display: flex; flex-direction: column; min-height: 0; background: var(--fbp-side); border-inline-end: 1px solid var(--fbp-line);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(10px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
}
.fbp-side-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 12px; }
.fbp-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; color: var(--fbp-text) !important; text-decoration: none; padding: 4px 6px; border-radius: 10px; }
.fbp-mark {
  position: relative; flex: none; display: inline-block; width: 28px; height: 28px; border-radius: 10px;
  background: linear-gradient(140deg, var(--fbp-mark-a), var(--fbp-mark-b));
}
.fbp-mark > span { position: absolute; top: 11px; left: 8px; width: 4px; height: 6px; border-radius: 3px; background: #fff; box-shadow: 8px 0 0 #fff; }
.fbp-mark-sm { width: 26px; height: 26px; border-radius: 9px; margin-top: 2px; }
.fbp-mark-sm > span { top: 10px; left: 7px; }
.fbp-mark-lg { width: 52px; height: 52px; border-radius: 18px; }
.fbp-mark-lg > span { top: 20px; left: 15px; width: 7px; height: 11px; border-radius: 4px; box-shadow: 15px 0 0 #fff; }
/* (Welle 5217) eigenes FriendsBot-Zeichen (Doppelring + Funke, PNG per PHP erzeugt) statt der Augen */
.fbp-mark { background: #00546a url("/assets/images/friendsbot/friendsbot-128.png") center / cover no-repeat; }
.fbp-mark-lg { background-image: url("/assets/images/friendsbot/friendsbot-256.png"); }
.fbp-mark > span { display: none; }

.fbp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--fbp-line); background: var(--fbp-surface); color: var(--fbp-text) !important; font-weight: 600; text-decoration: none; cursor: pointer;
}
.fbp-btn:hover { background: var(--fbp-hover); }
.fbp-btn-primary { background: var(--fbp-accent); border-color: var(--fbp-accent); color: var(--fbp-on-accent) !important; }
.fbp-btn-primary:hover { background: var(--fbp-accent-strong); border-color: var(--fbp-accent-strong); }
.fbp-btn-danger { background: var(--fbp-danger); border-color: var(--fbp-danger); color: var(--fbp-bg) !important; }
.fbp-btn-danger:hover { background: var(--fbp-danger); filter: brightness(.92); }
.fbp-new { width: 100%; }
.fbp-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 10px;
  background: transparent; color: var(--fbp-muted); cursor: pointer;
}
.fbp-iconbtn:hover { background: var(--fbp-hover); color: var(--fbp-text); }
.fbp-iconbtn-sm { width: 32px; height: 32px; border-radius: 8px; }

.fbp-search { position: relative; margin: 12px 0 8px; color: var(--fbp-muted); }
.fbp-search > .fbp-ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.fbp-search input {
  width: 100%; height: 40px; padding-block: 0; padding-inline: 36px 12px; border-radius: 10px; border: 1px solid var(--fbp-line);
  background: var(--fbp-surface); color: var(--fbp-text); font-size: 16px; -webkit-appearance: none; appearance: none;
}
.fbp-search input::placeholder { color: var(--fbp-muted); opacity: 1; }
.fbp-list-wrap { flex: 1; min-height: 0; overflow-y: auto; margin-inline: -4px; padding-inline: 4px; overscroll-behavior: contain; }
.fbp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fbp-conv-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.fbp-conv-row:hover, .fbp-conv-row:focus-within { background: var(--fbp-hover); }
.fbp-conv-row.is-active { background: var(--fbp-soft); }
.fbp-conv {
  flex: 1; min-width: 0; min-height: 42px; padding: 8px 10px; border: 0; background: transparent; text-align: start; cursor: pointer; border-radius: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem;
}
.fbp-conv-row.is-active .fbp-conv { font-weight: 600; }
.fbp-conv-tools { display: none; flex: none; padding-inline-end: 4px; }
.fbp-conv-row:hover .fbp-conv-tools, .fbp-conv-row:focus-within .fbp-conv-tools, .fbp-conv-row.is-active .fbp-conv-tools { display: inline-flex; }
@media (hover: none) { .fbp-conv-tools { display: inline-flex; } }
.fbp-list-empty { color: var(--fbp-muted); font-size: .9rem; padding: 10px; margin: 0; }
.fbp-side-foot { border-top: 1px solid var(--fbp-line); padding-top: 8px; margin-top: 8px; display: flex; flex-direction: column; gap: 1px; }
.fbp-usage { margin: 0 0 4px; padding: 2px 8px; font-size: .82rem; color: var(--fbp-muted); font-variant-numeric: tabular-nums; }
.fbp-foot-link {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--fbp-muted) !important; font-size: .88rem; text-decoration: none; text-align: start; cursor: pointer;
}
.fbp-foot-link:hover { background: var(--fbp-hover); color: var(--fbp-text) !important; }

/* ── Kopf, Verlauf ─────────────────────────────────────────────────────────── */
.fbp-top {
  display: flex; align-items: center; gap: 8px; flex: none; min-height: 54px;
  padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right, 0px)) 0 16px; border-bottom: 1px solid var(--fbp-line);
}
.fbp-title { flex: 1; min-width: 0; margin: 0; font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbp-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; outline: none; scroll-padding-bottom: 16px; }
.fbp-scroll > .fbp-col { padding-block: 16px 24px; min-height: 100%; display: flex; flex-direction: column; }
.fbp-notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; font-size: .84rem; line-height: 1.45;
  color: var(--fbp-muted); background: var(--fbp-surface); border: 1px solid var(--fbp-line);
}
.fbp-notice .fbp-ico { margin-top: 2px; color: var(--fbp-accent); }
.fbp-hello { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 0; }
.fbp-hello h2 { margin: 18px 0 6px; font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.8rem); font-weight: 650; letter-spacing: -.01em; }
.fbp-hello p { margin: 0; max-width: 34rem; color: var(--fbp-muted); }
.fbp-sugs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.fbp-sug {
  min-height: 42px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--fbp-line); background: var(--fbp-surface); cursor: pointer; font-size: .92rem;
}
.fbp-sug:hover { border-color: var(--fbp-accent); background: var(--fbp-hover); }

.fbp-log { display: flex; flex-direction: column; gap: 18px; padding-top: 10px; }
.fbp-msg { display: flex; gap: 12px; min-width: 0; }
.fbp-msg-body { min-width: 0; max-width: 100%; }
.fbp-msg-user { justify-content: flex-end; }
.fbp-msg-user .fbp-msg-body { max-width: min(86%, 620px); display: flex; flex-direction: column; align-items: flex-end; }
.fbp-msg-user .fbp-bubble { background: var(--fbp-soft); padding: 10px 14px; border-radius: 18px; border-end-end-radius: 6px; white-space: pre-wrap; }
.fbp-msg-bot .fbp-msg-body { flex: 1; }
.fbp-bubble { overflow-wrap: anywhere; word-break: break-word; }
.fbp-bubble > :first-child { margin-top: 0; }
.fbp-bubble > :last-child { margin-bottom: 0; }
.fbp-bubble p { margin: 0 0 .75em; }
.fbp-bubble ul, .fbp-bubble ol { margin: 0 0 .75em; padding-inline-start: 1.4em; }
.fbp-bubble li { margin: .2em 0; }
.fbp-bubble hr { border: 0; border-top: 1px solid var(--fbp-line); margin: 1em 0; }
.fbp-bubble code { font: .88em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; background: var(--fbp-code); border: 1px solid var(--fbp-line); border-radius: 6px; padding: .08em .35em; }
.fbp-bubble pre { margin: 0 0 .75em; padding: 12px 14px; background: var(--fbp-code); border: 1px solid var(--fbp-line); border-radius: 12px; overflow-x: auto; }
.fbp-bubble pre code { background: none; border: 0; padding: 0; white-space: pre; }
.fbp-bubble.is-fail { display: inline-block; padding: 8px 12px; border-radius: 12px; background: var(--fbp-danger-soft); color: var(--fbp-danger); }
.fbp-wait { display: flex; align-items: center; gap: 10px; color: var(--fbp-muted); min-height: 28px; }
.fbp-wait-sub { margin: 4px 0 0 !important; font-size: .86rem; color: var(--fbp-muted); }
.fbp-wait-sub:empty { display: none; }
.fbp-dots { display: inline-flex; gap: 4px; }
.fbp-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--fbp-accent); opacity: .35; animation: fbp-dot 1.2s infinite ease-in-out; }
.fbp-dots i:nth-child(2) { animation-delay: .15s; }
.fbp-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes fbp-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.fbp-msg-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; min-height: 30px; }
.fbp-msg-user .fbp-msg-actions { opacity: 0; transition: opacity .12s; }
.fbp-msg-user:hover .fbp-msg-actions, .fbp-msg-user:focus-within .fbp-msg-actions { opacity: 1; }
@media (hover: none) { .fbp-msg-user .fbp-msg-actions { opacity: 1; } }
.fbp-act {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--fbp-muted); font-size: .82rem; cursor: pointer;
}
.fbp-act:hover { background: var(--fbp-hover); color: var(--fbp-text); }
.fbp-act.is-done { color: var(--fbp-accent-strong); }
.fbp-tail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--fbp-muted); font-size: .9rem; padding-inline-start: 38px; }

/* ── Eingabe ───────────────────────────────────────────────────────────────── */
.fbp-compose { flex: none; padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--fbp-bg) 70%, transparent); }
.fbp-alert { margin: 0 0 8px; padding: 9px 12px; border-radius: 12px; background: var(--fbp-danger-soft); color: var(--fbp-danger); font-size: .9rem; }
.fbp-form {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 16px; background: var(--fbp-surface); border: 1px solid var(--fbp-line);
  border-radius: 24px; box-shadow: var(--fbp-shadow);
}
[dir="rtl"] .fbp-form { padding: 6px 16px 6px 6px; }
.fbp-form:focus-within { border-color: var(--fbp-accent); box-shadow: 0 0 0 3px var(--fbp-hover), var(--fbp-shadow); }
.fbp-form textarea:focus-visible { outline: none; }
.fbp-form textarea {
  flex: 1; min-width: 0; min-height: 40px; max-height: 200px; padding: 8px 0; border: 0; outline: 0; background: transparent; resize: none;
  font-size: 16px; line-height: 1.5; overflow-y: auto;
}
.fbp-form textarea::placeholder { color: var(--fbp-muted); opacity: 1; }
.fbp-send {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--fbp-accent); color: var(--fbp-on-accent); cursor: pointer;
}
.fbp-send:hover { background: var(--fbp-accent-strong); }
.fbp-send:disabled { background: var(--fbp-line); color: var(--fbp-muted); cursor: default; }
.fbp-stop { background: var(--fbp-text); color: var(--fbp-bg); }
.fbp-stop:hover { background: var(--fbp-text); opacity: .85; }
[dir="rtl"] .fbp-send:not(.fbp-stop) .fbp-ico { transform: scaleX(-1); }
.fbp-hint { margin: 6px 0 0; text-align: center; font-size: .76rem; color: var(--fbp-muted); }

/* ── Dialog, Torseite ─────────────────────────────────────────────────────────── */
.fbp-dialog { width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--fbp-line); border-radius: 18px; background: var(--fbp-surface); color: var(--fbp-text); box-shadow: var(--fbp-shadow); }
.fbp-dialog::backdrop { background: rgba(8, 14, 15, .5); }
.fbp-dialog h2 { margin: 0 0 8px; font-size: 1.1rem; }
.fbp-dialog p { margin: 0 0 12px; color: var(--fbp-muted); }
.fbp-dialog label { display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 600; }
.fbp-dialog input { width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--fbp-line); background: var(--fbp-bg); font-size: 16px; }
.fbp-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.fbp-gate { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; overflow: auto; height: 100%; }
.fbp-gate-card { max-width: 440px; text-align: center; background: var(--fbp-surface); border: 1px solid var(--fbp-line); border-radius: 20px; padding: 32px 24px; box-shadow: var(--fbp-shadow); }
.fbp-gate-card .fbp-mark { width: 52px; height: 52px; border-radius: 18px; }
.fbp-gate-card .fbp-mark > span { top: 20px; left: 15px; width: 7px; height: 11px; border-radius: 4px; box-shadow: 15px 0 0 #fff; }
.fbp-gate-card h1 { margin: 14px 0 6px; font-size: 1.4rem; }
.fbp-gate-card p { margin: 0 0 12px; color: var(--fbp-muted); }
.fbp-gate-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px !important; }

/* ── Schmal (Handy, PWA) ──────────────────────────────────────────────────────── */
@media (max-width: 899.98px) {
  .fbp { grid-template-columns: minmax(0, 1fr); }
  .fbp-only-mobile { display: inline-flex !important; }
  .fbp-side {
    position: fixed; z-index: 30; inset-block: 0; inset-inline-start: 0; width: min(86vw, 330px); height: var(--fbp-vh, 100dvh);
    transform: translateX(-102%); transition: transform .2s ease; visibility: hidden; box-shadow: var(--fbp-shadow);
  }
  [dir="rtl"] .fbp-side { transform: translateX(102%); }
  .fbp.is-side .fbp-side { transform: none; visibility: visible; }
  .fbp-scrim { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 15, .45); }
  .fbp-top { padding-inline-start: max(6px, env(safe-area-inset-left, 0px)); }
  .fbp-hint { display: none; }
  .fbp-iconbtn { width: 44px; height: 44px; }
  .fbp-iconbtn-sm { width: 40px; height: 40px; }
  .fbp-send { width: 44px; height: 44px; }
  .fbp-conv { min-height: 46px; }
  .fbp-msg-user .fbp-msg-body { max-width: 90%; }
  .fbp-tail { padding-inline-start: 0; }
  .fbp-hello { padding: 12px 0; }
  .fbp-hello h2 { margin-top: 12px; }
  .fbp-sugs { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .fbp-dots i { animation: none; opacity: .7; }
  .fbp-side { transition: none; }
}
@media (forced-colors: active) {
  .fbp-send, .fbp-btn, .fbp-form, .fbp-conv-row.is-active { border: 1px solid CanvasText; }
}
