/* meinKI Briefkasten: Formensprache der meinKI-Oberfläche (Inter, Serif nur für Überschriften,
   warmes Papier, schwarze Primärflächen, Radius 12/16). Hell ist Standard, dunkel folgt der Systemeinstellung.
   Kontraste (WCAG AA, im Test festgeschrieben): Text mindestens 4,5:1, Formularränder mindestens 3:1. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2");
}
:root {
  color-scheme: light dark;
  --paper: #faf9f7;
  --card: #ffffff;
  --surface: #f4f1ea;
  --ink: #1a1a1a;
  --ink-hover: #3b3a37;
  --muted: #6b6860;
  --line: #e8e3d7;
  --line-strong: #d6d0c1;
  --control: #8a8578;
  --accent: #a8502f;
  --accent-hover: #8c3f23;
  --accent-soft: #cc785c;
  --tint: #f9f6f0;
  --on-accent: #ffffff;
  --on-ink: #ffffff;
  --band: #1a1a1a;
  --shadow: 0 1px 2px rgba(26, 26, 26, .05), 0 4px 14px rgba(26, 26, 26, .05);
  --radius: 12px;
  --radius-card: 16px;
  --text-small: .8125rem;
  --text-base: 1rem;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Tiempos, Charter, "Iowan Old Style", Georgia, serif;
  --sidebar: 256px;
  --wash: #f8ece6;
  --wash-line: #ecd3c6;
  --folder-w: 220px;
  --list-w: clamp(320px, 27vw, 380px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a18; --card: #242321; --surface: #2c2a27; --ink: #f2efe8; --ink-hover: #ffffff;
    --muted: #b0ab9f; --line: #3d3a35; --line-strong: #504c45; --control: #8f8a7e;
    --accent: #e8987c; --accent-hover: #f2b39d; --accent-soft: #e8987c; --tint: #2a2622;
    --on-accent: #1b1a18; --on-ink: #1b1a18; --band: #0f0e0d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
    --wash: #33241e; --wash-line: #5a3d30;
  }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--text-base)/1.55 var(--font); font-optical-sizing: auto; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: .25em; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 { max-width: 24ch; font-family: var(--serif); font-size: 2.25rem; font-weight: 400; line-height: 1.15; }
h2 { font-family: var(--serif); font-size: 1.5rem; line-height: 1.25; font-weight: 400; }
h3 { font-size: 1rem; font-weight: 600; line-height: 1.4; }
p { max-width: 62ch; text-wrap: pretty; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 30; padding: 12px 16px; border-radius: var(--radius); color: var(--on-accent); background: var(--accent); }
.skip-link:focus { top: 1rem; }
.icon { flex: 0 0 auto; }

/* Rahmen: Seitenleiste links, Inhalt rechts */
.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--paper); }
.sidebar-brand { display: flex; align-items: center; height: 72px; padding: 0 20px; background: var(--band); }
.desktop-navigation { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; overflow-y: auto; flex: 1; }
.sidebar-account { padding: 12px; border-top: 1px solid var(--line); }
.account-line { display: flex; align-items: center; gap: 12px; padding: 4px 12px 8px; color: var(--muted); font-size: .875rem; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); color: var(--muted); }
.avatar .icon { width: 18px; height: 18px; }

/* Logo mit Zusatz */
.brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-logo { display: block; height: 22px; width: auto; }
.brand-product { padding-left: 12px; border-left: 1px solid var(--line-strong); font-size: 1rem; font-weight: 500; line-height: 1.2; }
.sidebar-brand .brand, .sidebar-brand .brand:hover { color: #fff; }
.sidebar-brand .brand-product { border-color: rgba(255, 255, 255, .35); }
.sidebar-brand a:focus-visible { outline-color: #fff; }
.logo-paper { display: none; }
@media (prefers-color-scheme: dark) {
  .logo-ink { display: none; }
  .logo-paper { display: block; }
}

/* Navigation (Seitenleiste, Tab-Leiste, Blatt „Mehr“) */
nav a, .tab-more summary { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius); color: var(--ink); font-size: .9375rem; line-height: 1.3; text-decoration: none; }
nav a:hover { background: var(--surface); color: var(--ink); }
nav a[aria-current="page"] { background: var(--ink); color: var(--on-ink); font-weight: 500; }
nav a.is-soon { color: var(--muted); }
.nav-tag { margin-left: auto; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: .75rem; line-height: 1.4; color: var(--muted); }
.logout-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radius); background: none; color: var(--muted); font-size: .9375rem; text-align: left; }
.logout-button:hover { background: var(--surface); color: var(--ink); }
.switch-link { display: flex; align-items: center; min-height: 40px; padding: 8px 12px; border-radius: var(--radius); color: var(--muted); font-size: .9375rem; text-decoration: none; }
.switch-link:hover { background: var(--surface); color: var(--ink); }

/* Arbeitsfläche */
.workspace { min-width: 0; display: flex; flex-direction: column; }
.mobile-header, .tabbar-wrap { display: none; }
.main-content { width: 100%; max-width: 1016px; padding: 48px 56px 32px; flex: 1; }
.main-content:focus { outline: none; }
.page-heading { margin-bottom: 32px; }
.section-label { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.lead { margin-top: 8px; color: var(--muted); font-size: .9375rem; max-width: 62ch; }
.lead strong { color: var(--ink); font-weight: 500; }
.small-label { font-size: var(--text-small); color: var(--muted); }

/* Knöpfe */
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; margin-top: 24px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--ink); color: var(--on-ink); font-size: .875rem; font-weight: 500; line-height: 1.3; text-decoration: none; }
.button:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: var(--on-ink); }
.button span { font-size: 1rem; font-weight: 400; line-height: 1; }
.button.secondary, .secondary { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.button.wide { display: flex; width: 100%; }
/* Postfach-Einstieg: Adresse als Text im Knopf, nicht als Pfeilsymbol. */
.entry-button { justify-content: flex-start; gap: .3em; }
.entry-button .entry-address { font-size: inherit; font-weight: 400; line-height: inherit; }
.entry-form + .entry-form .button { margin-top: 12px; }
.entry-form + :not(.entry-form) { margin-top: 32px; }
.text-button, .actions > a { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--ink); font-size: .875rem; text-decoration: none; }
.text-button:hover, .actions > a:hover { background: var(--surface); color: var(--ink); }
.quiet-link { display: inline-flex; gap: 18px; margin-top: 24px; padding: 8px 12px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: var(--radius); background: none; color: var(--ink); }
button:disabled { opacity: .55; cursor: default; }

/* Karten und Verzeichnisse */
.overview-state, .record, .form-section, .next-steps, .empty-state, .invoice-detail, fieldset { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); }
.overview-state { display: block; padding: 28px; }
.overview-state h2 { margin-top: 8px; }
.overview-state p { margin-top: 12px; color: var(--muted); max-width: 55ch; }
.mail-slot { display: none; }
.section-topline { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0 12px; border-bottom: 1px solid var(--line); }
.section-topline h2 { font-family: var(--font); font-size: 1rem; font-weight: 600; }
.next-steps { margin-top: 24px; padding: 12px 24px 4px; }
.step-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 24px; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.step-row:last-child { border-bottom: 0; }
.step-number { font-size: var(--text-small); font-variant-numeric: tabular-nums; color: var(--muted); }
.step-row p { margin-top: 2px; font-size: .875rem; color: var(--muted); }
.step-row:hover h3, .row-arrow { color: var(--accent); }
.row-arrow { font-size: 1.25rem; text-align: right; }
.empty-state { padding: 32px; }
.empty-state h2 { max-width: 25ch; }
.empty-state p { margin-top: 12px; color: var(--muted); max-width: 52ch; }
.page-note { display: flex; gap: 16px; margin-top: 32px; max-width: 65ch; color: var(--muted); font-size: var(--text-small); }
.note-line { flex: 0 0 22px; border-top: 2px solid var(--accent-soft); margin-top: 9px; }
.workspace-footer { padding: 20px 56px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); }
.record { margin-top: 16px; padding: 20px 24px; overflow-wrap: anywhere; }
.record-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.record h2 { font-size: 1.25rem; }
.record p + p { margin-top: 8px; }
.status { font-size: .875rem; color: var(--muted); }
.form-section { margin-top: 24px; padding: 24px; }
.form-section > p { margin-top: 8px; margin-bottom: 20px; color: var(--muted); }
.form-section h2 { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.notice { padding: 16px 20px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--tint); margin-bottom: 24px; white-space: pre-line; }
.notice h2 { font-family: var(--font); font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.error-summary { border-color: var(--accent); }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.actions .button { margin: 0; }
.actions form { margin: 0; }
.inline-form { display: flex; align-items: end; gap: 16px; margin: 16px 0; }
.inline-form .button { margin: 0; }
.invoice-row { display: flex; justify-content: space-between; gap: 24px; margin-top: 12px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.invoice-row:hover { border-color: var(--line-strong); }
.invoice-row p { margin-top: 4px; color: var(--muted); }
.invoice-detail { padding: 24px; }
.invoice-detail > .record-heading, .invoice-detail > h2 { margin-top: 32px; }
.invoice-detail .ledger > div { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.context-copy { white-space: pre-wrap; margin-top: 16px; }
.empty-copy { padding: 16px 0; color: var(--muted); }
.ledger { margin: 16px 0 24px; }
.ledger > div { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.ledger dt { overflow-wrap: anywhere; color: var(--muted); }
.ledger dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats dd { font-size: 1.5rem; font-weight: 500; }
.attention-row { padding: 14px 0; border-bottom: 1px solid var(--line); }

/* Formulare */
label { display: block; font-size: .875rem; font-weight: 500; }
input, select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; margin-top: 6px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--control); border-radius: var(--radius); background-color: var(--card); color: var(--ink); font-weight: 400; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 21px) 50%, calc(100% - 15px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
textarea { resize: vertical; }
input[type=checkbox], input[type=radio] { display: inline-block; width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--ink); }
.checkbox { display: flex; align-items: center; gap: 12px; margin: 24px 0; font-weight: 400; }
.field { min-width: 0; }
.field-error { color: var(--ink); font-size: .875rem; min-height: 1em; padding-top: 4px; }
[aria-invalid=true] { border: 2px solid var(--accent); }
fieldset { margin: 24px 0; padding: 20px; min-width: 0; box-shadow: none; }
legend { padding: 0 8px; font-weight: 600; }
.builder-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 14px; }
.builder-row input, .builder-row select { margin-top: 0; }

/* Tabellen, Details */
.table-scroll { overflow-x: auto; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
caption { text-align: left; color: var(--muted); padding: 12px 16px; }
th, td { text-align: left; vertical-align: top; padding: 14px 16px; border-bottom: 1px solid var(--line); min-width: 145px; overflow-wrap: anywhere; }
th { background: var(--surface); color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
pre { padding: 12px 14px; border-radius: var(--radius); background: var(--surface); font-size: .8125rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
details { margin: 12px 0; }
summary { cursor: pointer; color: var(--accent); padding: 8px 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Anmeldung und Meldungsseiten */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 0 24px; }
.auth-header { display: flex; justify-content: center; padding: 64px 0 32px; }
.auth-header .brand { flex-direction: column; gap: 10px; }
.auth-header .brand-logo { height: 44px; }
.auth-header .brand-product { padding: 0; border: 0; color: var(--muted); font-size: 1rem; }
.auth-main { width: 100%; max-width: 440px; flex: 1; padding-bottom: 48px; }
.auth-card { padding: 32px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .lead { margin-top: 12px; }
.auth-card .button { margin-top: 28px; }
.auth-hint { font-size: var(--text-small); color: var(--muted); margin-top: 16px; text-align: center; }
.auth-card .check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 20px; font-size: .875rem; color: var(--muted); }

.check-list { display: grid; gap: 8px; border: 0; padding: 0; margin: 20px 0 0; }
.check-list legend { font-weight: 500; margin-bottom: 4px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; }

.check-row[hidden], .check-list[hidden] { display: none; }
.choice-list { display: grid; gap: 10px; margin-top: 24px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.choice:hover { background: var(--surface); }
.choice:has(input:checked) { border-color: var(--ink); }
.choice input, .check-row input { flex: none; width: 18px; height: 18px; min-height: 0; padding: 0; margin: 3px 0 0; box-shadow: none; accent-color: var(--ink); }
.choice span { display: grid; gap: 2px; font-weight: 400; }
.choice strong { font-weight: 500; font-size: .9375rem; }
.choice small { color: var(--muted); font-size: .875rem; }
.choice.is-planned { opacity: .6; cursor: default; }
.choice-list .button { margin-top: 18px; }
.auth-aside { margin-top: 28px; text-align: center; }
.auth-aside h2 { font-family: var(--font); font-size: .9375rem; font-weight: 500; }
.auth-aside p { margin: 8px auto 0; color: var(--muted); font-size: .875rem; max-width: 40ch; }
.auth-footer { width: 100%; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-small); text-align: center; }

@media (max-width: 1100px) {
  .app-shell { --sidebar: 220px; }
  .main-content { padding-inline: 32px; }
  .workspace-footer { padding-inline: 32px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar, .workspace-footer { display: none; }
  .mobile-header { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; justify-items: center; height: 60px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--paper); }
  .mobile-header .brand-product { font-size: .875rem; }
  .main-content { padding: 28px 20px calc(96px + env(safe-area-inset-bottom)); }
  .page-heading { margin-bottom: 24px; }
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.375rem; }
  .button, .text-button, .actions > a { min-height: 44px; }
  .overview-state { padding: 20px; }
  .next-steps { padding-inline: 16px; }
  .step-row { gap: 12px; grid-template-columns: 24px minmax(0, 1fr) 20px; }
  .record { padding: 16px; }
  .form-section { padding: 20px 16px; }
  .empty-state { padding: 24px 20px; }
  .form-grid, .builder-row { grid-template-columns: minmax(0, 1fr); }
  .record-heading, .inline-form, .invoice-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .builder-row { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
  fieldset { padding: 16px; }
  .ledger > div { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .invoice-detail { padding: 16px; }
  .invoice-detail .ledger > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .tabbar-wrap { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: block; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--paper); }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tabbar > a, .tab-more summary { flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; padding: 8px 2px; border-radius: 0; color: var(--muted); font-size: .75rem; font-weight: 500; text-align: center; list-style: none; }
  .tab-more { margin: 0; }
  .tab-more summary { color: var(--muted); padding: 8px 2px; cursor: pointer; }
  .tab-more summary::-webkit-details-marker { display: none; }
  .tab-more[open] summary { color: var(--accent); }
  .tabbar > a:hover { background: none; color: var(--ink); }
  .tabbar > a[aria-current="page"] { background: none; color: var(--accent); font-weight: 600; }
  .more-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); max-height: calc(100vh - 160px); overflow-y: auto; }
  .more-sheet a { min-height: 48px; }
  .more-sheet .logout-button { min-height: 48px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin-top: 4px; }
  .auth-header { padding-top: 40px; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, nav a, .text-button, .invoice-row { transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease; }
}

/* ===== Postfach (Auftrag 21b): Ordner | Liste | Lesebereich im selben Rahmen ===== */
.nav-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; margin-left: auto; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums; }
.brand-mark { display: none; border-radius: 8px; }
.app-shell.is-mailbox .workspace { height: 100vh; height: 100dvh; min-height: 0; }
.mailbox-main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--card); }
.mailbox-main:focus { outline: none; }
/* Meldungen schweben über dem Rahmen, damit Liste und Lesebereich nicht springen */
.mail-notices { position: absolute; top: 12px; left: 50%; z-index: 20; display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100% - 32px)); transform: translateX(-50%); pointer-events: none; }
.mail-notice { max-width: none; padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); font-size: .875rem; pointer-events: auto; }
.mail-notice-alert { border-color: var(--wash-line); background: var(--wash); }
.mailbox { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--folder-w) var(--list-w) minmax(0, 1fr); }
.mailbox > * { min-width: 0; min-height: 0; }

/* Ordnerspalte */
.folder-pane { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--paper); }
.compose-button { margin: 0 0 12px; }
.box-address-static { padding: 0 12px 12px; color: var(--muted); font-size: .8125rem; overflow-wrap: anywhere; }
.box-switch { margin: 0 0 8px; }
.box-switch summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--ink); font-size: .8125rem; list-style: none; }
.box-switch summary::-webkit-details-marker { display: none; }
.box-address { overflow-wrap: anywhere; }
.box-switch ul { margin: 4px 0 0; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.box-switch li a { padding: 8px 10px; border-radius: 8px; font-size: .8125rem; overflow-wrap: anywhere; }
.folder-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.folder-link { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius); color: var(--ink); font-size: .9375rem; text-decoration: none; }
.folder-link:hover { background: var(--surface); color: var(--ink); }
.folder-link.is-active { background: var(--surface); font-weight: 600; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.pane-label { max-width: none; margin: 16px 12px 4px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.manage-link { display: flex; align-items: center; min-height: 40px; margin-top: 12px; padding: 8px 12px; border-radius: var(--radius); color: var(--muted); font-size: .8125rem; text-decoration: none; }
.manage-link:hover { background: var(--surface); color: var(--ink); }

/* Nachrichtenliste */
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--card); }
.list-head { display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.list-title h2 { font-family: var(--font); font-size: 1.125rem; font-weight: 600; }
.folder-menu, .icon-tool.compose-mobile { display: none; }
.search-field { position: relative; display: block; }
.search-field .icon { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input { margin: 0; min-height: 40px; padding: 8px 12px 8px 38px; background: var(--paper); }
.list-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-chip { position: relative; display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink); font-size: .8125rem; text-decoration: none; }
.filter-chip::after { content: ""; position: absolute; inset: -4px; }
.filter-chip:hover { background: var(--surface); color: var(--ink); }
.filter-chip.is-on { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }
.filter-chip.is-on:hover { background: var(--ink-hover); color: var(--on-ink); }
.list-count { margin-left: auto; color: var(--muted); font-size: .8125rem; }
.mail-list:focus { outline: none; }
.mail-list { flex: 1; min-height: 0; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.mail-item { position: relative; display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 0 8px; min-height: 72px; padding: 12px 16px 12px 10px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.mail-item:hover { background: var(--tint); color: var(--ink); }
.mail-item.is-active { background: var(--surface); }
.mail-item.is-active::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--accent); }
.mail-item:focus-visible { outline-offset: -3px; }
.mi-dot { align-self: start; justify-self: center; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; }
.is-unread .mi-dot { background: var(--accent); }
.mi-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mi-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mi-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9375rem; }
.mi-date { flex: none; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.mi-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .875rem; }
.is-unread .mi-from, .is-unread .mi-subject { color: var(--ink); font-weight: 600; }
.mi-meta { display: flex; gap: 8px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; }
.pager .text-button { min-height: 40px; }
.list-empty { padding: 40px 24px; }
.list-empty h3 { font-size: 1rem; }
.list-empty p { margin-top: 8px; color: var(--muted); font-size: .875rem; }

/* Lesebereich */
.reader-pane { display: flex; flex-direction: column; background: var(--card); container-type: inline-size; }
.reader, .compose, .manage { display: flex; flex: 1; flex-direction: column; min-height: 0; margin: 0; }
.reader-scroll, .compose-scroll, .manage-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.reader-scroll { display: flex; flex-direction: column; gap: 20px; padding: 24px 32px 32px; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.tool-group { display: flex; align-items: center; gap: 4px; }
.tool-group-end { margin-left: auto; }
.tool-form { margin: 0; }
.tool { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--ink); font-size: .875rem; font-weight: 500; line-height: 1.3; list-style: none; text-decoration: none; }
.tool::-webkit-details-marker { display: none; }
.tool:hover { background: var(--surface); color: var(--ink); }
.tool-primary { border-color: var(--line-strong); }
.menu { position: relative; margin: 0; }
.menu > summary { padding: 8px 12px; color: var(--ink); }
.menu-sheet { position: absolute; top: calc(100% + 4px); right: 0; z-index: 6; min-width: 230px; max-height: 60vh; overflow-y: auto; padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius-card); background: var(--card); box-shadow: var(--shadow); }
.menu-form, .menu-confirm, form.menu-sheet { margin: 0; }
.menu-title { max-width: none; padding: 6px 10px; color: var(--muted); font-size: .75rem; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font-size: .875rem; text-align: left; text-decoration: none; }
.menu-item:hover { background: var(--surface); color: var(--ink); }
.menu-danger { color: var(--accent); }
.menu-confirm { padding-top: 4px; border-top: 1px solid var(--line); }
.check-line { display: flex; align-items: center; gap: 12px; padding: 8px 10px; font-weight: 400; }
.only-narrow, .back-link { display: none; }
.back-link { align-items: center; gap: 4px; width: fit-content; min-height: 40px; margin: -8px 0 8px -8px; padding: 8px 12px 8px 8px; border-radius: var(--radius); color: var(--ink); font-size: .875rem; text-decoration: none; }
.back-link:hover { background: var(--surface); color: var(--ink); }
.reader-head h2:focus, .compose-head h2:focus, .manage h2:focus { outline: none; }
.reader-head h2 { max-width: none; font-size: 1.625rem; overflow-wrap: anywhere; }
.sender-line { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.sender-initial { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--muted); font-weight: 600; }
.sender-text p { max-width: none; overflow-wrap: anywhere; }
.sender-address { color: var(--muted); font-size: .875rem; }
.sender-date { color: var(--muted); font-size: .8125rem; }
.recipients { margin: 4px 0 0; }
.recipients summary { display: flex; align-items: center; min-height: 40px; color: var(--muted); font-size: .8125rem; }
.recipients p { max-width: none; overflow-wrap: anywhere; font-size: .875rem; }
.bk-bar { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border: 1px solid var(--wash-line); border-radius: var(--radius-card); background: var(--wash); }
.bk-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.bk-title { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: .8125rem; font-weight: 600; }
.bk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bk-actions form { margin: 0; }
.bk-button { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 12px; border: 1px solid var(--wash-line); border-radius: var(--radius); background: var(--card); color: var(--ink); font-size: .8125rem; font-weight: 500; text-decoration: none; }
.bk-button:hover { border-color: var(--accent-soft); background: var(--surface); color: var(--ink); }
.bk-button[disabled] { color: var(--muted); cursor: not-allowed; opacity: .7; }
.bk-button[disabled]:hover { border-color: var(--wash-line); background: var(--card); color: var(--muted); }
.bk-note, .bk-wait { max-width: none; color: var(--muted); font-size: .8125rem; }
.bk-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; max-width: none; color: var(--muted); font-size: .8125rem; }
.bk-status a { display: inline-flex; align-items: center; min-height: 32px; }
.chip { display: inline-flex; align-items: center; padding: 2px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); color: var(--ink); font-size: .75rem; font-weight: 600; }
.chip-warn { border-color: var(--accent); color: var(--accent); }
.chip-ok { background: var(--surface); }
.reader-body { display: flex; flex-direction: column; gap: 8px; }
.mail-frame { display: block; width: 100%; height: max(480px, 62vh); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color-scheme: light; }
.mail-text { max-width: 70ch; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.6; }
.image-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: 0; color: var(--muted); font-size: .8125rem; }
.link-button { position: relative; min-height: 32px; padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; text-decoration: underline; text-underline-offset: .25em; }
.link-button::after { content: ""; position: absolute; inset: -4px -6px; }
.link-button:hover { color: var(--accent-hover); }
.image-privacy { flex-basis: 100%; font-size: .75rem; }
.attachments h3 { color: var(--muted); font-size: .8125rem; }
.attach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.attach-tile { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; }
.attach-tile:hover { background: var(--surface); color: var(--ink); }
.attach-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
/* Fremde Namen dürfen die Leserichtung ihrer Umgebung nicht umdrehen. */
bdi { unicode-bidi: isolate; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 500; }
.attach-size { color: var(--muted); font-size: .75rem; }
.attach-get { color: var(--muted); }
.reader-empty, .mailbox-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 24px; text-align: center; }
.mailbox-state { max-width: 480px; margin: auto; }
.reader-empty p, .mailbox-state p { margin: 0 auto; color: var(--muted); font-size: .9375rem; }
.mailbox-state .button { margin-top: 12px; }
.state-mark { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--surface); color: var(--muted); }
.keys-hint { font-size: .8125rem; }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; font-size: .75rem; }

/* Editor und Ordnerverwaltung */
.compose-head { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.compose-head h2 { font-family: var(--font); font-size: 1.125rem; font-weight: 600; }
.compose-head .back-link { display: inline-flex; margin: 0; }
.compose-scroll { padding: 8px 24px 24px; }
.compose-scroll .notice { margin: 12px 0; }
.compose-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--line); }
.compose-row label, .compose-label { color: var(--muted); font-size: .875rem; font-weight: 500; }
.compose-row input, .compose-row select { min-height: 48px; margin: 0; padding-inline: 0; border: 0; border-radius: 0; background-color: transparent; }
.compose-row select { padding-right: 24px; background-position: calc(100% - 10px) 50%, calc(100% - 4px) 50%; }
.compose-static { padding: 12px 0; overflow-wrap: anywhere; }
.compose-hint { max-width: none; padding-top: 6px; color: var(--muted); font-size: .75rem; }
.cc-toggle { margin: 0; }
.cc-toggle summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0; color: var(--muted); font-size: .8125rem; list-style: none; }
.cc-toggle summary::-webkit-details-marker { display: none; }
.cc-toggle summary::after { content: ""; width: 6px; height: 6px; margin-top: -3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.cc-toggle[open] summary::after { margin-top: 3px; transform: rotate(-135deg); }
.compose-text { display: block; width: calc(100% + 24px); max-width: calc(80ch + 24px); min-height: 320px; margin: 12px -12px 0; padding: 8px 12px; border: 0; border-radius: 0; background: transparent; line-height: 1.6; }
.compose-attached ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: .875rem; }
.compose-attached li { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.compose-attached, .compose-files { margin-top: 16px; }
.compose-files input { min-height: 0; padding: 10px; border-style: dashed; }
.compose-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 24px; border-top: 1px solid var(--line); background: var(--card); }
.compose-actions .button { margin: 0; }
.manage-scroll { display: flex; flex-direction: column; gap: 16px; max-width: 680px; padding: 24px; }
.manage-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); }
.manage-card h3 { margin-bottom: 4px; }
.manage-form { display: grid; gap: 12px; margin: 12px 0 0; }
.manage-form .button { justify-self: start; margin: 0; }
.manage-form .check-line { padding: 0; }

/* Enge Container: seltene Aktionen wandern in „Mehr“, Beschriftungen entfallen */
@container (max-width: 760px) {
  .tool-wide .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tool-wide { padding: 8px 10px; }
  .reader-scroll { padding: 20px 20px 28px; }
}
@container (max-width: 520px) {
  .tool-wide { display: none; }
  .only-narrow { display: flex; }
  .tool-compact .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tool-compact { padding: 8px 10px; }
}
@media (min-width: 761px) {
  .tool-compact .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .tool-compact { padding: 8px 10px; }
}

/* Mittlere Breiten bis 1359 px: Hauptnavigation als schmale Leiste, damit der Lesebereich Platz behält */
@media (min-width: 761px) and (max-width: 1359px) {
  .app-shell.is-mailbox { --sidebar: 68px; --folder-w: 208px; --list-w: 320px; }
  .is-mailbox .sidebar-brand { justify-content: center; padding: 0; }
  .is-mailbox .sidebar-brand .brand { display: none; }
  .is-mailbox .brand-mark { display: block; }
  .is-mailbox .desktop-navigation { align-items: center; padding: 12px 8px; }
  .is-mailbox .desktop-navigation a { position: relative; justify-content: center; width: 48px; padding: 8px; }
  .is-mailbox .desktop-navigation .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .is-mailbox .desktop-navigation .nav-count { position: absolute; top: 0; right: 0; min-width: 18px; margin: 0; padding: 0 5px; font-size: .6875rem; }
  .is-mailbox .account-line, .is-mailbox .switch-link { display: none; }
  .is-mailbox .logout-button { justify-content: center; padding: 8px; font-size: 0; }
}
/* Bis 1099 px: keine eigene Ordnerspalte, die Ordner stecken in einer Auswahl über der Liste */
@media (max-width: 1099px) {
  .mailbox { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  .folder-pane { display: none; }
  .folder-menu { display: block; margin: 0; }
  .folder-menu summary { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--ink); font-size: .875rem; list-style: none; }
  .folder-menu summary::-webkit-details-marker { display: none; }
  .folder-menu .menu-sheet { left: 16px; right: auto; width: 260px; }
  .list-title { justify-content: flex-start; }
  .list-title h2 { margin-right: auto; }
  .icon-tool.compose-mobile { display: inline-flex; }
}
.icon-tool { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius); color: var(--ink); }
.icon-tool:hover { background: var(--surface); color: var(--ink); }
.list-title { position: relative; }

/* Mobil: Liste und Nachricht nacheinander, Aktionen als feste Leiste über der Tab-Leiste */
@media (max-width: 760px) {
  .nav-count { position: absolute; top: 4px; left: calc(50% + 4px); min-width: 18px; margin: 0; padding: 0 5px; font-size: .6875rem; }
  .tabbar > a { position: relative; }
  .app-shell.is-mailbox .workspace { height: auto; min-height: 100vh; }
  .mailbox-main { padding-bottom: calc(61px + env(safe-area-inset-bottom)); }
  .mailbox { display: block; }
  .mailbox.has-detail .list-pane, .mailbox:not(.has-detail) .reader-pane { display: none; }
  .reader-pane { container-type: normal; }
  .list-pane { border-right: 0; }
  .list-head { padding-inline: 16px; }
  .folder-menu .menu-sheet { position: fixed; top: auto; right: 8px; bottom: calc(69px + env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: 70vh; }
  .back-link { display: inline-flex; }
  .reader-scroll { overflow: visible; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .reader-head h2 { font-size: 1.375rem; }
  .toolbar { position: fixed; right: 0; bottom: calc(61px + env(safe-area-inset-bottom)); left: 0; z-index: 15; justify-content: space-around; padding: 4px 8px; border-top: 1px solid var(--line); border-bottom: 0; background: var(--paper); }
  .tool-group, .tool-group-end { display: contents; }
  .tool-wide { display: none; }
  .only-narrow { display: flex; }
  .tool, .menu > summary { flex-direction: column; gap: 2px; min-width: 56px; min-height: 56px; padding: 6px 4px; font-size: .6875rem; }
  .tool-primary { border-color: transparent; }
  .menu { position: static; }
  .menu-sheet { position: fixed; top: auto; right: 8px; bottom: calc(129px + env(safe-area-inset-bottom)); left: 8px; max-height: 60vh; }
  .menu-item { min-height: 48px; }
  .compose, .manage { display: block; }
  .compose-scroll { overflow: visible; padding: 8px 16px 24px; }
  .compose-head { padding-inline: 8px; }
  .compose-row { grid-template-columns: 72px minmax(0, 1fr); }
  .compose-actions { bottom: calc(61px + env(safe-area-inset-bottom)); z-index: 5; padding: 10px 16px; }
  .manage-scroll { padding: 16px; }
  .mail-frame { height: max(420px, 60vh); }
}
@media (prefers-reduced-motion: no-preference) {
  .mail-item, .folder-link, .tool, .menu-item, .bk-button, .filter-chip, .attach-tile { transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease; }
}
