/* Headsquarter AI – gemeinsames Stylesheet
   Farben und Formen angelehnt an headsquarter.com (warmes Off-White, Serif-Titel, Pill-Buttons).
   Schriften: Systemschriften als Platzhalter für Headsquarter Serif / Sans. */

:root {
  --paper: #FAFAF8; --paper-2: #F3F1EC; --stone: #E8E5DE;
  --line: rgba(64, 62, 55, .10); --line-2: rgba(64, 62, 55, .18);
  --ink: #403E37; --ink-2: #6E6B62; --ink-3: #A29E94; --white: #FFFFFF;
  --ok: #4E7A55; --warn: #B07A2A; --bad: #A4483B;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --shadow-sm: 0 1px 2px rgba(64, 62, 55, .06), 0 4px 12px rgba(64, 62, 55, .05);
  --shadow-lg: 0 2px 4px rgba(64, 62, 55, .05), 0 18px 40px -12px rgba(64, 62, 55, .25);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B1A18; --paper-2: #232220; --stone: #2E2C29;
    --line: rgba(250, 250, 248, .09); --line-2: rgba(250, 250, 248, .16);
    --ink: #EEECE6; --ink-2: #B5B1A7; --ink-3: #7E7A71; --white: #262522;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); letter-spacing: -.003em; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
.serif { font-family: var(--serif); font-weight: 400; }
.muted { color: var(--ink-3); }

/* Druck-Feedback sofort beim Drücken */
.press { transition: transform 120ms var(--ease), background-color 160ms, border-color 160ms, box-shadow 160ms, opacity 160ms; }
.press:active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 14px; padding: 9px 18px; border-radius: 50px; background: var(--ink); color: var(--paper); white-space: nowrap; }
.btn:hover { opacity: .9; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { border-color: var(--ink-2); opacity: 1; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(164, 72, 59, .35); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn svg, .send svg { width: 15px; height: 15px; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; }
.send:disabled { opacity: .35; }

.chip { font-size: 13px; padding: 7px 14px; border-radius: 50px; background: var(--white); border: 1px solid var(--line); color: var(--ink-2); }
.chip:hover { border-color: var(--line-2); color: var(--ink); }

.badge { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 50px; background: var(--ink); color: var(--paper); white-space: nowrap; }
.badge.soft { background: var(--stone); color: var(--ink-2); }

/* ---------- Gespräch (Kunden + Intern) ---------- */
.thread { max-width: 700px; margin: 0 auto; padding: 0 24px; }
.turn { margin-bottom: 30px; animation: rise 360ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.me { display: flex; justify-content: flex-end; }
.me div { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 20px 20px 6px 20px; max-width: 80%; white-space: pre-wrap; overflow-wrap: anywhere; }
.bot { display: flex; gap: 12px; margin-top: 18px; }
.mark { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--paper-2); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--serif); font-size: 15px; }
.bot-body { flex: 1; min-width: 0; }
.bot-body .answer { margin: 3px 0 0; font-size: 15.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.bot-body .answer.none { color: var(--ink-2); }
.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.sources { display: grid; gap: 10px; margin-top: 14px; }
.source { display: flex; gap: 12px; align-items: stretch; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-sm); text-decoration: none; }
a.source:hover { border-color: var(--line-2); }
.source .rule { flex: none; width: 2px; border-radius: 2px; background: var(--stone); }
.source .file { flex: none; width: 30px; height: 38px; border-radius: 5px; background: var(--paper-2); border: 1px solid var(--line); display: grid; place-items: end center; padding-bottom: 4px; font-size: 8px; font-weight: 700; letter-spacing: .05em; color: var(--ink-2); }
.source .info { min-width: 0; flex: 1; }
.source .meta { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.source .title { font-size: 14px; font-weight: 500; margin: 1px 0 3px; }
.source q { display: block; font-family: var(--serif); font-size: 15px; color: var(--ink-2); font-style: italic; quotes: "“" "”"; overflow-wrap: anywhere; }
.source .open { align-self: center; font-size: 13px; color: var(--ink-2); white-space: nowrap; }

.error-note { color: var(--bad); font-size: 14px; }

/* ---------- Eingabefeld ---------- */
.askbar { display: flex; align-items: flex-end; gap: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 26px; padding: 8px 8px 8px 20px; box-shadow: var(--shadow-lg); }
.askbar textarea { flex: 1; border: 0; background: none; outline: none; resize: none; font-size: 16px; line-height: 1.45; padding: 8px 0; max-height: 160px; letter-spacing: -.01em; }
.askbar textarea::placeholder { color: var(--ink-3); }
.askbar .count { align-self: center; font-size: 11px; color: var(--ink-3); }

/* ---------- Sidebar-Layout (Intern + Admin) ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; height: 100dvh; }
.sidebar { background: var(--paper-2); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar .brand { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 16px; }
.wordmark { font-size: 18px; letter-spacing: -.02em; font-weight: 500; text-decoration: none; }
.wordmark sup { font-size: 9px; letter-spacing: .12em; margin-left: 4px; opacity: .6; vertical-align: 5px; }
.s-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 12px 10px 4px; }
.s-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.s-item:hover { background: rgba(64, 62, 55, .05); }
.s-item.on { background: rgba(64, 62, 55, .09); color: var(--ink); font-weight: 500; }
.s-item svg { flex: none; width: 16px; height: 16px; opacity: .8; }
.s-item .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; font-size: 13px; border-top: 1px solid var(--line); }
.user .who { flex: 1; min-width: 0; line-height: 1.3; }
.user .who small { color: var(--ink-3); font-size: 12px; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--stone); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.icon-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: rgba(64, 62, 55, .07); }
.icon-btn svg { width: 16px; height: 16px; }

.topbar { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(20px) saturate(180%); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); transition: transform 320ms var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .scrim { position: fixed; inset: 0; background: rgba(27, 26, 24, .3); z-index: 15; }
}

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; letter-spacing: .03em; color: var(--ink-2); }
.input { width: 100%; background: var(--white); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 15px; outline: none; }
.input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(64, 62, 55, .08); }
textarea.input { resize: vertical; min-height: 180px; line-height: 1.5; }

.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { font-size: 13px; padding: 5px 13px; border-radius: 7px; color: var(--ink-2); }
.seg button.on { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 50px; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 50; animation: rise 300ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--paper); backdrop-filter: none; }
}
