/* TradeM8te - Mobile-First-Oberflaeche
   Layout: unter 900 px Tab-Leiste unten, darueber Seitennavigation links. */

:root {
  --bg: #0b0f16;
  --bg-elev: #131a25;
  --bg-elev2: #1a2331;
  --line: #243044;
  --line-soft: #1b2433;
  --text: #e6edf6;
  --text-dim: #93a3b8;
  --text-faint: #64748b;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --violet: #a78bfa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --bg-elev2: #eef2f8;
  --line: #d5dde9;
  --line-soft: #e5eaf2;
  --text: #101828;
  --text-dim: #566076;
  --text-faint: #7b8798;
  --accent: #0369a1;
  --accent-dim: #0284c7;
  --good: #047857;
  --warn: #b45309;
  --bad: #b91c1c;
  --violet: #6d28d9;
  --shadow: 0 4px 18px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

/* Ohne !important gewinnt das `display: inline-flex` der Schaltflächen gegen
   das hidden-Attribut - Elemente, die eine Rolle nicht sehen darf, blieben
   dann sichtbar. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(64px + var(--safe-b));
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 17px; line-height: 1.1; }
.brand-sub { margin: 0; font-size: 11px; color: var(--text-faint);
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; font-weight: 800; font-size: 13px; letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--accent), var(--violet)); color: #05121c;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #05121c; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text-dim); cursor: pointer; font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* -------------------------------------------------------------- Layout */
.shell { display: block; }
.sidenav { display: none; }
/* width:100% ist hier Pflicht, nicht Kosmetik: als Grid-Element wuerde `.main`
   sonst auf seine Inhaltsbreite wachsen. Ein waagerecht scrollender Bereich
   (etwa die Chip-Leiste) traegt seine volle Breite zur intrinsischen Groesse
   bei - trotz overflow-x:auto - und schoebe damit die ganze Seite auf. */
.main { padding: 14px; max-width: 1280px; margin: 0 auto; width: 100%; min-width: 0; }
.main:focus { outline: none; }

.view-head { margin-bottom: 14px; }
.view-head h2 { font-size: 21px; }
.view-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }

/* --------------------------------------------------------------- Cards */
.card {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .hint { font-size: 12px; color: var(--text-faint); }

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) {
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-2-1 { grid-template-columns: 2fr 1fr; }
}

/* ------------------------------------------------------------ Kennzahl */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 12px;
}
.kpi .label { font-size: 11px; color: var(--text-faint); text-transform: uppercase;
              letter-spacing: .05em; display: block; margin-bottom: 4px; }
.kpi .value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums;
              letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
@media (min-width: 700px) { .kpi .value { font-size: 24px; } }

.pos { color: var(--good); } .neg { color: var(--bad); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--text-dim); } .faint { color: var(--text-faint); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.center { text-align: center; } .right { text-align: right; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------- Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 650;
  border: 1px solid var(--line); background: var(--bg-elev2); color: var(--text-dim);
  white-space: nowrap;
}
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent);
              background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
              background: color-mix(in srgb, var(--warn) 12%, transparent); }
.badge.bad  { color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
              background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent);
              background: color-mix(in srgb, var(--accent) 12%, transparent); }
.badge.violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 40%, transparent);
                background: color-mix(in srgb, var(--violet) 12%, transparent); }

/* -------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
     color: var(--text-faint); font-weight: 650; white-space: nowrap;
     position: sticky; top: 0; background: var(--bg-elev); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-elev2); }

/* ------------------------------------------------------------- Signale */
.signal {
  border: 1px solid var(--line-soft); border-left-width: 4px;
  border-radius: var(--radius); background: var(--bg-elev);
  padding: 12px; margin-bottom: 10px;
}
.signal[data-action="kaufen"], .signal[data-action="aufstocken"] { border-left-color: var(--good); }
.signal[data-action="halten"] { border-left-color: var(--text-faint); }
.signal[data-action="trimmen"] { border-left-color: var(--warn); }
.signal[data-action="verkaufen"] { border-left-color: var(--bad); }
.signal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.signal-title { min-width: 0; }
.signal-title h4 { font-size: 15px; }
.signal-title .sym { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.signal-amount { text-align: right; flex: none; }
.signal-amount .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.reasons { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.reasons li { display: flex; gap: 8px; font-size: 13px; line-height: 1.45; }
.reasons .tag {
  flex: none; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 5px; background: var(--bg-elev2);
  color: var(--text-faint); height: fit-content; margin-top: 1px; min-width: 76px; text-align: center;
}
.reasons li[data-w="entscheidend"] .tag { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.reasons li[data-w="stark"] .tag { background: color-mix(in srgb, var(--violet) 16%, transparent); color: var(--violet); }
.reasons li[data-w="warnung"] .tag { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.reasons li[data-a="panik_bremse"] .tag { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }

/* --------------------------------------------------------- Kausalkette */
.chain { display: grid; gap: 0; margin: 10px 0; }
.chain-link { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.chain-rail { display: flex; flex-direction: column; align-items: center; }
.chain-node {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex: none;
  border: 2px solid var(--line); background: var(--bg-elev2); color: var(--text-dim);
}
.chain-link[data-status="supported"] .chain-node { border-color: var(--good); color: var(--good); }
.chain-link[data-status="contradicted"] .chain-node { border-color: var(--bad); color: var(--bad); }
.chain-line { width: 2px; flex: 1; min-height: 14px; background: var(--line); }
.chain-body { padding-bottom: 14px; min-width: 0; }
.chain-cause { font-size: 13px; color: var(--text-dim); }
.chain-effect { font-size: 14px; font-weight: 600; margin: 2px 0; }
.chain-mech { font-size: 12px; color: var(--text-faint); font-style: italic; }
.chain-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.falsifier {
  display: flex; gap: 9px; align-items: flex-start; padding: 9px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.falsifier:last-child { border-bottom: 0; }
.falsifier .mark { flex: none; font-size: 14px; line-height: 1.4; }
.falsifier[data-hit="true"] { color: var(--bad); }

/* --------------------------------------------------------------- Meter */
.meter { height: 7px; border-radius: 99px; background: var(--bg-elev2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter.good > span { background: var(--good); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }

.bar-row { display: grid; grid-template-columns: 110px 1fr 62px; gap: 8px;
           align-items: center; font-size: 13px; margin-bottom: 7px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .val { text-align: right; font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- News */
.news-item { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.news-item:last-child { border-bottom: 0; }
.news-item h4 { font-size: 14px; font-weight: 600; line-height: 1.4; }
.news-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
             margin-top: 6px; font-size: 11px; color: var(--text-faint); }

/* --------------------------------------------------------------- Forms */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 9px 11px; font: inherit; font-size: 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px;
  border-color: var(--accent);
}
.field-help { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .form-grid { grid-template-columns: 1fr 1fr; } }

/* -------------------------------------------------------------- Chips */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; min-width: 0;
         -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 550;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text-dim);
  cursor: pointer; white-space: nowrap; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #05121c; }

/* ------------------------------------------------------- Bottom-Navigation */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 2px; min-height: 58px; color: var(--text-faint);
  font-size: 10px; position: relative;
}
.tabbar a i { font-style: normal; font-size: 17px; line-height: 1; }
.tabbar a.active { color: var(--accent); }
.tabbar .dot { position: absolute; top: 7px; right: calc(50% - 16px);
               width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }

/* --------------------------------------------------------- Desktop-Layout */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .shell { display: grid; grid-template-columns: 218px minmax(0, 1fr); align-items: start; }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
    position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
    border-right: 1px solid var(--line-soft);
  }
  .sidenav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border-radius: var(--radius-sm); color: var(--text-dim); font-size: 14px; font-weight: 550;
  }
  .sidenav a i { font-style: normal; font-size: 15px; width: 18px; text-align: center; }
  .sidenav a:hover { background: var(--bg-elev); color: var(--text); }
  .sidenav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
  .sidenav .pill {
    margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 7px;
    border-radius: 999px; background: var(--bad); color: #fff;
  }
  .sidenav .pill:empty { display: none; }
  .main { padding: 20px 24px 40px; }
  .table-wrap { margin: 0; padding: 0; }
  table { min-width: 0; }
}

/* ------------------------------------------------------------- Bottom-Sheet */
.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg-elev); border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line); box-shadow: var(--shadow);
  animation: sheet-up .22s cubic-bezier(.22, 1, .36, 1);
  padding-bottom: var(--safe-b);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line-soft); flex: none;
}
.sheet-head h2 { font-size: 16px; }
.sheet-body { padding: 14px 16px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (min-width: 900px) {
  .sheet-panel {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%); width: min(820px, 92vw);
    max-height: 86vh; border-radius: var(--radius); border: 1px solid var(--line);
    animation: sheet-in .18s ease;
  }
  @keyframes sheet-in { from { opacity: 0; transform: translate(-50%, -46%); } }
}

/* -------------------------------------------------------------- Toasts */
.toasts {
  position: fixed; left: 12px; right: 12px; bottom: calc(72px + var(--safe-b));
  z-index: 90; display: grid; gap: 8px; pointer-events: none;
}
@media (min-width: 900px) { .toasts { left: auto; right: 20px; bottom: 20px; width: 380px; } }
.toast {
  background: var(--bg-elev2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13px;
  box-shadow: var(--shadow); animation: toast-in .2s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* -------------------------------------------------------------- Sonstiges */
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-dim);
           padding: 40px 0; justify-content: center; font-size: 14px; }
.spinner {
  width: 17px; height: 17px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy .run-label::after { content: " …"; }

.empty { text-align: center; padding: 34px 16px; color: var(--text-faint); }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .55; }

.notice {
  display: flex; gap: 9px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent);
  font-size: 12.5px; color: var(--text); line-height: 1.45; margin-bottom: 12px;
}
.notice.info { background: color-mix(in srgb, var(--accent) 9%, transparent);
               border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.notice.bad { background: color-mix(in srgb, var(--bad) 10%, transparent);
              border-color: color-mix(in srgb, var(--bad) 34%, transparent); }

details.expander { border-top: 1px solid var(--line-soft); padding-top: 9px; margin-top: 9px; }
details.expander > summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim);
                             list-style: none; min-height: 30px; display: flex; align-items: center; }
details.expander > summary::-webkit-details-marker { display: none; }
details.expander > summary::before { content: "▸ "; margin-right: 5px; }
details.expander[open] > summary::before { content: "▾ "; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; }
.kv dt { color: var(--text-faint); } .kv dd { margin: 0; text-align: right;
                                              font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 9px; }
hr.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 14px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------- Berater-Chat */
/* Der Chat fuellt genau den Platz zwischen Kopfbereich und Eingabefeld.
   Feste Hoehenabzuege waeren geraten und wuerden das Eingabefeld auf kleinen
   Geraeten hinter die Tab-Leiste schieben - deshalb eine Flex-Spalte mit
   fester Viewport-Hoehe. dvh statt vh, damit die einblendbare Browserleiste
   auf dem Handy nicht stoert. */
.chat-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - 57px - 64px - var(--safe-b) - 28px);
  height: calc(100dvh - 57px - 64px - var(--safe-b) - 28px);
  min-height: 420px;
}
.chat-shell > .view-head, .chat-shell > .notice,
.chat-shell > .chips, .chat-shell > form, .chat-shell > p { flex: none; }

.chat {
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 0 10px; flex: 1 1 auto; min-height: 90px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
@media (min-width: 900px) {
  .chat-shell {
    height: calc(100vh - 57px - 60px);
    height: calc(100dvh - 57px - 60px);
  }
}

.chat-row { display: flex; gap: 9px; align-items: flex-start; }
.chat-row.user { justify-content: flex-end; }
.chat-avatar {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid;
  place-items: center; font-size: 14px; color: #05121c;
  background: linear-gradient(135deg, var(--accent), var(--violet));
}
.chat-avatar.big { width: 46px; height: 46px; font-size: 21px; border-radius: 13px; margin: 0 auto 10px; }

.bubble {
  max-width: min(680px, 88%); padding: 11px 14px; border-radius: 14px;
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere;
}
.chat-row.user .bubble {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-elev));
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  border-bottom-right-radius: 5px;
}
.chat-row.advisor .bubble { border-bottom-left-radius: 5px; }
.bubble.err { border-color: color-mix(in srgb, var(--bad) 40%, transparent);
              background: color-mix(in srgb, var(--bad) 8%, var(--bg-elev)); }
.bubble p { margin: 0 0 9px; }
.bubble p:last-of-type { margin-bottom: 0; }
.bubble h4 { font-size: 14px; margin: 11px 0 5px; }
.bubble h4:first-child { margin-top: 0; }
.bubble ul, .bubble ol { margin: 0 0 9px; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }
.bubble code { font-family: var(--mono); font-size: 12.5px;
               background: var(--bg-elev2); padding: 1px 5px; border-radius: 4px; }
.bubble strong { font-weight: 650; }
.chat-time { font-size: 10.5px; color: var(--text-faint); margin-top: 6px; }

.chat-intro { text-align: center; padding: 26px 14px; margin: auto 0; }
.chat-intro h3 { font-size: 17px; margin-bottom: 7px; }
.chat-intro p { max-width: 460px; margin: 0 auto; }

.chat-input {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--line);
}
.chat-input textarea {
  flex: 1; min-height: 44px; max-height: 160px; resize: none; overflow-y: auto;
  border: 0; background: transparent; padding: 10px 4px; font-size: 16px;
}
.chat-input textarea:focus { outline: none; }
.chat-input textarea:disabled { opacity: .55; }
.chat-input .btn {
  flex: none; width: 44px; min-height: 44px; padding: 0;
  font-size: 18px; border-radius: 11px;
}

/* ------------------------------------------------------------ Anmeldung */
body.abgemeldet { padding-bottom: 0; }
.shell.ohne-navigation { display: block; }

.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px 22px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-card .field { margin-bottom: 14px; }

.user-chip {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #05121c; border-color: transparent;
}
.user-chip:hover { color: #05121c; opacity: .88; }

/* Elemente, die eine Nur-Lese-Rolle nicht braucht */
body.nur-lesen [data-nur-schreiben] { display: none; }

/* ------------------------------------------------------ Gegenüberstellung */
table.vgl th:first-child, table.vgl td:first-child {
  position: sticky; left: 0; background: var(--bg-elev); z-index: 2;
}
table.vgl thead th:first-child { z-index: 3; }
table.vgl td.best {
  color: var(--good); font-weight: 650;
  background: color-mix(in srgb, var(--good) 10%, transparent);
}
table.vgl th.num { text-align: right; }

/* Auswahlkästchen in Formularen sollen nicht die volle Breite einnehmen */
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; min-height: 0; accent-color: var(--accent);
}
