:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel2: #1e2530;
  --line: #2a313c;
  --text: #e8ecf1;
  --muted: #93a0b0;
  --accent: #4fd1a5;
  --warn: #f0b429;
  --danger: #ef6b6b;
  --you: #7fb4ff;
  --nav-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* 16px Mindestgroesse: verhindert das automatische Zoomen auf dem Handy. */
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1 { font-size: 1.15rem; font-weight: 650; margin: 0; letter-spacing: 0.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; color: var(--accent); }
p { margin: 0 0 10px; }
a { color: var(--you); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ---------- Rahmen ---------- */

.root { min-height: 100dvh; }
.app { display: flex; min-height: 100dvh; }
.side { display: contents; }
.side-title { display: none; }
.main {
  flex: 1; min-width: 0; max-width: 860px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
}
.auth { max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 60px; }
.view { display: flex; flex-direction: column; gap: 14px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.picker { width: auto; max-width: 220px; min-height: 40px; padding: 6px 10px; }

.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.lang-btn { background: transparent; color: var(--muted); border: 0; padding: 8px 12px; font-size: 16px; cursor: pointer; min-height: 40px; }
.lang-btn.active { background: var(--panel); color: var(--text); }

/* Navigation: unten auf dem Handy, links auf dem Desktop */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
}
.nav-btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: transparent; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 2px;
}
.nav-btn.active { color: var(--accent); }
.nav-ico { font-size: 1.2rem; line-height: 1; }
.nav-label { font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

@media (min-width: 900px) {
  .side {
    display: flex; flex-direction: column; gap: 14px; width: 220px; flex: none; padding: 20px 12px;
    background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh;
  }
  .side-title { display: block; font-weight: 700; padding: 0 10px; }
  .nav { position: static; flex-direction: column; height: auto; padding: 0; border: 0; background: transparent; gap: 4px; }
  .nav-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px; border-radius: 10px; }
  .nav-btn.active { background: var(--panel2); }
  .nav-label { font-size: 1rem; }
  .main { padding: 24px 28px 60px; }
}

/* ---------- Bausteine ---------- */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
details.card summary { cursor: pointer; font-weight: 650; margin-bottom: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); background: var(--panel);
  padding: 10px 0; border-top: 1px solid var(--line); margin-top: 6px;
}
.sticky-actions .notice { margin-bottom: 8px; }
@media (min-width: 900px) { .sticky-actions { bottom: 26px; } }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.label { font-size: 0.85rem; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus-visible, .btn:focus-visible, .lang-btn:focus-visible, .nav-btn:focus-visible, .stat:focus-visible,
.check input:focus-visible, .review-check input:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.btn {
  min-height: 46px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #062018; }
.btn.accent { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #2b0606; }
.btn.small { min-height: 38px; padding: 6px 12px; font-weight: 500; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.notice { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; }
.notice.bad { background: rgba(239, 107, 107, 0.12); border: 1px solid var(--danger); color: #ffd7d7; }
.notice.good { background: rgba(79, 209, 165, 0.12); border: 1px solid var(--accent); color: #d4fff0; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag { font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.tag.good { border-color: var(--accent); color: var(--accent); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.bad { border-color: var(--danger); color: var(--danger); }
.tag.link { color: var(--you); border-color: var(--you); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--panel2); font-size: 0.9rem; }

/* ---------- Uebersicht ---------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 16px; text-align: left;
}
.stat.alert { border-color: var(--warn); }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat.alert .stat-value { color: var(--warn); }
.stat-label { color: var(--muted); font-size: 0.9rem; }

/* ---------- Wissen ---------- */

.group { display: flex; flex-direction: column; gap: 2px; }
.fact { padding: 10px 0; border-top: 1px solid var(--line); }
.group .fact:first-of-type, .card > .fact:first-child { border-top: 0; }
.fact.expired .fact-text { color: var(--muted); text-decoration: line-through; }
.fact-text { margin: 0; overflow-wrap: anywhere; }
.form { margin-top: 4px; }
.history { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.history-line { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 8px; border-radius: 10px; background: var(--bg); }
.old { color: var(--muted); font-style: italic; overflow-wrap: anywhere; }

/* ---------- Import ---------- */

.jobs { display: flex; flex-direction: column; gap: 6px; }
.job { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: var(--panel); border-left: 3px solid var(--line); }
.job.running, .job.queued { border-left-color: var(--warn); }
.job.done { border-left-color: var(--accent); }
.job.failed { border-left-color: var(--danger); }
.job-label { overflow-wrap: anywhere; }
.review { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.review-check input, .check input { width: 24px; height: 24px; margin: 10px 0 0; flex: none; accent-color: var(--accent); }
.review-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.quote { margin: 0; color: var(--muted); font-size: 0.85rem; font-style: italic; overflow-wrap: anywhere; }

/* ---------- Gespraech ---------- */

.stage { display: flex; flex-direction: column; min-height: 240px; max-height: 46dvh; }
.state { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: var(--muted); font-size: 0.95rem; min-height: 1.5em; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.connecting, .dot.waiting { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.dot.listening { background: var(--accent); }
.dot.thinking { background: var(--warn); animation: pulse 0.7s ease-in-out infinite; }
.dot.speaking { background: var(--you); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none !important; } }
.log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--muted); margin: 0; }
.line { display: flex; flex-direction: column; gap: 2px; max-width: 92%; }
.line .who { font-size: 0.8rem; color: var(--muted); }
.line .body { padding: 9px 12px; border-radius: 12px; background: var(--panel2); overflow-wrap: anywhere; }
.line.you { align-self: flex-end; align-items: flex-end; }
.line.you .body { background: #1d2c44; }
.line.agent .who { color: var(--accent); }
.line.you .who { color: var(--you); }
.consent p { font-size: 0.95rem; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; }
.teach-help { font-size: 0.9rem; margin: 0; }
.controls { display: flex; gap: 10px; }
.controls .btn { flex: 1; min-height: 52px; }

/* ---------- Hinweis und Version ---------- */

.cookie {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; font-size: 0.9rem; max-width: 720px; margin: 0 auto;
}
.version {
  position: fixed; right: 10px; bottom: calc(var(--nav-h) + 4px + env(safe-area-inset-bottom)); z-index: 4;
  font-size: 11px; color: var(--muted); opacity: 0.7; pointer-events: none;
}
/* Solange der Hinweis sichtbar ist, bleibt darunter Platz, damit er nichts verdeckt. */
body.has-cookie .main, body.has-cookie .auth { padding-bottom: calc(var(--nav-h) + 150px + env(safe-area-inset-bottom)); }
body.no-nav .cookie { bottom: calc(10px + env(safe-area-inset-bottom)); }
body.no-nav .version { bottom: calc(2px + env(safe-area-inset-bottom)); opacity: 0.5; }
@media (min-width: 900px) {
  .cookie { bottom: 14px; }
  .version { bottom: 8px; }
}
.card details summary { cursor: pointer; font-weight: 650; margin: 12px 0 8px; }
.dup-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
