: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-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; }
.btn-nav {
    padding: 0;
    background: #f3f4f6;
    color: #374151;
    width: 34px;
    height: 34px;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-nav:hover { background: #e5e7eb; }

.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); }

/* ── Attachments ── */
.attachment-list {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}
.attachment-title {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 7px 12px;
    margin: 0 8px 8px 0;
    text-decoration: none;
    color: #374151;
    font-size: 13.5px;
    transition: background .15s, border-color .15s;
}
.attachment-item:hover { background: #e5e7eb; border-color: var(--c1); }
.att-icon { font-size: 18px; }
.att-name { font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: #9ca3af; font-size: 12px; }
.att-dl   { color: var(--c1); font-size: 16px; margin-left: 2px; }

/* ── File input ── */
.file-input { display: block; width: 100%; padding: 8px 0; font-size: 14px; }
.file-hint  { font-size: 12px; color: #9ca3af; margin-top: 4px; }

/* ── Hamburger ── */
.hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    backdrop-filter: blur(6px);
}
.sidebar-close {
    display: none;
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 201;
    background: none;
    border: none;
    font-size: 20px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    text-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* ── Mobile responsive ── */
/* ══════════════════════════════════════════
   MOBILE  –  Hochformat  (≤ 700 px breit)
   ══════════════════════════════════════════ */
@media (max-width: 700px) {
    .hamburger     { display: block; }
    .sidebar-close { display: block; }

    .app { display: block; }

    /* Sidebar als Slide-in-Overlay */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 82vw;
        max-width: 300px;
        height: 100dvh;          /* dynamic viewport height */
        z-index: 150;
        transform: translateX(-110%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,.28);
        /* Canvas auf Mobile deaktivieren – stattdessen CSS-Gradient */
        background: linear-gradient(160deg,
            rgb(90,140,165) 0%,
            rgb(80,110,150) 40%,
            rgb(70,140,80)  100%);
        overflow: hidden;
    }
    .sidebar.sidebar-open { transform: translateX(0); }

    /* Canvas ausblenden – Gradient reicht auf Mobile */
    .sidebar #sidebar-bg { display: none; }

    /* Sidebar-Inhalt voll scrollbar */
    .sidebar-content {
        height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Abdunkel-Overlay hinter der Sidebar */
    body.sidebar-visible::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.40);
        z-index: 140;
    }

    /* Hauptbereich */
    .main {
        padding: 52px 10px 16px;
        overflow-x: hidden;
        min-height: 100dvh;
    }

    /* ── Mail-Liste: kompakte Cards ── */
    .message-list { display: block; background: transparent; box-shadow: none; }
    .msg-header   { display: none; }

    .message-item {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0 8px;
        padding: 8px 10px 8px 12px;
        margin-bottom: 5px;
        border: 1px solid #e5e7eb;
        border-radius: 9px;
        background: #fff;
        position: relative;
        min-height: 0;         /* aufheben */
    }
    .message-item.unread { border-left: 3px solid var(--c1); }
    .message-item.unread::before { display: none; } /* Punkt entfernen */

    /* Spalten neu verdrahten */
    .msg-from {
        grid-column: 1; grid-row: 1;
        padding: 0;
        font-size: 13px;
        font-weight: 600;
        color: #111827;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .msg-date {
        grid-column: 2; grid-row: 1;
        padding: 0;
        font-size: 11px;
        color: #9ca3af;
        text-align: right;
        white-space: nowrap;
    }
    .msg-subject {
        grid-column: 1 / 3; grid-row: 2;
        padding: 0;
        font-size: 12.5px;
        color: #6b7280;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 2px;
    }
    .message-item.unread .msg-subject { color: #374151; }

    /* Löschen-Icon: rechts oben als 3. Spalte simuliert */
    .msg-delete {
        grid-column: 2; grid-row: 2;
        opacity: 1;
        position: static;
        align-self: end;
        justify-self: end;
        width: 24px; height: 24px;
        margin-top: 2px;
    }
    .msg-delete svg { width: 13px; height: 13px; }

    /* Inbox-Header */
    .inbox-header { flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 10px; }
    .inbox-header h1 { font-size: 19px; }

    /* E-Mail-Ansicht */
    .email-actions { flex-wrap: wrap; gap: 5px; padding-bottom: 6px; }
    .email-header h2 { font-size: 16px; }
    .email-meta { flex-direction: column; gap: 3px; font-size: 13px; }

    /* Compose */
    .compose-view { padding: 8px 0; }
    .form-actions { flex-direction: column; gap: 8px; }
    .form-actions .btn { width: 100%; justify-content: center; }

    /* Anhänge */
    .attachment-item { font-size: 12.5px; padding: 6px 10px; }
    .att-name { max-width: 140px; }
}

/* ══════════════════════════════════════════
   MOBILE  –  Querformat  (≤ 900 px, Landscape)
   ══════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .hamburger { display: block; }

    .app { display: flex; }   /* bleibt nebeneinander */

    /* Sidebar schmal & scrollbar */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 200px;
        min-width: 200px;
        height: 100dvh;
        z-index: 150;
        transform: translateX(-110%);
        transition: transform .25s cubic-bezier(.4,0,.2,1);
        background: linear-gradient(160deg,
            rgb(90,140,165) 0%,
            rgb(80,110,150) 40%,
            rgb(70,140,80)  100%);
        overflow: hidden;
    }
    .sidebar #sidebar-bg { display: none; }
    .sidebar.sidebar-open { transform: translateX(0); }
    .sidebar-content {
        height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-close { display: block; }

    body.sidebar-visible::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 140;
    }

    /* Hauptbereich: kleiner Top-Abstand wegen geringer Höhe */
    .main {
        padding: 48px 18px 12px;
        overflow-x: hidden;
    }

    /* Mail-Liste: zwei-zeilige kompakte Cards wie Hochformat */
    .message-list { display: block; background: transparent; box-shadow: none; }
    .msg-header   { display: none; }
    .message-item {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0 8px;
        padding: 6px 10px 6px 12px;
        margin-bottom: 4px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff;
        min-height: 0;
    }
    .message-item.unread { border-left: 3px solid var(--c1); }
    .message-item.unread::before { display: none; }
    .msg-from    { grid-column:1; grid-row:1; padding:0; font-size:13px; font-weight:600; color:#111827; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .msg-date    { grid-column:2; grid-row:1; padding:0; font-size:11px; color:#9ca3af; text-align:right; white-space:nowrap; }
    .msg-subject { grid-column:1/3; grid-row:2; padding:0; font-size:12px; color:#6b7280; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:1px; }
    .msg-delete  { grid-column:2; grid-row:2; opacity:1; position:static; align-self:end; justify-self:end; width:22px; height:22px; margin-top:2px; }
    .msg-delete svg { width:12px; height:12px; }

    /* Inbox-Header kompakter */
    .inbox-header { gap: 4px; margin-bottom: 8px; }
    .inbox-header h1 { font-size: 17px; }

    /* E-Mail-Ansicht */
    .email-actions { flex-wrap: wrap; gap: 4px; }
    .email-header h2 { font-size: 15px; }
    .email-meta { flex-direction: row; flex-wrap: wrap; gap: 6px; font-size: 12px; }

    /* Compose kompakter */
    .form-group { margin-bottom: 10px; }
    .form-group textarea { min-height: 80px; }
}
