/* Kompasswerk — ruhiges, klares Design ohne Framework */
:root {
  --bg: #f5f7f6;
  --card: #ffffff;
  --ink: #26343c;
  --muted: #64707a;
  --accent: #2f6f6a;
  --accent-dark: #24544f;
  --accent-soft: #e4efed;
  --line: #e4e9e7;
  --warn-bg: #fdf3e4;
  --warn-ink: #8a5a1d;
  --error-bg: #fbe9e7;
  --error-ink: #8c3226;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(38, 52, 60, .04), 0 1px 3px rgba(38, 52, 60, .06);
  --shadow: 0 6px 22px rgba(38, 52, 60, .10);
  --ring: 0 0 0 3px rgba(47, 111, 106, .22);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}
.container { width: min(960px, 92vw); margin: 0 auto; }
main.container { flex: 1; padding: 1.5rem 0 3rem; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.22; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* Header/Footer */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .8rem 0; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--ink); }
.brand-group { display: flex; align-items: baseline; gap: .55rem; min-width: 0; }
.brand-context { color: var(--muted); font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-context::before { content: "/"; color: var(--line); margin-right: .55rem; font-weight: 400; }
.nav a { margin-left: 1rem; text-decoration: none; }
.site-footer { background: var(--card); border-top: 1px solid var(--line); padding: 1rem 0 1.4rem; font-size: .85rem; color: var(--muted); }
.footer-crisis { background: var(--warn-bg); color: var(--warn-ink); padding: .55rem .8rem; border-radius: 8px; margin-bottom: .8rem; }
.footer-crisis a { color: var(--warn-ink); }
.footer-links a { margin-right: 1rem; color: var(--muted); }

/* Cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: .9rem 0; box-shadow: var(--shadow-sm); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.hero { padding: 2.2rem 0 .6rem; }
.hero h1 { font-size: 2rem; margin: 0 0 .5rem; }
.hero-sub { color: var(--muted); font-size: 1.06rem; max-width: 46rem; }
.notice-card { background: var(--accent-soft); border-color: transparent; }
.cta-card { text-align: center; padding: 1.6rem; }
.muted { color: var(--muted); font-size: .9rem; }
.prose { max-width: 46rem; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: .58rem 1.25rem; border-radius: 999px; text-decoration: none;
  font-size: 1rem; line-height: 1.3; font-weight: 600; cursor: pointer;
  font-family: inherit; box-shadow: var(--shadow-sm);
  transition: background .15s ease, box-shadow .15s ease, transform .04s ease,
    color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--accent-dark); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-big { padding: .78rem 1.7rem; font-size: 1.06rem; }
.btn-small { padding: .34rem .9rem; font-size: .9rem; }
/* Sekundär: ruhiger Umriss statt Vollfläche */
.btn-secondary { background: #fff; color: var(--accent-dark); border-color: var(--line); box-shadow: none; }
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent-soft); box-shadow: none; }
/* Destruktiv: dezent; füllt sich erst beim Hover (klare Hierarchie) */
.btn-danger { background: #fff; color: #a33c2e; border-color: #e7c6c0; box-shadow: none; }
.btn-danger:hover { background: #a33c2e; color: #fff; border-color: #a33c2e; box-shadow: var(--shadow-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }

form p { margin: .7rem 0; }
label { font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; padding: .62rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
input[type="checkbox"] { width: auto; margin-right: .45rem; }
button[type="submit"], form .primary { margin-top: .4rem; }
form button { font: inherit; }
.helptext, .form-hint { color: var(--muted); font-size: .85rem; font-weight: 400; display: block; }
.errorlist { color: var(--error-ink); margin: .2rem 0; padding-left: 1.1rem; font-size: .9rem; }
form ul { padding-left: 1.1rem; }
form label:has(input[type="checkbox"]) { font-weight: 400; display: block; margin: .5rem 0; }

/* Flash messages */
.flash { padding: .7rem 1rem; border-radius: 8px; margin: .8rem 0; background: var(--accent-soft); }
.flash-error { background: var(--error-bg); color: var(--error-ink); }
.flash-success { background: #e7f3e7; color: #2c5f2e; }
.flash-info { background: var(--accent-soft); }

/* Products */
.product-card { display: flex; flex-direction: column; gap: .6rem; }
.price { font-size: 1.3rem; font-weight: 700; }
.price-note { font-size: .85rem; color: var(--muted); font-weight: 400; }
.waiver { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; font-size: .88rem; color: var(--muted); }
.waiver input { margin-top: .25rem; }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; flex: 1; min-height: 380px; }
/* Chat-Seite füllt den Viewport: main als Flex-Spalte, damit .chat-wrap (flex:1)
   die Höhe füllt — keine Leerfläche zwischen Krisenzeile und Footer. */
main.container:has(.chat-wrap) { display: flex; flex-direction: column; padding-bottom: 1rem; }
.chat-toolbar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.chat-toolbar select { max-width: 300px; width: auto; }
/* Formular „auflösen“, damit der Lösch-Button ein direktes Flex-Kind ist und
   exakt auf einer Linie mit dem Link-Button sitzt */
.chat-toolbar form { display: contents; }
.chat-toolbar .btn { margin: 0; }
/* Teilen-Panel (öffentlicher Link) */
.share-panel { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .1rem 0 .5rem; }
.share-panel input { flex: 1; min-width: 220px; font-size: .85rem; background: var(--card); }
.share-panel .muted { font-size: .8rem; }
/* Mount-Knoten der React-Insel (assistant-ui) — füllt die Chat-Höhe; das
   Styling der Insel selbst lebt isoliert im Shadow-Root. */
.kompass-chat-root { flex: 1 1 auto; min-height: 420px; }
.chat-messages {
  flex: 1; overflow-y: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.msg { max-width: 80%; margin: .5rem 0; padding: .72rem 1rem; border-radius: 14px; line-height: 1.5; white-space: normal; overflow-wrap: break-word; }
.msg p { margin: .35rem 0; }
.msg ul, .msg ol { margin: .3rem 0; padding-left: 1.3rem; }
.msg-user { margin-left: auto; background: var(--accent-soft); border-bottom-right-radius: 5px; }
.msg-assistant { margin-right: auto; background: #eef2f1; border-bottom-left-radius: 5px; }
.msg-status { text-align: center; color: var(--muted); font-size: .85rem; margin: .5rem 0; }
.msg-error { background: var(--error-bg); color: var(--error-ink); margin-right: auto; }
.msg-content.streaming > :last-child::after {
  content: "▋"; animation: blink 1s step-start infinite; color: var(--accent); margin-left: .06em;
}
@keyframes blink { 50% { opacity: 0; } }

/* Warte-Indikator: rotierende Phrasen + animierte Punkte */
.msg-assistant.thinking { color: var(--muted); }
.thinking-text { transition: opacity .25s ease; opacity: 1; }
.thinking-text.fade { opacity: 0; }
.thinking-dots::after {
  display: inline-block; content: ""; width: 1.2em; text-align: left;
  animation: thinking-dots 1.6s steps(1, end) infinite; color: var(--accent);
}
@keyframes thinking-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}
.chat-composer { display: flex; gap: .6rem; margin-top: .7rem; align-items: flex-end; }
.chat-composer textarea { resize: none; height: 74px; flex: 1; }
.chat-blocked { background: var(--warn-bg); color: var(--warn-ink); padding: .8rem 1rem; border-radius: 8px; margin-top: .7rem; }
.chat-crisis { font-size: .8rem; color: var(--muted); margin-top: .45rem; text-align: center; }
.chat-meta { font-size: .75rem; color: var(--muted); font-family: ui-monospace, monospace; margin-top: .3rem; }

/* Formatierte Antworten (Markdown), Codeblöcke & Kopier-Buttons */
.msg-content > :first-child { margin-top: 0; }
.msg-content > :last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3, .msg-content h4 {
  font-size: 1.02em; margin: .7rem 0 .3rem; line-height: 1.3; letter-spacing: 0;
}
.msg-content a { overflow-wrap: break-word; }
.msg-content blockquote {
  margin: .5rem 0; padding: .15rem .8rem; border-left: 3px solid var(--accent-soft); color: var(--muted);
}
.msg-content hr { border: none; border-top: 1px solid var(--line); margin: .8rem 0; }
.msg-content table {
  border-collapse: collapse; margin: .5rem 0; font-size: .92em; display: block; overflow-x: auto; max-width: 100%;
}
.msg-content th, .msg-content td { border: 1px solid var(--line); padding: .35rem .55rem; text-align: left; }
.msg-content th { background: rgba(47, 111, 106, .10); font-weight: 600; }
/* Inline-Code */
.msg-content :not(pre) > code {
  background: var(--accent-soft); color: var(--accent-dark); padding: .08em .38em; border-radius: 5px;
  font-size: .9em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* Codeblock */
.msg-content pre {
  position: relative; margin: .55rem 0; padding: .8rem .9rem; background: #1f2a2e; color: #e7edea;
  border-radius: var(--radius-sm); overflow-x: auto; font-size: .86em; line-height: 1.5;
}
.msg-content pre code {
  white-space: pre; background: none; color: inherit; padding: 0; font-size: 1em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Kopier-Button (ganze Antwort) — dezent, immer sichtbar (auch mobil) */
.msg-actions { margin-top: .4rem; display: flex; justify-content: flex-end; opacity: .55; transition: opacity .15s ease; }
.msg-assistant:hover .msg-actions, .msg-assistant:focus-within .msg-actions { opacity: 1; }
.copy-btn {
  display: inline-flex; align-items: center; gap: .3rem; background: transparent;
  border: 1px solid var(--line); color: var(--muted); padding: .2rem .55rem; border-radius: 999px;
  font: inherit; font-size: .8rem; line-height: 1.2; cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.copy-btn:hover { background: var(--card); color: var(--ink); }
.copy-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.copy-btn.is-copied { color: var(--accent); border-color: var(--accent); }
.copy-ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Kopier-Button (einzelner Codeblock) — Icon oben rechts */
.code-copy {
  position: absolute; top: .4rem; right: .4rem; padding: .3rem; gap: 0; border-radius: 7px;
  color: #cdd6d2; background: rgba(255, 255, 255, .10); border-color: rgba(255, 255, 255, .18); opacity: .8;
}
.msg-content pre:hover .code-copy { opacity: 1; }
.code-copy:hover { background: rgba(255, 255, 255, .2); color: #fff; }
.code-copy.is-copied { color: #b9d9a0; border-color: rgba(185, 217, 160, .5); background: rgba(255, 255, 255, .12); }

/* highlight.js — kompakte, themebare Tokenfarben auf dunklem Codehintergrund */
.hljs-comment, .hljs-quote { color: #8b9a95; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-doctag, .hljs-name, .hljs-tag { color: #8fd3c8; }
.hljs-string, .hljs-attr, .hljs-meta .hljs-string, .hljs-addition { color: #b9d9a0; }
.hljs-number, .hljs-built_in, .hljs-type, .hljs-symbol, .hljs-bullet, .hljs-attribute { color: #e6c384; }
.hljs-title, .hljs-title.function_, .hljs-selector-id, .hljs-selector-class { color: #f0a5a0; }
.hljs-variable, .hljs-template-variable, .hljs-regexp, .hljs-link { color: #cdd6d2; }
.hljs-meta { color: #8b9a95; }
.hljs-deletion { color: #f0a5a0; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* Sprache (Voice): runder Mikrofon-Knopf + dezente Vorlese-Option */
.btn-icon {
  padding: 0; width: 2.6rem; min-width: 2.6rem; height: 2.6rem;
  border-radius: 50%; font-size: 1.2rem;
}
.btn-icon.listening { background: #a33c2e; animation: voice-pulse 1.2s ease-in-out infinite; }
.btn-icon.listening:hover { background: #85301f; }
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 60, 46, .45); }
  50%      { box-shadow: 0 0 0 .5rem rgba(163, 60, 46, 0); }
}
.voice-opt {
  display: inline-flex; align-items: center; cursor: pointer;
  margin-top: .5rem; font-weight: 400; font-size: .85rem; color: var(--muted);
}
.voice-opt input { width: auto; margin: 0 .4rem 0 0; }

/* Tables (account) */
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th, table.list td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-weight: 600; }

/* Legal prose */
.legal h1 { font-size: 1.6rem; }
.legal h2 { font-size: 1.15rem; margin-top: 1.6rem; }
.legal { max-width: 46rem; }
.placeholder { background: #fff3cd; padding: .1rem .3rem; border-radius: 4px; }

/* --- Mobile-Feinschliff (Basis ist bereits responsiv: viewport-Meta, ------
   92vw-Container, Flex/Grid). Hier nur Ecken abrunden für schmale Screens. */
@media (max-width: 640px) {
  /* Kopfzeile darf umbrechen; Navigation rückt zusammen */
  .header-inner { flex-wrap: wrap; gap: .2rem .9rem; padding: .6rem 0; }
  .nav a { margin-left: 0; margin-right: .9rem; }

  /* Überschriften/Abstände kompakter */
  main.container { padding: 1.1rem 0 2.4rem; }
  .hero { padding: 1.4rem 0 .4rem; }
  .hero h1 { font-size: 1.7rem; }
  .hero-sub { font-size: 1rem; }

  /* Chat füllt den sichtbaren Bereich (dvh gegen mobile Browserleisten) */
  .chat-wrap { min-height: 300px; }
  .msg { max-width: 90%; }
  .chat-toolbar select { max-width: 100%; }

  /* Breite Tabellen horizontal scrollen statt die Seite zu verbreitern */
  table.list { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
}

/* --- Ein-Produkt-Startseite (Marken-Entry) ------------------------------------
   Genutzt von templates/brands/entry.html; Farben kommen aus den Theme-Variablen. */
.brand-hero { padding: 2.6rem 0 1rem; max-width: 46rem; }
.brand-eyebrow {
  text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 700;
  color: var(--gold, var(--muted)); margin: 0 0 .6rem;
}
.brand-hero h1 { font-size: 2.4rem; margin: 0 0 .6rem; }
.brand-hero .hero-sub { font-size: 1.1rem; }
.brand-cta { margin-top: 1.4rem; display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.brand-cta .muted { margin: 0; }

/* --- Theme: Belastungskompass -------------------------------------------------
   Exakte Tokens der Marken-Landingpage (belastungskompass.de). Da die gesamte
   UI variablengesteuert ist, reskint dieser Block Kopf/Fuß/Buttons/Formulare
   UND den Chat auf dem Marken-Host. Der Plattform-Standard (Kompasswerk) bleibt
   unberührt. */
body.theme-belastungskompass {
  --bg: #faf7f0;             /* Sand */
  --card: #fffefa;
  --ink: #122c43;            /* tiefes Navy */
  --muted: #5d6c70;
  --accent: #122c43;         /* Primärbutton in Navy (wie die Hero-CTA der Seite) */
  --accent-dark: #0a1c2c;
  --accent-soft: #e8eee8;    /* Sage: weiche Flächen, Nutzer-Sprechblase, Notice-Card */
  --line: #e0d9ca;
  --gold: #b8904e;           /* Messing-Akzent (Kicker, Hairlines) */
  --radius: 22px;
  --radius-sm: 14px;
  --shadow-sm: 0 1px 2px rgba(18, 44, 67, .05), 0 1px 3px rgba(18, 44, 67, .06);
  --shadow: 0 14px 42px rgba(18, 44, 67, .08);
  --ring: 0 0 0 3px rgba(18, 44, 67, .20);
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", system-ui, Arial, sans-serif;
  --font-display: "Iowan Old Style", Baskerville, "Palatino Linotype", "Book Antiqua", Georgia, serif;
}
body.theme-belastungskompass h1,
body.theme-belastungskompass h2,
body.theme-belastungskompass h3,
body.theme-belastungskompass .brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}
/* Chat-Feinschliff: Assistenten-Blase & Codeblock an die Markenwelt angleichen
   (die betreffenden app.css-Regeln nutzen feste Literale statt Variablen). */
body.theme-belastungskompass .msg-assistant { background: #eef1ea; }
body.theme-belastungskompass .msg-content pre { background: #16232e; }
body.theme-belastungskompass .msg-content th { background: rgba(18, 44, 67, .08); }
