:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0f0ed; --text: #1c1c1e; --muted: #6b6b70;
  --border: #e2e2de; --accent: #1f4e8c; --accent-text: #ffffff;
  --danger: #b42318; --warn: #b54708; --ok: #067647;
  --radius: 10px; --nav-w: 220px;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214; --surface: #1a1b1e; --surface-2: #232428; --text: #ececef; --muted: #9b9ba2;
    --border: #2d2e33; --accent: #7ba8e8; --accent-text: #0b1322;
    --danger: #f97066; --warn: #fdb022; --ok: #47cd89;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem 0 .25rem; }
#app { min-height: 100dvh; }

.nav { position: fixed; inset: 0 auto 0 0; width: var(--nav-w); background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); padding: 6px 10px 18px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent); color: var(--accent-text); }
.nav-icon { width: 20px; text-align: center; }
.content { margin-left: var(--nav-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.search-trigger { flex: 1; max-width: 480px; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.main { padding: 24px; max-width: 960px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; font-size: .85rem; }
.muted, .empty { color: var(--muted); }
.error { color: var(--danger); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs, .chips { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a, .chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.tabs a.active, .chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); background: none; border: 0; padding: 0; text-align: left; font: inherit; cursor: pointer; }
.item-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list.compact .item { padding: 8px 12px; }
.check { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.due { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.due-overdue { color: var(--danger); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.tag { display: inline-block; padding: 1px 8px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--surface-2); font-size: .8rem; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.markdown { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 18px; overflow-wrap: anywhere; }
.markdown pre { overflow-x: auto; }
.markdown img { max-width: 100%; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card .list { border: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 8px; }
.card .section-head { margin-top: 0; }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.md-input { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.md-input textarea, .md-input .preview { width: 100%; }
.row { display: flex; gap: 8px; }
.inline { display: inline-flex; gap: 8px; align-items: center; }

.dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 18px; width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(0 0 0 / .4); }
.dialog.search { margin-top: 10vh; }
.search-input { font-size: 1.05rem; margin-bottom: 8px; }
.search-results { max-height: 60vh; overflow-y: auto; }
.fab { position: fixed; right: 24px; bottom: 24px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); font-size: 1.6rem; box-shadow: 0 6px 18px rgb(0 0 0 / .25); cursor: pointer; z-index: 10; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.toast.error { background: var(--danger); color: #fff; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Startseite (nicht angemeldet) im eHS-Navy */
.landing { position: relative; min-height: 100dvh; overflow: hidden; display: flex; flex-direction: column; background: #0E2841; color: #F4F6F9; padding: 24px 16px calc(16px + env(safe-area-inset-bottom)); }
.landing-glow { position: absolute; inset: -20%; background: radial-gradient(40% 35% at 70% 30%, rgb(127 211 91 / .16), transparent 70%), radial-gradient(45% 40% at 25% 75%, rgb(240 160 112 / .14), transparent 70%); animation: glow 14s ease-in-out infinite alternate; pointer-events: none; }
@keyframes glow { to { transform: translate(4%, -3%) scale(1.08); } }
.landing-top, .landing-hero, .landing-foot { position: relative; width: 100%; max-width: 760px; margin: 0 auto; }
.landing-logo { height: 120px; width: auto; margin: -34px 0 -30px -6px; object-fit: contain; }
.landing-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 18px; padding: 32px 0; }
.landing-eyebrow { margin: 0; font: 10px/1.6 "Press Start 2P", ui-monospace, monospace; color: #7FD35B; letter-spacing: .04em; }
.landing h1 { font-size: clamp(2.6rem, 9vw, 4.6rem); line-height: 1; letter-spacing: -.02em; font-weight: 700; }
.landing-lead { margin: 0; max-width: 30ch; font-size: clamp(1.15rem, 3.4vw, 1.5rem); line-height: 1.35; color: #BFCCDB; }
.landing-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.landing-chips li { padding: 5px 12px; border-radius: 999px; background: #17375A; color: #F0A070; font-size: .9rem; }
.landing-btn { margin-top: 8px; padding: 13px 22px; border: 0; border-radius: 10px; background: #F4F6F9; color: #0E2841; font: 600 1rem/1 inherit; font-family: inherit; cursor: pointer; box-shadow: 0 8px 24px rgb(0 0 0 / .3); transition: transform .15s; }
.landing-btn:hover { transform: translateY(-1px); }
.landing-replay { padding: 0; border: 0; background: none; color: #8FA3BA; font: 9px/1.6 "Press Start 2P", ui-monospace, monospace; cursor: pointer; }
.landing-replay:hover { color: #7FD35B; }
.landing .error { color: #f97066; }
.landing-foot { font-size: .8rem; color: #8FA3BA; }
.landing-hold > * { visibility: hidden; }
.landing-enter .landing-hero > * { animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
.landing-enter .landing-hero > :nth-child(2) { animation-delay: .08s; }
.landing-enter .landing-hero > :nth-child(3) { animation-delay: .16s; }
.landing-enter .landing-hero > :nth-child(4) { animation-delay: .24s; }
.landing-enter .landing-hero > :nth-child(n+5) { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* C64-Intro */
.c64 { position: fixed; inset: 0; z-index: 100; background: #6c5eb5; cursor: pointer; }
.c64 canvas { display: block; image-rendering: pixelated; }
.c64-hint { position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); text-align: center; font: 8px/1 "Press Start 2P", ui-monospace, monospace; color: #352879; opacity: .8; }
.c64-out { opacity: 0; transition: opacity .6s ease; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .landing-glow, .landing-enter .landing-hero > * { animation: none; } }
.mobile-only { display: none; }

@media (max-width: 767px) {
  .nav { inset: auto 0 0 0; width: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); z-index: 20; }
  .brand, .desktop-only { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 0; padding: 6px 2px; font-size: .7rem; text-align: center; }
  .nav-icon { font-size: 1.1rem; width: auto; }
  .content { margin-left: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 16px; }
  .mobile-only { display: inline-flex; }
  .main { padding: 16px; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; }
  kbd { display: none; }
}

.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; }
.nav-item.active .badge { background: var(--accent-text); color: var(--accent); }
.mail-list { display: grid; gap: 12px; }
.mail-card { display: grid; gap: 10px; }
.mail-card.reply { border-left: 4px solid var(--accent); }
.mail-head { display: grid; gap: 2px; }
.mail-folder { font-size: .8rem; color: var(--muted); }
.mail-subject { font-size: 1.05rem; }
.mail-excerpt { margin: 4px 0 0; color: var(--muted); white-space: pre-line; }
.sugg-list { display: grid; gap: 8px; }
.sugg-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.small { font-size: .85rem; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
@media (max-width: 767px) {
  .badge { position: absolute; top: 2px; right: 50%; transform: translateX(18px); margin: 0; }
  .nav-item { position: relative; }
  .sugg-row { grid-template-columns: auto 1fr; }
  .sugg-row input[type=date], .sugg-row select { grid-column: 2; }
  .mail-actions .btn { min-height: 44px; }
}

.banner[hidden] { display: none; }
.mobile-only-block { display: none; }
@media (max-width: 767px) { .mobile-only-block { display: block; } }
.inbox-hint { display: block; margin-bottom: 12px; color: var(--text); }

/* Verknüpfung mit Vorschlagsliste (Firma, Projekt) */
.ref-input { display: block; }
.ref-input input { width: 100%; }
.mail-actions .ref-input { flex: 1 1 220px; min-width: 0; }

/* Agent */
.agent-body { white-space: pre-wrap; font: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; max-height: 320px; overflow: auto; }
.agent-page .stack { display: grid; gap: 12px; }
.agent-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.template-row { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.template-row .btn { justify-self: start; }
