/* TTH Mail – "Leitstelle": Nebelblau, Marine-Tinte, ein Signalgelb */
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("/fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("/fonts/schibsted-grotesk-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --fog: #e9eef3;
  --paper: #ffffff;
  --paper-2: #f3f6f9;
  --rule: #d3dbe4;
  --ink: #13243a;
  --slate: #5a6b80;
  --signal: #ffc21a;
  --signal-ink: #13243a;
  --signal-wash: #fff4d1;
  --action: #1d5fc4;
  --select: #e3ebf5;
  --danger: #b3261e;
  --ok: #1f8a4c;
  --lift: 0 18px 40px -12px rgba(19, 36, 58, .35), 0 2px 6px rgba(19, 36, 58, .08);
  --font: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --fog: #0d1726;
  --paper: #132238;
  --paper-2: #182a43;
  --rule: #24364f;
  --ink: #e4ebf4;
  --slate: #8fa1b8;
  --signal: #ffc21a;
  --signal-ink: #13243a;
  --signal-wash: #2e2a18;
  --action: #7fb0ff;
  --select: #1d3352;
  --danger: #ff8a80;
  --ok: #5fd08f;
  --lift: 0 18px 40px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--fog); color: var(--ink); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--action); }
code { background: var(--paper-2); border: 1px solid var(--rule); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--slate); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 1px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Schaltflächen & Felder */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); border-radius: 6px;
  padding: 7px 13px; cursor: pointer; background: var(--paper); font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--paper-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink); opacity: .9; }
:root[data-theme="dark"] .btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer; color: var(--slate); }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.active { color: var(--ink); }
.icon-btn.active svg { fill: var(--signal); stroke: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.link-btn { border: 0; background: none; color: var(--action); cursor: pointer; padding: 2px 0; font-size: 13px; align-self: flex-start; }
.chip { border: 1px solid var(--rule); background: transparent; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); font-weight: 650; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--slate); font-weight: 500; }
.field input, .field select, .select-sm {
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); padding: 9px 11px; color: var(--ink); font-size: 14px; font-weight: 400; }
.field input:focus, .field select:focus { outline: 3px solid var(--signal); outline-offset: -1px; border-color: transparent; }
.select-sm { padding: 6px 8px; font-size: 13px; max-width: 170px; }
.form-error { color: var(--danger); margin: 0; font-size: 13px; font-weight: 500; }

/* ---------- Marke */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; font-size: 17px; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; flex: none;
  background: var(--signal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 7l8 5.5L20 7M4 6.5h16v11H4z' fill='none' stroke='%2313243a' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") center / 68% no-repeat; }
.brand-lg { font-size: 24px; }
.brand-lg .brand-mark { width: 36px; height: 36px; border-radius: 8px; }

/* ---------- Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--paper); border: 1px solid var(--rule); border-top: 6px solid var(--signal);
  border-radius: 10px; padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 16px; }
.login-card p { margin: 0; }
.login-foot { text-align: center; font-size: 12px; }
.login-foot a { color: var(--slate); }

/* ---------- App-Gerüst */
.app > *, .mail > * { min-width: 0; }
.app { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 60px 1fr; height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 14px 0 18px; }
.topbar .brand { width: 198px; }
.search { flex: 1; max-width: 620px; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--paper);
  border: 1px solid var(--rule); border-radius: 8px; padding: 0 12px; color: var(--slate); }
.search:focus-within { outline: 3px solid var(--signal); outline-offset: -1px; border-color: transparent; }
.search input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; padding: 9px 0; outline: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.user-btn:hover { background: var(--paper); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700;
  font-size: 12px; color: #fff; background: var(--ink); flex: none; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.menu { position: absolute; right: 0; top: 44px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: var(--lift); padding: 5px; min-width: 160px; z-index: 30; }
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; cursor: pointer; }
.menu button:hover { background: var(--paper-2); }

/* ---------- Seitenleiste */
.sidebar { padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.btn-compose { background: var(--signal); border: 0; color: var(--signal-ink); border-radius: 8px; padding: 12px 16px;
  font-weight: 750; font-size: 15px; justify-content: flex-start; gap: 10px; }
.btn-compose:hover { background: var(--signal); filter: brightness(1.04); }
.btn-compose svg { stroke-width: 2.4; }
.folders { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 6px; border: 0;
  background: none; cursor: pointer; text-align: left; width: 100%; color: var(--ink); }
.nav-item svg { color: var(--slate); }
.nav-item:hover { background: var(--paper); }
.nav-item.active { background: var(--paper); font-weight: 700; box-shadow: inset 3px 0 0 var(--signal); }
.nav-item.active svg { color: var(--ink); }
.nav-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 12px; font-weight: 750; background: var(--signal); color: var(--signal-ink);
  border-radius: 999px; padding: 0 7px; line-height: 19px; font-variant-numeric: tabular-nums; }
.nav-item.sub { padding-left: 30px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--rule); padding-top: 10px; }

/* ---------- Postfach */
.mail { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; min-height: 0; background: var(--paper);
  border-top-left-radius: 12px; border: 1px solid var(--rule); border-right: 0; border-bottom: 0; overflow: hidden; }
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--rule); min-height: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 12px 18px; border-bottom: 1px solid var(--rule); }
.list-head h1 { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.message-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.msg { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; padding: 11px 16px 12px 20px; cursor: pointer;
  border-bottom: 1px solid var(--rule); position: relative; }
.msg:hover { background: var(--paper-2); }
.msg.selected { background: var(--select); }
.msg.unread::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; background: var(--signal); border-radius: 0 3px 3px 0; }
.msg .from { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .date { font-size: 12px; color: var(--slate); white-space: nowrap; }
.msg .subject { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .preview { grid-column: 1 / -1; color: var(--slate); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .from, .msg.unread .subject { font-weight: 750; }
.msg .badges { display: inline-flex; gap: 4px; margin-left: 6px; color: var(--slate); vertical-align: -3px; }
.msg .badges svg { width: 14px; height: 14px; }
.msg .badges .flag { fill: var(--signal); stroke: var(--ink); }
.list-foot { padding: 9px 18px; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--slate); }
.empty-state { padding: 48px 24px; text-align: center; color: var(--slate); }

/* ---------- Leseansicht */
.reader { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.reader-empty { margin: auto; text-align: center; color: var(--slate); }
.reader-empty svg { width: 44px; height: 44px; stroke-width: 1.3; }
.reader-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.reader-toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.reader-head { padding: 20px 26px 8px; }
.reader-head h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; line-height: 1.2; letter-spacing: -.02em; word-break: break-word; max-width: 60ch; }
.r-meta { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.r-who { flex: 1; min-width: 0; word-break: break-word; }
.r-who strong { font-weight: 700; }
.notice { margin: 6px 26px; padding: 8px 12px; background: var(--signal-wash); border-left: 4px solid var(--signal); border-radius: 0 6px 6px 0;
  display: flex; align-items: center; gap: 12px; justify-content: space-between; font-size: 13px; }
.r-frame { flex: 1; width: calc(100% - 36px); margin: 8px 18px 14px; border: 1px solid var(--rule); border-radius: 8px;
  background: #fff; min-height: 240px; }
.r-frame.plain-dark { background: #132238; }
.attachments { list-style: none; margin: 0; padding: 0 26px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments:empty { display: none; }
.att { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); border-radius: 6px;
  padding: 6px 10px; background: var(--paper); max-width: 280px; text-decoration: none; color: var(--ink); font-size: 13px; }
.att:hover { background: var(--paper-2); }
.att .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att .att-x { border: 0; background: none; cursor: pointer; color: var(--slate); padding: 0 2px; font-size: 16px; line-height: 1; }

/* ---------- Schreiben */
.compose { position: fixed; right: 24px; bottom: 0; width: min(560px, calc(100vw - 24px)); height: min(620px, calc(100vh - 80px));
  background: var(--paper); border: 1px solid var(--rule); border-radius: 10px 10px 0 0; box-shadow: var(--lift);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden; }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 18px;
  background: var(--ink); color: var(--paper); }
:root[data-theme="dark"] .compose-head { background: var(--paper-2); color: var(--ink); }
.compose-head .icon-btn { color: inherit; }
.compose-head .icon-btn:hover { background: rgba(255, 255, 255, .12); color: inherit; }
.compose-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 4px 18px 14px; gap: 2px; }
.c-row, .c-extra label { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--rule); }
.c-row:focus-within, .c-extra label:focus-within { border-bottom-color: var(--signal); box-shadow: 0 1px 0 var(--signal); }
.c-extra { flex-direction: column; align-items: stretch; border: 0; gap: 2px; }
.c-row span, .c-extra span { color: var(--slate); width: 56px; font-size: 13px; font-weight: 500; }
.c-row input, .c-extra input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 0; outline: none; }
.c-text { flex: 1; border: 0; background: transparent; resize: none; padding: 12px 0; outline: none; line-height: 1.6; min-height: 120px; }
.compose-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid var(--rule); }
.compose-foot .btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); font-weight: 750; padding: 8px 20px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attachments-edit { padding: 4px 0 8px; }

/* ---------- Verwaltung */
.admin { overflow-y: auto; background: var(--paper); border-top-left-radius: 12px; border: 1px solid var(--rule); border-right: 0; border-bottom: 0; }
.admin-inner { max-width: 980px; padding: 24px 30px 56px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-head h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.section-title { font-size: 17px; font-weight: 750; letter-spacing: -.01em; margin: 32px 0 12px; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.status { padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; border-right: 1px solid var(--rule); background: var(--paper); }
.status:last-child { border-right: 0; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--slate); }
.status.ok .dot { background: var(--ok); }
.status.bad { background: color-mix(in srgb, var(--danger) 8%, var(--paper)); }
.status.bad .dot { background: var(--danger); }
.status strong { display: block; font-weight: 700; }
.status .muted { display: block; font-variant-numeric: tabular-nums; }
.hint { margin: 10px 0 0; }
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 18px; }
.field-wide { grid-column: 1 / -1; }
.pw-row { display: flex; gap: 6px; }
.pw-row input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table th { font-size: 12.5px; color: var(--slate); font-weight: 600; background: var(--paper-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.num { font-variant-numeric: tabular-nums; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--rule); color: var(--slate); }

/* ---------- Meldung */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 18px 10px 16px; border-left: 5px solid var(--signal); border-radius: 6px; box-shadow: var(--lift); z-index: 60;
  font-weight: 600; max-width: 90vw; }
.toast.error { border-left-color: var(--danger); }

/* ---------- Mobil */
.only-mobile { display: none; }
@media (max-width: 900px) {
  .mail { grid-template-columns: 1fr; }
  .mail.reading .list-pane { display: none; }
  .mail:not(.reading) .reader { display: none; }
  .only-mobile { display: inline-grid; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .topbar { gap: 8px; padding: 0 8px; }
  .topbar .brand { width: auto; }
  .topbar .brand span:last-child, .hide-mobile { display: none; }
  .sidebar { position: fixed; top: 60px; bottom: 0; left: 0; width: 264px; z-index: 35; background: var(--fog);
    box-shadow: var(--lift); transform: translateX(-105%); transition: transform .18s ease; padding-top: 12px; }
  .sidebar.open { transform: none; }
  .mail, .admin { border-radius: 0; border-left: 0; }
  .compose { right: 0; width: 100vw; height: calc(100dvh - 40px); }
  .form-grid { grid-template-columns: 1fr; }
  .reader-head h2 { font-size: 20px; }
  .admin-inner { padding: 18px 16px 48px; }
  .status { border-right: 0; border-bottom: 1px solid var(--rule); }
  .status:last-child { border-bottom: 0; }
}
