:root {
    --accent: #00786e;
    --accent-bg: #e0f2f1;
    --border: #d5dcdc;
    --text: #1e2426;
    --muted: #5c6668;
    --bg: #ffffff;
    --bg2: #f4f7f7;
    --danger: #b3261e;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #4db6ac;
        --accent-bg: #17302d;
        --border: #34403f;
        --text: #e6ecec;
        --muted: #9aa7a8;
        --bg: #161b1c;
        --bg2: #1d2425;
        --danger: #f2b8b5;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--border); background: var(--bg2); border-radius: 4px; padding: 5px 10px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; }
button.wide { width: 100%; margin-bottom: 6px; }
input, select { border: 1px solid var(--border); background: var(--bg); border-radius: 4px; padding: 5px 8px; }
.error { color: var(--danger); }
.info, .empty { color: var(--muted); padding: 12px; }
.right { text-align: right; }

.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 6px 14px; background: var(--accent); color: #fff; }
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar nav { display: flex; gap: 12px; }
.topbar nav a { padding: 2px 6px; border-radius: 4px; }
.topbar nav a.active { background: rgba(255, 255, 255, .22); }
.topbar .spacer, .spacer { flex: 1; }
.topbar form { margin: 0; }
.topbar button.link { color: #fff; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.banner { padding: 6px 14px; background: var(--accent-bg); border-bottom: 1px solid var(--border); }
.banner.error { color: var(--danger); }

.mail { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px 360px 1fr; }
.mail > * { min-height: 0; overflow: auto; border-right: 1px solid var(--border); }
.folders { padding: 10px; background: var(--bg2); }
.folders ul { list-style: none; margin: 0; padding: 0; }
.node { display: flex; align-items: center; gap: 2px; padding: 3px 6px; border-radius: 4px; cursor: pointer; }
.node:hover { background: var(--accent-bg); }
.node.current { background: var(--accent-bg); font-weight: 600; }
.node.header > .name { font-weight: 600; color: var(--muted); }
.node .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.twisty { width: 16px; border: 0; background: none; padding: 0; color: var(--muted); }
.badge { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; }

.list { display: flex; flex-direction: column; overflow: hidden; }
.searchbar { display: flex; gap: 6px; padding: 8px; }
.searchbar input { flex: 1; min-width: 0; }
.list .title { padding: 2px 10px 6px; color: var(--muted); font-size: 12px; }
.rows { flex: 1; overflow: auto; }
.row { padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.row:hover { background: var(--bg2); }
.row.selected { background: var(--accent-bg); }
.row .line1, .row .line2 { display: flex; gap: 6px; align-items: baseline; }
.row .from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .date { color: var(--muted); font-size: 12px; }
.row .subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .from, .row.unread .subject { font-weight: 700; }
.row .flag { color: var(--danger); }
.footer { display: block; margin: 8px auto; }

.reader { display: flex; flex-direction: column; overflow: hidden; border-right: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.reader h2.subject { margin: 10px 14px 2px; font-size: 18px; }
.headers { margin: 0 14px 6px; color: var(--muted); font-size: 12px; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 14px 8px; }
.attachments a { background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; text-decoration: none; }
iframe.body { flex: 1; width: 100%; border: 0; background: #fff; }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; z-index: 10; }
.compose { width: min(900px, 96vw); height: min(720px, 94vh); background: var(--bg); border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.compose .head { display: flex; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.compose .fields { padding: 6px 12px; }
.compose .fields label { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.compose .fields label > :first-child { width: 0; }
.compose .fields input, .compose .fields select { flex: 1; }
.compose .format { display: flex; gap: 4px; padding: 4px 12px; }
.compose .editor { flex: 1; overflow: auto; margin: 0 12px; padding: 10px; border: 1px solid var(--border); border-radius: 4px; outline: none; background: #fff; color: #1e2426; }
.compose .attach { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; }
.chip { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 10px; }
.filebutton { position: relative; cursor: pointer; color: var(--accent); }
.filebutton input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compose .actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }

.page { padding: 18px 24px; overflow: auto; max-width: 1000px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.form { display: grid; gap: 8px; max-width: 520px; }
.form label { display: grid; gap: 3px; }
fieldset { border: 1px solid var(--border); border-radius: 6px; display: grid; gap: 8px; }

.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.login form { display: grid; gap: 10px; }
.login label { display: grid; gap: 3px; }
.login h1 { color: var(--accent); }

#blazor-error-ui { position: fixed; bottom: 0; left: 0; right: 0; background: #ffe9a8; color: #000; padding: 8px 16px; z-index: 20; }

@media (max-width: 900px) {
    .mail { grid-template-columns: 1fr; grid-auto-rows: minmax(200px, auto); overflow: auto; }
}

/* ---- Kontakte, Aufgaben (Liste links, Bearbeiten rechts) ---- */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px 1fr; }
.split > * { min-height: 0; overflow: auto; }
.split .side { display: flex; flex-direction: column; border-right: 1px solid var(--border); overflow: hidden; }
.split .detail { padding: 14px 20px; }
.form.wide { max-width: 760px; display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
textarea { border: 1px solid var(--border); background: var(--bg); color: inherit; border-radius: 4px; padding: 6px 8px; font: inherit; resize: vertical; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
a.button { border: 1px solid var(--border); background: var(--bg2); border-radius: 4px; padding: 5px 10px; text-decoration: none; }
label.check { display: flex; align-items: center; gap: 6px; padding: 0 10px 6px; }
.form label.check { padding: 0; }
.muted { color: var(--muted); }
.row.task .line1 { align-items: center; }
.row.task.done .subject { text-decoration: line-through; color: var(--muted); }
.row .overdue { color: var(--danger); font-weight: 600; }

/* ---- Notizen ---- */
.notes .searchbar { max-width: 700px; padding: 0 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { border-radius: 6px; padding: 10px 12px; cursor: pointer; min-height: 120px; box-shadow: 0 1px 3px rgba(0,0,0,.2); color: #1e2426; }
.card .text { white-space: pre-wrap; margin-top: 6px; font-size: 13px; }
.card .meta { margin-top: 8px; font-size: 11px; opacity: .65; }
.note-yellow { background: #fff2a8; } .note-blue { background: #bfe3ff; } .note-green { background: #c8f0c0; }
.note-pink { background: #ffd0e0; } .note-purple { background: #e0d0ff; } .note-white { background: #ffffff; }
.compose.small { width: min(640px, 96vw); height: auto; max-height: 92vh; }
.compose.small.note-yellow, .compose.small.note-blue, .compose.small.note-green, .compose.small.note-pink, .compose.small.note-purple, .compose.small.note-white { color: #1e2426; }
.notetext { margin: 8px 12px; min-height: 260px; background: transparent; color: inherit; border-color: rgba(0,0,0,.25); }
.compose .form.scroll { overflow: auto; padding: 8px 14px; max-width: none; }
.compose .actions.bar { border-top: 1px solid var(--border); padding: 10px 12px; }
.modes { display: flex; gap: 16px; }

/* ---- Kalender ---- */
.calendar { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px 1fr; }
.calfolders { padding: 10px; background: var(--bg2); border-right: 1px solid var(--border); overflow: auto; }
.minihead { color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.calfolder { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.calmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; }
.calmain .toolbar { align-items: center; }
.caltitle { margin-left: 10px; font-size: 15px; }
.chip { color: #fff; border-radius: 3px; padding: 1px 5px; margin: 1px 0; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip span { opacity: .85; margin-right: 4px; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; }
.month .dow { text-align: center; padding: 4px; color: var(--muted); border-bottom: 1px solid var(--border); }
.month .cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 96px; padding: 2px 3px; min-width: 0; }
.month .cell.other { background: var(--bg2); color: var(--muted); }
.month .cell.today .num { background: var(--accent); color: #fff; border-radius: 10px; }
.month .num { display: inline-block; padding: 0 6px; cursor: pointer; }
.month .more { font-size: 12px; color: var(--accent); cursor: pointer; }
.week { display: flex; flex-direction: column; min-width: 560px; }
.whead, .band { display: grid; grid-template-columns: 56px repeat(var(--days), 1fr); border-bottom: 1px solid var(--border); }
.gutter { color: var(--muted); font-size: 11px; padding: 2px 4px; }
.dayhead { text-align: center; padding: 4px; border-left: 1px solid var(--border); }
.dayhead.today { color: var(--accent); font-weight: 700; }
.bandcell { border-left: 1px solid var(--border); padding: 1px 2px; min-height: 22px; min-width: 0; }
.grid { display: grid; grid-template-columns: 56px repeat(var(--days), 1fr); position: relative; }
.hours .hour { height: 48px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; border-top: 1px solid var(--border); box-sizing: border-box; }
.daycol { position: relative; border-left: 1px solid var(--border); min-width: 0; }
.daycol .slot { height: 48px; border-top: 1px solid var(--border); box-sizing: border-box; cursor: pointer; }
.daycol .slot:hover { background: var(--accent-bg); }
.daycol .event { position: absolute; box-sizing: border-box; color: #fff; border-radius: 4px; padding: 2px 4px; font-size: 12px; overflow: hidden; cursor: pointer; border: 1px solid var(--bg); }
.daycol .event .loc { opacity: .85; }
.daycol .now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); pointer-events: none; }
@media (max-width: 900px) {
    .split, .calendar { grid-template-columns: 1fr; }
    .grid2 { grid-template-columns: 1fr; }
}

/* =====================================================================
   Aufbau wie im Desktop-Programm: Kopfzeile mit Menü und Suche, Symbolleiste
   links, Befehlsleiste über dem Modul
   ===================================================================== */
:root {
    --nav: #123438;
    --nav-hover: #224e52;
    --nav-text: #dcecea;
    --command: #f2f5f5;
    --pane: #f7f8f8;
    --selection: #d1ece8;
    --highlight: #ffb300;
}
@media (prefers-color-scheme: dark) {
    :root { --command: #1d2425; --pane: #161b1c; --selection: #17302d; }
}

.topbar { background: var(--nav); color: #fff; height: 44px; padding: 0 14px 0 6px; gap: 10px; flex: none; }
.topbar .brand { font-size: 15px; font-weight: 600; margin: 0 10px 0 6px; white-space: nowrap; }
.topbar .who { display: inline-flex; align-items: center; gap: 6px; color: var(--nav-text); white-space: nowrap; }
.searchbox { display: flex; align-items: center; gap: 6px; background: #fff; color: #5c6668; border-radius: 4px; padding: 0 8px; width: min(420px, 38vw); height: 28px; }
.searchbox input { border: 0; background: transparent; flex: 1; min-width: 0; color: #1e2426; padding: 0; outline: none; }

/* Menüleiste */
.menubar { display: flex; position: relative; z-index: 31; }
.menu { position: relative; }
.menutitle { background: transparent; border: 0; color: #fff; padding: 6px 10px; border-radius: 3px; }
.menutitle:hover:not(:disabled), .menu.open > .menutitle { background: var(--nav-hover); border: 0; }
.menu-backdrop { position: fixed; inset: 0; z-index: 30; }
.dropdown { position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.28); padding: 4px; z-index: 32; }
.dropdown .menuitem { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; background: transparent; border: 0; padding: 6px 8px; border-radius: 3px; color: inherit; }
.dropdown .menuitem:hover { background: var(--selection); }
.dropdown .menuitem .check { width: 14px; color: var(--accent); }
.dropdown .menuitem .text { flex: 1; }
.dropdown .menuitem .gesture, .dropdown .arrow { color: var(--muted); font-size: 12px; margin-left: 24px; }
.dropdown .sep { height: 1px; background: var(--border); margin: 4px 2px; }
.dropdown form { margin: 0; }
.dropdown .sub { position: relative; }
.dropdown .sub > .menuitem { justify-content: space-between; }
.dropdown .subdrop { display: none; top: 0; left: 100%; }
.dropdown .sub:hover > .subdrop { display: block; }

/* Hauptbereich: Symbolleiste links + Modul */
.shell { flex: 1; min-height: 0; display: flex; }
.shell > main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.rail { width: 68px; flex: none; background: var(--nav); display: flex; flex-direction: column; justify-content: space-between; padding: 8px 0 6px; }
.railbtn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 56px; color: var(--nav-text); text-decoration: none; font-size: 11px; }
.railbtn:hover { background: var(--nav-hover); color: #fff; }
.railbtn.active { background: var(--accent); color: #fff; }
.railbtn.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: var(--highlight); }
.railbadge { position: absolute; top: 4px; left: 38px; background: var(--highlight); color: var(--nav); border-radius: 8px; min-width: 18px; height: 16px; padding: 0 4px; font-size: 10px; display: flex; align-items: center; justify-content: center; }

/* Modul mit Befehlsleiste */
.module { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.module > .split, .module > .calendar, .module > .mail, .module > .page { flex: 1; min-height: 0; }
.commandbar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 2px; padding: 3px 6px; background: var(--command); border-bottom: 1px solid var(--border); flex: none; }
.commandbar .ribbon, .commandbar .ribbonselect { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 62px; padding: 3px 8px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--text); font-size: 11.5px; cursor: pointer; }
.commandbar .ribbon .icon, .commandbar .ribbonselect .icon { color: var(--accent); }
.commandbar .ribbon:hover:not(:disabled), .commandbar .ribbonselect:hover { background: var(--selection); border-color: #b2dfdb; }
.commandbar .ribbon.active { background: var(--selection); border-color: #b2dfdb; }
.commandbar .ribbon:disabled { opacity: .45; cursor: default; }
.commandbar .rsep { width: 1px; background: var(--border); margin: 4px 4px; }
.commandbar select.inline { align-self: center; }
.ribbonselect { position: relative; }
.ribbonselect select { border: 0; background: transparent; font-size: 11.5px; max-width: 90px; padding: 0; cursor: pointer; }

/* E-Mail-Modul: Lesebereich rechts, unten oder aus */
.mail.read-bottom { grid-template-columns: 250px 1fr; grid-template-rows: 1fr 1fr; }
.mail.read-bottom .folders { grid-row: 1 / span 2; }
.mail.read-bottom .reader { border-top: 1px solid var(--border); }
.mail.read-off { grid-template-columns: 250px 1fr; }
.mail.read-off .reader { position: fixed; inset: 70px 8% 8% 8%; z-index: 20; background: var(--bg); border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,.35); border-radius: 8px; }
.mail.read-off .reader .empty { display: none; }
.mail.read-off .reader:not(:has(.subject)) { display: none; }
.closepane { display: none; margin: 6px 10px; align-self: flex-end; }
.mail.read-off .closepane { display: block; }

.caltitlebar { padding: 6px 12px; }
.folders { background: var(--pane); }
.row.selected, .node.current { background: var(--selection); }
.calendar { grid-template-columns: 200px 1fr; }
.topbar .menubar { gap: 0; }

/* ---- Verfassen wie im Desktop-Programm ---- */
.overlay.top { z-index: 40; }
.compose.big { width: min(1100px, 98vw); height: min(860px, 96vh); }
.cwtitle { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.cwtitle b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ribtabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.ribtabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; border-radius: 0; padding: 6px 12px; }
.ribtabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.composebar { flex-wrap: nowrap; overflow: visible; position: relative; z-index: 35; }
.composebar .rgroup { display: flex; flex-wrap: wrap; max-width: 330px; align-content: flex-start; }
.composebar .rgroup > .ribbon, .composebar .rgroup > .menuwrap { flex: none; }
.composebar .sendbutton { background: var(--accent); color: #fff; min-width: 70px; border-radius: 4px; }
.composebar .sendbutton .icon { color: #fff; }
.composebar .sendbutton:hover:not(:disabled) { background: #00544e; }
.filebutton2 { position: relative; cursor: pointer; }
.filebutton2 input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.menuwrap { position: relative; }
.popmenu { top: 100%; left: 0; min-width: 240px; max-height: 320px; overflow: auto; z-index: 50; }
.menuhead { padding: 4px 8px; font-size: 11px; color: var(--muted); }
.optionsrow { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 8px 12px; }
.optionsrow label { display: flex; gap: 6px; align-items: center; }
.cwerror { margin: 4px 12px; padding: 0; }
.cwfields { padding: 4px 12px; border-bottom: 1px solid var(--border); }
.frow { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.frow > label { width: 56px; flex: none; color: var(--muted); font-size: 12px; }
.frow > input, .frow > select, .addrwrap { flex: 1; min-width: 0; }
.frow > input, .frow > select, .addrwrap input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; padding: 6px 2px; width: 100%; }
.frow input:focus, .frow select:focus { outline: none; border-bottom: 2px solid var(--accent); }
.addrwrap { position: relative; }
.suggest { position: absolute; z-index: 45; left: 0; right: 0; top: 100%; list-style: none; margin: 0; padding: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.suggest li { padding: 5px 8px; border-radius: 3px; cursor: pointer; }
.suggest li:hover { background: var(--selection); }
.ccs { display: flex; gap: 8px; }
.formatbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.formatbar button, .colorbtn { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; background: transparent; border-radius: 3px; color: var(--text); cursor: pointer; }
.formatbar button:hover, .colorbtn:hover { background: var(--selection); }
.colorbtn { position: relative; }
.colorbtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.formatbar .fontsel { width: 130px; } .formatbar .sizesel { width: 76px; }
.formatbar .fsep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editorframe { flex: 1; min-height: 120px; width: 100%; border: 0; background: #fff; }
.cwstatus { display: flex; padding: 3px 12px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); background: var(--command); }
.booklist { max-height: 50vh; overflow: auto; padding: 4px 12px; }
.bookrow { display: flex; gap: 6px; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--border); }
.bookrow .from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foldername { overflow-wrap: anywhere; }
.calfolder { align-items: flex-start; }
.calfolder .dot { margin-top: 5px; flex: none; }
