:root {
    --c1:     rgb(119, 170, 192);
    --c2:     rgb(170, 119, 192);
    --c3:     rgb(192, 119, 170);
    --c1-dim: rgb( 68, 118, 140);
    --c2-dim: rgb(112,  68, 140);
    --c3-dim: rgb(140,  68, 112);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #ede8f8 0%, #e4eff7 100%);
    color: #1f2937;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
    gap: 0;
}

/* ── Sidebar ── */
.sidebar {
    width: 248px;
    min-width: 248px;
    position: relative;
    overflow: hidden;
    height: 100vh;
    flex-shrink: 0;
    /* saubere rechte Kante – kein Spalt, keine schiefe Linie */
    box-shadow: 2px 0 8px rgba(0,0,0,.12);
    z-index: 10;
}

#sidebar-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
}

.sidebar-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 22px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.22);
    backdrop-filter: blur(4px);
}

.logo {
    font-size: 14.5px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.45);
    display: flex;
    align-items: flex-start;
    gap: 7px;
    line-height: 1.3;
}

.user-email {
    font-size: 11px;
    color: rgba(255,255,255,.85);
    text-shadow: 0 1px 3px rgba(0,0,0,.4);
    word-break: break-all;
    margin-top: 5px;
}

.compose-btn {
    display: block;
    margin: 14px 12px;
    padding: 10px 0;
    background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3));
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    transition: opacity .2s;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.compose-btn:hover { opacity: .86; }

.folder-label {
    padding: 8px 10px 4px;
    margin: 4px 8px 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #fff;
    background: rgba(0,0,0,.28);
    backdrop-filter: blur(4px);
    border-radius: 5px;
    text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    color: rgba(255,255,255,.88);
    text-shadow: 0 1px 3px rgba(0,0,0,.35);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 7px;
    margin: 1px 8px;
    transition: background .14s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.folder-item:hover  { background: rgba(255,255,255,.22); color: #fff; }
.folder-item.active {
    background: rgba(255,255,255,.32);
    color: #fff;
    border-left-color: #fff;
    font-weight: 600;
    padding-left: 13px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.22);
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(4px);
}
.logout-link {
    color: rgba(255,255,255,.80);
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
    text-decoration: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.logout-link:hover { color: #fff; }

/* ── Main ── */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ── Alerts ── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Inbox ── */
.inbox-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}
.inbox-header h1 { font-size: 22px; font-weight: 700; }
.msg-count { color: #6b7280; font-size: 14px; }

.message-list {
    --w-from: 200px;
    --w-date: 88px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

/* ── Spalten-Header ── */
.msg-header {
    display: grid;
    grid-template-columns: var(--w-from) 1fr var(--w-date) 36px;
    align-items: center;
    gap: 10px;
    padding: 0 14px 0 22px;
    background: #f5f2fc;
    border-bottom: 2px solid #e8dff5;
    position: sticky;
    top: 0;
    z-index: 2;
}

.mh-cell {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 8px 0;
    position: relative;
    white-space: nowrap;
    overflow: visible;
    user-select: none;
}
.mh-date { text-align: right; }

/* ── Resize-Handle ── */
.col-resizer {
    position: absolute;
    top: 0;
    width: 14px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
}
/* Resizer der Von-Spalte: rechte Kante */
.mh-from .col-resizer { right: -7px; }
/* Resizer der Datum-Spalte: linke Kante */
.mh-date .col-resizer { left: -7px; }

.col-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 18%;
    transform: translateX(-50%);
    width: 2px;
    height: 64%;
    background: #d1d5db;
    border-radius: 2px;
    transition: background .14s, width .14s;
}
.col-resizer:hover::after,
.col-resizer.active::after {
    background: var(--c2);
    width: 3px;
}

/* ── Mail-Zeilen ── */
.message-item {
    display: grid;
    grid-template-columns: var(--w-from) 1fr var(--w-date) 36px;
    align-items: center;
    gap: 10px;
    padding: 0 14px 0 22px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    transition: background .12s;
    position: relative;
    min-height: 48px;
}
.message-item:last-child { border-bottom: none; }
.message-item:hover { background: #faf7fd; }
.message-item:hover .msg-delete { opacity: 1; }
.message-item.unread { font-weight: 600; color: #111827; }
.message-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--c3);
    border-radius: 50%;
}

.msg-from, .msg-subject, .msg-date {
    text-decoration: none;
    color: inherit;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 14px 0;
}
.msg-from    { font-size: 13.5px; }
.msg-subject { font-size: 13.5px; color: #6b7280; }
.message-item.unread .msg-subject { color: #374151; }
.msg-date    { font-size: 12px; color: #9ca3af; text-align: right; white-space: nowrap; }

.msg-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    text-decoration: none;
    color: #c4b8d8;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
    flex-shrink: 0;
}
.msg-delete svg { width: 15px; height: 15px; display: block; }
.msg-delete:hover { background: #fee2e2; color: #dc2626; opacity: 1; }

.empty-state {
    text-align: center;
    padding: 70px;
    color: #9ca3af;
    font-size: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

/* ── Email View ── */
.email-view {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

.email-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.email-nav-group {
    display: flex;
    gap: 2px;
    margin-right: 4px;
}

.btn-nav {
    padding: 6px;
    border-radius: 7px;
    background: #f3f4f6;
    color: #374151;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-nav svg { width: 16px; height: 16px; display: block; }
.btn-nav:hover { background: #e5e7eb; }
.btn-nav-off {
    opacity: .3;
    cursor: default;
    pointer-events: none;
}

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all .15s;
    line-height: 1;
}
.btn-primary        { background: var(--c1); color: #fff; }
.btn-primary:hover  { background: var(--c1-dim); }
.btn-secondary      { background: #f3f4f6; color: #374151; }
.btn-secondary:hover{ background: #e5e7eb; }
.btn-danger         { background: #fee2e2; color: #dc2626; }
.btn-danger:hover   { background: #fecaca; }

.email-header {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e5e7eb;
}
.email-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 14px; line-height: 1.3; }
.email-meta { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #6b7280; }
.email-meta span { display: flex; gap: 6px; }
.email-meta strong { color: #374151; min-width: 44px; }

.email-body { font-size: 15px; line-height: 1.65; }
.email-iframe { width: 100%; border: none; min-height: 200px; display: block; }
.email-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 14.5px;
    color: #374151;
}

/* ── Compose ── */
.compose-view {
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    max-width: 820px;
}
.compose-view h1 { font-size: 22px; margin-bottom: 22px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #fff;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--c2);
    box-shadow: 0 0 0 3px rgba(170,119,192,.15);
}
.form-group textarea { resize: vertical; }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 22px;
}

/* ── Login page ── */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: auto;
    background: transparent;
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.80);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.65);
    border-radius: 18px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(60,30,100,.20), 0 2px 8px rgba(0,0,0,.08);
    overflow: hidden;
}

.login-banner {
    height: 5px;
    background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3));
}

.login-inner {
    padding: 38px 40px 44px;
}

.login-logo  { font-size: 44px; text-align: center; margin-bottom: 10px; }
.login-title {
    font-size: 21px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    color: #111827;
    line-height: 1.25;
}
.login-sub   { font-size: 13px; color: #6b7280; text-align: center; margin-bottom: 30px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.login-form input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 8px;
    font-size: 15px;
    background: rgba(255,255,255,.7);
    transition: border-color .15s;
    color: #111827;
}
.login-form input:focus {
    outline: none;
    border-color: var(--c2);
    background: rgba(255,255,255,.9);
    box-shadow: 0 0 0 3px rgba(170,119,192,.18);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(90deg, var(--c1), var(--c2));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 22px;
    transition: opacity .2s, transform .1s;
    box-shadow: 0 3px 12px rgba(170,119,192,.35);
}
.login-btn:hover  { opacity: .88; }
.login-btn:active { transform: scale(.98); }
