/* Mailhelp web interface – mobile first, light and dark, no external resources. */
:root {
  color-scheme: light dark;
  /* Design tokens 5.0 (Planung 5.0, 1.2): every text/surface pair reaches WCAG AA 4.5:1. */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #047857;
  --accent-text: #ffffff;
  --accent-soft: #ecfdf5;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #92400e;
  --warn-soft: #fffbeb;
  --kind-event: #1d4ed8;
  --kind-task: #c2410c;
  --kind-draft: #0f766e;
  --sidebar-bg: #0f2f26;
  --sidebar-text: #ecfdf5;
  --sidebar-muted: #a7c4b8;
  --sidebar-hover: #1a4436;
  --sidebar-active: #047857;
  --focus: #f0a400;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #141b22;
    --surface-2: #1c242f;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #2a3441;
    --accent: #34d399;
    --accent-text: #052e1f;
    --accent-soft: #0c2a20;
    --danger: #f87171;
    --danger-soft: #3a1d20;
    --ok: #4ade80;
    --ok-soft: #10291a;
    --warn: #fbbf24;
    --warn-soft: #33270d;
    --kind-event: #93c5fd;
    --kind-task: #fdba74;
    --kind-draft: #5eead4;
    --sidebar-bg: #0f1720;
    --sidebar-text: #e2e8f0;
    --sidebar-muted: #94a3b8;
    --sidebar-hover: #1c2a36;
    --sidebar-active: #134e3a;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Header and navigation */
.top {
  position: static;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* On phones the wrapped navigation takes several rows. Fixed at the top it would cover a large
   part of the screen and the actions scrolled underneath it, so there it scrolls away with the page. */
@media (max-width: 719px) {
  .top { position: static; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.brand img { border-radius: 6px; }

.connection {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .85rem;
  background: var(--warn-soft);
  color: var(--warn);
}

.connection[data-state="online"] { background: var(--ok-soft); color: var(--ok); }

.nav {
  display: flex;
  width: 100%;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: thin;
  padding-bottom: 6px;
}

.nav a {
  flex: 0 0 auto;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  gap: 9px;
  white-space: nowrap;
}

.nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h1 { font-size: 1.55rem; line-height: 1.25; margin: 8px 0 16px; letter-spacing: -.035em; }
h2 { font-size: 1.05rem; margin: 28px 0 12px; color: var(--muted); }
h3 { font-size: 1.1rem; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 0 0 16px;
}

.card.current { border: 2px solid var(--accent); }
/* 5.0.7: kind of a card by stripe, symbol and text (colour is never the only mark). */
.card:is(.kind-event, .kind-task, .kind-change, .kind-cancel, .kind-draft) { border-left: 6px solid var(--kind-colour); }
.kind-event { --kind-colour: var(--kind-event); }
.kind-task { --kind-colour: var(--kind-task); }
.kind-change { --kind-colour: var(--kind-event); }
.kind-cancel { --kind-colour: var(--danger); }
.kind-draft { --kind-colour: var(--kind-draft); }
.kind-change.card { border-left-style: double; border-left-width: 8px; }
.kind-label { color: var(--kind-colour); font-weight: 700; }
.card.narrow { max-width: 440px; margin: 24px auto; }

.card-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.card-head h3 { margin: 4px 0 8px; line-height: 1.4; }
.kind { font-size: .85rem; color: var(--muted); font-weight: 600; margin: 0 0 4px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

.facts { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 6px; }
.facts li { display: flex; gap: 8px; overflow-wrap: anywhere; }
.facts .icon { flex: none; width: 1.4em; text-align: center; }

.source, .meta { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.source { margin: 4px 0 0; }

.questions {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--text);
}

.questions p { margin: 0 0 4px; font-weight: 600; }
.questions ul { margin: 0; padding-left: 20px; }

details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
details .full { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }

blockquote {
  margin: 8px 0 0;
  padding: 6px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
  overflow-wrap: anywhere;
}
/* 5.0.7: the evidence as a styled quotation in the colour of the card's kind. */
blockquote.evidence {
  position: relative; padding: 10px 14px 10px 36px; border-radius: 0 12px 12px 0;
  background: var(--surface-2); border-left-color: var(--kind-colour, var(--border));
  color: var(--text); font-style: italic;
}
blockquote.evidence::before {
  content: "„"; position: absolute; left: 10px; top: -2px; font-size: 1.8rem; line-height: 1;
  color: var(--kind-colour, var(--muted)); font-style: normal;
}

/* Forms and buttons */
.stack { display: grid; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions form { flex: 1 1 140px; display: flex; }
.actions .button { width: 100%; }

label { font-weight: 600; }
.hint { font-weight: 400; color: var(--muted); }

input, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents zooming on iOS */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}

textarea { min-height: 88px; resize: vertical; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.button.small { min-height: 44px; padding: 6px 12px; font-size: .9rem; }
.button.link { background: none; border: none; color: var(--accent); padding: 8px 0; }
.button:disabled { opacity: .6; cursor: wait; }
.button:not(:disabled):hover { border-color: var(--accent); }

.answer { margin-top: 14px; display: grid; gap: 8px; }
.answer .quick { display: flex; gap: 8px; }
.answer .quick form { flex: 1; display: flex; }
.answer .quick .button { width: 100%; }
.secondary-form { margin-top: 8px; }

/* Notices */
.notice { padding: 10px 12px; border-radius: 8px; margin: 0 0 16px; background: var(--accent-soft); }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* Lists */
.devices, .recent { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.device, .recent li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.recent li > span:first-child { overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat strong { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .9rem; }
.status-link { color: var(--text); text-decoration: none; min-height: 88px; }
.status-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.status-link span { text-decoration: underline; text-underline-offset: .2em; }

code { font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

@media (min-width: 720px) {
  .top { flex-wrap: wrap; padding-bottom: 0; }
  .nav { width: 100%; order: 3; }
  .nav a { flex: none; }
  .connection { order: 2; margin-left: 12px; }
  .brand { margin-right: auto; }
  main { padding-top: 24px; }
  h1 { font-size: 1.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Review pages */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.labels { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.count {
  font-variant-numeric: tabular-nums;
  display: inline-block; min-width: 1.8em; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 1rem; text-align: center;
  vertical-align: middle;
}
.card-head h3 a {
  display: flex; align-items: center; min-height: 44px;
  color: var(--text); text-decoration: none;
}
.card-head h3 a:hover { text-decoration: underline; }
.card-links { margin: 12px 0 0; }
.facts-table {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin: 0 0 16px; overflow: hidden;
}
.facts-table dt, .facts-table dd { margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); }
.facts-table dt:first-of-type, .facts-table dt:first-of-type + dd { border-top: none; }
.facts-table dt { color: var(--muted); }
.facts-table dd { font-weight: 600; overflow-wrap: anywhere; }
/* 5.9.11: figures open the call list; underlined and with › so they read as links. */
.fact-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.fact-link:hover { color: var(--accent); }
/* Touch: the figure links are full-height tap targets. */
@media (max-width: 899px), (pointer: coarse) {
  .fact-link { display: inline-flex; align-items: center; min-height: 44px; }
}
.calls-explanation ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.calls-pages { margin: .75rem 0; }
.calls-table td { vertical-align: top; }
/* 5.0.6: the proposal of the card next to each comparison candidate. */
.compare { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 12px 0; }
.compare-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; }
.compare-side h3 { margin: 0 0 10px; }
/* 5.0.7: the proposal in question stands out by frame, tint and label. */
.compare-this { border: 3px solid var(--accent); background: var(--accent-soft); }
.compare-other { border-style: dashed; }
.compare-tag {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .95rem;
  border: 1px solid var(--muted); color: var(--muted);
}
.compare-this .compare-tag { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.compare-side dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0;
  align-items: baseline; }
.compare-side dt { color: var(--muted); }
.compare-side dd { margin: 0; overflow-wrap: anywhere; }
.compare-side dd a { display: inline-flex; align-items: center; min-height: 44px; }
@media (min-width: 720px) { .compare { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) {
  .compare-side dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .compare-side dd { margin-bottom: 8px; }
  .compare-tag { font-size: .9rem; }
}
.run-progress { width: 100%; height: 12px; margin: 0 0 12px; accent-color: var(--accent); }
h3 { margin: 16px 0 8px; }
@media (max-width: 480px) {
  .facts-table { grid-template-columns: 1fr; }
  .facts-table dd { border-top: none; padding-top: 0; }
}
.mail h2 { margin-top: 0; color: var(--text); }
.mail-head { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 12px; }
.mail-head dt { color: var(--muted); }
.mail-head dd { margin: 0; overflow-wrap: anywhere; }
.inline-form { display: inline-block; margin: 0; }
.sender-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.sender-actions .meta { flex-basis: 100%; margin: 0; }
.sender-list { list-style: none; padding: 0; margin: 0 0 16px; }
.sender-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sender-entry { flex: 1 1 12rem; font-weight: 600; overflow-wrap: anywhere; }
.mail-text {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem;
  border-top: 1px solid var(--border); padding-top: 12px;
}

.archive-list { list-style: none; padding: 0; display: grid; gap: 16px; }
.stack input[type="text"] { max-width: 100%; width: 100%; font-size: 16px; min-height: 44px; }

.nav { flex-wrap: nowrap; overflow-x: auto; }
.nav a { flex: 0 0 auto; }
h2 { overflow-wrap: anywhere; }

.stack input[type="checkbox"] { width: 44px; height: 44px; min-height: 44px; vertical-align: middle; }

.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 16px; }
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 640px; }
.table-scroll th, .table-scroll td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; overflow-wrap: anywhere; }

/* 2.0: quick filters, image previews, dialogs, undo toast, split view, thumb zone */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.filter-chips .button { border-radius: 999px; padding: 8px 14px; font-size: .9rem; }
.filter-chips [aria-current="true"] { background: var(--accent); color: var(--accent-text); }
/* 6.0.6: one tool row for the open decisions: quick filters, search, sort and grouping. */
.open-toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; margin: 12px 0 16px; }
.open-toolbar .filter-chips { margin: 0; }
/* Quick filters on the first line, every other control together on the second. */
.open-search { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; flex: 1 1 100%; }
.open-field { display: flex; flex-direction: column; gap: 4px; }
.open-field label { font-size: .85rem; color: var(--muted); }
.open-field:first-of-type { flex: 1 1 14rem; max-width: 24rem; }
.open-field input, .open-field select { width: 100%; box-sizing: border-box; }
.open-group { display: flex; gap: 6px; align-items: center; min-height: 44px; white-space: nowrap; }
@media (max-width: 719px) {
  .open-search, .open-field:first-of-type { flex-basis: 100%; max-width: none; }
  .open-field { flex: 1 1 100%; }
}
.image-preview { list-style: none; margin: 12px 0; }
.image-preview img { display: block; max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); }
.disclosure { margin: 16px 0; }
.disclosure > summary { min-height: 48px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.modal { max-width: min(95vw, 1200px); max-height: 95vh; padding: 20px; border: 0; border-radius: 16px; background: var(--surface); color: inherit; }
.modal::backdrop { background: #000c; }
.modal dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.modal dt { font-weight: 700; }
.lightbox img { display: block; margin-top: 12px; max-width: 85vw; max-height: 80vh; object-fit: contain; cursor: zoom-in; }
.lightbox img.zoomed { max-width: none; max-height: none; cursor: zoom-out; }
.undo-toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; max-width: 90vw; padding: 12px 16px; background: var(--surface); border: 2px solid var(--border); border-radius: 16px; box-shadow: 0 8px 32px #0004; }
[hidden] { display: none !important; }
.card { transition: opacity .2s ease, transform .2s ease; }
.card.leaving { opacity: 0; transform: translateX(24px); pointer-events: none; }
.draft-box textarea { display: block; width: 100%; font: inherit; margin: 12px 0; }
.draft-box .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.draft-box textarea[readonly] { opacity: .75; }
.inbox-zero { text-align: center; }
.inbox-zero .badge { font-size: 1.5rem; padding: 8px 16px; }
/* 5.0.10: today's results as tiles; the entrance only moves, so contrast stays full throughout. */
.inbox-zero { animation: inbox-zero-in .35s ease-out both; }
@keyframes inbox-zero-in { from { transform: translateY(12px); } }
.kpi-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
  margin: 16px 0; text-align: left; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 12px 14px;
  border-top: 4px solid var(--kind-colour, var(--border)); }
.kpi dt { color: var(--muted); font-size: .85rem; }
.kpi dd { margin: 4px 0 0; font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
/* 5.1.1: the processing path of a mail; the badge names the outcome, the colour repeats it. */
.path-steps { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 12px; }
.path-step { border-left: 3px solid var(--border); padding: 2px 0 2px 14px; overflow-wrap: anywhere; }
.path-step p { margin: 2px 0; }
.path-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.outcome-done { border-left-color: var(--ok); }
.outcome-failed { border-left-color: var(--danger); }
.outcome-missing { border-left-color: var(--warn); }
.outcome-pending { border-left-color: var(--accent); }
.model-reason { color: var(--muted); font-style: italic; }
.model-reason .meta { font-style: normal; }
.path-notes { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.path-hints { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.path-hints li { overflow-wrap: anywhere; }
.path-hints .meta { display: block; margin-top: 2px; }
.badge.info { background: var(--surface-2); color: var(--text); }
.path-result { margin-top: 14px; padding: 12px 14px; border-left-width: 4px; border-radius: 0 12px 12px 0;
  background: var(--surface-2); }
/* 5.2: the check of a written entry; colour repeats the text, the table names expected and actual. */
.verification { margin-top: 12px; padding: 12px 14px; border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0; background: var(--surface-2); overflow-wrap: anywhere; }
.verification p { margin: 2px 0; }
.verification-verified { border-left-color: var(--ok); }
.verification-mismatch, .verification-not_found, .verification-unavailable { border-left-color: var(--warn); }
.verification-diff { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .95rem; }
.verification-diff th, .verification-diff td { text-align: left; vertical-align: top; padding: 6px 8px;
  border-top: 1px solid var(--border); }
.verification-diff thead th { color: var(--muted); font-weight: 600; border-top: 0; }
@media (max-width:480px) {
  .verification-diff thead { display: none; }
  .verification-diff tr { display: grid; grid-template-columns: 1fr; padding: 6px 0;
    border-top: 1px solid var(--border); }
  .verification-diff th, .verification-diff td { border-top: 0; padding: 2px 0; }
  .verification-diff td:nth-of-type(1)::before { content: "Bestätigt: "; color: var(--muted); }
  .verification-diff td:nth-of-type(2)::before { content: "Beim Anbieter: "; color: var(--muted); }
}
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-pane { display: none; min-width: 0; }
@media (min-width: 1024px) {
  main:has(.split-view) { max-width: 1500px; }
  .split-view { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 24px; align-items: start; }
  .master-pane { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; padding: 4px; }
  .master-pane .card { cursor: pointer; }
  .master-pane .card.selected { outline: 2px solid var(--accent); background: var(--accent-soft); }
  .master-pane .card { padding: 18px; margin-bottom: 12px; }
  .master-pane .source { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .master-pane h2 { font-size: .85rem; margin-top: 16px; }
  .master-pane .facts { font-size: .88rem; }
  .detail-pane > .card { padding: 24px; }
  /* Only the selection is framed; "Aktuell in Telegram" stays a badge in the list,
     and the kind stripe stays on that card (5.0.7). */
  .master-pane .card.current { border-width: 1px 1px 1px 6px;
    border-color: var(--border) var(--border) var(--border) var(--kind-colour, var(--border)); }
  .master-pane .card :is(blockquote, details, .actions, .questions, .notice, form, .card-links, p:not(.kind, .source, .labels)) { display: none; }
  /* 4.4: the outcome of an action stays visible in the list, also for unselected items. */
  .master-pane .card [data-command-result] .notice { display: block; }
  .detail-pane { display: block; padding: 4px; }
  /* 5.0.8: the decision row of the selected item stays visible at the bottom edge. */
  .detail-pane .card .decision-bar {
    position: sticky; bottom: 0; z-index: 3; margin: 16px -24px 0; padding: 14px 24px;
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .detail-pane .card .decision-bar:last-child { margin-bottom: -24px; border-radius: 0 0 var(--radius) var(--radius); }
  /* Quick loads (e.g. a background refresh) finish before the pane dims. */
  .detail-pane[aria-busy="true"] { opacity: .6; transition: opacity .15s ease .3s; }
  .detail-pane[inert] { opacity: .4; }
}
@media (max-width: 1023px) {
  /* Thumb zone: actions stay at the bottom edge while their card is on screen. */
  .card .actions { position: sticky; bottom: 0; z-index: 3; background: var(--surface); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .card .actions .button, .draft-box button, .undo-toast .button { min-height: 48px; }
  .draft-box .actions { position: static; padding: 0; }
  .card .actions form { order: 2; }
  .card .actions form:has(.danger) { order: 1; }
  .card .actions form:has(.primary) { order: 3; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .inbox-zero { animation: none; }
}

/* Filter forms (Auswertung, Mails, Verlauf) */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 0 0 16px; align-items: end; }
.filters label { display: grid; gap: 4px; }
select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}

/* Settings: one expandable row per value */
details.setting {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin: 0 0 8px; padding: 0 14px;
}
details.setting summary { justify-content: space-between; gap: 12px; color: var(--text); }
details.setting summary span { flex: 1 1 auto; min-width: 0; }
details.setting summary strong { flex: 0 0 auto; max-width: 55%; overflow-wrap: anywhere; text-align: right; }
details.setting[open] { padding-bottom: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

.filter-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 14px; }
.filter-box[open] { padding-bottom: 12px; }

/* Help stays outside the edit disclosure: reading it never opens or submits a form. */
.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 4px; align-items: start; }
.setting-help { position: relative; display: inline-block; font-size: 14px; font-weight: normal; }
.info-trigger { width: 44px; height: 44px; padding: 10px; border: 0; background: transparent;
  color: var(--accent); cursor: help; font: inherit; }
.info-trigger > span { display: block; width: 22px; height: 22px; border: 1px solid currentColor;
  border-radius: 50%; line-height: 20px; text-align: center; font-weight: 700; }
.setting-tooltip { display: none; position: absolute; right: 0; top: 100%; z-index: 30;
  width: min(34rem, calc(100vw - 40px)); padding: 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  line-height: 1.5; overflow-wrap: anywhere; text-align: left; }
.setting-help:not(.dismissed):hover .setting-tooltip,
.setting-help:not(.dismissed):focus-within .setting-tooltip { display: block; }
/* 2.2 activity reports */
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.event-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.event-list .filters { align-items: end; }
/* 3.0 setup and diagnosis: desktop and phone touch controls. */
.setup-page .button, .setup-page input:not([type="hidden"]), .setup-page select { min-height: 48px; }
.setup-page form { margin-bottom: 16px; }
.setup-page summary h2 { display: inline; }
.setup-page label:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.setup-page input[type="checkbox"] { width: 24px; min-height: 24px; flex: 0 0 24px; }

/* Application frame: a quiet workspace, with navigation independent of the mail content. */
.skip-link {
  position: absolute; left: 16px; top: -80px; z-index: 50; min-height: 44px;
  padding: 10px 16px; background: var(--surface); color: var(--accent);
  border: 2px solid var(--accent); border-radius: 8px;
}
.skip-link:focus { position: fixed; top: 12px; }
.nav-section { display: contents; }
.nav-section-label { display: none; }
.nav-icon { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; }
.page-heading { margin: 4px 0 22px; }
.page-heading h1 { margin: 6px 0 10px; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px; }
.page-intro { color: var(--muted); font-size: .95rem; margin: 0; max-width: 66ch; }
.card-context { border-top: 1px solid var(--border); margin-top: 14px; }
.card-context > summary { font-size: .87rem; font-weight: 600; }
.card-context[open] { padding-bottom: 8px; }
.count { font-size: .85rem; line-height: 1.8; padding: 0 10px; vertical-align: middle; letter-spacing: 0; }
.settings-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.model-overview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 16px; margin: 0 0 20px; }
.model-overview > summary { font-weight: 600; color: var(--text); }
.model-overview[open] { padding-bottom: 16px; }
.settings-layout { display: grid; gap: 24px; align-items: start; }
.settings-values { min-width: 0; }
.settings-index { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.settings-index .eyebrow { flex-basis: 100%; }
.settings-index a { display: flex; align-items: center; min-height: 48px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  text-decoration: none; color: var(--text); font-size: .87rem; }
.settings-index a:hover { background: var(--accent-soft); color: var(--accent); }
.settings-section { scroll-margin-top: 28px; margin-bottom: 32px; }
.settings-section h2 { color: var(--text); margin-top: 12px; font-size: 1.15rem; }
.settings-index a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.settings-tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.settings-tile { display: flex; flex-direction: column; gap: 4px; min-height: 48px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.settings-tile:hover, .settings-tile:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.settings-tile strong { color: var(--text); }
.settings-tile span { color: var(--muted); font-size: .9rem; }
.settings-tile .badge { align-self: flex-start; margin-top: 4px; font-style: normal; }
.settings-tile.danger strong { color: var(--danger); }
.settings-search { margin: 0 0 24px; }
.settings-search label { display: block; font-weight: 600; margin-bottom: 6px; }
.settings-search-row { display: flex; gap: 8px; }
.settings-search-row input { flex: 1 1 auto; min-width: 0; }
.settings-search-row input, .settings-search-row button { min-height: 48px; }
.setup-page h2 a { display: inline-flex; align-items: center; min-height: 48px; }
.area-heading h2 { margin: 0; font-size: 1.4rem; }
.area-heading { margin-bottom: 16px; }
form fieldset { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 12px;
  padding: 4px 14px 14px; margin: 0;
  min-width: 0; }
form fieldset legend { font-weight: 600; padding: 0 6px; }
.credential-group { margin-top: 20px; }
.credential-group h3 { margin-bottom: 10px; }
.credential-setting { margin-bottom: 10px; }
.guest-shell main { max-width: 620px; padding-top: 40px; }

@media (min-width: 900px) {
  main:has(.settings-layout) { max-width: 1240px; }
  .settings-layout { grid-template-columns: 205px minmax(0, 1fr); }
  .settings-index { display: grid; position: sticky; top: 24px; gap: 4px; }
  .settings-index a { border-color: transparent; background: transparent; padding: 10px 12px; }
  .settings-index a:hover, .settings-index a:focus-visible { background: var(--surface); border-color: var(--border); }
}

/* 5.0.1 navigation: sidebar from 900 px (icon rail up to 1199 px or when collapsed),
   bottom bar with "Mehr" below 900 px. Both work without JavaScript. */
.nav-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6em;
  margin-left: auto; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-size: .75rem; font-weight: 700; line-height: 1.6; font-variant-numeric: tabular-nums; }
:is(.nav-toggle, .shortcut-hint) { display: none; }
.tab-bar { display: none; }

@media (max-width: 899px) {
  /* Focus and scrolled-to controls never end up under the bar at the bottom edge. */
  html:has(.app-shell) { scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .app-shell .top { padding-bottom: 8px; }
  .app-shell .nav { display: none; }
  .app-shell { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .tab-bar { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 56px;
    padding: 4px 4px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, .06); }
  .tab-bar a, .tab-more > summary { position: relative; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; min-height: 56px; padding: 6px 2px; color: var(--muted); font-size: .72rem;
    font-weight: 600; text-decoration: none; border-radius: 10px; cursor: pointer; list-style: none; }
  .tab-more > summary::-webkit-details-marker { display: none; }
  .tab-bar .nav-icon { display: block; width: 22px; height: 22px; }
  .tab-bar a[aria-current="page"], .tab-more.has-current > summary { color: var(--accent); background: var(--accent-soft); }
  .tab-bar .nav-count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
  .tab-more { position: relative; }
  .tab-menu { position: absolute; right: 0; bottom: calc(100% + 8px); display: grid; gap: 2px; min-width: 220px;
    padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 8px 32px rgba(15, 23, 42, .18); }
  .tab-menu a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 10px 12px;
    font-size: .95rem; color: var(--text); }
  .card .actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .undo-toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (min-width: 900px) {
  .app-shell { --sidebar-width: 236px; padding-left: var(--sidebar-width); }
  .app-shell .top { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); padding: 28px 18px 24px;
    display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    background: var(--sidebar-bg); border: 0; overflow: hidden; }
  .app-shell .brand { color: var(--sidebar-text); margin: 0 0 28px; padding: 0 10px; font-size: 1.25rem; gap: 12px; }
  .app-shell .brand img { width: 32px; height: 32px; border-radius: 9px; }
  .app-shell .nav { display: block; width: 100%; flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto;
    order: 2; scrollbar-color: var(--sidebar-muted) transparent; }
  .app-shell .nav-section { display: block; margin-bottom: 24px; }
  .app-shell .nav-section-label { display: block; margin: 0 12px 9px; color: var(--sidebar-muted);
    font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 600; }
  .app-shell .nav a { position: relative; justify-content: flex-start; border: 0; border-radius: 9px; color: var(--sidebar-text);
    font-size: .87rem; gap: 12px; margin-bottom: 3px; min-height: 46px; padding: 10px 12px; }
  .app-shell .nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
  .app-shell .nav a[aria-current="page"] { background: var(--sidebar-active); color: #ffffff; }
  .app-shell :is(.nav-toggle, .shortcut-hint) { order: 4; display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--sidebar-hover); border-radius: 9px;
    background: transparent; color: var(--sidebar-text); font: inherit; font-size: .8rem; cursor: pointer; }
  .app-shell :is(.nav-toggle, .shortcut-hint):hover { background: var(--sidebar-hover); }
  .app-shell .shortcut-hint > span[aria-hidden] { font-weight: 700; }
  .app-shell .connection { order: 3; margin: 18px 10px 0; align-self: flex-start; font-size: .8rem; }
  .app-shell main { padding: 32px 32px 56px; }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .app-shell { --sidebar-width: 76px; }
  .app-shell :is(.nav-toggle, .shortcut-hint) { display: none; }
  .app-shell .top { padding: 20px 10px; }
  .app-shell .brand { justify-content: center; padding: 0; font-size: 0; }
  .app-shell .nav-section { margin-bottom: 14px; }
  .app-shell .nav-section-label { display: none; }
  .app-shell .nav a { justify-content: center; padding: 12px 0; min-height: 48px; }
  .app-shell .nav .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app-shell .nav .nav-count { position: absolute; top: 2px; right: 4px; margin: 0; }
  .app-shell .connection { margin: 14px 0 0; align-self: stretch; text-align: center; font-size: .65rem; padding: 2px 4px; }
}
@media (min-width: 1200px) {
  .app-shell.nav-collapsed { --sidebar-width: 76px; }
  .nav-collapsed .top { padding: 20px 10px; }
  .nav-collapsed .brand { justify-content: center; padding: 0; font-size: 0; }
  .nav-collapsed .nav-section { margin-bottom: 14px; }
  .nav-collapsed .nav-section-label { display: none; }
  .nav-collapsed .nav a { justify-content: center; padding: 12px 0; min-height: 48px; }
  .nav-collapsed :is(.nav, .nav-toggle, .shortcut-hint) .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-collapsed .nav .nav-count { position: absolute; top: 2px; right: 4px; margin: 0; }
  .nav-collapsed .connection { margin: 14px 0 0; align-self: stretch; text-align: center; font-size: .65rem; padding: 2px 4px; }
}

@media (max-width: 719px) {
  .nav-icon { display: none; }
  .nav a { font-size: .88rem; padding: 8px 10px; }
  .card { padding: 16px; }
  .page-heading { margin-bottom: 16px; }
}

/* Charts of the evaluation page (3.3.9): server-side SVG, colours from the theme variables. */
.chart-grid-layout { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.chart { margin: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.chart figcaption { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 14px; font-weight: 600; margin-bottom: 8px; }
.chart figcaption > span { flex: 1 1 180px; }
.chart-zoom { flex-shrink: 0; min-height: 44px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart:not(.chart-expanded) svg { cursor: zoom-in; }
.chart-plot { position: relative; }
.chart [data-chart-detail]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.chart-detail { display: none; position: sticky; left: 0; height: 80px; margin-top: 8px; overflow: auto; }
.chart-interactive .chart-detail { display: block; }
.chart-hint { margin: 0; padding: 10px 12px; font-size: .85rem; color: var(--muted); }
.chart-tooltip { position: absolute; inset: 0 0 auto; min-height: 100%; margin: 0; padding: 10px 12px;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; z-index: 2; }
.chart-modal { width: min(1400px, calc(100vw - 32px)); max-width: none; max-height: 94vh;
  padding: 18px; box-sizing: border-box; }
.chart-modal > button { min-height: 44px; margin-bottom: 12px; }
.chart-modal .chart { box-shadow: none; }
.chart-modal .chart-plot { overflow-x: auto; }
.chart-modal svg { min-width: 640px; }
.chart-modal [data-chart-detail] { cursor: help; }
body:has(.chart-modal[open]) { overflow: hidden; }
.chart details { margin-top: 8px; font-size: .9rem; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis, .chart-legend { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-ok, .chart-bar { fill: var(--accent); }
.chart-failed { fill: var(--danger); }
.chart-cost { fill: var(--warn); }
.chart-ok-text { fill: var(--accent); }
.chart-failed-text { fill: var(--danger); }
.chart-cost-text { fill: var(--warn); }
.chart-bar-text { fill: var(--accent); }
/* 5.9.8: average and 7-day mean of the cost chart. */
.chart-average-line { stroke: var(--kind-event); }
.chart-average-text { fill: var(--kind-event); }
.chart-cost-trend { stroke: var(--text); }
.chart-trend-text { fill: var(--text); }
/* 5.9.9: duration scatter plot; failures are crosses, not only another colour. */
.chart-grid-fine { stroke: var(--border); stroke-width: .5; stroke-dasharray: 2 3; }
.chart-dot { fill: var(--accent); }
.chart-cross { stroke: var(--danger); }
.chart-trend-line { stroke: var(--text); }
.chart-subtitle { margin: 0 0 4px; }
/* 5.9.10: pipeline plan as an ordered list; arrows are decoration (CSS content, not read out). */
.pipeline-figure { grid-column: 1 / -1; }
.pipeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.pipeline-step { position: relative; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.pipeline-step:not(:last-child)::after { content: "↓" / ""; position: absolute; left: 50%; bottom: -20px;
  color: var(--muted); }
.pipeline-step.is-local { color: var(--muted); padding: 4px 10px; }
.pipeline-step.is-bottleneck { border: 2px solid var(--warn); }
.pipeline-part { display: flex; flex-direction: column; gap: 2px; flex: 1 1 10rem; min-width: 0; }
.pipeline-name { font-weight: 600; }
.pipeline-step.is-local .pipeline-name { font-weight: 400; }
.pipeline-branch { flex-basis: 100%; margin: 0; }
.pipeline-mark { font-weight: 700; color: var(--warn); }
.pipeline-others { margin: 0; padding-left: 1.1rem; }
.pipeline-bar { display: block; height: 6px; border-radius: 3px; background: var(--accent); min-width: 2px; }
.pipeline-bar.share-0 { width: 0%; }
.pipeline-bar.share-5 { width: 5%; }
.pipeline-bar.share-10 { width: 10%; }
.pipeline-bar.share-15 { width: 15%; }
.pipeline-bar.share-20 { width: 20%; }
.pipeline-bar.share-25 { width: 25%; }
.pipeline-bar.share-30 { width: 30%; }
.pipeline-bar.share-35 { width: 35%; }
.pipeline-bar.share-40 { width: 40%; }
.pipeline-bar.share-45 { width: 45%; }
.pipeline-bar.share-50 { width: 50%; }
.pipeline-bar.share-55 { width: 55%; }
.pipeline-bar.share-60 { width: 60%; }
.pipeline-bar.share-65 { width: 65%; }
.pipeline-bar.share-70 { width: 70%; }
.pipeline-bar.share-75 { width: 75%; }
.pipeline-bar.share-80 { width: 80%; }
.pipeline-bar.share-85 { width: 85%; }
.pipeline-bar.share-90 { width: 90%; }
.pipeline-bar.share-95 { width: 95%; }
.pipeline-bar.share-100 { width: 100%; }
@media (min-width: 900px) {
  .pipeline { flex-direction: row; flex-wrap: wrap; align-items: stretch; column-gap: 28px; }
  .pipeline-step { flex: 0 1 11rem; }
  .pipeline-step:has(.pipeline-branch) { flex-basis: 18rem; }
  .pipeline-step:not(:last-child)::after { content: "→" / ""; left: auto; right: -21px; bottom: auto;
    top: 50%; transform: translateY(-50%); }
}
/* 5.3: live search results directly below the settings search field. */
.settings-live-status:empty { display: none; }
.settings-live-results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.settings-live-results li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); overflow-wrap: anywhere; }
.settings-live-results a { display: inline-block; min-height: 44px; line-height: 44px; font-weight: 600; }
.settings-live-results .meta { display: block; }
.settings-search.searching .settings-live-results { opacity: .6; }
/* 5.3: packaged help sections, readable without JavaScript. */
.help-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.55; }
/* 5.3: help chat; answers are plain text, links come from the server. */
.help-chat { display: grid; gap: 14px; margin: 16px 0; }
.help-turn { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.help-question { margin: 0 0 6px; overflow-wrap: anywhere; }
.help-answer { overflow-wrap: anywhere; line-height: 1.55; }
/* 5.5.6: the rendered Markdown subset of answers. */
.help-answer p, .help-answer-text p { margin: 0 0 8px; }
.help-answer ol, .help-answer ul, .help-answer-text ol, .help-answer-text ul { margin: 0 0 8px; padding-left: 22px; }
.help-answer li, .help-answer-text li { margin: 2px 0; }
.help-answer > :last-child, .help-answer-text > :last-child { margin-bottom: 0; }
.help-answer code, .help-answer-text code { font-size: .9em; padding: 1px 4px; border-radius: 4px;
  background: var(--accent-soft); overflow-wrap: anywhere; }
.help-answer pre, .help-answer-text pre { margin: 0 0 8px; padding: 8px; border-radius: 8px; overflow-x: auto;
  background: var(--accent-soft); }
.help-answer pre code, .help-answer-text pre code { padding: 0; background: none; }
.help-md-heading { margin-top: 10px; }
.help-answer-full { margin: 6px 0 0; }
.help-answer-full summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; width: fit-content;
  color: var(--accent); }
.help-answer-full summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.help-answer-text { overflow-wrap: anywhere; line-height: 1.55; }
.help-sources { margin: 4px 0 0; padding-left: 18px; }
.help-sources a, .ask-help { display: inline-block; min-height: 44px; line-height: 44px; }
.help-form textarea { width: 100%; font-size: 16px; }
/* 5.3.12: floating help chat button on the settings pages, above the phone tab bar. */
.help-fab { position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px;
  border-radius: 50%; background: var(--accent); color: var(--accent-text);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .25); }
.help-fab:hover { filter: brightness(1.08); }
.help-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.help-fab .nav-icon { display: block; width: 26px; height: 26px; stroke-width: 1.9; }
.app-shell main:has(~ .help-fab) { padding-bottom: 88px; }
@media (max-width: 899px) {
  .help-fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: calc(16px + env(safe-area-inset-right)); }
}
@media print { .help-fab { display: none; } }
/* 5.4: a non-modal window, independent of the settings forms behind it. */
#help-widget [hidden] { display: none !important; }
.help-launch { margin: 0; }
.help-launch:has(~ #help-window:not([hidden])) { display: none; }
#help-window button { min-height: 48px; }
#help-window a { display: inline-block; min-height: 48px; padding: 10px 0; }
#help-window { position: fixed; z-index: 24; right: calc(20px + env(safe-area-inset-right));
  bottom: calc(84px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 24px));
  max-height: min(520px, 65dvh); display: flex; flex-direction: column; overflow: hidden;
  border: 2px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 8px 32px #0004; }
.help-window-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; border-bottom: 1px solid var(--border); cursor: move; touch-action: none; }
.help-window-head h2 { margin: 0; font-size: 1rem; }
.help-window-head form { margin: 0; }
#help-window.help-top-left, #help-window.help-top-right { top: 8px; bottom: auto; }
#help-window.help-top-left, #help-window.help-bottom-left { left: 8px; right: auto; }
.help-window-head button { min-width: 44px; min-height: 44px; font-size: 1.3rem; }
/* 5.5.3: grips at the borders and corners (added by the script; without it the size is fixed). */
.help-resize { position: absolute; z-index: 2; touch-action: none; }
.help-resize-n, .help-resize-s { left: 14px; right: 14px; height: 8px; cursor: ns-resize; }
.help-resize-e, .help-resize-w { top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
.help-resize-n { top: 0; } .help-resize-s { bottom: 0; } .help-resize-e { right: 0; } .help-resize-w { left: 0; }
.help-resize-ne, .help-resize-nw, .help-resize-se, .help-resize-sw { width: 14px; height: 14px; }
.help-resize-nw { top: 0; left: 0; cursor: nwse-resize; } .help-resize-se { bottom: 0; right: 0; cursor: nwse-resize; }
.help-resize-ne { top: 0; right: 0; cursor: nesw-resize; } .help-resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
#help-window { min-width: min(280px, calc(100vw - 16px)); }
.help-cost-hint { margin: 0; font-size: .9rem; color: var(--muted); }
.help-cost-hint summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; width: fit-content; }
.help-cost-hint summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.help-cost-hint p { margin: 0 0 6px; }
.help-window-head h2:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
#help-window-content, #help-document { padding: 8px 12px; overflow-y: auto; min-height: 0; }
#help-window-content { flex: 1; }
#help-window-content .help-chat { margin: 0; }
#help-window-content .help-form { margin-top: 12px; }
#help-window-content .help-form textarea { min-height: 80px; }
#help-window-status { margin: 0; padding: 0 12px; font-size: .9rem; }
.help-document-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Explicit confirmations remain operable even when the window overlaps their form. */
/* 5.5.2: only their buttons and only while the window is open; a whole raised form (the topics
   page is one) covered the window's own controls and, when closed, the chat button. */
body:has(#help-window:not([hidden])) #inhalt form:has(input[name="confirm"][value="yes"]) button {
  position: relative; z-index: 26; }
@media (max-width: 899px) {
  #help-window { bottom: calc(140px + env(safe-area-inset-bottom)); right: 12px; }
}
@media print { #help-widget { display: none; } }
/* 5.6: the old rule and its editable successor remain directly comparable. */
.rule-diff { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
/* 6.0.1: words break only at word boundaries (anywhere split "Bisher" into "Bi/sh/er"). */
.rule-diff section { min-width: 0; overflow-wrap: break-word; word-break: normal; }
.rule-diff section > label { display: block; margin-top: .65rem; }
.rule-diff textarea, .rule-diff input:not([type="checkbox"]) { width: 100%; box-sizing: border-box; }
.rule-diff dt { font-weight: 600; }
.rule-diff dd { margin: 0 0 0.75rem; white-space: pre-wrap; }
/* 6.0.1: the two columns follow the width of the card, not of the window (sidebar). */
.rule-review { container-type: inline-size; }
@container (max-width: 999px) { .rule-diff { grid-template-columns: 1fr; } }
@media (min-width: 1024px) { main:has(.rule-review) { max-width: 1600px; } }
.topic-tabs { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1rem 0; }
.topic-tabs [aria-current="page"] { border-color: var(--accent); font-weight: 700; }
.topic-table { width: 100%; border-collapse: collapse; }
.topic-table caption { text-align: left; font-weight: 700; padding: .75rem 0; }
/* 5.9.6: words break only at word boundaries; only the technical id may break anywhere. */
.topic-table th, .topic-table td { text-align: left; padding: .7rem; vertical-align: top;
  overflow-wrap: normal; word-break: normal; hyphens: manual; }
.topic-table th { font-size: .9rem; }
.topic-table td small { display: block; color: var(--muted); overflow-wrap: anywhere; }
@media (min-width: 801px) {
  .topic-table td[data-label="Status"] { white-space: nowrap; }
  .topic-table td[data-label="Beispiele / Ausschlüsse"] { white-space: nowrap; text-align: center;
    font-variant-numeric: tabular-nums; }
  .topic-table td[data-label="Beschreibung"] { overflow-wrap: break-word; }
  .topic-table .topic-action { white-space: nowrap; text-align: right; }
}
/* Minimum widths only where they fit next to the sidebar (no horizontal scrolling at 1024 px). */
@media (min-width: 1280px) {
  .topic-table td[data-label="Thema"] { min-width: 12rem; }
  .topic-table td[data-label="Geltungsbereich"] { min-width: 9rem; }
  .topic-table td[data-label="Beschreibung"] { min-width: 16rem; }
}
.topic-row { border-top: 1px solid var(--border); }
.topic-row.is-disabled { color: var(--muted); }
.topic-row[hidden] { display: none; }
@media (max-width: 800px) {
  .topic-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .topic-table tbody, .topic-row, .topic-table td { display: block; }
  .topic-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin: .8rem 0; }
  .topic-row[hidden] { display: none; }
  .topic-table td { padding: .45rem .8rem; }
  .topic-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; }
}
/* 5.7.3: one comparison for topic edits and rule learning; changes are marked in text, not only colour. */
.rule-compare { min-width: 0; }
.compare-table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
.compare-table caption { text-align: left; font-weight: 700; padding: .5rem 0; }
.compare-table th, .compare-table td { text-align: left; vertical-align: top; padding: .6rem; border-top: 1px solid var(--border);
  overflow-wrap: break-word; word-break: normal; }
.compare-table thead th { font-size: .9rem; color: var(--muted); border-top: 0; white-space: nowrap; }
.compare-table th[scope="row"] { min-width: 6.5rem; max-width: 9.5rem; font-weight: 600; }
.compare-table td[data-label="Bisher"] { min-width: 6.5rem; }
.compare-table .badge, .compare-table .diff-mark { white-space: nowrap; }
.compare-table th[scope="row"] .badge { display: inline-block; margin-top: .25rem; }
.compare-text { white-space: pre-wrap; }
.line-diff { margin: 0; padding-left: 1.1rem; }
.line-diff li { margin: .15rem 0; }
.line-diff .diff-added { background: var(--ok-soft); border-radius: 6px; padding: 0 .3rem; }
.line-diff .diff-removed { background: var(--danger-soft); border-radius: 6px; padding: 0 .3rem; }
.diff-mark { font-weight: 700; font-size: .85rem; }
.compare-unchanged { margin: .25rem 0 1rem; }
.compare-unchanged > summary { font-weight: 600; cursor: pointer; }
.compare-unchanged dt { font-weight: 600; margin-top: .5rem; }
.compare-unchanged dd { margin: 0; white-space: pre-wrap; color: var(--muted); }
@media (max-width: 720px) {
  .compare-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .compare-table, .compare-table tbody, .compare-table tr, .compare-table th, .compare-table td { display: block; width: auto; }
  .compare-table tr { border: 1px solid var(--border); border-radius: 12px; margin: .6rem 0; padding: .2rem 0; }
  .compare-table th, .compare-table td { border-top: 0; padding: .35rem .7rem; }
  .compare-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; }
}
.rule-summary ol { margin: .5rem 0 0; padding-left: 1.3rem; }
.rule-review { scroll-margin-top: 1rem; }
.rule-select { display: flex; gap: .5rem; align-items: center; font-weight: 600; margin: .25rem 0 .75rem;
  padding: .55rem .75rem; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); }
.rule-evidence { margin: .5rem 0 1rem; }
.rule-evidence > summary { font-weight: 600; cursor: pointer; }
.rule-evidence ul { padding-left: 1.1rem; }
.rule-evidence li { margin: .5rem 0; }
.rule-evidence li details { margin-top: .25rem; }
.confirm-bar { position: sticky; bottom: 0; z-index: 4; background: var(--surface); border-top: 1px solid var(--border);
  padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: center; }
.confirm-bar p { margin: 0; flex-basis: 100%; }
/* Content scrolled into view (also by keyboard focus) never ends up underneath the bar. */
html:has(.confirm-bar) { scroll-padding-bottom: 12rem; }
@media (max-width: 899px) { .confirm-bar { bottom: calc(64px + env(safe-area-inset-bottom)); } }
.learning-steps fieldset { border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
.learning-steps legend { font-weight: 700; padding: 0 .35rem; }
.learning-steps label { display: block; margin-top: .5rem; }
.learning-folders { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--muted); }
/* 5.7.6: which decisions a rule analysis uses. */
.rule-scope { border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem; margin: 0 0 1rem; }
.rule-scope legend { font-weight: 700; padding: 0 .35rem; }
.rule-scope label { display: flex; gap: .5rem; align-items: flex-start; margin-top: .5rem; font-weight: 600; }
.rule-scope .meta { margin: .15rem 0 0 1.6rem; }

/* 5.8: compact tasks; evidence, explanations and technical facts remain accessible. */
.topic-heading { margin: 0; }
/* 5.9.6: one tool row from 720 px (search, status, filter, "Neues Thema"); wraps below. */
.topic-toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: flex-end; margin: .5rem 0; }
#topic-filter { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; flex: 1 1 32rem; }
#topic-filter label { display: block; margin: 0 0 .25rem; }
#topic-filter .topic-search { flex: 1 1 18rem; max-width: 28rem; }
#topic-filter .topic-search input, #topic-filter select { width: 100%; box-sizing: border-box; }
#topic-filter .topic-state { flex: 0 1 11rem; }
.topic-new { margin-left: auto; white-space: nowrap; }
@media (max-width: 719px) {
  .topic-toolbar, #topic-filter { display: block; }
  #topic-filter > * { margin-bottom: .5rem; max-width: none; }
  .topic-new { display: inline-block; margin: .25rem 0 0; }
}
.topic-tabs { gap: .4rem; margin: .5rem 0; }
.topic-guidance { margin: 1rem 0; }
main:has(.topic-field) > form { max-width: 760px; gap: 1rem; }
.topic-field > label { display: block; font-weight: 600; margin: 0 0 .25rem; }
.topic-field > input, .topic-field > textarea { width: 100%; }
.topic-field > .meta { margin: .25rem 0 0; }
.topic-field > .notice { margin: .4rem 0 0; }
.learning-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1rem; }
.learning-options .card { margin: 0; gap: .4rem; }
.learning-options .card > :is(h2, p) { margin: 0; }
.learning-options .help-cost-hint { margin: .35rem 0; }
.settings-layout:not(:has(.settings-index)) { grid-template-columns: minmax(0, 1fr); }
.rule-reanalyze { margin: 1.5rem 0; }
.rule-final > .card { margin: .8rem 0; }
.status-summary p { margin: .5rem 0; }
.status-details > summary, .decision-help > summary { min-height: 44px; padding: .6rem 0; }
.master-pane .decision-help { display: none; } /* Available on the linked detail page. */
@media (max-width: 719px) {
  .card { padding: 14px; margin-bottom: 12px; }
  .card .kind, .card .labels, .card .facts { margin-top: 6px; margin-bottom: 6px; }
  .card .facts { gap: 2px; }
  .card .questions { padding: 8px 10px; margin: 8px 0; }
  .card .notice { padding: 8px 10px; margin: 8px 0; }
  .card .card-links, .card .card-context { margin-top: 8px; }
  .card .decision-help { font-size: .85rem; }
  .topic-tabs .button { padding: 6px 8px; font-size: .9rem; }
}
/* 5.9.3: a field conflict shows both values side by side; no side is preselected or highlighted. */
.conflict { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius);
  padding: 12px 14px; margin: 12px 0; }
.conflict h4 { margin: 0; font-size: 1rem; }
.conflict .compare { margin: 10px 0 6px; }
.conflict-side { display: flex; flex-direction: column; gap: 8px; }
.conflict-side .compare-tag { align-self: flex-start; margin: 0; overflow-wrap: anywhere; }
.conflict-value { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.conflict-side form { margin-top: auto; }
.conflict-side .button { width: 100%; white-space: normal; }
.conflict .meta { margin: 6px 0 0; }
/* 5.9.6: only the topic list gets more width; the editor pages stay narrow. */
@media (min-width: 1024px) { main:has(.topic-table) { max-width: 1320px; } }
