:root {
  --red: #b3121a; --red-dark: #8c0d13; --bg: #f4f4f5; --card: #fff; --text: #18181b;
  --muted: #71717a; --line: #e4e4e7; --me: #b3121a; --bot: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111113; --card: #1c1c1f; --text: #f4f4f5; --muted: #a1a1aa; --line: #2e2e33; --bot: #1c1c1f; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.hidden { display: none !important; }
.screen { height: 100dvh; display: flex; flex-direction: column; }
#login { align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px; color: var(--text); }
.card h1, .card h2 { margin: 0; }
.logo { width: 64px; height: 64px; border-radius: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
label:has(> input[type=checkbox]) { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
input[type=checkbox] { width: 20px; height: 20px; }
button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--red); color: #fff; border-color: var(--red); }
button.danger { color: var(--red); }
button.small { font-size: 13px; padding: 6px 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.err { color: var(--red); min-height: 1em; margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--card); }
header .title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
header .title span { font-size: 12px; }
button.icon { width: 42px; height: 42px; padding: 0; font-size: 20px; border-radius: 50%; }

#msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; }
.msg.user { align-self: flex-end; background: var(--me); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { align-self: center; color: var(--red); font-size: 14px; background: transparent; }
.msg .tools { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.msg.assistant:active { opacity: .7; }
.hint { color: var(--muted); text-align: center; margin: auto; padding: 20px; line-height: 1.5; }

.status { text-align: center; min-height: 22px; font-size: 14px; color: var(--muted); padding: 0 10px; }
footer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); }
#textForm { display: flex; gap: 8px; }
#textForm input { flex: 1; }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 10px; }
.controls > :first-child { justify-self: start; }
.controls .toggle { justify-self: end; flex-direction: row; align-items: center; gap: 6px; font-size: 14px; }
.mic { width: 78px; height: 78px; border-radius: 50%; background: var(--red); color: #fff; border: none; display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); grid-column: 2; }
/* Ruhe = grün (bereit), Zuhören = rot pulsierend, Arbeiten = grau, Vorlesen = blau */
.mic, .mic.idle { background: #16a34a; }
.mic.rec { background: #dc2626; animation: pulse 1.2s infinite; }
.mic.busy { background: var(--muted); }
.mic.speaking { background: #2563eb; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.6); } 70% { box-shadow: 0 0 0 18px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
dialog { border: none; padding: 0; background: transparent; width: min(94vw, 440px); }
dialog::backdrop { background: rgba(0,0,0,.45); }

/* ---------- Objektdatenblatt ---------- */
#od, .overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); }
#od .odbody, .overlay .odbody { flex: 1; overflow-y: auto; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
#od .card, .overlay .card { max-width: none; }
.od-sec { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.od-sec h3 { margin: 0 0 8px; font-size: 16px; color: var(--red); }
.od-sec h2 { margin: 0; font-size: 18px; }
.od-kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 4px 10px; font-size: 15px; }
.od-kv dt { color: var(--muted); } .od-kv dd { margin: 0; word-break: break-word; }
.od-nb { color: var(--muted); font-style: italic; }
.od-list { margin: 0; padding-left: 18px; } .od-list li { margin: 3px 0; }
.od-item { border-top: 1px solid var(--line); padding: 7px 0; font-size: 15px; } .od-item:first-of-type { border-top: none; }
.od-item b { display: block; }
.od-item a { color: var(--red); text-decoration: none; margin-right: 12px; white-space: nowrap; }
.od-kurz { background: rgba(179,18,26,.07); border-color: rgba(179,18,26,.35); }
.od-zugang { border: 2px solid var(--red); }
.od-small { font-size: 12px; color: var(--muted); }
.od-hit { display: block; width: 100%; text-align: left; margin-top: 6px; }
.od-tap { cursor: pointer; } .od-tap:active { opacity: .6; }
.msg .quellen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg .quellen a { font-size: 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; }
.msg .quellen a::before { content: "🔗 "; }

/* ---------- Kacheln, Objektsuche, Fehlersuche (v1.7) ---------- */
#od { z-index: 25; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; padding: 8px 12px 0; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; font-size: 13px; }
.tile b { font-size: 22px; font-weight: normal; }
textarea { width: 100%; resize: vertical; min-height: 44px; }
.inrow { display: flex; gap: 6px; align-items: flex-start; }
.inrow > input, .inrow > textarea { flex: 1; min-width: 0; }
button.icon.mini { width: 44px; height: 44px; font-size: 18px; flex: none; }
button.rec { background: #dc2626 !important; color: #fff; animation: pulse 1.2s infinite; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fotorow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btnlike { display: inline-flex; flex-direction: row; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; background: var(--card); }
#fsFotoBox { display: inline-flex; gap: 6px; align-items: center; }
#fsFotoPrev { height: 64px; border-radius: 8px; border: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 14px; }
.chip.on { background: var(--red); color: #fff; border-color: var(--red); }
.os-hit { display: block; width: 100%; text-align: left; margin-top: 6px; line-height: 1.35; }
.os-hit .muted { font-size: 13px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #f59e0b; color: #111; margin-left: 6px; vertical-align: middle; }
.fs-msg { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; line-height: 1.45; font-size: 15px; margin-bottom: 10px; word-wrap: break-word; }
.fs-msg.user { background: rgba(179,18,26,.07); border-color: rgba(179,18,26,.3); }
.fs-msg img { display: block; max-height: 140px; margin-top: 8px; border-radius: 8px; }
.fs-safe { border: 2px solid var(--red); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; background: var(--card); font-size: 14px; }
.fs-safe b { color: var(--red); } .fs-safe ul { margin: 6px 0 0; padding-left: 18px; } .fs-safe li { margin: 3px 0; }
.fs-safe a { color: var(--red); margin-right: 10px; white-space: nowrap; }
.src { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; white-space: normal; }
.src a, .src span { font-size: 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; }
.msg .quellen span.wq { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; }
.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.two input, .two select { width: 100%; min-width: 0; }
#fsActions { justify-content: flex-start; }
#fsActions button { font-size: 14px; padding: 8px 10px; }
#fsResult:empty + .status:empty { min-height: 0; }

.actbar { display: flex; gap: 8px; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.actbar button { flex: 1; font-size: 14px; padding: 9px 8px; white-space: nowrap; }
.savebtns { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
button.warn { background: #f59e0b; border-color: #f59e0b; color: #111; }

/* ---------- v1.8 ---------- */
.controls .left { justify-self: start; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.controls .left .toggle { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; }
a.nr-link { color: var(--red); font-weight: 700; text-decoration: underline; padding: 4px 2px; }
.os-bez { display: inline !important; }
#osOrtHint, #fsTypHint { min-height: 1em; }
details summary { cursor: pointer; color: var(--red); font-weight: 600; }

.haupt { color: #15803d; font-weight: 600; }
.bem { font-size: 13px; color: var(--muted); font-style: italic; white-space: pre-wrap; }
