/* Mail-Oberfläche (Explorer-Baum, Liste, Leseansicht, Verfassen). Farben passen zur goldenen Linienzeichnung des Logos. */
.mail-shell, .compose, .mail-app {
    --gold: #b8923a; --gold-dark: #8a6a1f; --gold-soft: #f6efdc; --gold-line: #e7dcc0;
    --ink: #2a2417; --ink-soft: #6b6453; --paper: #fffdf8; --pane: #faf7ef; --line: #e9e3d3; --unread: #1f1a0e;
    --err: #a12a2a; --ok: #2f6b3a;
}
.mail-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--paper); color: var(--ink); }
.mail-main { flex: 1; min-height: 0; overflow: hidden; }

#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.icon { flex: none; vertical-align: -3px; }
.mail-app button, .compose button { font-family: inherit; }
.mail-app .link, .compose .link { background: none; color: var(--gold-dark); padding: 0; text-decoration: underline; font-size: inherit; }

/* ---- Drei Spalten ---- */
.mail-app { display: grid; grid-template-columns: 17.5rem minmax(20rem, 26rem) minmax(0, 1fr); height: 100%; }
.mail-tree { overflow-y: auto; background: var(--pane); border-right: 1px solid var(--line); padding: .5rem 0 2rem; }
.mail-list { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; border-right: 1px solid var(--line); background: #fff; }
.mail-reader { min-width: 0; min-height: 0; overflow-y: auto; background: var(--paper); display: flex; flex-direction: column; }

/* ---- Explorer-Baum ---- */
.tree-section { text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; font-weight: 600; color: var(--ink-soft); padding: .9rem 1rem .3rem; display: flex; align-items: center; gap: .4rem; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list.nested { padding-left: .9rem; }
.tree-empty { color: var(--ink-soft); font-size: .85rem; padding: .25rem 1rem; margin: 0; }
.node { display: flex; align-items: center; gap: .45rem; width: 100%; text-align: left; background: none; color: var(--ink); border-radius: 0; padding: .32rem .75rem; font-size: .92rem; line-height: 1.3; }
.node:hover { background: var(--gold-soft); }
.node.sel { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); font-weight: 600; }
.node .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node.folder { padding-left: calc(.75rem + var(--depth, 0) * .8rem); }
.node.off .label { color: var(--ink-soft); text-decoration: line-through; }
/* Ordner anlegen/löschen: kleine Knöpfe rechts am Eintrag, beim Überfahren oder per Tastatur sichtbar; auf Touch immer. */
.tree-item { position: relative; }
.node-actions { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); display: none; gap: .1rem; z-index: 1; background: var(--gold-soft); border-radius: 6px; }
.tree-item:not(.box):hover > .node-actions, .tree-item:not(.box):focus-within > .node-actions { display: inline-flex; }
/* Postfach: Knopf an der Kopfzeile, nur wenn genau die überfahren wird (nicht beim Überfahren der Ordner darunter). */
.tree-item.box > .node-actions { top: .95rem; }
.tree-item.box:has(> .node:hover) > .node-actions, .tree-item.box > .node-actions:hover, .tree-item.box > .node-actions:focus-within,
.tree-item.box:has(> .node:focus-visible) > .node-actions { display: inline-flex; }
.node-act { display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; padding: .2rem; border-radius: 4px; color: var(--ink-soft); cursor: pointer; }
.node-act:hover { background: #fff; color: var(--ink); }
.node-act.del:hover { color: var(--err); }
@media (hover: none) {
    .node-actions { display: inline-flex; background: none; }
    .tree-item:not(.box):has(> .node-actions) > .node, .tree-item.box > .node.mailbox { padding-right: 4rem; }
}
.chev { display: inline-flex; transition: transform .12s; color: var(--ink-soft); }
.chev.open { transform: rotate(90deg); }
.dot { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; flex: none; }
.badge { background: var(--gold); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; font-weight: 600; min-width: 1.2rem; text-align: center; }
.count { color: var(--ink-soft); font-size: .8rem; }
.peek, .err { display: inline-flex; color: var(--ink-soft); }
.err { color: var(--err); }
.hint-tag { font-size: .65rem; text-transform: none; letter-spacing: 0; background: var(--gold-soft); color: var(--gold-dark); border-radius: 999px; padding: 0 .4rem; font-weight: 500; }

/* ---- Liste ---- */
.list-bar { display: flex; align-items: center; gap: .4rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; flex-wrap: wrap; }
.search { flex: 1 1 5rem; min-width: 5rem; display: flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 .65rem; background: var(--paper); color: var(--ink-soft); }
.search input { border: 0; background: none; outline: none; padding: .35rem 0; width: 100%; font: inherit; color: var(--ink); }
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.list-title { display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem .2rem; }
.list-title h1 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.btn-primary { display: inline-flex; align-items: center; gap: .4rem; background: var(--gold); color: #fff !important; text-decoration: none; border-radius: 6px; padding: .4rem .8rem; font-size: .92rem; border: 0; cursor: pointer; }
.btn-primary:hover { background: var(--gold-dark); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.ghost { display: inline-flex; align-items: center; gap: .35rem; background: none; color: var(--ink); border: 1px solid transparent; border-radius: 6px; padding: .3rem .55rem; font-size: .88rem; cursor: pointer; text-decoration: none; }
.ghost:hover { background: var(--gold-soft); }
.ghost.on { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-dark); }
.ghost.del { color: var(--err); }
.ghost.small { font-size: .82rem; padding: .2rem .45rem; border-color: var(--line); }
.ghost:disabled { opacity: .5; }

.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li { display: flex; align-items: flex-start; border-bottom: 1px solid var(--line); position: relative; }
.msg-list li:hover { background: #fcf9f0; }
.msg-list li.sel { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
/* Mehrfachauswahl (Strg-/Umschalt-Klick): gleiche Farbe wie die geöffnete Mail; kein Text markieren beim Umschalt-Klick. */
.msg-list li.picked { background: var(--gold-soft); }
.msg-list a.msg { user-select: none; -webkit-user-select: none; }
.msg-list li.unread .from, .msg-list li.unread .subj { font-weight: 700; color: var(--unread); }
.msg-list li.unread::before { content: ""; position: absolute; left: .3rem; top: .95rem; width: .4rem; height: .4rem; border-radius: 50%; background: var(--gold); }
.pick { margin: .9rem 0 0 .95rem; accent-color: var(--gold-dark); }
.msg { flex: 1; min-width: 0; display: block; padding: .55rem .4rem .55rem .6rem; color: inherit; text-decoration: none; }
.cell-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.line1, .line2, .line3 { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .93rem; }
.date { color: var(--ink-soft); font-size: .78rem; flex: none; }
.subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.line3 { color: var(--ink-soft); font-size: .8rem; }
.snip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clip, .ans { color: var(--ink-soft); display: inline-flex; }
.star { background: none; color: #cfc6ae; padding: .6rem .6rem; border-radius: 0; }
.star:hover { color: var(--gold); }
.star.on { color: var(--gold); }
.star.on svg { fill: var(--gold); }
.more { margin: .75rem auto; background: var(--paper); border: 1px solid var(--gold-line); color: var(--gold-dark); }
.empty { color: var(--ink-soft); text-align: center; padding: 2rem 1rem; margin: 0; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--gold-soft); color: var(--ink); border-radius: 999px; padding: 0 .55rem; font-size: .78rem; line-height: 1.5; white-space: nowrap; flex: none; }
.chip.plain { background: #f1eee4; color: var(--ink-soft); }
.chip.warn { background: #fbe9e7; color: var(--err); }
.chip.small { font-size: .72rem; padding: 0 .45rem; }
.chip a { color: inherit; text-decoration: none; font-weight: 700; }
.bulk-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .4rem .8rem; background: var(--gold-soft); font-size: .88rem; }
.confirm-bar { background: #fbeaea; }
.busy-bar { color: var(--gold-dark); }
.msg-list li.deleting { opacity: .45; pointer-events: none; }
.spinner { width: 1rem; height: 1rem; border: 2px solid var(--gold-line); border-top-color: var(--gold-dark); border-radius: 50%; animation: q-spin .8s linear infinite; flex: none; }
@keyframes q-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.banner { margin: .5rem .8rem; padding: .55rem .8rem; border-radius: 6px; font-size: .88rem; display: flex; gap: .5rem; align-items: flex-start; }
.banner ul { margin: 0; padding-left: 1.1rem; }
.ok-banner { background: #e9f4ea; color: var(--ok); border: 1px solid #c9e2cd; }
.err-banner { background: #fdeceb; color: var(--err); border: 1px solid #f1c6c3; }
.peek-banner { background: var(--gold-soft); color: var(--gold-dark); border: 1px solid var(--gold-line); }
.muted { color: var(--ink-soft); }

/* ---- Leseansicht ---- */
.reader { display: flex; flex-direction: column; min-height: 100%; }
.reader-empty { margin: auto; text-align: center; color: var(--gold); display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.reader-empty p { color: var(--ink-soft); margin: 0; }
.reader-bar { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; padding: .45rem .7rem; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 2; }
.reader-bar .sep { width: 1px; height: 1.3rem; background: var(--line); margin: 0 .35rem; }
.move { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-soft); }
.move select { border: 1px solid var(--line); border-radius: 6px; padding: .25rem .35rem; font: inherit; font-size: .85rem; background: #fff; color: var(--ink); max-width: 11rem; }
.reader-head { padding: .9rem 1.25rem .4rem; }
.reader-head h2 { margin: 0 0 .4rem; font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.from-line { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: baseline; }
.from-line .addr { color: var(--ink-soft); font-size: .88rem; }
.from-line .when { margin-left: auto; color: var(--ink-soft); font-size: .84rem; }
.rcpt { font-size: .86rem; color: var(--ink-soft); margin-top: .2rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; overflow-wrap: anywhere; }
.rcpt > span:first-child { min-width: 4.2rem; }
.attachments { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: .4rem 1.25rem; margin: 0; }
.attachments a { display: inline-flex; gap: .35rem; align-items: center; border: 1px solid var(--gold-line); border-radius: 8px; padding: .25rem .6rem; text-decoration: none; color: var(--ink); background: #fff; font-size: .86rem; }
.attachments a:hover { background: var(--gold-soft); }
.attachments .sz { color: var(--ink-soft); font-size: .78rem; }
.attachments .fn { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-bar { display: flex; align-items: center; gap: .6rem; padding: .3rem 1.25rem; font-size: .82rem; flex-wrap: wrap; }
.mail-frame { flex: 1; width: 100%; min-height: 24rem; border: 0; border-top: 1px solid var(--line); background: #fff; }
.plain-body { margin: 0; padding: 1rem 1.25rem 2rem; white-space: pre-wrap; overflow-wrap: anywhere; font: 14.5px/1.55 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; border-top: 1px solid var(--line); background: #fff; flex: 1; }

/* ---- Verfassen ---- */
.compose { max-width: 62rem; margin: 0 auto; padding: .75rem 1rem 3rem; height: 100%; overflow-y: auto; box-sizing: border-box; }
.compose-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.compose-head h1 { font-size: 1.2rem; margin: 0; }
.compose-form { margin-top: .5rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.compose-form .row { display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid var(--line); padding: 0 .8rem; }
.compose-form .row label { width: 4rem; color: var(--ink-soft); font-size: .88rem; flex: none; }
.compose-form .row input, .compose-form .row select { flex: 1; border: 0; outline: none; padding: .6rem 0; font: inherit; background: none; color: var(--ink); min-width: 0; }
.compose-form .row:focus-within { background: #fffdf5; }
.ccbtns { display: flex; gap: .6rem; }
.editor-host { min-height: 22rem; }
.editor-host .tox-tinymce { border: 0 !important; border-radius: 0 0 8px 8px; }
.editor-loading { padding: 1rem; }
.small-note { font-size: .8rem; padding: 0 .8rem .6rem; margin: 0; }
.compose-actions { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; flex-wrap: wrap; }
.compose-actions .grow { flex: 1; }

.only-narrow { display: none; }

/* Dialog „Neuer Ordner“ / „Ordner löschen“ */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(20, 16, 8, .35); z-index: 50; }
.folder-dialog { position: fixed; z-index: 51; left: 50%; top: 18vh; transform: translateX(-50%); width: min(26rem, calc(100vw - 2rem));
    background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 1.1rem 1.2rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.folder-dialog h2 { font-size: 1.05rem; margin: 0; overflow-wrap: anywhere; }
.folder-dialog p { margin: 0; font-size: .92rem; }
.folder-dialog .dialog-sub { color: var(--ink-soft); font-size: .86rem; overflow-wrap: anywhere; }
.folder-dialog input { font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; box-sizing: border-box; }
.folder-dialog input:focus { outline: 2px solid var(--gold-line); border-color: var(--gold); }
.folder-dialog .dialog-err { color: var(--err); font-size: .88rem; }
.folder-dialog .dialog-actions { display: flex; align-items: center; gap: .8rem; margin-top: .2rem; }
.folder-dialog .link { background: none; color: var(--gold-dark); padding: 0; text-decoration: underline; font-size: inherit; border: 0; cursor: pointer; }
.btn-primary.danger { background: var(--err); }
.btn-primary.danger:hover { background: #8a2020; }

/* ---- Schmale Bildschirme: eine Spalte, Baum als Schublade ---- */
@media (max-width: 1100px) {
    .mail-app { grid-template-columns: 15rem minmax(0, 1fr); }
    .mail-reader { grid-column: 1 / -1; display: none; }
    .mail-app.has-msg .mail-list { display: none; }
    .mail-app.has-msg .mail-reader { display: flex; grid-column: 2; }
    .only-narrow { display: inline-flex; }
}
@media (max-width: 720px) {
    .mail-app { grid-template-columns: minmax(0, 1fr); position: relative; }
    .mail-tree { display: none; position: absolute; inset: 0 25% 0 0; z-index: 10; box-shadow: 4px 0 16px rgba(0,0,0,.18); }
    .mail-app.tree-open .mail-tree { display: block; }
    .mail-app.has-msg .mail-reader { grid-column: 1; }
    .reader-head { padding: .7rem .8rem .3rem; }
    .from-line .when { margin-left: 0; }
    .compose-form .row label { width: 3.2rem; }
}


/* Anhänge im Verfassen-Dialog */
.attach-box { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .4rem .8rem .6rem; }
.attach-box .small-note { padding: 0; }
.compose-attachments { width: 100%; padding: 0; }
.compose-attachments .chip { display: inline-flex; gap: .35rem; align-items: center; border: 1px solid var(--gold-line); border-radius: 8px; padding: .2rem .3rem .2rem .6rem; background: #fff; font-size: .86rem; }
.compose-attachments .chip-x { background: none; border: 0; cursor: pointer; color: var(--ink-soft); display: inline-flex; padding: .15rem; border-radius: 4px; }
.compose-attachments .chip-x:hover { background: var(--gold-soft); color: var(--err); }
.attach-pick { position: relative; overflow: hidden; border-color: var(--line); }
.attach-pick.disabled { opacity: .5; pointer-events: none; }
.attach-pick .attach-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.forward-attachments { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; width: 100%; }
.forward-attachments .chip { display: inline-flex; gap: .35rem; align-items: center; border: 1px solid var(--gold-line); border-radius: 8px; padding: .2rem .6rem; background: #fff; font-size: .86rem; cursor: pointer; }

/* Rechtschreibung unter dem Editor (T7) */
.spell-panel { margin-top: .5rem; font-size: .9rem; }
.spell-panel .spell-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spell-panel ul { list-style: none; padding: 0; margin: .4rem 0 0; }
.spell-panel li { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .15rem 0; }
.spell-panel li strong { color: var(--ink); }

.spam-why { margin-top: .4rem; font-size: .86rem; color: var(--ink); }
.spam-why summary { cursor: pointer; color: var(--err); }
.spam-why ul { margin: .3rem 0 0; padding-left: 1.2rem; }
