@font-face { font-family: Sora; src: url(fonts/Sora-Regular.ttf); font-weight: 400; }
@font-face { font-family: Sora; src: url(fonts/Sora-Medium.ttf); font-weight: 500; }
@font-face { font-family: Sora; src: url(fonts/Sora-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: Sora; src: url(fonts/Sora-Bold.ttf); font-weight: 700; }

:root {
    --bg: #06070a;
    --panel: #0b0d12;
    --card: #10131a;
    --card2: #151924;
    --line: rgba(255, 255, 255, .06);
    --line2: rgba(255, 255, 255, .11);
    --text: #e8ebf2;
    --muted: #8b93a7;
    --dim: #5b6377;
    --accent: #3b7bff;
    --accent2: #6b9dff;
    --accent-soft: rgba(59, 123, 255, .14);
    --danger: #ff5468;
    --ok: #2fd27a;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --back: cubic-bezier(.34, 1.56, .64, 1);
    --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 Sora, "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

/* ------------------------------------------------------------ Icons + Knöpfe */
.ic { display: inline-flex; flex: none; }
.ic svg { display: block; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line2);
    background: var(--card2); font-weight: 600; font-size: 13px; white-space: nowrap;
    transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .25s, opacity .2s;
}
.btn:hover { background: #1b2030; border-color: rgba(255, 255, 255, .16); }
.btn:active { transform: scale(.96); }
.btn.primary {
    background: linear-gradient(180deg, #4a87ff, #2f6bf0); border-color: transparent;
    box-shadow: 0 6px 22px -8px rgba(59, 123, 255, .8), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn.primary:hover { box-shadow: 0 8px 30px -8px rgba(59, 123, 255, 1), inset 0 1px 0 rgba(255, 255, 255, .28); filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255, 84, 104, .12); border-color: rgba(255, 84, 104, .35); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card2); color: var(--text); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.busy { pointer-events: none; color: transparent; position: relative; }
.btn.busy::after {
    content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite;
}

.icon-btn {
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
    transition: background .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--card2); color: var(--text); border-color: var(--line); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.spin .ic { animation: spin .8s var(--ease); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Felder */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input {
    height: 44px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line2);
    background: #0d1017; outline: none; width: 100%;
    transition: border-color .2s, box-shadow .25s, background .2s;
}
.input::placeholder { color: var(--dim); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #0f131c; }
textarea.input { height: auto; padding: 12px 14px; resize: none; line-height: 1.55; }
.input-suffix { display: flex; align-items: center; }
.input-suffix .input { border-radius: 11px 0 0 11px; }
.input-suffix span {
    height: 44px; display: flex; align-items: center; padding: 0 12px; color: var(--muted);
    border: 1px solid var(--line2); border-left: 0; border-radius: 0 11px 11px 0; background: var(--card);
    font-size: 13px; white-space: nowrap;
}
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--muted); }
.check input { display: none; }
.check .box {
    width: 38px; height: 22px; border-radius: 11px; background: #23293a; position: relative; transition: background .25s;
}
.check .box::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
    transition: transform .3s var(--back);
}
.check input:checked + .box { background: var(--accent); }
.check input:checked + .box::after { transform: translateX(16px); }

/* ------------------------------------------------------------ Hintergrund */
.backdrop { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.backdrop::before {
    content: ""; position: absolute; inset: -20%;
    background:
        radial-gradient(40% 35% at 15% 10%, rgba(59, 123, 255, .16), transparent 70%),
        radial-gradient(35% 30% at 90% 95%, rgba(59, 123, 255, .10), transparent 70%);
    animation: drift 18s ease-in-out infinite alternate;
}
.star { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: .0; animation: twinkle var(--d) ease-in-out infinite; animation-delay: var(--delay); }
@keyframes drift { to { transform: translate(3%, 2%) scale(1.05); } }
@keyframes twinkle { 0%, 100% { opacity: 0; } 50% { opacity: var(--o); } }

/* ------------------------------------------------------------ Login */
.login-wrap { position: relative; z-index: 1; height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 400px; padding: 34px 30px 28px; border-radius: 22px;
    background: linear-gradient(180deg, rgba(20, 24, 34, .92), rgba(12, 14, 20, .92));
    border: 1px solid var(--line2);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), 0 0 0 1px rgba(59, 123, 255, .05), 0 0 80px -40px rgba(59, 123, 255, .5);
    display: flex; flex-direction: column; gap: 16px;
    animation: rise .7s var(--back) both;
    backdrop-filter: blur(12px);
}
.login-card .logo { width: 68px; height: 68px; margin: 0 auto 2px; filter: drop-shadow(0 0 18px rgba(59, 123, 255, .65)); animation: float 4s ease-in-out infinite; }
.login-card h1 { margin: 0; text-align: center; font-size: 24px; letter-spacing: -.01em; }
.login-card h1 b { color: var(--accent); }
.login-card p { margin: -8px 0 6px; text-align: center; }
.login-card .btn { height: 46px; margin-top: 4px; }
.login-card > * { animation: rise .6s var(--ease) both; }
.login-card > *:nth-child(2) { animation-delay: .06s; }
.login-card > *:nth-child(3) { animation-delay: .1s; }
.login-card > *:nth-child(4) { animation-delay: .14s; }
.login-card > *:nth-child(5) { animation-delay: .18s; }
.login-card > *:nth-child(6) { animation-delay: .22s; }
.login-card > *:nth-child(7) { animation-delay: .26s; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.shake { animation: shake .45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes float { 50% { transform: translateY(-5px); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ------------------------------------------------------------ Layout */
.shell {
    position: relative; z-index: 1; height: 100%; display: grid;
    grid-template-columns: 240px minmax(300px, 400px) 1fr; animation: fade .4s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }

.side {
    display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; border-right: 1px solid var(--line);
    background: rgba(9, 11, 15, .7); min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(59, 123, 255, .6)); }
.brand b { color: var(--accent); font-weight: 700; }
.side .compose { margin-bottom: 12px; height: 44px; }

.folders { display: flex; flex-direction: column; gap: 2px; position: relative; }
.folder {
    position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px;
    border-radius: 10px; border: 0; background: transparent; color: var(--muted); text-align: left;
    font-weight: 500; transition: color .2s, background .2s;
}
.folder:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.folder.active { color: #fff; }
.folder .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .badge {
    min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff;
    animation: pop .4s var(--back);
}
.folder-glider {
    position: absolute; left: 0; right: 0; height: 40px; border-radius: 10px; background: var(--accent-soft);
    border: 1px solid rgba(59, 123, 255, .25); transition: transform .35s var(--back), opacity .2s; pointer-events: none;
}
.folder-glider::before {
    content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.user-card {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--card);
    border: 1px solid var(--line);
}
.user-card .who { min-width: 0; flex: 1; }
.user-card .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .who .n { font-weight: 600; font-size: 13px; }
.user-card .icon-btn { width: 32px; height: 32px; }

.avatar {
    flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; text-transform: uppercase;
    background: linear-gradient(135deg, hsl(var(--h) 75% 58%), hsl(calc(var(--h) + 40) 70% 42%));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

/* ------------------------------------------------------------ Liste */
.list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: rgba(8, 9, 13, .55); }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 10px; }
.list-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.search { position: relative; margin: 4px 14px 10px; }
.search .ic { position: absolute; left: 13px; top: 13px; color: var(--dim); pointer-events: none; }
.search .input { padding-left: 40px; height: 42px; }
.items { flex: 1; overflow-y: auto; padding: 4px 8px 16px; scrollbar-width: thin; scrollbar-color: #262c3b transparent; }
.item {
    position: relative; display: flex; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; transition: background .2s, border-color .2s, transform .2s var(--ease);
    animation: slideIn .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms);
}
.items.quiet .item { animation: none; }
.item:hover { background: rgba(255, 255, 255, .03); }
.item:active { transform: scale(.985); }
.item.active { background: var(--card2); border-color: var(--line2); }
.item .meta { flex: 1; min-width: 0; }
.item .row1 { display: flex; align-items: baseline; gap: 8px; }
.item .from { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.item .date { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.item .subj { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.item .subj span { overflow: hidden; text-overflow: ellipsis; }
.item.unread .from, .item.unread .subj { color: var(--text); font-weight: 600; }
.item.unread::before {
    content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.item.removing { animation: slideOut .3s var(--ease) forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; } }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--dim); text-align: center; padding: 40px 20px; animation: fade .5s both; }
.empty .ic { color: #2a3142; }
.more { margin: 8px auto 0; display: flex; }

.skeleton { height: 62px; margin: 4px 0; border-radius: 12px; background: linear-gradient(90deg, var(--card) 0%, #161a25 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ Leser */
.reader { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.msg { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 18px 24px 20px; gap: 14px; animation: readerIn .4s var(--ease) both; }
@keyframes readerIn { from { opacity: 0; transform: translateY(8px); } }
.msg-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.msg-actions .sep { width: 1px; height: 22px; background: var(--line2); margin: 0 6px; }
.msg-actions .back { display: none; }
.msg-subject { margin: 0; font-size: 21px; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.msg-from { display: flex; align-items: center; gap: 12px; }
.msg-from .who { flex: 1; min-width: 0; }
.msg-from .name { font-weight: 600; overflow-wrap: anywhere; }
.msg-from .addr { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 12.5px; }
.msg-from .to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; }
.att {
    display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding: 8px 12px; border-radius: 10px;
    background: var(--card); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 12.5px;
    transition: border-color .2s, background .2s, transform .15s; animation: rise .35s var(--ease) both;
}
.att:hover { border-color: rgba(59, 123, 255, .4); background: var(--card2); }
.att:active { transform: scale(.97); }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .sz { color: var(--dim); white-space: nowrap; }
.notice {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 12.5px;
    background: var(--accent-soft); border: 1px solid rgba(59, 123, 255, .25); color: #c8d7ff; animation: rise .35s var(--ease) both;
}
.notice button { margin-left: auto; background: none; border: 0; color: var(--accent2); font-weight: 600; padding: 2px 4px; }
.mail-frame { flex: 1; min-height: 200px; width: 100%; border: 0; border-radius: var(--radius); background: #fff; box-shadow: 0 10px 40px -20px #000; opacity: 0; transition: opacity .35s; }
.mail-frame.ready { opacity: 1; }

/* ------------------------------------------------------------ Modals */
.modal-back {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(3, 4, 7, 0); backdrop-filter: blur(0); transition: background .25s, backdrop-filter .25s;
}
.modal-back.open { background: rgba(3, 4, 7, .62); backdrop-filter: blur(6px); }
.modal {
    width: 100%; max-width: 440px; max-height: calc(100% - 32px); overflow: auto; border-radius: 18px; background: var(--panel);
    border: 1px solid var(--line2); box-shadow: 0 40px 100px -30px #000; transform: translateY(18px) scale(.94); opacity: 0;
    transition: transform .4s var(--back), opacity .25s;
}
.modal.wide { max-width: 720px; }
.modal-back.open .modal { transform: none; opacity: 1; }
.modal-back.closing .modal { transform: translateY(10px) scale(.97); opacity: 0; transition: transform .2s, opacity .2s; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 6px 22px; }
.modal-head h3 { margin: 0; flex: 1; font-size: 17px; }
.modal-body { padding: 12px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

.compose .row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.compose .row label { width: 56px; color: var(--muted); font-size: 12.5px; font-weight: 600; flex: none; }
.compose .row input { flex: 1; height: 42px; background: transparent; border: 0; outline: none; min-width: 0; }
.compose .row .toggle { background: none; border: 0; color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.compose .row .toggle:hover { color: var(--text); background: var(--card2); }
.compose textarea { min-height: 260px; border: 0; background: transparent; outline: none; resize: vertical; padding: 10px 0; line-height: 1.6; width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 8px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; animation: pop .3s var(--back); }
.chip button { border: 0; background: none; color: var(--muted); padding: 0; display: flex; }
.chip button:hover { color: var(--danger); }

.tabs { position: relative; display: flex; gap: 4px; padding: 4px; margin: 0 22px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.tabs button { position: relative; z-index: 1; flex: 1; height: 34px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; border-radius: 9px; transition: color .2s; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.tabs button.active { color: #fff; }
.tabs .glider { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 9px; background: var(--card2); border: 1px solid var(--line2); transition: transform .35s var(--back), width .35s var(--back); }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.card { border-radius: 14px; background: var(--card); border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.urow { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
.urow:last-child { border-bottom: 0; }
.urow .who { flex: 1; min-width: 0; }
.urow .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent2); margin-left: 6px; vertical-align: 1px; }
.tag.you { background: rgba(47, 210, 122, .12); color: var(--ok); }
.row-2 { display: flex; gap: 8px; align-items: flex-end; }
.row-2 > .field { flex: 1; min-width: 0; }
.row-2 > .btn, .row-2 > .icon-btn { height: 44px; flex: none; }
.row-2 > .icon-btn { width: 44px; border-color: var(--line2); background: var(--card2); }
.hint { font-size: 12px; color: var(--dim); }
.pw-meter { height: 4px; border-radius: 2px; background: #1c2130; overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: 2px; transition: width .35s var(--ease), background .35s; }

/* ------------------------------------------------------------ Toasts */
#toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 360px; padding: 12px 16px; border-radius: 12px;
    background: #121620; border: 1px solid var(--line2); box-shadow: 0 16px 40px -16px #000; font-size: 13px;
    animation: toastIn .45s var(--back) both;
}
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: var(--danger); }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.92); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ------------------------------------------------------------ Schmal */
@media (max-width: 1100px) {
    .shell { grid-template-columns: 76px minmax(280px, 360px) 1fr; }
    .side { padding: 16px 10px; align-items: stretch; }
    .brand span, .folder .label, .side .compose .txt, .user-card .who, .user-card .icon-btn.settings { display: none; }
    .brand { justify-content: center; padding: 4px 0 14px; }
    .folder { justify-content: center; padding: 0; }
    .folder .badge { position: absolute; top: 2px; right: 4px; min-width: 18px; height: 16px; font-size: 10px; padding: 0 5px; }
    .side .compose { padding: 0; }
    .user-card { flex-direction: column; padding: 8px 4px; gap: 6px; }
}
@media (max-width: 760px) {
    body { overflow: auto; }
    .shell { display: flex; flex-direction: column; height: 100%; }
    .side { flex-direction: row; align-items: center; gap: 4px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
    .brand { padding: 0 6px 0 0; }
    .folders { flex-direction: row; }
    .folder { width: 40px; }
    .folder-glider { display: none; }
    .folder.active { background: var(--accent-soft); }
    .side .compose { margin: 0; width: 40px; height: 40px; flex: none; }
    .side .grow { display: none; }
    .user-card { flex-direction: row; padding: 0; border: 0; background: none; margin-left: auto; }
    .list, .reader { flex: 1; min-height: 0; border: 0; }
    .shell[data-view="list"] .reader { display: none; }
    .shell[data-view="reader"] .list { display: none; }
    .msg { padding: 14px 14px 16px; }
    .msg-actions .back { display: inline-flex; }
    .modal { max-height: calc(100% - 16px); }
}
