/*
 * App „IDO Mail“ fürs Handy (installierbar vom Browser, ohne Store). Aufbau und Farben wie Outlook für iOS/Android:
 * Ordner links ausklappbar, Mailliste mit Wischgesten, runder Knopf „Neue E-Mail“, unten die Bereiche.
 * Ab 900 px Breite Liste und Lesebereich nebeneinander.
 */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #ebebeb;
  --line: #e0e0e0;
  --text: #242424;
  --muted: #616161;
  --subtle: #6b6b6b;
  --input-border: #8a8a8a;
  --brand: #0f6cbd;
  --brand-strong: #115ea3;
  --brand-soft: #ebf3fc;
  --on-brand: #ffffff;
  --unread: #0f6cbd;
  --flag: #c4314b;
  --danger: #c50f1f;
  --on-danger: #ffffff;
  --swipe-del: #d13438;
  --swipe-flag: #ca5010;
  --shadow: 0 2px 6px rgba(0, 0, 0, .14), 0 8px 24px rgba(0, 0, 0, .12);
  --backdrop: rgba(0, 0, 0, .4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 52px;
  --tab-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Dunkel: wie das Gerät oder fest gewählt (Mehr → Darstellung) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1b1f;
    --bg-2: #242428;
    --bg-3: #2e2e33;
    --line: #38383e;
    --text: #f2f2f2;
    --muted: #adadad;
    --subtle: #8f8f8f;
    --brand: #479ef5;
    --brand-strong: #62abf5;
    --brand-soft: #1e2a3a;
    --on-brand: #0b1a2b;
    --unread: #62abf5;
    --flag: #f1707b;
    --danger: #f1707b;
    --on-danger: #2b0d10;
    --input-border: #74747c;
    --backdrop: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1f;
  --bg-2: #242428;
  --bg-3: #2e2e33;
  --line: #38383e;
  --text: #f2f2f2;
  --muted: #adadad;
  --subtle: #8f8f8f;
  --brand: #479ef5;
  --brand-strong: #62abf5;
  --brand-soft: #1e2a3a;
  --on-brand: #0b1a2b;
  --unread: #62abf5;
  --flag: #f1707b;
  --danger: #f1707b;
  --on-danger: #2b0d10;
  --input-border: #74747c;
  --backdrop: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Keine Scrollbalken auf dem Handy (Wischen reicht wie in nativen Apps); am PC mit Maus bleiben sie */
@media (pointer: coarse) {
  * { scrollbar-width: none; }
  *::-webkit-scrollbar { display: none; width: 0; height: 0; }
}
[hidden] { display: none !important; }
html, body { height: var(--app-h, 100%); }
body { margin: 0; font: 15px/1.4 var(--font); color: var(--text); background: var(--bg); overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
/* 16 px: sonst vergrößert Safari auf dem iPhone die Seite beim Tippen und sie bleibt abgeschnitten */
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); margin: 8px 0; font-size: 14px; }
.error:empty { display: none; }
/* sichtbarer Fokus für Tastatur und Schaltersteuerung */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Knöpfe */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.link-btn { color: var(--brand); font-weight: 600; padding: 8px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--text); }
.icon-btn:active, .avatar-btn:active { background: var(--bg-3); }
.icon-btn.on { color: var(--flag); }
.icon-btn.on svg { fill: currentColor; }

/* Anmeldung */
.login { min-height: 100%; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom)); background: var(--bg-2); }
.login-card { width: 100%; max-width: 380px; background: var(--bg); border-radius: 14px; padding: 28px 22px; box-shadow: var(--shadow); text-align: left; }
.login-logo { width: 64px; height: 64px; display: block; margin: 0 auto 8px; }
.login-card h1 { text-align: center; margin: 0 0 6px; font-size: 24px; }
.login-card p.muted { text-align: center; margin: 0 0 18px; }
.login-card label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 4px; height: 46px; padding: 0 12px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--bg); }
.login-card .code-input { text-align: center; font-size: 24px; letter-spacing: 3px; text-transform: uppercase; font-family: var(--mono, ui-monospace, monospace); }
.login-switch { margin-top: 8px; }
/* App installieren */
.install-box { width: 100%; max-width: 380px; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); }
.install-box[hidden] { display: none; }
.install-box svg { width: 32px; height: 32px; fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.install-box strong { display: block; font-size: 15px; }
.install-box span { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; }
.install-box .btn { min-height: 38px; padding: 0 14px; }
.install-card { max-width: 400px; max-height: calc(100% - 20px); overflow-y: auto; }
.install-card p { margin: 0 0 12px; }
.install-steps { list-style: none; counter-reset: is; padding: 0; margin: 0 0 12px; display: grid; gap: 14px; }
.install-steps li { counter-increment: is; position: relative; padding-left: 38px; }
.install-steps li::before { content: counter(is); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 14px; }
.install-art { margin-top: 8px; }
.install-art svg { stroke: none; fill: none; display: block; width: 100%; max-width: 260px; height: auto; }
.ia-bar { fill: var(--bg-2); stroke: var(--line); }
.ia-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ia-dots { fill: none; stroke: var(--muted); stroke-width: 3.5; stroke-linecap: round; }
.ia-hi { fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ia-ring { fill: none; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 4 3; }
.ia-text { stroke: none; fill: var(--text); font: 600 14px system-ui, -apple-system, sans-serif; }
.ia-muted { fill: var(--muted); font-weight: 400; }
.ia-strong { fill: var(--brand); }
.install-code { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 14px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.install-code span { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.install-code strong { font: 700 20px var(--mono, ui-monospace, monospace); letter-spacing: 1px; white-space: nowrap; }
.install-code .btn { min-height: 38px; }

.login-card input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
#install-hint { margin-top: 16px; text-align: center; }

/* Rahmen */
.app { position: fixed; top: 0; left: 0; right: 0; height: var(--app-h, 100%); display: flex; flex-direction: column; }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.bar { flex: none; display: flex; align-items: center; gap: 4px; min-height: calc(var(--bar-h) + var(--safe-top)); padding: var(--safe-top) 6px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 6px; }
.bar-title strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-saved { color: var(--muted); font-size: 12px; white-space: nowrap; }
.c-saved:empty { display: none; }
.avatar-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 600; flex: none; background: var(--brand); text-transform: uppercase; }
.avatar-lg { width: 44px; height: 44px; font-size: 16px; }

.tabbar { flex: none; display: flex; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabbar button { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); position: relative; }
.tabbar button.active { color: var(--brand); }
.tabbar button.active svg { stroke-width: 2.1; }
.tabbar .tab-hilfe { display: none !important; }
.tabbar .dot { position: absolute; top: 8px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg); }

/* Mail */
.mail-split { flex: 1; min-height: 0; display: flex; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.list-pane { flex: 1; }
.read-pane { display: none; }
.search { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.search input { flex: 1; height: 38px; border-radius: 8px; border: 0; background: var(--bg-2); padding: 0 14px; }
.search input:focus { outline: 2px solid var(--brand); }
.filters { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.chip-btn { height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; white-space: nowrap; color: var(--muted); }
.chip-btn.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.list-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; position: relative; }
.pull { height: 0; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; color: var(--muted); font-size: 13px; transition: height .15s; }
.msg-list { list-style: none; margin: 0; padding: 0 0 96px; }
.msg { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.msg-under { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; color: #fff; font-weight: 600; font-size: 13px; }
.msg-under .u-flag, .msg-under .u-del { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.msg-under.left { background: var(--swipe-flag); }
.msg-under.right { background: var(--swipe-del); justify-content: flex-end; }
.msg-row { position: relative; display: flex; gap: 12px; padding: 12px 14px 12px 12px; background: var(--bg); width: 100%; text-align: left; touch-action: pan-y; transition: transform .2s; }
.msg-row.dragging { transition: none; }
.msg-actions { display: none; }
@media (hover: hover) and (pointer: fine) {
  .msg-row:not(.selected):hover { background: var(--bg-2); }
  .msg:hover .msg-actions { position: absolute; right: 10px; bottom: 8px; display: flex; gap: 2px; background: var(--bg); border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }
  .msg-act { display: flex; align-items: center; justify-content: center; width: 30px; height: 28px; border-radius: 6px; color: var(--muted); }
  .msg-act svg { width: 17px; height: 17px; }
  .msg-act:hover { background: var(--brand-soft); color: var(--text); }
  .msg-act.on { color: var(--flag); }
  .msg-act.del:hover { color: var(--swipe-del); }
}
.msg-row.selected { background: var(--brand-soft); }
.msg-row .avatar { width: 40px; height: 40px; font-size: 15px; }
.msg-main { flex: 1; min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 8px; }
.msg-from { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.msg-time { flex: none; font-size: 12px; color: var(--muted); }
.msg-subject { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.msg-subject span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-subject svg { width: 16px; height: 16px; }
.msg-subject .flag { color: var(--flag); fill: var(--flag); }
.msg-subject .replied { color: var(--muted); }
.msg.unread .msg-from { font-weight: 700; }
.msg.unread .msg-subject span { color: var(--unread); font-weight: 600; }
.msg.unread .msg-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--unread); }
.list-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.more-btn { display: block; margin: 12px auto 100px; color: var(--brand); font-weight: 600; padding: 10px 18px; }
.fab { position: absolute; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 8px; background: var(--brand); color: var(--on-brand); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); z-index: 5; }
.fab svg { width: 26px; height: 26px; stroke-width: 2; }
.fab:active { transform: scale(.96); }

/* Ordnerleiste */
.drawer-backdrop, .sheet-backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 30; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, 86vw); background: var(--bg); z-index: 31; display: flex; box-shadow: var(--shadow); padding-top: var(--safe-top); animation: slide-in .18s ease-out; }
.drawer.with-rail { width: min(372px, 92vw); }
.drawer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drawer-rail { flex: none; width: 56px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.drawer-rail[hidden] { display: none; }
.rail-btn { position: relative; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); }
.rail-btn .avatar { width: 34px; height: 34px; font-size: 13px; }
.rail-btn.active { background: var(--brand-soft); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.rail-icon svg { width: 24px; height: 24px; }
.rail-dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg-2); }
.folder-row { position: relative; }
.folder-toggle { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); }
.folder-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.folder-toggle.open svg { transform: rotate(90deg); }
.folder-toggle:hover { background: var(--bg-3); }
.box-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; text-align: left; }
.box-row:hover { background: var(--bg-2); }
.box-row .count { font-size: 13px; color: var(--brand); font-weight: 600; }
.box-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.box-text strong, .box-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-text small { color: var(--muted); }
.box-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.box-back { width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); }
.box-back:hover { background: var(--bg-2); }
.box-back svg { width: 20px; height: 20px; }
.tab-groups { display: none !important; }
@keyframes slide-in { from { transform: translateX(-100%); } }
.drawer-head { display: flex; gap: 12px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.drawer-head div { min-width: 0; display: flex; flex-direction: column; }
.drawer-head strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-head small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 6px 0 calc(16px + var(--safe-bottom)); }
.folder-group { padding: 14px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: flex; justify-content: space-between; gap: 8px; }
.folder-group span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0; }
.folder { display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 16px; text-align: left; }
.folder.sub { padding-left: 34px; }
.folder.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.folder .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .count { font-size: 13px; color: var(--brand); font-weight: 600; }

/* Mail lesen und schreiben: auf dem Handy über allem */
.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.reader-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.r-subject { font-size: 20px; font-weight: 600; margin: 16px 16px 4px; overflow-wrap: anywhere; }
.r-head { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; }
.r-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.r-who { flex: 1; min-width: 0; }
.r-who strong { display: block; overflow-wrap: anywhere; }
.r-who small { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.r-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.r-details { margin: 0 16px 8px; font-size: 13px; color: var(--muted); }
.r-details summary { cursor: pointer; color: var(--brand); list-style: none; }
.r-details summary::-webkit-details-marker { display: none; }
.r-details dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; }
.r-details dd { margin: 0; overflow-wrap: anywhere; }
.r-banner { margin: 0 16px 8px; padding: 8px 12px; border-radius: 8px; background: var(--bg-2); font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inv-card { margin: 0 16px 10px; padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; background: var(--bg-2); display: flex; flex-direction: column; gap: 3px; }
.inv-head { display: flex; align-items: center; gap: 8px; color: var(--brand); font-size: 13px; }
.inv-head svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.inv-title { font-weight: 600; font-size: 16px; }
.inv-card small { color: var(--muted); font-size: 13px; }
.inv-card .inv-status { color: var(--text); }
.inv-card .inv-status:empty { display: none; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inv-actions:empty { display: none; }
.inv-actions .btn { min-height: 40px; padding: 0 14px; }
.r-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 10px; }
.att { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; text-align: left; }
.att svg { width: 20px; height: 20px; color: var(--brand); flex: none; }
.att small, .att .x { flex: none; }
.att span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.att small { color: var(--muted); }
.att .x { color: var(--muted); padding: 0 2px; }
.r-body { padding: 4px 16px 24px; }
.r-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
/* Zitat in reinen Textmails, Farben wie im HTML-Zitat (QUOTE_CSS in mailapp.js) */
.r-text .ido-q1 { color: #1f5fa8; }
.r-text .ido-q2 { color: #2e7d4f; }
.r-text .ido-q3 { color: #9a4a15; }
:root[data-theme="dark"] .r-text .ido-q1 { color: #7fb2ec; }
:root[data-theme="dark"] .r-text .ido-q2 { color: #7cc79a; }
:root[data-theme="dark"] .r-text .ido-q3 { color: #e0a47c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .r-text .ido-q1 { color: #7fb2ec; }
  :root:not([data-theme="light"]) .r-text .ido-q2 { color: #7cc79a; }
  :root:not([data-theme="light"]) .r-text .ido-q3 { color: #e0a47c; }
}
.r-frame { width: 100%; border: 0; display: block; min-height: 120px; background: #fff; border-radius: 4px; }
.reader-actions { flex: none; display: flex; border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); background: var(--bg); }
.reader-actions button { flex: 1; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--brand); }
.compose-form { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); }
.field { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 0 12px 0 16px; min-height: 48px; }
.field > span { color: var(--muted); width: 56px; flex: none; font-size: 14px; }
.field input, .field select { flex: 1; min-width: 0; border: 0; background: transparent; height: 46px; outline: none; }
/* Ersatz für die abgeschaltete Umrandung: Linie unter dem aktiven Feld */
.field:focus-within { box-shadow: inset 0 -2px var(--brand); }
.field input.toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.suggest { border-bottom: 1px solid var(--line); background: var(--bg); }
.suggest-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 16px; text-align: left; min-height: 52px; }
.suggest-item:active, .suggest-item:hover { background: var(--bg-2); }
.suggest-item .avatar { width: 32px; height: 32px; font-size: 13px; flex: none; }
.suggest-text { display: flex; flex-direction: column; min-width: 0; }
.suggest-text b, .suggest-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-text b { font-weight: 500; }
.suggest-text small { color: var(--muted); font-size: 12px; }
.compose-form textarea { flex: 1; min-height: 240px; border: 0; padding: 14px 16px; resize: none; outline: none; background: transparent; line-height: 1.3; }
.compose-form textarea:focus-visible { box-shadow: inset 2px 0 var(--brand); }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px; }
.att-list:not(:empty) { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--brand); }
.send-btn:disabled { opacity: .4; }
.send-btn svg { stroke-width: 2; }
.send-btn.busy { opacity: 1; }
.send-btn.busy svg { display: none; }
.send-btn.busy::after { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand); animation: send-spin .8s linear infinite; }
@keyframes send-spin { to { transform: rotate(360deg); } }

/* Auswahlliste von unten */
.picker { position: fixed; left: 0; right: 0; bottom: 0; max-height: 80vh; background: var(--bg); z-index: 41; border-radius: 16px 16px 0 0; padding: 8px 0 calc(10px + var(--safe-bottom)); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: up .15s ease-out; }
.sheet-backdrop { z-index: 40; }
.picker-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 8px; }
.picker-title { padding: 4px 18px 8px; font-size: 15px; }
.picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.picker-list button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 18px; text-align: left; }
.picker-list button:active { background: var(--bg-2); }
.picker-list .sep { padding: 10px 18px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.picker-list .danger { color: var(--danger); }

/* Mehr */
.menu-list { list-style: none; margin: 0; padding: 8px 0; overflow-y: auto; }
.menu-list button { display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 18px; text-align: left; font-size: 16px; }
.menu-list button:active { background: var(--bg-2); }
.menu-list svg { color: var(--brand); }
#logout, #logout svg { color: var(--danger); }
.portal-frame { flex: 1; width: 100%; height: 100%; border: 0; background: var(--bg); }
/* Ladebalken über einer Portalseite, bis sie geladen ist (danach zeigt die Seite selbst ihre Ladeanzeige) */
.frame-bar { flex: none; height: 3px; background: linear-gradient(90deg, transparent 0, var(--brand) 30%, var(--brand) 50%, transparent 80%) var(--brand-soft); background-size: 200% 100%; animation: frame-load 1.2s linear infinite; }
.frame-bar[hidden] { display: none; }
@keyframes frame-load { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .frame-bar { animation-duration: 3s; } }
.menu-list .menu-sep { padding: 18px 18px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.more-frame { flex: 1; min-height: 0; }

/* Rückfrage, Hinweis */
.modal { position: fixed; inset: 0; background: var(--backdrop); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--bg); border-radius: 14px; padding: 20px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 18px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + 16px + var(--safe-bottom)); z-index: 70; margin: 0 auto; max-width: 520px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 8px; background: #2b2b2b; color: #fff; box-shadow: var(--shadow); font-size: 14px; }
.toast .link-btn { color: #7cb7ff; padding: 0 4px; }

/* Kalender wie Outlook: Wochenleiste, Terminübersicht, Tag und 3 Tage */
.cal-hint { flex: none; display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: 13px; }
.cal-hint[hidden] { display: none; }
.cal-hint span { flex: 1; min-width: 0; color: var(--text); }
.cal-hint .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.week-strip { flex: none; display: grid; grid-template-columns: repeat(7, 1fr); padding: 6px 4px 8px; border-bottom: 1px solid var(--line); touch-action: pan-y; user-select: none; }
.week-strip .wd { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 2px 0; }
.week-strip .wd small { font-size: 11px; color: var(--muted); }
.week-strip .wd b { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 15px; }
.week-strip .wd.today b { color: var(--brand); font-weight: 700; }
.week-strip .wd.sel b { background: var(--brand); color: var(--on-brand); }
.week-strip .wd i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.week-strip .wd.has i { background: var(--subtle); }
.cal-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; padding-bottom: 90px; }
.ag-day { position: sticky; top: 0; z-index: 1; padding: 10px 16px 6px; background: var(--bg-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.ag-day.today { color: var(--brand); }
.ag-none { padding: 12px 16px; color: var(--subtle); font-size: 14px; }
.ev-row { display: flex; gap: 12px; width: 100%; padding: 10px 16px; text-align: left; align-items: stretch; border-bottom: 1px solid var(--line); }
.ev-time { width: 74px; flex: none; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; }
.ev-time b { color: var(--text); font-weight: 500; font-size: 14px; }
.ev-time { font-size: 12px; }
.ev-bar { width: 4px; border-radius: 2px; flex: none; }
.ev-main { flex: 1; min-width: 0; }
.ev-main strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-main small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-top { position: sticky; top: 0; z-index: 4; background: var(--bg); }
.grid-allday { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); min-height: 6px; }
.grid-allday .gl { width: 48px; flex: none; font-size: 10px; color: var(--muted); padding: 4px; }
.grid-allday .gc { flex: 1; min-width: 0; padding: 2px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); }
.grid-head { display: flex; background: var(--bg); border-bottom: 1px solid var(--line); }
.grid-head .gl { width: 48px; flex: none; }
.grid-head .gc { flex: 1; text-align: center; padding: 4px 0; font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); }
.grid-head .gc.today { color: var(--brand); font-weight: 700; }
.grid { display: flex; position: relative; }
.grid .hours { width: 48px; flex: none; }
.grid .hours div { height: 56px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.grid .col { flex: 1; min-width: 0; position: relative; border-left: 1px solid var(--line); background: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent 56px); }
.grid .now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.chip-ev { position: absolute; border-radius: 4px; padding: 2px 5px; font-size: 12px; line-height: 1.25; overflow: hidden; text-align: left; color: var(--text); border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 18%, var(--bg)); }
.chip-ev.allday { position: static; white-space: nowrap; text-overflow: ellipsis; }
.chip-ev small { display: block; color: var(--muted); }

/* Ansehen: Termin, Kontakt */
.d-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 22px 16px 10px; gap: 6px; }
.d-hero .avatar { width: 72px; height: 72px; font-size: 26px; }
.d-hero h1 { margin: 6px 0 0; font-size: 22px; overflow-wrap: anywhere; }
.d-hero p { margin: 0; color: var(--muted); }
.d-actions { display: flex; justify-content: center; gap: 22px; padding: 6px 16px 16px; }
.d-actions a, .d-actions button { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--brand); font-size: 12px; text-decoration: none; }
.d-actions span.round { width: 48px; height: 48px; border-radius: 50%; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; }
.d-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.d-list li { display: flex; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.d-list li svg { color: var(--muted); margin-top: 1px; }
.d-list li div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.d-list li small { display: block; color: var(--muted); font-size: 12px; }
.d-list li a { color: var(--brand); text-decoration: none; }
.d-ev-title { padding: 18px 16px 4px; display: flex; gap: 12px; align-items: flex-start; }
.d-ev-title i { width: 14px; height: 14px; border-radius: 4px; margin-top: 7px; flex: none; }
.d-ev-title h1 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.d-note { white-space: pre-wrap; }
.sig-preview { margin: 12px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; font: inherit; font-size: 14px; }
.d-info { margin: 12px 16px; padding: 10px 12px; border-radius: 8px; background: var(--bg-2); color: var(--muted); font-size: 13px; }
.d-buttons { margin: 12px 16px 24px; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.switch-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.switch-row div { flex: 1; min-width: 0; }
.switch-row small { display: block; color: var(--muted); font-size: 12px; }
.share-row select { flex: none; max-width: 52%; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.toggle { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 6px; background: var(--input-border); position: relative; flex: none; transition: background .15s; margin: 0; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 4px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.toggle:checked { background: var(--brand); }
.toggle:checked::after { transform: translateX(20px); }
.toggle:disabled { opacity: .5; }
.sec-head { padding: 16px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Bearbeiten */
.field textarea { flex: 1; min-width: 0; border: 0; background: transparent; min-height: 96px; padding: 12px 0; outline: none; resize: vertical; }
.field.top { align-items: flex-start; }
.field.top > span { padding-top: 13px; }
.field input[type=date], .field input[type=time] { flex: 0 1 auto; min-width: 0; }
.field .pair { flex: 1; display: flex; gap: 8px; justify-content: flex-end; }
.time-pick { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.time-pick[hidden] { display: none; }
.field .time-pick select { flex: none; width: auto; min-width: 0; padding: 0 2px; text-align: center; }
.time-sep { color: var(--muted); }
.field input.toggle { flex: none; width: 50px; height: 30px; margin-left: auto; background: var(--input-border); }
.field input.toggle:checked { background: var(--brand); }
#e-form .field > span { width: 96px; }
.e-danger { margin: 18px 16px; color: var(--danger); font-weight: 600; padding: 12px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }

/* Kontakte */
.ct-list { list-style: none; margin: 0; padding: 0 0 96px; }
.ct-letter { position: sticky; top: 0; padding: 4px 16px; background: var(--bg-2); font-size: 13px; font-weight: 700; color: var(--brand); }
.ct-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; text-align: left; }
.ct-row:active { background: var(--bg-2); }
.ct-row div { min-width: 0; flex: 1; }
.ct-row strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-row small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search input[type=search] { font-size: 16px; }

/* Aufgaben (wie Microsoft To Do) */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.task .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--subtle); flex: none; display: flex; align-items: center; justify-content: center; }
.task .check svg { width: 16px; height: 16px; stroke-width: 2.6; opacity: 0; color: #fff; }
.task.done .check { background: var(--brand); border-color: var(--brand); }
.task.done .check svg { opacity: 1; }
.task .t-main { flex: 1; min-width: 0; text-align: left; }
.task .t-main strong { display: block; font-weight: 500; overflow-wrap: anywhere; }
.task.done .t-main strong { text-decoration: line-through; color: var(--muted); }
.task .t-main small { display: block; font-size: 12px; color: var(--muted); }
.task .t-main small.late { color: var(--danger); }
.task .prio { color: var(--danger); font-weight: 800; }
.task-done summary { padding: 14px 16px; font-weight: 600; color: var(--muted); cursor: pointer; }
.task-add { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.task-add input { flex: 1; height: 42px; border: 0; border-radius: 8px; padding: 0 14px; background: var(--bg-2); outline: none; }
.task-add input:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; }

/* Breiter Bildschirm (Tablet, PC): Liste und Lesebereich nebeneinander */
@media (min-width: 900px) and (min-height: 521px) {
  .list-pane { flex: none; width: 380px; border-right: 1px solid var(--line); }
  .read-pane { display: flex; flex: 1; }
  .read-pane .read-empty { margin: auto; text-align: center; color: var(--muted); }
  .read-pane .read-empty svg { width: 64px; height: 64px; stroke-width: 1; }
  .reader.in-pane { position: static; inset: auto; z-index: auto; animation: none; flex: 1; min-height: 0; }
  .reader.in-pane [data-close] { display: none; }
  .tabbar { order: -1; flex-direction: column; width: 76px; border-top: 0; border-right: 1px solid var(--line); padding: var(--safe-top) 0 0; }
  .tabbar button { flex: none; height: 68px; }
  .tabbar .tab-groups:not([hidden]) { display: flex !important; }
  .tabbar .tab-hilfe:not([hidden]) { display: flex !important; margin-top: auto; }
  .app { flex-direction: row; }
  .toast { bottom: 20px; }
}

/* Anhang aus der Firmen-Cloud */
#detail.on-top { z-index: 25; }
.cp-file { display: flex; align-items: center; }
.cp-file .ct-row { flex: 1; min-width: 0; }
.cp-file .link-btn { padding: 0 16px; height: 44px; }
.cp-crumbs { padding: 4px 16px 8px; font-size: 14px; color: var(--muted); }
.cp-crumbs .link-btn { padding: 0; }

/* Kategorien (Farben wie in Outlook) */
.cat-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; min-width: 0; }
.cat-tag { display: inline-flex; align-items: center; gap: 5px; max-width: 160px; padding: 1px 6px; border-radius: 4px; font-size: 12px; line-height: 18px;
  color: var(--text); background: color-mix(in srgb, var(--c) 28%, var(--bg)); border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-more { font-size: 12px; color: var(--muted); line-height: 20px; }
#reader-body > .cat-tags { margin: 6px 16px 4px; }
.cat-dot { width: 18px; height: 18px; border-radius: 4px; flex: none; }
.cat-pick span:nth-child(2) { flex: 1; }
.cat-pick .cat-check { width: 20px; height: 20px; color: var(--brand); visibility: hidden; }
.cat-pick.on .cat-check { visibility: visible; }

/* Darstellung wählen */
.choice-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; }
.choice-row div { flex: 1; display: flex; flex-direction: column; }
.choice-row small { color: var(--muted); }
.choice-row .choice-check { visibility: hidden; color: var(--brand); }
.choice-row.on .choice-check { visibility: visible; }

/* Handy: iOS zoomt in Eingabefelder unter 16px hinein; App nur im Hochformat (iOS lässt sich nicht sperren, daher Hinweis) */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
/* Nur eine Decke darüber: die App darunter bleibt unverändert (Handy-Ansicht, siehe min-height bei 900px) und geht nach dem Zurückdrehen weiter */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  body::after { content: "Bitte drehen Sie das Handy ins Hochformat."; position: fixed; inset: 0; z-index: 2147483647; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; font-size: 17px; color: var(--text); background: var(--bg); }
}

/* Speicher voll oder fast voll: Hinweis über der Mailliste (Farben folgen hellem und dunklem Design) */
.st-banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.4; color: var(--text); }
.st-banner.warn { background: color-mix(in srgb, var(--swipe-flag) 14%, var(--bg)); }
.st-banner.full { background: color-mix(in srgb, var(--danger) 14%, var(--bg)); }
.st-banner.duty { background: color-mix(in srgb, var(--brand) 8%, var(--bg)); }
.st-banner.offline { background: color-mix(in srgb, var(--swipe-flag) 14%, var(--bg)); }
.st-banner-go:disabled { opacity: .6; cursor: default; }
.st-banner-more { color: inherit; font-weight: 600; white-space: nowrap; }
.st-banner > span { flex: 1 1 auto; min-width: 0; }
.st-banner-go { flex: none; border: 0; border-radius: 6px; padding: 7px 10px; font: inherit; font-weight: 600; background: var(--brand); color: var(--on-brand); cursor: pointer; }
.st-banner-x { flex: none; border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; padding: 2px 6px; cursor: pointer; }

/* IDO Mail Team (/team): ohne Mail, Kalender, Kontakte, Aufgaben; schon vor dem Start ausblenden (kein Aufblitzen) */
html.team .mail-only:not(.team-keep), html.team .no-team, html.team .tabbar [data-go="kalender"], html.team .tabbar [data-go="adressbuch"], html.team .tabbar [data-go="aufgaben"] { display: none !important; }
