:root {
  --bg: #0f172a;
  --panel: #16213a;
  --accent: #1e3a5f;
  --accent-light: #2d5486;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --error: #f87171;
  --ok: #4ade80;
  --warn: #facc15;
  --radius: 10px;
  /* Kategoriale Chart-Farben (Todo #73, Vermögens-Cockpit) - feste
     Reihenfolge, aus dem validierten Dark-Mode-Set der dataviz-Skill
     (references/palette.md), per validate_palette.js geprüft (CVD/Kontrast
     PASS für alle 4 Slots). Nicht als generisches "series-N" gedacht -
     jede feste Zuordnung (Immobilienwert=1, Restschuld=2, BSV=3, Netto=4)
     lebt direkt am Chart in immolino.html. */
  --chart-series-1: #3987e5; /* blau */
  --chart-series-2: #d95926; /* orange */
  --chart-series-3: #199e70; /* aqua */
  --chart-series-4: #c98500; /* gelb */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Sicherheitsnetz: seitliches Scrollen der ganzen Seite soll nie vorkommen –
     breite Inhalte (Tabellen etc.) scrollen stattdessen innerhalb ihres
     eigenen .block-Containers (siehe immolino.css). */
  overflow-x: hidden;
}

body.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
  max-width: 92vw;
}

.card h1 {
  font-size: 20px;
  margin: 0 0 20px;
  text-align: center;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

/* textarea dazu: bisher gab es außerhalb des generischen Formular-Modals
   (dessen .field-Wrapper eigene Regeln hat) kein freistehendes <textarea> in
   den Einstellungen - jetzt bei der Nebenkosten-PDF-Absenderadresse (siehe
   views/immolino.html) - ohne diese Ergänzung bliebe es ein unstyliertes
   weißes Browser-Textfeld mitten im dunklen Theme. */
input, textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: #0b1222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  /* 16px statt 14px: unter 16px zoomt iOS Safari beim Fokussieren des Feldes
     ungefragt in die Seite hinein – auf dem Handy sehr störend. */
  font-size: 16px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-light);
}

/* Todo #86: Das Kalender-Icon von <input type="date"> ist in Chrome/Edge/
   Safari standardmäßig dunkel gezeichnet und war auf dem dunklen
   Eingabefeld-Hintergrund (#0b1222) praktisch unsichtbar. invert(1) macht es
   weiß, passend zum restlichen hellen Text im Dark Theme. (Firefox hat kein
   ::-webkit-calendar-picker-indicator, zeichnet das Icon dort aber ohnehin
   schon hell auf dunklem Grund.) */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

button {
  width: 100%;
  padding: 10px 12px;
  background: var(--accent-light);
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

button:hover { background: #3a67a3; }
button:disabled { opacity: 0.5; cursor: default; }

.error {
  color: var(--error);
  font-size: 13px;
  margin: -8px 0 12px;
  min-height: 16px;
}

/* --- App-Shell --- */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Menüleiste oben */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--accent);
  flex-shrink: 0;
}

.topnav .brand {
  font-weight: 600;
  font-size: 15px;
  margin-right: 24px;
  white-space: nowrap;
}

.topnav .tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.topnav .tab {
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  border: 1px solid transparent;
}

.topnav .tab:hover {
  background: rgba(255,255,255,0.04);
}

/* Ampel am Chat-Reiter: grün = Session nutzbar, gelb = wird knapp,
   rot = aktuell gesperrt (siehe updateSessionStatusDot() in chat.html). */
.tab-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  background: var(--ok);
  vertical-align: middle;
}
.tab-status-dot.dot-warm { background: var(--warn); }
.tab-status-dot.dot-hot { background: var(--error); }

.topnav .tab.active {
  background: var(--accent-light);
  color: var(--text);
}

/* Handy-Breite: Die Menüleiste (App-Switch + Reiter + Limits/Aktionen) passt
   nicht mehr nebeneinander in eine Zeile. Reiter bekommen eine eigene,
   horizontal scrollbare Zeile, damit alle erreichbar bleiben statt abgeschnitten
   zu werden. */
@media (max-width: 720px) {
  .topnav {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    row-gap: 4px;
    padding: 8px 10px;
  }

  .topnav .app-switch {
    order: 1;
  }

  .limits-box,
  .topnav .topnav-actions {
    order: 2;
  }

  .topnav .tabs {
    order: 3;
    flex: 1 1 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .topnav .tabs::-webkit-scrollbar {
    display: none;
  }

  .topnav .tab {
    flex-shrink: 0;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .app-switch-item {
    padding: 6px 10px;
  }

  /* Etwas größere Tippflächen auf dem Handy (Empfehlung: mind. ~40px) statt
     der 34px/28px, die für Maus-Bedienung ausgelegt waren. */
  .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .topnav button.logout {
    padding: 8px 14px;
  }
}

.limits-box {
  display: flex;
  gap: 6px;
  margin-right: 8px;
  white-space: nowrap;
}

.limit-chip {
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
}

.limit-chip.limit-warm { color: var(--warn); border-color: var(--warn); }
.limit-chip.limit-hot { color: var(--error); border-color: var(--error); }

.topnav .topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav button.logout {
  width: auto;
  padding: 6px 14px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--accent);
}
.topnav button.logout:hover { background: var(--accent); }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1;
}
.icon-btn:hover { background: var(--accent); }

/* --- Einstellungs-Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  width: 440px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 17px;
}

.modal h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 24px 0 12px;
}

.modal h3:first-of-type { margin-top: 0; }

.modal .close-x {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
}

.modal-inner {
  position: relative;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #0b1222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
}

.user-row .role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--text);
  text-transform: uppercase;
}

/* Nutzeranfrage 16.09.: Telegram-Chat-ID + Benachrichtigungs-Matrix pro
   Benutzer in der Admin-Liste (siehe loadUserList in chat.html) - die
   normale .user-row ist eine einzeilige space-between-Zeile, hier braucht
   es zusätzlich Platz für Eingabefeld + Tabelle darunter. */
.user-row--admin-notify {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.user-row--admin-notify .user-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-row--admin-notify .notify-matrix { margin: 4px 0; }
.user-row--admin-notify .user-notify-save { align-self: flex-start; }

/* Todo #102: Benachrichtigungs-Matrix (Kategorie × Telegram/E-Mail) im
   Einstellungen-Modal - schlichte Tabelle im gleichen Look wie .user-list. */
.notify-matrix {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 16px;
  font-size: 13px;
}
.notify-matrix td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--accent);
}
.notify-matrix td:first-child { color: var(--text); }
.notify-matrix td:not(:first-child) {
  text-align: center;
  width: 70px;
}
.notify-matrix th {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding-bottom: 4px;
}
.notify-matrix th:first-child { text-align: left; }
.notify-matrix input[type="checkbox"] { width: auto; margin: 0; }

.form-msg {
  font-size: 13px;
  margin: 4px 0 12px;
  min-height: 16px;
}
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--error); }

select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: #0b1222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px; /* wie input: verhindert iOS-Autozoom beim Fokussieren */
}

/* Info-Leiste: gerade von Claude benutzte Dateien.
   Liegt horizontal zwischen der Kopfzeile (Tab "Claude Chat") und der
   Sidebar (Button "+ Neue Unterhaltung"). */
.infobar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--accent);
  flex-shrink: 0;
  min-height: 20px;
}

.infobar-section {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.infobar-files {
  flex: 1;
  min-width: 0;
}

.infobar-icon {
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.8;
}

.active-files {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.active-files-empty {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.4s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.file-chip .file-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.file-chip.file-active {
  color: var(--text);
  border-color: var(--accent-light);
  background: rgba(96,165,250,0.14);
}

.file-chip.file-active .file-chip-dot {
  animation: file-pulse 1.1s ease-in-out infinite;
}

@keyframes file-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(96,165,250,0.55); }
  50% { box-shadow: 0 0 0 4px rgba(96,165,250,0); }
}

/* Hauptbereich: Sidebar + Content */
.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative; /* Bezugsrahmen für die Sidebar als Overlay auf dem Handy */
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--accent);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Handy/Tablet: Die Historie-Sidebar nimmt sonst einen Großteil der schmalen
   Breite weg und macht den Chat unbedienbar. Wird stattdessen als
   ausblendbare Schublade über dem Inhalt eingeblendet (Button #toggleSidebar
   in der Kopfzeile), mit abdunkelndem Hintergrund zum Schließen per Klick. */
@media (max-width: 820px) {
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 82vw;
    max-width: 300px;
    z-index: 45;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
  }
  .sidebar-backdrop.show { display: block; }
}

@media (min-width: 821px) {
  .sidebar {
    transition: width 0.2s ease, opacity 0.15s ease, border-color 0.2s ease;
  }
  .sidebar.sidebar-collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right-color: transparent;
    overflow: hidden;
  }
}

.sidebar .new-chat {
  margin: 12px;
  width: auto;
}

.sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 4px 16px 8px;
}

.sidebar .history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border: 1px solid transparent;
}

.history-item-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Todo #64: Löschen-Button pro Historien-Eintrag. War ursprünglich nur bei
   Hover/Fokus sichtbar (opacity 0 im Ruhezustand), damit die Liste im
   Normalzustand aufgeräumt bleibt - das hat sich aber als unzuverlässig
   erwiesen (Nutzer-Meldung 10.09.: in Chrome, auch frisch/inkognito, war der
   Button nicht auffindbar - vermutlich Hover-Erkennung je nach
   Eingabegerät/Browser nicht konsistent). Jetzt immer dezent sichtbar statt
   komplett unsichtbar, wird bei Hover/Fokus voll sichtbar - kein
   Verlass mehr auf zuverlässige Hover-Erkennung nötig. */
.history-item-del {
  flex-shrink: 0;
  width: auto;
  padding: 2px 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  opacity: 0.55;
  transition: opacity 0.1s ease;
}
.history-item:hover .history-item-del,
.history-item-del:focus {
  opacity: 1;
}
.history-item-del:hover {
  color: var(--error);
}

.history-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.history-item.active {
  background: var(--accent);
  color: var(--text);
}

.history-empty {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#chatView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Status-Panel */
.status-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.status-block {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.status-block h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.live-status {
  font-size: 14px;
}

.kv div {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.kv strong {
  color: var(--text);
  font-weight: 500;
  margin-right: 6px;
}

.usage-bar {
  margin-top: 6px;
  height: 6px;
  background: #0b1222;
  border-radius: 999px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--accent-light);
}

.usage-bar-fill.limit-warm { background: var(--warn); }
.usage-bar-fill.limit-hot { background: var(--error); }

/* Session-Nutzung (5h-/7-Tage-Fenster) im Status-Tab: verbraucht/übrig je Fenster. */
.session-limits {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--accent);
  font-size: 13px;
  color: var(--text-dim);
}

.session-limit-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-limit-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.session-limit-head strong {
  color: var(--text);
  font-weight: 500;
}

.session-limit-head span.limit-warm { color: var(--warn); }
.session-limit-head span.limit-hot { color: var(--error); }

.session-limit-reset {
  font-size: 11px;
  opacity: 0.85;
}

/* Zusammenfassung oben im Status-Tab: "kann ich gerade nutzen?" auf einen
   Blick, statt sich das aus zwei Balken selbst zusammenzureimen. */
.session-limit-summary {
  font-size: 13px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
}
.session-limit-summary.limit-hot {
  border-color: var(--error);
  background: rgba(248,113,113,0.08);
  color: var(--error);
}
.session-limit-summary .limit-disclaimer {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.85;
}

.file-graph-box {
  overflow: hidden;
  color: var(--text-dim);
  font-size: 13px;
}

.file-graph-canvas {
  display: block;
  width: 100%;
  height: 460px;
  cursor: grab;
  touch-action: none;
  border-radius: var(--radius);
  background: #0b1222;
}

.file-graph-canvas:active {
  cursor: grabbing;
}

.file-graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
}

.file-graph-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.file-graph-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.file-graph-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* --- To-Dos-Panel (Reiter neben "Status"): Vorschläge von Bruno + eigene
   Ideensammlung, persistiert serverseitig in data/todos.json --- */
.todo-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.todo-add-row input {
  flex: 1;
  margin-bottom: 0;
}
.todo-add-row button {
  width: auto;
  padding: 10px 16px;
  flex-shrink: 0;
}
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  background: #0b1222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
}
.todo-item input[type="checkbox"] {
  width: auto;
  margin: 3px 0 0;
  flex-shrink: 0;
}
.todo-item .todo-text {
  flex: 1;
  min-width: 0;
}
.todo-item .todo-text-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  word-wrap: break-word;
}
.todo-item.done .todo-text-row .todo-text-line {
  text-decoration: line-through;
  color: var(--text-dim);
}
.todo-item .todo-id {
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
  flex-shrink: 0;
}
.todo-item .todo-status-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  word-wrap: break-word;
}
.todo-item .todo-del {
  width: auto;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid var(--accent);
  font-size: 12px;
  flex-shrink: 0;
}
.todo-item .todo-del:hover { background: var(--accent); }

/* Todo #69: Kommentare pro To-Do (Antwort/Rückmeldung an Bruno, ohne dass es
   im Chatverlauf untergeht). */
.todo-comments {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.todo-comment {
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--accent-light);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  word-wrap: break-word;
}
.todo-comment-meta {
  color: var(--text-dim);
  font-size: 11px;
}
.todo-comment-add-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.todo-comment-input {
  flex: 1;
  margin-bottom: 0;
  padding: 6px 10px;
  font-size: 13px;
}
.todo-comment-submit {
  width: auto;
  padding: 6px 12px;
  font-size: 12px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .status-panel { padding: 14px; gap: 14px; }

  /* Schließen-Kreuz im Modal war mit 28px auf dem Handy knapp zu treffen. */
  .modal .close-x { width: 36px; height: 36px; top: 12px; right: 12px; }
  .modal { padding: 18px; }
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 720px;
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent-light);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--accent);
}

.msg.tool {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--text-dim);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.msg.error {
  align-self: flex-start;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.msg.status {
  align-self: center;
  color: var(--text-dim);
  font-size: 12px;
}

#inputbar {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--panel);
  border-top: 1px solid var(--accent);
}

#inputbar textarea {
  flex: 1;
  resize: none;
  background: #0b1222;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px; /* verhindert iOS-Autozoom beim Fokussieren */
  font-family: inherit;
  max-height: 160px;
}

#inputbar textarea:focus {
  outline: none;
  border-color: var(--accent-light);
}

#inputbar button {
  width: 90px;
  flex-shrink: 0;
}

/* Anhang-Button (📎) ist ein schmaler Icon-Button, kein 90px-Textbutton wie
   "Senden" – höhere Spezifität (#inputbar .icon-btn) nötig, um die Regel
   direkt darüber zu überstimmen. */
#inputbar .icon-btn {
  width: 40px;
  height: 40px;
  align-self: flex-end;
}

/* Vorschau-Chip für ein angehängtes Bild, bevor die Nachricht abgeschickt
   wird (siehe uploadImage()/pendingImage in chat.html). */
.image-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--panel);
  border-top: 1px solid var(--accent);
  font-size: 13px;
  color: var(--text-dim);
}
.image-preview img {
  height: 44px;
  width: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--accent);
}
.image-preview span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-preview button {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.image-preview button:hover { background: var(--accent); color: var(--text); }

/* Bild-Thumbnail innerhalb einer Chat-Bubble (angehängtes Foto des Nutzers). */
.msg-image {
  display: block;
  max-width: 280px;
  max-height: 280px;
  border-radius: 8px;
  margin-bottom: 6px;
}

/* Handy: Eingabeleiste bekommt etwas weniger Rand, damit mehr Platz fürs
   Tippen bleibt; Senden-Button etwas schmaler statt fixer 90px. */
@media (max-width: 640px) {
  #inputbar { padding: 10px 12px; gap: 8px; }
  #inputbar button { width: 64px; padding: 10px 6px; }
  #inputbar .icon-btn { width: 40px; }
  .image-preview { padding: 8px 12px; }
}
