/* uChat – Gestaltung der Chat-Seite.
   Übernommen aus uMProxy `src/web/site.css` (Stand cf2de67). site.css bedient dort drei Seiten
   (Startseite, Verwaltung, Chat); hier stehen nur die Regeln, die der Chat wirklich benutzt —
   im Wortlaut und in der Reihenfolge des Originals, damit ein Abgleich leicht bleibt.
   Neu ist nur der mit „uChat" gekennzeichnete Abschnitt am Ende.
   Das Original hat genau ein Design (dunkel); es gibt keinen Hell-/Dunkel-Umschalter. */

:root {
  --bg: #08080a;
  --bar: #18181b;
  --surface: #121215;
  --surface-2: #1a1a1f;
  --surface-3: #232329;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --subtle: #8b8b94;

  --success: #4ade80;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warn: #fcd34d;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --danger: #fca5a5;
  --danger-bg: rgba(239, 68, 68, 0.12);

  --accent-fill: #7c3aed;
  --accent-2: #a855f7;
  --accent-text: #c4b5fd;
  --accent-soft: rgba(139, 92, 246, 0.16);
  --on-accent: #ffffff;
  --glow: #5b21d6;

  --radius: 14px;
  --radius-lg: 20px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -0.015em; line-height: 1.15; }
button, input, textarea, select { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: 6px; }

.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 24px; }

.i {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Kopfzeile ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--bar) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: 32px; height: 68px; }

.logo { display: inline-flex; align-items: center; gap: 10px; font: 700 19px/1 var(--font-display); letter-spacing: -0.02em; }
.logo-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-fill));
  box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset, 0 6px 18px -6px var(--glow);
  color: #fff;
}
.logo-mark .i { width: 18px; height: 18px; stroke-width: 2.4; }
.logo b { color: var(--accent-text); font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 10px; background: transparent; color: #d4d4d8; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; font-size: 15px; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-accent { background: var(--accent-fill); color: var(--on-accent); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: #d4d4d8; border-color: var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,.06); color: #fff; }

/* ---------- Begrüssung ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.16);
  font-size: 13px; color: #e4e4e7;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); box-shadow: 0 0 10px var(--accent-text); }
.eyebrow .dot.ok { background: var(--success); box-shadow: 0 0 10px var(--success); }
.eyebrow .dot.off { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

.display { margin: 24px auto 0; max-width: 20ch; text-wrap: balance; font-size: clamp(2.5rem, 6.4vw, 4.9rem); font-weight: 600; line-height: 1.04; letter-spacing: -0.03em; }
.lead { margin: 22px auto 0; max-width: 58ch; font-size: clamp(1.05rem, 1.8vw, 1.3rem); color: #e4e4e7; }

/* Etikett am Datei-Chip */
.tag { padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.06); color: #d4d4d8; font-size: 12px; white-space: nowrap; }

/* ---------- Code-Blöcke ---------- */
.code { position: relative; border-radius: 14px; border: 1px solid var(--border-strong); background: #0c0c0f; overflow: hidden; }
.code pre { margin: 0; padding: 16px 18px; padding-right: 96px; overflow-x: auto; font-size: 13px; line-height: 1.7; color: #d4d4d8; }
.code + .code { margin-top: 10px; }
.copy-btn { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.copy-btn:hover { background: var(--surface-3); }
.copy-btn.done { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }

/* ---------- Dialog „Ihr API-Key" ---------- */
dialog.modal {
  width: 100%; max-width: min(480px, 100vw - 32px);
  margin: auto; padding: 16px;
  border: 0; background: transparent; color: inherit;
}
dialog.modal::backdrop { background: rgba(8, 8, 10, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] { animation: modal-in .16s ease-out; }
  dialog.modal[open]::backdrop { animation: modal-backdrop-in .16s ease-out; }
}
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } }
@keyframes modal-backdrop-in { from { opacity: 0; } }
body:has(dialog.modal[open]) { overflow: hidden; }

.auth-card {
  position: relative;
  width: 100%; padding: 60px 36px 40px;
  border-radius: 24px; background: rgba(18,18,21,.92);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.9);
  backdrop-filter: blur(12px);
}
.auth-card .badge-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-text); }
.auth-card .badge-icon .i { width: 24px; height: 24px; }
.auth-card h2 { margin-top: 22px; font-size: 28px; font-weight: 600; }
.auth-card .sub { margin-top: 8px; color: var(--muted); }
.auth-card .sub b { color: #fff; }
.auth-card form { margin-top: 28px; display: grid; gap: 18px; }
.auth-card .foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.modal-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; }
.link { color: var(--accent-text); font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.field { display: grid; gap: 8px; }
.field > label { font-size: 14px; font-weight: 600; color: #e4e4e7; }
.input-wrap { position: relative; }
.input-wrap .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px 0 44px;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: #0c0c0f; color: #fff; font-size: 16px;
}
.input::placeholder { color: #71717a; }
.input:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--accent-soft); }

.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; font-size: 14px; border: 1px solid; }
.alert .i { margin-top: 1px; }
.alert b { display: block; margin-bottom: 2px; }
.alert-warn { background: var(--warn-bg); border-color: rgba(245,158,11,.3); color: #fef3c7; }
.alert-warn .i { color: var(--warn); }

/* ---------- Responsive (allgemeiner Teil) ---------- */
@media (max-width: 760px) {
  .container { padding-inline: 16px; }
  .header-actions, .nav-links + .header-actions { margin-left: auto; }
  .auth-card { padding: 56px 22px 30px; }
  .code pre { padding-right: 18px; padding-top: 46px; }
}

/* ---------- Kleinteile aus dem gemeinsamen Teil ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 13.5px; }
.foot-split { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.site-header .logo + .header-actions { margin-left: auto; }

/* `glow-top` wirkt im Original nur zusammen mit `.app-main` (Verwaltungsseite). Die Regel steht
   unverändert hier, damit der Chat genauso aussieht wie auf ai.ugur.at — sie greift dort nicht. */
.app-main.glow-top { background: radial-gradient(ellipse 60% 340px at 50% -80px, color-mix(in srgb, var(--glow) 70%, transparent), transparent 80%), var(--bg); }

/* Tabellen (Markdown-Tabellen in Antworten) */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { padding: 12px 22px; text-align: left; font-weight: 500; font-size: 13px; color: var(--subtle); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 22px; border-bottom: 1px solid var(--border); white-space: nowrap; color: #e4e4e7; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.025); }

@media (max-width: 760px) {
  th, td { padding-inline: 14px; }
}

/* ---------- Chat (/chat) ---------- */
.hide-sm { display: inline; }
.spacer { flex: 1; }
textarea.input { min-height: 84px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.field .opt { font-weight: 400; color: var(--subtle); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent-fill); }
.check b { display: block; font-weight: 600; font-size: 14.5px; }
.check small { color: var(--muted); font-size: 13px; }

.chat-body { min-height: 100dvh; }
.chat-main { flex: 1; padding: 32px 0 24px; }
.chat-col { width: 100%; max-width: 860px; margin-inline: auto; padding-inline: 24px; }

.chat-empty { text-align: center; padding: 7vh 0 12px; }
.chat-title { font-size: clamp(2rem, 5vw, 3.4rem); margin-top: 22px; }
.chat-empty .lead { font-size: 1.05rem; max-width: 52ch; color: var(--muted); }
.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 40px; text-align: left; }
.suggestion { display: grid; gap: 4px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.suggestion:hover { border-color: color-mix(in srgb, var(--accent-text) 45%, transparent); background: var(--surface-2); }
.suggestion b { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-text); }
.suggestion span { font-size: 14.5px; color: #d4d4d8; }

.messages { display: grid; gap: 26px; }
.msg { display: flex; gap: 14px; min-width: 0; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { max-width: 82%; padding: 12px 16px; border-radius: 18px 18px 6px 18px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent-text) 22%, transparent); }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-note { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.msg-images img { max-width: 220px; max-height: 180px; border-radius: 10px; border: 1px solid var(--border-strong); }
.msg-avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; margin-top: 2px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent-fill)); box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset, 0 6px 18px -6px var(--glow); }
.msg-avatar .i { width: 17px; height: 17px; }
.msg-assistant .msg-body { flex: 1; min-width: 0; padding-top: 4px; }
.msg-wait { color: var(--subtle); letter-spacing: .2em; animation: blink 1.1s steps(1) infinite; }
.msg-err { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: var(--danger-bg); border: 1px solid rgba(239,68,68,.3); color: #fee2e2; font-size: 14px; }
.msg-foot { display: flex; align-items: center; gap: 4px; margin-top: 10px; color: var(--subtle); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.msg-foot span { margin-right: 6px; }
.msg-act { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); cursor: pointer; }
.msg-act:hover { background: rgba(255,255,255,.07); color: #fff; }
.msg-act.done { color: var(--success); font-size: 11px; width: auto; padding: 0 8px; }
.msg-think { margin-bottom: 12px; border-left: 2px solid var(--border-strong); padding-left: 14px; }
.msg-think summary { cursor: pointer; font-size: 13px; color: var(--subtle); }
.msg-think summary:hover { color: #fff; }
.msg-think p { margin-top: 8px; white-space: pre-wrap; font-size: 13.5px; color: var(--muted); }

/* Blinken des „…" während die Antwort läuft (.msg-wait) */
@keyframes blink { 50% { opacity: 0; } }

/* Markdown in Antworten */
.md { font-size: 15.5px; line-height: 1.65; color: #e9e9ec; word-break: break-word; }
.md > * + * { margin-top: 14px; }
.md h3, .md h4, .md h5, .md h6 { font-size: 1.12em; font-weight: 600; margin-top: 22px; letter-spacing: -0.01em; }
.md h3 { font-size: 1.3em; }
.md ul, .md ol { margin-bottom: 0; padding-left: 22px; display: grid; gap: 6px; }
.md li::marker { color: var(--accent-text); }
.md code { padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.08); font-size: .9em; }
.md blockquote { margin-inline: 0; margin-bottom: 0; padding: 4px 0 4px 14px; border-left: 3px solid var(--accent-text); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); }
.md-code pre { padding-top: 40px; }
.md-code pre code { padding: 0; background: none; font-size: 13px; }
.code-lang { position: absolute; top: 12px; left: 16px; font: 12px var(--mono); color: var(--subtle); }
.md-table { border-radius: 12px; border: 1px solid var(--border); }
.md-table th, .md-table td { padding: 9px 14px; white-space: normal; }

/* Eingabe */
.composer-wrap { position: sticky; bottom: 0; z-index: 10; padding: 28px 0 calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, var(--bg) 34%); }
.composer { border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 20px 50px -24px rgba(0,0,0,.9); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--accent-soft), 0 20px 50px -24px rgba(0,0,0,.9); }
.composer textarea { display: block; width: 100%; max-height: 220px; padding: 16px 18px 6px; border: 0; outline: 0; resize: none; background: transparent; color: #fff; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder { color: #71717a; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px 12px; }
.composer-hint { font-size: 12.5px; color: var(--subtle); }
.composer-send.is-stop { background: var(--surface-3); color: #fff; border-color: var(--border-strong); }
.composer-foot { margin-top: 10px; text-align: center; font-size: 12.5px; color: var(--subtle); }
.composer-alert { margin-bottom: 12px; align-items: flex-start; }
.composer-alert > div { flex: 1; }
.composer-alert .icon-btn { width: 28px; height: 28px; margin: -4px -6px 0 0; color: inherit; }
.model-pick { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 0 10px 0 12px; height: 34px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--accent-text); }
.model-pick select { min-width: 0; max-width: 300px; border: 0; outline: 0; background: transparent; color: #e4e4e7; font: 13px var(--mono); cursor: pointer; text-overflow: ellipsis; }
.model-pick select option { background: var(--surface-2); color: #e4e4e7; }
.model-pick:focus-within { border-color: var(--accent-text); }
.composer-attach { width: 34px; height: 34px; border-radius: 999px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.attachment { position: relative; }
/* Datei-Chip (kein Bild): Symbol und Name nebeneinander */
.attachment .tag { display: inline-flex; align-items: center; gap: 6px; }
.attachment img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border-strong); }
.attachment-x { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; color: #09090b; cursor: pointer; }
.attachment-x .i { width: 11px; height: 11px; stroke-width: 3; }

@media (max-width: 760px) {
  .hide-sm { display: none; }
  .chat-col { padding-inline: 14px; }
  .suggestions { grid-template-columns: 1fr; }
  .msg-user .msg-body { max-width: 92%; }
  .msg-avatar { display: none; }
  .model-pick select { max-width: 150px; }
}

/* Code-Blöcke im Chat: „Herunterladen" und „Kopieren" nebeneinander oben rechts */
.code-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.code-actions .copy-btn { position: static; }
.md-code pre { padding-right: 18px; } /* Code beginnt ohnehin unter den Knöpfen → rechts gleicher Abstand wie links */
.md-code .code-lang { max-width: calc(100% - 230px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* langer Sprachname läuft nicht unter die Knöpfe */

/* ---------- uChat: die einzigen eigenen Regeln ----------
   Alles darüber steht im Wortlaut der site.css des uMProxy. Hier darunter stehen die
   Regeln, die es dort nicht gibt. Überschrieben wird nur über `#settings …`-Selektoren,
   damit die übernommenen Regeln oben unverändert bleiben und der Abgleich möglich bleibt.

   1. `#settings-save` stand im Original als style-Attribut in der Seite (style="min-height:50px").
      Es steht jetzt hier, damit die Seite ohne `style-src 'unsafe-inline'` auskommt — dieselbe Optik.
   2. Das Feld „API-Adresse" (nur bei UCHAT_API_BASE_EDITABLE=true) benutzt die vorhandenen Klassen
      `.field` / `.input-wrap` / `.input`; nur „Zurücksetzen" braucht eine Stelle im Raster.
   3. Der Dialog „Ihr API-Key" ist breiter und zweispaltig, damit er ohne Scrollbalken auf
      einen gewöhnlichen Laptop-Bildschirm passt. Farben, Schrift, Rundungen, Knöpfe und
      Eingabefelder bleiben die des Originals — geändert sind nur Breite, Anordnung und Abstände. */
#settings-save { min-height: 50px; }

/* Das Design ist nur dunkel. Ohne diese Angabe zeichnet der Browser seine eigenen Teile
   hell: Scrollbalken, unausgefüllte Häkchen, Auswahlfeld-Listen, Autofill-Hintergrund.
   Eigene Regel — die übernommene `:root`-Regel ganz oben bleibt unangetastet. */
:root { color-scheme: dark; }

/* ---------- Dialog „Ihr API-Key": Breite und Rollen ---------- */
/* Rollen muss notfalls die Karte, nie der Dialog: sonst läge der Scrollbalken über den
   runden Ecken. `100vh` steht als Rückfall vor `100dvh` (ältere Browser). */
#settings.modal {
  max-width: min(720px, 100vw - 32px);
  max-height: 100vh;
  max-height: 100dvh;
}
#settings .auth-card {
  padding: 24px 28px 22px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
}

/* ---------- Kopf in einer Zeile ---------- */
/* Rechts bleibt Platz, damit der Erklärsatz nicht unter den Schliessen-Knopf läuft. */
#settings .settings-head { display: flex; align-items: flex-start; gap: 14px; padding-right: 40px; }
#settings .settings-head-text { min-width: 0; }
#settings .settings-head .badge-icon { width: 40px; height: 40px; border-radius: 12px; }
#settings .settings-head .badge-icon .i { width: 20px; height: 20px; }
#settings .settings-head h2 { margin-top: 0; font-size: 22px; }
#settings .settings-head .sub { margin-top: 4px; font-size: 14px; }

/* ---------- Zwei Spalten ---------- */
#settings #settings-form { margin-top: 18px; gap: 16px; }
#settings .settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
#settings .settings-col { display: grid; align-content: start; gap: 12px; }

/* „Zurücksetzen" steht in der Zeile der Beschriftung, rechtsbündig. Im Markup bleibt es
   hinter dem Eingabefeld stehen — so läuft die Tabulator-Taste weiter Adresse →
   Zurücksetzen → Key, und die Stelle im Raster macht allein das CSS.
   `[hidden]` wirkt trotzdem: die Regel ganz oben hat `!important`. */
#settings #api-base-field { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
#settings #api-base-field > label { grid-column: 1; grid-row: 1; align-self: end; }
#settings #api-base-field > .input-wrap { grid-column: 1 / -1; grid-row: 2; }
#settings #api-base-reset { grid-column: 2; grid-row: 1; align-self: end; justify-self: end; font-size: 13px; }

/* „Auf diesem Gerät merken": schlichte Zeile statt Kasten. */
#settings .check { padding: 0; border: 0; background: none; gap: 10px; }

/* Die Systemanweisung füllt die Höhe der linken Spalte (Zeile `1fr`); die Mindesthöhe
   von drei Zeilen sorgt dafür, dass ohne das Feld „API-Adresse" kein Loch entsteht.
   `resize: vertical` bleibt: zieht jemand das Feld grösser, wächst die Zeile und damit
   die Karte — überlappen kann dabei nichts. */
#settings .settings-col-system { grid-template-rows: auto 1fr; }
#settings .settings-col-system #system { min-height: 98px; }

/* ---------- Fuss in einer Zeile ---------- */
/* Optisch links die Verweise, rechts „Speichern"; im Markup umgekehrt (Tabulator-
   Reihenfolge). Abstand nur über `gap` — ist „API-Key anfordern" ausgeblendet, bleibt
   darum kein verwaister Trenner und kein Loch stehen. */
#settings .settings-foot { margin-top: 0; padding-top: 14px; align-items: center; gap: 16px; }
#settings .settings-links { order: -1; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

/* ---------- Kleine Bildschirme: eine Spalte ---------- */
@media (max-width: 640px) {
  #settings .auth-card { padding: 22px 18px 20px; }
  #settings .settings-head { gap: 12px; padding-right: 36px; }
  #settings .settings-grid { grid-template-columns: minmax(0, 1fr); }
  #settings .settings-foot { flex-direction: column; align-items: stretch; gap: 12px; }
  #settings .settings-links { order: 0; justify-content: center; }
}
