/* Dunkles Navy mit Glaskarten, schlicht gehalten: wenige Farben, viel Luft, klare Hierarchie. Folgt dem Hell-Dunkel-Modus des Systems. */
:root {
  color-scheme: dark light;
  --backdrop:
    radial-gradient(1100px 620px at 85% -10%, rgb(0 113 227 / 28%), transparent 62%),
    radial-gradient(900px 560px at -10% 105%, rgb(88 64 214 / 24%), transparent 60%),
    linear-gradient(160deg, #070b24, #0b1437 58%, #060a20);
  --sidebar: rgb(255 255 255 / 3%);
  --surface: rgb(255 255 255 / 6%);
  --surface-strong: #141c3f;
  --fill: rgb(255 255 255 / 10%);
  --fill-hover: rgb(255 255 255 / 16%);
  --field: rgb(255 255 255 / 7%);
  --line: rgb(255 255 255 / 10%);
  --ink: #f5f5f7;
  --muted: #a7b0cc;
  --accent: #0071e3;
  --accent-hover: #0a7ff0;
  --accent-ink: #ffffff;
  --link: #4aa8ff;
  --tint: rgb(10 132 255 / 18%);
  --tint-ink: #8fc7ff;
  --ok-soft: rgb(48 209 88 / 16%);
  --ok-ink: #5ee283;
  --warn-soft: rgb(255 214 10 / 12%);
  --warn-ink: #ffdf5e;
  --danger-fill: #d70015;
  --danger-hover: #e6001a;
  --danger-soft: rgb(255 69 58 / 16%);
  --danger-ink: #ff8a82;
  --bar: rgb(10 15 42 / 78%);
  --shadow: 0 24px 60px rgb(0 0 0 / 45%);
}

@media (prefers-color-scheme: light) {
  :root {
    --backdrop: linear-gradient(180deg, #f5f5f7, #f5f5f7);
    --sidebar: rgb(255 255 255 / 55%);
    --surface: rgb(255 255 255 / 86%);
    --surface-strong: #ffffff;
    --fill: rgb(0 0 0 / 6%);
    --fill-hover: rgb(0 0 0 / 10%);
    --field: #ffffff;
    --line: rgb(0 0 0 / 9%);
    --ink: #1d1d1f;
    --muted: #65656b;
    --link: #0066cc;
    --tint: rgb(0 113 227 / 11%);
    --tint-ink: #0058b0;
    --ok-soft: rgb(36 138 61 / 12%);
    --ok-ink: #1b7a33;
    --warn-soft: rgb(178 124 0 / 12%);
    --warn-ink: #7c5600;
    --danger-soft: rgb(215 0 21 / 10%);
    --danger-ink: #c20013;
    --bar: rgb(250 250 252 / 84%);
    --shadow: 0 24px 60px rgb(0 0 0 / 18%);
  }
  html { background: #f5f5f7 !important; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: #070b24; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--backdrop) fixed;
  color: var(--ink);
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.022em; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 0.88em; overflow-wrap: anywhere; }
ul { margin: 0; padding: 0; list-style: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Fensterrahmen auf dem Mac: Die Titelleiste liegt über dem Inhalt. */
.titlebar-drag { position: fixed; inset: 0 0 auto; z-index: 40; height: 28px; -webkit-app-region: drag; }
.mac-app .sidebar { padding-top: 44px; }
.mac-app .topbar { padding-top: 40px; }

/* Rahmen */
.layout { display: grid; grid-template-columns: clamp(216px, 14vw, 280px) minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 22px; height: 100dvh; padding: 22px 14px 18px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; padding: 0 8px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--ink); background: var(--fill); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--tint); }
.nav a[aria-current="page"] .icon { color: var(--tint-ink); }
.icon { flex: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.account { display: grid; gap: 4px; padding: 12px 10px 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.account-name { overflow: hidden; color: var(--ink); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account button { justify-self: start; }
.content { width: 100%; padding: clamp(24px, 2.6vw, 48px) clamp(24px, 3vw, 64px) 64px; }
.topbar { padding: 22px 26px 0; }
.page-notices:not(:empty) { padding: 16px 26px 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.page-head p { margin-top: 6px; max-width: 72ch; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.head-actions label.field { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.head-actions select { width: auto; }
.stack { display: grid; gap: 16px; }
.stack-tight { display: grid; gap: 6px; justify-items: start; }
/* Nutzt breite Fenster: Abschnitte stehen nebeneinander, sobald jeder genug Platz hat. */
.columns { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); align-items: start; }
.columns > .notice { grid-column: 1 / -1; }
.card { padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: saturate(160%) blur(24px); -webkit-backdrop-filter: saturate(160%) blur(24px); }
.card > h2 + p, .card > h3 + p { margin-top: 6px; }

/* Hinweisleisten */
.demo-strip, .live-strip, .paused-strip { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 18px; padding: 10px 14px; border-radius: 12px; font-size: 13px; }
.demo-strip { background: var(--tint); color: var(--tint-ink); }
.demo-strip a { color: inherit; font-weight: 600; text-decoration: underline; }
.live-strip { background: var(--warn-soft); color: var(--warn-ink); }
.paused-strip { background: var(--danger-soft); color: var(--danger-ink); font-weight: 600; }

/* Kennzahlen */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 1vw, 16px); margin-bottom: 18px; }
.tile { display: grid; gap: 2px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: saturate(160%) blur(24px); -webkit-backdrop-filter: saturate(160%) blur(24px); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Bedienelemente */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 16px; font: inherit; font-size: 14px; font-weight: 500; color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 980px; cursor: pointer; text-decoration: none; }
button:hover:not(:disabled), .button:hover { background: var(--accent-hover); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { color: var(--ink); background: var(--fill); }
button.secondary:hover:not(:disabled) { background: var(--fill-hover); }
button.danger { color: var(--danger-ink); background: var(--danger-soft); }
button.danger:hover:not(:disabled) { color: var(--danger-ink); background: var(--danger-soft); filter: brightness(1.15); }
button.destructive { color: #ffffff; background: var(--danger-fill); }
button.destructive:hover:not(:disabled) { background: var(--danger-hover); }
button.link { min-height: 0; padding: 0; color: var(--link); background: none; font-size: inherit; font-weight: 400; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
label.field { display: grid; gap: 5px; font-size: 13px; font-weight: 500; }
input[type="text"], input[type="search"], select, textarea { width: 100%; min-height: 38px; padding: 8px 12px; font: inherit; font-weight: 400; color: inherit; background: var(--field); border: 1px solid var(--line); border-radius: 10px; }
select option { color: #1d1d1f; background: #ffffff; }
.inline-field { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-field input { width: 180px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; font-weight: 400; }
.choice input { margin-top: 5px; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
fieldset { margin: 0; padding: 0; border: 0; }
fieldset.card { padding: 20px 22px; border: 1px solid var(--line); }
legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; font-weight: 600; font-size: 15px; }
legend + * { clear: both; }

/* Hinweise */
.notice { padding: 11px 14px; border-radius: 12px; background: var(--fill); font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
.notice.error { background: var(--danger-soft); color: var(--danger-ink); }
.notice.ok { background: var(--ok-soft); color: var(--ok-ink); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; max-width: min(520px, calc(100vw - 32px)); padding: 11px 18px; background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); border-radius: 980px; transform: translateX(-50%); font-size: 14px; box-shadow: var(--shadow); }

/* Anmeldung */
.auth { min-height: calc(100dvh - 90px); padding: clamp(28px, 4vw, 72px) clamp(24px, 6vw, 120px); display: grid; gap: clamp(32px, 6vw, 112px); grid-template-columns: minmax(0, 1.2fr) minmax(360px, 1fr); align-items: center; }
.auth h1 { font-size: clamp(36px, 4vw, 68px); letter-spacing: -0.03em; line-height: 1.06; }
.auth .lead { margin-top: 14px; font-size: clamp(18px, 1.4vw, 24px); color: var(--muted); max-width: 40ch; }
.facts { display: grid; gap: 16px; margin-top: 30px; }
.facts strong { display: block; font-weight: 600; }
.facts span { color: var(--muted); }
.auth-forms { display: grid; gap: 14px; }

/* Gesendet */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; backdrop-filter: saturate(160%) blur(24px); -webkit-backdrop-filter: saturate(160%) blur(24px); }
.mail-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main side" "people side"; gap: 8px 20px; align-items: center; padding: 16px 20px; border-top: 1px solid var(--line); }
.mail-main { grid-area: main; min-width: 0; }
.mail-row .recipients { grid-area: people; margin-top: 0; }
.mail-side { grid-area: side; }
.mail-row:first-child { border-top: 0; }
.mail-row h3 { overflow-wrap: anywhere; }
.mail-side { display: grid; gap: 6px; justify-items: end; text-align: right; }
.recipients { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 10px; border-radius: 980px; font-size: 12px; overflow-wrap: anywhere; background: var(--fill); color: var(--muted); }
.chip::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.chip.ready { background: var(--ok-soft); color: var(--ok-ink); }
.chip.ready::before { opacity: 1; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 980px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge.no { background: var(--danger-soft); color: var(--danger-ink); }
.badge.wait { background: var(--warn-soft); color: var(--warn-ink); }

/* Dialog */
dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 24px; color: var(--ink); background: var(--surface-strong); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(2 4 16 / 52%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h2 { font-size: 19px; overflow-wrap: anywhere; }
dialog .stack { margin-top: 14px; }
dialog .actions { justify-content: flex-end; }
.check-list { display: grid; gap: 8px; }
.result-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.result-row:first-child { border-top: 0; }
.bullets { display: grid; gap: 4px; padding-left: 18px; list-style: disc; font-size: 14px; }

/* Protokoll und Listen */
.log-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 4px 14px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; }
.log-row:first-child { border-top: 0; }
.simple-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding: 11px 0; border-top: 1px solid var(--line); }
.simple-row:first-child { border-top: 0; }
.provider-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 20px; padding: 13px 0; border-top: 1px solid var(--line); }
.provider-row:first-of-type { margin-top: 10px; }
.role-text { display: grid; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.card > h2 + .simple-row, .card > p + .simple-row { margin-top: 10px; }
.plan-option { display: grid; gap: 2px; min-height: 0; padding: 14px 16px; text-align: left; color: var(--ink); background: var(--fill); border-radius: 14px; font-weight: 400; justify-content: start; justify-items: start; }
.plan-option:hover:not(:disabled) { color: var(--ink); background: var(--fill-hover); }
.plan-option[aria-pressed="true"] { background: var(--tint); box-shadow: inset 0 0 0 1.5px var(--link); }
.plan-option[aria-pressed="true"]:hover:not(:disabled) { background: var(--tint); }
.plan-option strong { font-size: 15px; font-weight: 600; }
.plan-option span { font-size: 13px; }
.empty { padding: 40px 24px; text-align: center; justify-items: center; }
.empty p { max-width: 56ch; }
.empty .actions { justify-content: center; margin-top: 6px; }
.loading { padding: 24px 0; color: var(--muted); }

/* Breite Fenster: Betreff, Empfänger und Knopf stehen in einer Zeile. */
@media (min-width: 1180px) {
  .rules-form { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(32px, 4vw, 72px); align-items: start; }
  .rules-form fieldset { grid-row: span 4; }
  .mail-row { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; grid-template-areas: "main people side"; }
}

/* Schmale Fenster und Handys: Die Navigation wandert nach unten, wie bei einer Tab-Leiste. */
@media (max-width: 820px) {
  .layout { display: block; }
  .sidebar { position: static; flex-direction: row; align-items: center; justify-content: space-between; height: auto; padding: 12px 16px; background: none; border-right: 0; }
  .mac-app .sidebar { padding-top: 36px; }
  .nav { position: fixed; inset: auto 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--bar); border-top: 1px solid var(--line); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); }
  .nav a { flex-direction: column; gap: 2px; padding: 4px 0; font-size: 11px; }
  .nav a[aria-current="page"], .nav a:hover { color: var(--tint-ink); background: none; }
  .icon { width: 23px; height: 23px; }
  .account { display: flex; align-items: center; gap: 10px; padding: 0; border-top: 0; }
  .account-name { max-width: 120px; }
  .content { padding: 8px 16px 96px; }
  .toast { bottom: 84px; border-radius: 16px; }
  h1 { font-size: 26px; }
  .auth { grid-template-columns: minmax(0, 1fr); min-height: 0; padding: 28px 16px 48px; gap: 24px; align-items: start; }
  .auth h1 { font-size: 32px; }
  .topbar { padding: 16px 16px 0; }
  .page-notices:not(:empty) { padding: 12px 16px 0; }
  .tiles { gap: 8px; }
  .tile { padding: 12px; border-radius: 14px; }
  .tile-label { font-size: 12px; }
  .tile-value { font-size: 22px; }
  .mail-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "people" "side"; }
  .provider-row { grid-template-columns: minmax(0, 1fr); }
  .mail-side { justify-items: start; text-align: left; }
  .log-row { grid-template-columns: minmax(0, 1fr); }
  .plan-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-transparency: reduce) {
  .card, .tile, .group, .nav { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
