/* ============================================================
   TCA Chat — Design System
   Swiss-präzise, hell, ruhig. Ein Akzent (TCA-Rot).
   Mobile-first, rem-basiert, garantiert überlauf-sicher.
   ============================================================ */

:root {
  /* Farben */
  --bg:            #f5f5f3;
  --surface:       #ffffff;
  --surface-2:     #ececeb;
  --line:          rgba(18, 18, 24, 0.10);
  --line-strong:   rgba(18, 18, 24, 0.20);
  --ink:           #17181c;
  --ink-soft:      #676b77;
  --accent:        #e0453e;
  --accent-soft:   rgba(224, 69, 62, 0.09);
  --code-bg:       #16171b;
  --code-ink:      #e6e7ea;

  /* Typo-Skala — eine Stufe pro Zweck, keine Zwischengrössen */
  --fs-xs:   0.6875rem;  /* 11px — Labels, Meta, Mono-Chips     */
  --fs-sm:   0.8125rem;  /* 13px — Sekundärtext, Quellen        */
  --fs-base: 1rem;       /* 16px — Fliesstext, Eingaben         */
  --fs-lg:   1.0625rem;  /* 17px — betonte Zeilen               */
  --fs-xl:   1.75rem;    /* 28px — Display                      */

  /* Abstände */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  /* Radien */
  --r-sm:   0.5rem;
  --r-md:   0.875rem;
  --r-lg:   1.25rem;
  --r-full: 999px;

  /* Höhen für Bedienelemente — überall identisch */
  --control-h: 2.25rem;   /* 36px */
  --tap:       2.75rem;   /* 44px — Mindestgrösse für Touch */

  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Archivo", system-ui, sans-serif;
}

/* ---------- Reset & Überlaufschutz ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

/* Kein Element darf breiter werden als sein Container. min-width:0 ist
   nötig, damit Flex-Kinder unter ihre Inhaltsbreite schrumpfen dürfen —
   sonst sprengt ein langes Wort oder ein Codeblock die ganze Seite. */
.frame, .frame * { max-width: 100%; }
.frame *, .frame *::before, .frame *::after { min-width: 0; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

/* ---------- Rahmen ---------- */
.frame {
  height: 100dvh;
  width: 100%;
  max-width: 52rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  flex: 0 0 auto;
  min-height: 3.25rem;
  padding: var(--sp-2) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

/* align-items: flex-start ist zwingend — sonst streckt der Flex-Container
   das Logo auf volle Breite und verzerrt es bei fixer Höhe. */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.brand-logo { height: 1.375rem; width: auto; flex: 0 0 auto; }
.powered-by {
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; }

.docs-toggle {
  height: var(--control-h);
  padding-inline: var(--sp-3);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  white-space: nowrap;
  transition: border-color 0.15s;
}
.docs-toggle:hover { border-color: var(--accent); }
.docs-count {
  min-width: 1.25rem;
  padding-inline: 0.35rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  line-height: 1.25rem;
  text-align: center;
}

/* ---------- Chat-Leiste (Zurück + aktives GPT) ---------- */
.chat-bar {
  flex: 0 0 auto;
  display: none;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) 0;
}
.frame.in-chat .chat-bar { display: flex; }

/* Zurück-Navigation trägt den Akzent, damit sie als Ausweg klar erkennbar
   ist — gleicher Look in der Chat-Leiste und in der Technik-Übersicht. */
.back-to-selection, .back-btn {
  flex: 0 0 auto;
  height: var(--control-h);
  padding-inline: var(--sp-4);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.back-to-selection:hover, .back-btn:hover,
.back-to-selection:active, .back-btn:active {
  background: var(--accent);
  color: #fff;
}

.active-gpt {
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Chat-Fläche ---------- */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-5) var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chat::-webkit-scrollbar { width: 5px; }
.chat::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-full); }

/* ---------- Startbildschirm ---------- */
.empty-state {
  margin: auto;
  width: 100%;
  text-align: center;
  padding-block: var(--sp-4);
  animation: rise 0.35s ease both;
}
.empty-kicker {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin-bottom: var(--sp-3);
}
.empty-state h1 {
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}
.empty-state .red { color: var(--accent); }
.empty-sub {
  margin-top: var(--sp-3);
  color: var(--ink-soft);
  font-size: var(--fs-sm);
}

.start-buttons {
  margin-top: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  text-align: left;
}

.start-btn {
  width: 100%;
  min-height: 4.75rem;
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  text-align: left;          /* Buttons zentrieren sonst per Browser-Default */
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(18, 18, 24, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.start-btn:hover {
  box-shadow: 0 3px 10px rgba(18, 18, 24, 0.09);
  transform: translateY(-1px);
}
.start-btn:active { transform: translateY(0); }

/* Technik trägt den Akzent (Kern der App), der freie Chat bleibt neutral.
   In der Technik-Übersicht sind alle Einträge Technik — dort durchgehend. */
#start-buttons .start-btn:not(:first-child),
#technik-list .start-btn { border-left-color: var(--accent); }
#start-buttons .start-btn:not(:first-child) .start-btn-emoji,
#technik-list .start-btn .start-btn-emoji {
  background: var(--accent-soft);
}

.start-btn-emoji {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--surface-2);
  border-radius: 50%;
}
.start-btn-text { display: flex; flex-direction: column; gap: 2px; }
.start-btn-text strong {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.start-btn-text small {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.35;
}
.start-btn-chevron { margin-left: auto; color: var(--ink-soft); flex: 0 0 auto; }

/* Aussehen kommt aus der gemeinsamen Regel weiter oben */
.back-btn { margin-top: var(--sp-4); }

.chat-hint {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
  animation: rise 0.3s ease both;
}
.chat-hint-text {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  text-align: center;
}
.chat-hint-text span { font-size: 1.125rem; }
.chat-hint-text strong { color: var(--ink); }

/* Schnellzugriff auf häufige Fehlercodes */
.quick-prompts {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.quick-label {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.quick-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
}
.quick-chip {
  height: var(--control-h);
  padding-inline: var(--sp-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.quick-chip:hover, .quick-chip:active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Nachrichten ---------- */
.msg { display: flex; flex-direction: column; animation: rise 0.25s ease both; }

.msg-user { align-items: flex-end; }
.msg-user .bubble {
  max-width: 88%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-assistant { align-items: flex-start; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.meta-gpt { color: var(--ink); font-weight: 500; }

.msg-assistant .bubble {
  width: 100%;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  border-top-left-radius: var(--r-sm);
  overflow-wrap: anywhere;
}

/* Fliesstext in Antworten */
.bubble > * + * { margin-top: 0.7em; }
.bubble h1, .bubble h2, .bubble h3 { font-size: var(--fs-base); font-weight: 700; }
.bubble ul, .bubble ol { padding-left: 1.25em; }
.bubble li + li { margin-top: 0.25em; }
.bubble a { color: var(--accent); text-decoration: underline; }
.bubble blockquote {
  border-left: 2px solid var(--accent);
  padding-left: var(--sp-3);
  color: var(--ink-soft);
}
.bubble hr { border: none; border-top: 1px solid var(--line); }

.bubble code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

/* Codeblöcke brechen um statt zu scrollen — horizontales Scrollen in
   verschachtelten Containern ist auf dem Handy nicht bedienbar und weitet
   dort die Seite auf. */
.codebox { position: relative; }
.bubble pre {
  padding: var(--sp-3);
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}
.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Platz für den Copy-Button schaffen, damit er den Code nicht überlappt */
.codebox pre { padding-top: 2.25rem; }
.copy-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  padding: 0.2rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.06em;
  color: #a9adb8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-sm);
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); }

/* Tabellen: umbrechen statt scrollen, damit sie in die Breite passen */
.table-scroll {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.bubble table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.bubble th, .bubble td {
  padding: var(--sp-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  overflow-wrap: break-word;
  hyphens: auto;
}
.bubble tr:last-child td { border-bottom: none; }
.bubble th {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  background: var(--surface-2);
}

.cite {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.5625rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1em 0.35em;
  border-radius: var(--r-sm);
  vertical-align: super;
  line-height: 1.3;
  white-space: nowrap;
}
.cite-link { cursor: pointer; }
.cite-link:hover { background: var(--accent); color: #fff; }

.cursor-blink {
  display: inline-block;
  width: 0.5rem;
  height: 1rem;
  background: var(--accent);
  border-radius: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.msg-error .bubble {
  border-color: rgba(224, 69, 62, 0.4);
  color: #b3352e;
  font-family: var(--mono);
  font-size: var(--fs-sm);
}

.lessons-chip {
  padding: 0.1rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px dashed rgba(224, 69, 62, 0.5);
  border-radius: var(--r-full);
}

/* ---------- Quellen ---------- */
.sources { width: 100%; margin-top: var(--sp-2); }
.sources summary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--control-h);
  padding-inline: var(--sp-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.sources summary::-webkit-details-marker { display: none; }
.sources summary::before { content: "▸"; color: var(--accent); }
.sources[open] summary::before { content: "▾"; }
.sources summary:hover { color: var(--ink); }

.source-item {
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
}
.source-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink);
}
.source-score { color: var(--accent); }
.source-view {
  margin-top: var(--sp-2);
  height: var(--control-h);
  padding-inline: var(--sp-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  transition: color 0.15s, border-color 0.15s;
}
.source-view:hover { color: var(--ink); border-color: var(--accent); }
.source-page-img {
  width: 100%;
  margin-top: var(--sp-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: #fff;
  cursor: zoom-in;
}

/* ---------- Icons ---------- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon svg { width: 1em; height: 1em; display: block; }
.meta-gpt .icon, .active-gpt .icon { font-size: 1.05em; margin-right: 0.35em; }
.fb-status .icon { font-size: 1.1em; margin-right: 0.3em; vertical-align: -0.15em; }

.approved-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.1rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.5625rem;
  letter-spacing: 0.05em;
  color: #1a7f4f;
  background: rgba(26, 127, 79, 0.1);
  border: 1px solid rgba(26, 127, 79, 0.35);
  border-radius: var(--r-full);
}
.approved-chip .icon { font-size: 1.1em; }

/* Antwort-Editor */
.answer-editor {
  width: 100%;
  min-height: 9rem;
  padding: var(--sp-3);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  outline: none;
  resize: vertical;
}

/* ---------- Feedback ---------- */
.feedback {
  width: 100%;
  margin-top: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.fb-btn {
  height: var(--control-h);
  min-width: var(--control-h);
  padding-inline: var(--sp-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.fb-btn svg { width: 1.05rem; height: 1.05rem; }
.fb-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.fb-btn.fb-up:hover { color: #1a7f4f; border-color: #1a7f4f; }
.fb-btn.fb-down:hover, .fb-btn.fb-edit:hover { color: var(--accent); border-color: var(--accent); }
.fb-save {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  filter: none;
  opacity: 1;
}
.fb-input {
  flex: 1;
  height: var(--control-h);
  padding-inline: var(--sp-3);
  font-size: var(--fs-base);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  outline: none;
}
.fb-input:focus { border-color: var(--accent); }
.fb-status { font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-soft); }
.fb-done { color: var(--accent); }

/* ---------- Eingabe ---------- */
.composer-wrap {
  flex: 0 0 auto;
  display: none;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
}
.frame.in-chat .composer-wrap { display: block; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color 0.15s;
}
.composer:focus-within { border-color: var(--line-strong); }

#input {
  flex: 1 1 auto;
  resize: none;
  border: none;
  background: none;
  outline: none;
  padding: var(--sp-2);
  font-size: var(--fs-base);   /* 16px verhindert Auto-Zoom auf iOS */
  line-height: 1.45;
  max-height: 10rem;
}
#input::placeholder { color: var(--ink-soft); }

.send-btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  transition: opacity 0.15s;
}
.send-btn:hover { opacity: 0.85; }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Drawer ----------
   Geschlossen komplett aus dem Layout (display:none). Ein nur verschobener
   Drawer weitet auf iOS die Seitenbreite auf. */
.drawer {
  position: absolute;
  inset: 0 0 0 auto;
  width: 100%;
  display: none;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 20;
  overflow-y: auto;
}
/* Reiner Fade — eine horizontale Bewegung könnte kurzzeitig überlaufen */
.drawer.open { display: flex; animation: drawer-in 0.18s ease both; }
@keyframes drawer-in { from { opacity: 0; } }

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.drawer-close {
  width: var(--control-h);
  height: var(--control-h);
  display: grid;
  place-items: center;
  font-size: var(--fs-base);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color 0.15s, border-color 0.15s;
}
.drawer-close:hover { color: var(--ink); border-color: var(--line-strong); }

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-3);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-plus { font-size: 1.5rem; line-height: 1; color: var(--accent); }
.upload-text {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  line-height: 1.5;
}
.upload-status {
  min-height: 1rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--accent);
}

/* Listen im Drawer — Dokumente und GPTs identisch aufgebaut */
.doc-list, .gpt-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  overflow-y: auto;
}
.doc-list { flex: 1 1 auto; }

.doc-item, .gpt-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.doc-info { flex: 1 1 auto; }
.doc-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-meta {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--ink-soft);
}
.doc-del {
  flex: 0 0 auto;
  width: var(--control-h);
  height: var(--control-h);
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color 0.15s, border-color 0.15s;
}
.doc-del:hover { color: var(--accent); border-color: var(--accent); }
.gpt-item-emoji { flex: 0 0 auto; font-size: var(--fs-base); }
.gpt-item .doc-info { cursor: pointer; }
.gpt-item.current { border-color: var(--accent); background: var(--accent-soft); }

.learned-count {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.learn-tag {
  display: inline-block;
  padding: 0 0.35em;
  margin-right: 0.3em;
  border-radius: var(--r-sm);
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
}
.learn-up { color: #1a7f4f; background: rgba(26, 127, 79, 0.12); }
.learn-corrected { color: #9a6b00; background: rgba(154, 107, 0, 0.12); }
.learn-down { color: var(--accent); background: var(--accent-soft); }
.gpt-item .doc-name { white-space: normal; }

/* ---------- Custom GPTs im Drawer ---------- */
.gpt-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.gpt-section-head { display: flex; align-items: center; justify-content: space-between; }
.gpt-section-head h2 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}
.gpt-new {
  height: var(--control-h);
  padding-inline: var(--sp-3);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  transition: border-color 0.15s;
}
.gpt-new:hover { border-color: var(--accent); }

.gpt-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.gpt-form[hidden] { display: none; }
.gpt-form-row { display: flex; gap: var(--sp-2); }
.gpt-form input[type="text"], .gpt-form textarea {
  flex: 1 1 auto;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-base);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  resize: vertical;
}
.gpt-form input:focus, .gpt-form textarea:focus { border-color: var(--accent); }
.gpt-emoji-input { flex: 0 0 3rem; text-align: center; }

.gpt-docs { display: flex; flex-direction: column; gap: var(--sp-1); }
.gpt-docs-hint, .gpt-docs-empty {
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--ink-soft);
}
.gpt-doc-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.gpt-doc-check input { accent-color: var(--accent); }

.gpt-form-actions { display: flex; gap: var(--sp-2); }
.gpt-save, .gpt-cancel {
  height: var(--control-h);
  padding-inline: var(--sp-4);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  border-radius: var(--r-full);
}
.gpt-save { color: #fff; background: var(--accent); }
.gpt-cancel { color: var(--ink-soft); border: 1px solid var(--line); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-4);
}
.login-card {
  width: min(22rem, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}
.login-brand img { height: 2.25rem; width: auto; flex: 0 0 auto; }
.login-card input {
  height: var(--tap);
  padding-inline: var(--sp-3);
  font-size: var(--fs-base);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  height: var(--tap);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--accent);
  border-radius: var(--r-sm);
}
.login-error {
  min-height: 1rem;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--accent);
  text-align: center;
}

/* ---------- Ab Tablet-Breite etwas grosszügiger ---------- */
@media (min-width: 40rem) {
  :root { --fs-xl: 2.25rem; }
  .topbar { padding-inline: var(--sp-5); }
  .chat-bar { padding-inline: var(--sp-5); }
  .chat { padding-inline: var(--sp-5); }
  .composer-wrap { padding-inline: var(--sp-5); }
  .start-buttons { width: min(24rem, 100%); margin-inline: auto; }
  .msg-assistant .bubble { width: auto; max-width: 92%; }
  .msg-user .bubble { max-width: 80%; }
  .sources, .feedback { width: auto; max-width: 92%; }
  .brand-logo { height: 1.625rem; }
  .drawer { width: min(21rem, 100%); }
}

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