/*
 * Oberfläche des Behördenbrief-Generators.
 * Quelle: design/components/App…/preview.html, Token aus design/project/tokens.json.
 * Nur ui-* Token. Die Druck-Token (ink/surface/muted) gehören dem Briefbogen; die beiden
 * Papier-Vorschauen verwenden wie im Design festes Weiß/Schwarz in Briefschrift.
 */

:root {
  --ui-bg: #f5f6f8;
  --ui-surface: #ffffff;
  --ui-surface-sunken: #eceef1;
  --ui-border: #d8dce2;
  --ui-border-strong: #8b929d;
  --ui-text: #1b2027;
  --ui-text-muted: #5c6470;
  --ui-accent: #2d5f8f;
  --ui-accent-hover: #244d76;
  --ui-accent-soft: #eef2f7;
  --ui-danger: #a33a34;
  --ui-danger-soft: #fbf0ef;

  --ui-radius-sm: 4px;
  --ui-radius-md: 6px;
  --ui-radius-lg: 10px;

  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-letter: 'Helvetica', 'Arial', sans-serif;
}

.ui, .sheet-layer, .toast-region {
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --sunken: var(--ui-surface-sunken);
  --line: var(--ui-border);
  --line-strong: var(--ui-border-strong);
  --text: var(--ui-text);
  --muted: var(--ui-text-muted);
  --accent: var(--ui-accent);
  --accent-soft: var(--ui-accent-soft);
  --danger: var(--ui-danger);
  --danger-soft: var(--ui-danger-soft);
  --r-sm: var(--ui-radius-sm);
  --r-md: var(--ui-radius-md);
  --r-lg: var(--ui-radius-lg);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.has-sheet { overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Fokus: 2 px ui-accent, 2 px Abstand, nie entfernt */
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }

/* ---------- Kopfleiste ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.brand { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Aufteilung ---------- */

.main {
  display: grid;
  grid-template-columns: 1fr 384px;
  grid-template-rows: auto auto;
  gap: 16px 20px;
  padding: 20px;
  align-items: start;
}
.main > .panel:first-child { grid-column: 1; grid-row: 1; }
.actionbar { grid-column: 1; grid-row: 2; }
.history { grid-column: 2; grid-row: 1; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap;
  gap: 4px 16px; margin-bottom: 16px;
}
.panel-head h2, .hist-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-title { display: flex; align-items: center; gap: 12px; min-height: 26px; }
.link:disabled { color: var(--muted); text-decoration: none; cursor: not-allowed; }
.from { font-size: 12px; color: var(--muted); }

/* ---------- Felder ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.opt {
  font-weight: 400; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 5px; margin-left: 4px;
}
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.label-row label { margin-bottom: 0; }

.input {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  resize: none;
}
.input::placeholder { color: var(--muted); }
.input.subject { font-size: 16px; font-weight: 500; padding: 11px; }
.input.mono { font-family: var(--font-mono); font-size: 13px; }
.input.body { font-size: 14px; line-height: 1.6; height: 236px; }
.input.is-invalid, .letter-preview.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(163, 58, 52, 0.10); }
/* Erste Nutzung: gesperrt, flächig hinterlegt, Text bleibt stehen */
.input:disabled { background: var(--sunken); border-color: var(--line); }
/* Ladezustand */
.input.is-locked { background: var(--sunken); color: var(--muted); }

.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.f-error {
  display: flex; align-items: center; gap: 6px;
  color: var(--danger); font-size: 12px; margin-top: 6px;
}
.f-error svg { flex: none; }

.row { display: flex; gap: 12px; margin-bottom: 16px; }
.row .field { margin-bottom: 0; }
.row .field { flex: 1; min-width: 0; }

/* Zeichen: Bezeichnung und Wert nebeneinander, beide so breit wie das, was darin steht */
.zeichen-felder { display: flex; gap: 12px; }
.zeichen-felder .select { width: 240px; flex: none; cursor: pointer; }
.zeichen-felder #f-zeichen_label_eigen { width: 200px; flex: none; }
.zeichen-felder .mono { width: 260px; flex: none; }
/* Anrede ist ein Satz, kein Datenfeld – aber die volle Panelbreite braucht sie nicht */
.input.w-anrede { max-width: 512px; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg {
  border: none; background: var(--surface); color: var(--muted);
  font-size: 12px; padding: 5px 14px;
}
.seg.is-active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.seg:disabled { cursor: not-allowed; }

.legend { font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend code {
  font-family: var(--font-mono);
  font-size: 12px; background: var(--sunken); border-radius: var(--r-sm); padding: 1px 5px;
}

/* Brieftext-Vorschau: gesetzt wie im PDF — Helvetica 11 pt, Absatzabstände und Satzbreite der Vorlage */
.letter-preview {
  height: 236px;
  overflow-y: auto;
  background: #ffffff;
  color: #000000;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 9px 11px;
}
.letter-preview-text {
  max-width: 165mm;
  font-family: var(--font-letter);
  font-size: 11pt;
  line-height: 1.2;
}
.letter-preview-text p { margin: 0 0 3mm 0; }
.letter-preview-text ul { margin: 0 0 3mm 0; padding-left: 6mm; }
.letter-preview-text li { margin: 0 0 1mm 0; }
.letter-preview-text .preview-note { font-family: var(--font-ui); font-size: 12px; color: var(--muted); }

/* Anlagen: Eingabe + Hinzufügen, darunter die nummerierte Liste */
.attach-add { display: flex; gap: 8px; }
.attach-add .input { flex: 1; min-width: 0; }
.attach-add .btn-secondary { flex: none; }
.attach-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.attach-item {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 4px 4px 11px;
  border-bottom: 1px solid var(--line);
}
.attach-item:last-child { border-bottom: none; }
.attach-no { flex: none; min-width: 20px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.attach-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.attach-remove { flex: none; }
.attach-remove:hover { color: var(--danger); }
.attach-remove:disabled { opacity: 0.5; cursor: not-allowed; }

.closing {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 18px; padding-top: 14px;
}
.closing-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.closing-value { font-size: 13px; }
/* Schalter "mit Unterschrift" rechts im Briefende */
.closing-sign {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.closing-sign input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------- Buttons (Maße aus AppBedienelemente) ---------- */

.btn-primary {
  background: var(--accent); color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  padding: 10px 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover:not(:disabled) { background: var(--ui-accent-hover); border-color: var(--ui-accent-hover); }
.btn-primary.is-busy { background: var(--ui-accent-hover); border-color: var(--ui-accent-hover); cursor: progress; }
.btn-primary:disabled { background: var(--sunken); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  font-size: 14px; padding: 9px 16px;
}
.btn-secondary.sm { font-size: 12px; padding: 5px 10px; }
.btn-secondary:disabled { background: var(--sunken); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

.btn-danger {
  background: var(--danger); color: #ffffff;
  border: 1px solid var(--danger); border-radius: var(--r-md);
  font-size: 13px; padding: 7px 13px;
}
.btn-danger.sm { font-size: 12px; padding: 5px 12px; }
.btn-danger:disabled { background: var(--sunken); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

.btn-ghost {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); font-size: 12px; padding: 4px 10px; color: var(--text);
  text-decoration: none;
}

.link {
  background: none; border: none; padding: 0 0 0 6px;
  color: var(--accent); font-size: 12px; text-decoration: underline;
}
.link.sm { font-size: 12px; padding: 0; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: ui-spin 0.8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

.actionbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.actionbar-hint { font-size: 12px; color: var(--muted); }
.actionbar-buttons { display: flex; align-items: center; gap: 8px; flex: none; }

/* Vorlage speichern: Namensfeld in der Aktionszeile */
.template-save { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.template-save label { font-size: 12px; font-weight: 500; color: var(--muted); }
.template-save .input { flex: 1; min-width: 180px; padding: 8px 11px; }
.template-save .f-error { flex-basis: 100%; margin-top: 0; }
.actionbar.is-saving-template .actionbar-hint,
.actionbar.is-saving-template #template-save-open { display: none; }

/* Beim Bearbeiten: kurzer Hinweis unter der Überschrift */
.edit-info { margin: -6px 0 16px; font-size: 12px; color: var(--muted); }
.edit-info span:first-child { color: var(--text); font-weight: 500; }

/* ---------- Banner (AppZustaende) ---------- */

.banner {
  display: flex; gap: 10px;
  background: var(--accent-soft); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 16px;
  color: var(--accent);
}
.banner svg { flex: none; margin-top: 1px; }
.banner-body { min-width: 0; }
.banner.is-error { background: var(--danger-soft); color: var(--danger); }
.banner-title { font-size: 13px; font-weight: 600; color: var(--text); }
.banner.is-error .banner-title { color: var(--danger); }
.banner-text { font-size: 12px; color: var(--muted); margin: 3px 0 9px; }
.banner-actions { display: flex; align-items: center; gap: 10px; }
.banner-details {
  margin: 9px 0 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
}

/* ---------- Listen: Meine Briefe und Vorlagen (design/components/AppHistorie) ---------- */

.history { padding: 0; display: flex; flex-direction: column; max-height: 712px; }

.tabs { display: flex; gap: 18px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  background: none; border: none; margin-bottom: -1px;
  border-bottom: 2px solid transparent; padding: 13px 0 11px;
  font-size: 13.5px; color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tab-n { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }

.hist-search { position: relative; padding: 12px 16px; flex: none; }
.hist-search svg { position: absolute; left: 27px; top: 21px; color: var(--muted); }
.input.search { padding-left: 32px; font-size: 13px; }

.hist-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; }
/* Eine Zeile: Betreff, Datum · Empfänger, Zeichen-Chip – rechts nur Herunterladen und ⋮ */
.hist-item { position: relative; }
.item-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px; border-radius: var(--r-md);
}
.hist-item + .hist-item .item-row { border-top: 1px solid var(--line); }
.hist-item:hover .item-row, .hist-item.is-current .item-row { background: var(--sunken); }
.hist-item:hover + .hist-item .item-row,
.hist-item.is-current + .hist-item .item-row { border-top-color: transparent; }

.item-main {
  display: block; flex: 1; min-width: 0; text-align: left;
  background: none; border: none; padding: 0; color: inherit; font: inherit;
}
/* Der Titel wird nach zwei Zeilen geklemmt; der volle Betreff steht im title-Attribut */
.item-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13.5px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere;
}
.item-meta {
  display: block; font-size: 12px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Zeichen als Chip: Monospace, weil man es Zeichen für Zeichen abgleicht */
.item-ref {
  display: inline-block; max-width: 100%; margin-top: 6px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 1px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.item-ctrls { display: flex; align-items: center; gap: 2px; }
.chip { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: var(--r-sm); padding: 1px 6px; white-space: nowrap; }
/* Zustand des Eintrags („Entwurf“, „Änderungen offen“): ruhiger als „im Editor“ */
.chip.is-quiet { color: var(--muted); background: var(--sunken); }
/* Hinweis, dass die ganze Zeile das PDF öffnet. Der Platz bleibt belegt, damit beim Zeigen nichts springt. */
.open-hint { font-size: 12px; color: var(--muted); visibility: hidden; }
.hist-item:hover .open-hint, .hist-item:focus-within .open-hint { visibility: visible; }
.hist-item.is-current .open-hint { display: none; }
.ic {
  width: 28px; height: 28px; flex: none; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: var(--r-sm);
}
.ic:hover, .ic.is-on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* Überlaufmenü: fest am ⋮-Knopf, damit die scrollende Liste es nicht abschneidet (app.js setzt top/left) */
.menu {
  position: fixed; z-index: 20;
  width: 208px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 6px 20px rgba(27, 32, 39, 0.14);
}
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-radius: var(--r-sm);
  padding: 7px 10px; font-size: 13px; color: var(--text);
}
.menu-item:hover { background: var(--sunken); }
.menu-item.is-danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* Rückfrage in der Zeile statt Dialog: die restliche Liste bleibt sichtbar */
.row-ask { padding: 10px; border-radius: var(--r-md); background: var(--sunken); }
.hist-item.is-confirm .row-ask { background: var(--danger-soft); }
.hist-item.is-confirm .ask-text { color: var(--danger); }
.ask-text { font-size: 13px; }
.ask-field { display: block; margin-top: 8px; }
.ask-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.ask-input { font-size: 13px; padding: 7px 10px; }
.ask-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
/* Fehlermeldung bleibt an der Zeile stehen, zu der sie gehört */
.row-error { padding: 0 10px 10px; font-size: 12px; color: var(--danger); }

.empty { padding: 34px 26px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.empty.tight { padding: 22px 26px 26px; border-top: none; }
.empty svg { color: var(--line-strong); }
.empty-title { font-size: 13.5px; font-weight: 500; color: var(--text); margin-top: 10px; }
.empty.tight .empty-title { margin-top: 0; }
.empty-text { font-size: 12px; margin-top: 4px; }
.empty .btn-secondary { margin-top: 12px; }

/* ---------- Einstellungs-Panel (AppEinstellungen) ---------- */

.sheet-layer { position: fixed; top: 56px; right: 0; bottom: 0; left: 0; z-index: 10; }
.dim { position: absolute; inset: 0; background: rgba(27, 32, 39, 0.38); }
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(27, 32, 39, 0.10);
  display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sheet-sub { margin: 6px 0 0; font-size: 12px; color: var(--muted); max-width: 380px; }
.sheet-body { padding: 20px 28px 24px; overflow-y: auto; flex: 1; }
.sheet-body .field { margin-bottom: 14px; flex: 1; min-width: 0; }
.sheet-body .row { margin-bottom: 14px; }
.sheet-body .row .field { margin-bottom: 0; }

.group-label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding-bottom: 8px; margin: 22px 0 14px;
  border-bottom: 1px solid var(--line);
}
/* Erste Gruppe direkt unter dem (meist ausgeblendeten) Fehlerbanner */
.sheet-body > .banner + .group-label { margin-top: 0; }

.paper { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.paper-inner {
  background: #ffffff; padding: 16px 18px;
  font-family: var(--font-letter);
  font-size: 13px; line-height: 1.35; color: #000000;
}
.paper-gap { height: 10px; }
.paper-note {
  background: var(--sunken); border-top: 1px solid var(--line);
  padding: 6px 18px; font-size: 11px; color: var(--muted);
}

/* Unterschrift im Einstellungs-Panel */
.dropzone {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--bg);
}
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-text { font-size: 12px; color: var(--muted); }
.paper-inner.paper-closing { font-size: 11pt; line-height: 1.2; }
.paper-signature { min-height: 18mm; }
.paper-signature img { display: block; }
.range-field { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; }
.range-field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.range-field input { flex: 1; accent-color: var(--accent); }
.range-field output { min-width: 52px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.signature-actions { display: flex; align-items: center; gap: 12px; }

.sheet-foot {
  border-top: 1px solid var(--line);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.saved { font-size: 12px; color: var(--muted); }
.foot-actions { display: flex; gap: 8px; }

/* ---------- Toast: nur für Erfolg ---------- */

.toast-region {
  position: fixed; right: 20px; bottom: 20px; z-index: 30;
  width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px 14px;
  box-shadow: 0 4px 16px rgba(27, 32, 39, 0.12);
}
.toast-check {
  width: 26px; height: 26px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
}
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; }
.toast-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Responsiv ---------- */

@media (max-width: 1099px) {
  .main { grid-template-columns: 1fr; }
  .history { grid-column: 1; grid-row: 3; max-height: none; }
  .hist-list { max-height: 400px; }
}

@media (max-width: 699px) {
  .row { flex-direction: column; gap: 16px; }
  .zeichen-felder { flex-direction: column; gap: 8px; }
  .zeichen-felder .select, .zeichen-felder #f-zeichen_label_eigen, .zeichen-felder .mono { width: 100%; }
  .actionbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .actionbar .btn-primary { width: 100%; }
  .actionbar-buttons { flex-direction: column; align-items: stretch; }
  .actionbar-buttons button { width: 100%; }
  .attach-add { flex-direction: column; }
}

@media (max-width: 639px) {
  .sheet { width: 100%; }
  .sheet-body .row { flex-direction: column; gap: 14px; }
}

/* ---------- Ergänzungen der Browser-Fassung ---------- */

/* Kein Server, kein Konto: der Hinweis gehört neben den Produktnamen, nicht in ein Banner. */
.brand-note {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--ui-border);
  font-size: 12px;
  font-weight: 400;
  color: var(--ui-text-muted);
}

/* Sicherung im Einstellungs-Panel */
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.backup-state {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: 12px;
  color: var(--text);
}
.backup-state.is-error { background: var(--danger-soft); color: var(--danger); }

/* Der Anschrift-Hinweis wird zur Warnung, wenn es fürs Kuvertfenster zu viel wird. */
.hint.is-warn { color: var(--ui-danger); }

@media (max-width: 699px) {
  .brand-note { display: none; }
}

/* ---------- Rechtsseiten (Impressum, Datenschutz) ---------- */

.brand-link { color: inherit; text-decoration: none; }
.brand-link:hover { text-decoration: underline; }

.seite {
  max-width: 68ch;
  margin: 0 auto;
  padding: 28px 20px 56px;
}
.seite h1 { font-size: 22px; font-weight: 600; margin: 0 0 20px; }
.seite h2 { font-size: 15px; font-weight: 600; margin: 26px 0 6px; }
.seite p, .seite ul { margin: 0 0 12px; }
.seite ul { padding-left: 20px; }
.seite li { margin-bottom: 4px; }
.seite a { color: var(--ui-accent); }
.seite code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--ui-surface-sunken);
  padding: 1px 4px;
  border-radius: var(--ui-radius-sm);
}

/* Die Kernaussage zuerst, in einfachen Worten – nicht im Kleingedruckten vergraben. */
.seite-kern {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  padding: 16px 18px;
  margin-bottom: 8px;
}

/* Sichtbare Lücke: darf so nicht online gehen. */
.seite-offen {
  background: var(--ui-danger-soft);
  border-left: 3px solid var(--ui-danger);
  padding: 10px 14px;
  border-radius: var(--ui-radius-sm);
}

.seite-zurueck {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--ui-border);
  font-size: 13px;
}

/* Fußzeile der Arbeitsansicht: das Impressum muss von jeder Seite erreichbar sein. */
.fusszeile {
  padding: 4px 20px 24px;
  font-size: 12px;
  color: var(--ui-text-muted);
}
.fusszeile a { color: inherit; }
