/* Mail crisis triage overlay */
#email-client {
    position: fixed;
    inset: 0;
    z-index: 50;
}

#email-client.email-hidden {
    display: none;
}

#email-client img {
    display: block;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

#email-client strong,
#email-client h2,
#email-client h3 {
    color: inherit;
}

.email-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 24% 18%, rgba(25, 57, 82, 0.44), transparent 30%),
        linear-gradient(135deg, rgba(6, 17, 28, 0.88), rgba(3, 7, 18, 0.82));
    backdrop-filter: blur(2px);
}

.email-window {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(1180px, 94vw);
    height: min(760px, 86vh);
    min-width: 720px;
    min-height: 520px;
    background:
        radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 5px),
        radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.09), transparent 38%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent 32%),
        #06111c;
    color: #111827;
    border: 3px solid #050505;
    border-radius: 4px;
    overflow: hidden;
    display: grid;
    grid-template-rows: 66px minmax(0, 1fr);
    box-shadow: 7px 7px 0 #050505, 0 28px 80px rgba(0, 0, 0, 0.78),
                inset 0 0 0 1px rgba(255, 255, 255, 0.07);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.email-header {
    min-width: 0;
    padding: 0 14px 0 20px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    border-bottom: 3px solid #050505;
    background:
        radial-gradient(circle at 72% 48%, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 7px),
        radial-gradient(circle at 18% 24%, rgba(56, 189, 248, 0.12), transparent 36%),
        linear-gradient(180deg, #0b2639 0%, #06111c 100%);
}

.email-title {
    color: #f8e7bb;
    font-size: 21px;
    font-weight: 950;
    font-style: italic;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    padding: 7px 12px;
    border: 2px solid #050505;
    background: #f0b429;
    color: #111827;
    box-shadow: 3px 3px 0 #050505;
    transform: skew(-6deg);
}

.email-player {
    display: none;
}

.email-toolbar {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(250px, auto) minmax(170px, 280px);
    justify-content: end;
    align-items: center;
    gap: 12px;
}

.email-view-buttons {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 6px;
}

.email-folder {
    min-width: 92px;
    border: 2px solid #050505;
    border-radius: 3px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
        #071726;
    color: #dbeafe;
    box-shadow: 2px 2px 0 #050505, inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    font: inherit;
    font-size: 12px;
    font-weight: 950;
    line-height: 1;
    padding: 11px 12px;
    cursor: pointer;
    text-transform: uppercase;
    transform: skew(-3deg);
    transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.email-folder:hover,
.email-folder:focus-visible {
    transform: skew(-3deg) translate(-1px, -1px);
    background: #123a55;
    color: #ffffff;
    outline: none;
    box-shadow: 3px 3px 0 #050505;
}

.email-folder.active {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent),
        #f0b429;
    color: #111827;
}

.email-search {
    height: 40px;
    min-width: 0;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border: 2px solid #050505;
    border-radius: 3px;
    background:
        radial-gradient(circle at 18% 20%, rgba(5, 5, 5, 0.035) 0 1px, transparent 1px 6px),
        #f8edd6;
    box-shadow: 2px 2px 0 #050505;
    transform: skew(-2deg);
}

.email-search-icon {
    width: 22px;
    height: 22px;
    background: url("../resources/mail/icon-mail-search.png") center / contain no-repeat;
}

.email-search input {
    min-width: 0;
    border: 0;
    background: transparent;
    color: #111827;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    outline: none;
    transform: skew(2deg);
}

.email-close {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 0;
    background: url("../resources/general/button-general-close.png") center / contain no-repeat;
    color: transparent;
    box-shadow: none;
    cursor: pointer;
    font-size: 27px;
    font-weight: 950;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.email-close:hover,
.email-close:focus-visible {
    transform: translate(-1px, -1px);
    outline: none;
    filter: brightness(1.08);
}

.email-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(320px, 35%) minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    overflow: hidden;
    background:
        radial-gradient(circle at 80% 18%, rgba(240, 180, 41, 0.06), transparent 30%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 42%),
        #06111c;
}

.email-sidebar {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border: 2px solid #050505;
    border-radius: 3px;
    background:
        radial-gradient(circle at 18% 22%, rgba(5, 5, 5, 0.045) 0 1px, transparent 1px 6px),
        radial-gradient(circle at 80% 52%, rgba(5, 5, 5, 0.028) 0 1px, transparent 1px 8px),
        linear-gradient(175deg, transparent 0 54%, rgba(5, 5, 5, 0.025) 54% 55%, transparent 55% 100%),
        radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.38), transparent 18%),
        linear-gradient(90deg, rgba(5, 5, 5, 0.025), transparent 22%),
        #f7edd8;
    box-shadow: 3px 3px 0 rgba(5, 5, 5, 0.84), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.email-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 0 18px;
    border-bottom: 2px solid rgba(5, 5, 5, 0.72);
    background:
        radial-gradient(circle at 24% 28%, rgba(5, 5, 5, 0.03) 0 1px, transparent 1px 6px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent),
        #f0e3c9;
}

.email-list-header h3 {
    margin: 0;
    color: #111827;
    font-size: 19px;
    font-weight: 950;
    text-transform: uppercase;
}

.email-list-header span {
    color: #374151;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.email-list {
    min-height: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}

.email-list-item {
    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    padding: 9px 11px 10px 11px;
    border: 0;
    border-bottom: 1px solid rgba(5, 5, 5, 0.5);
    background:
        radial-gradient(circle at 82% 22%, rgba(5, 5, 5, 0.034) 0 1px, transparent 1px 6px),
        linear-gradient(90deg, rgba(5, 5, 5, 0.02), transparent 20%),
        radial-gradient(circle at 10% 18%, rgba(5, 5, 5, 0.026) 0 1px, transparent 1px 6px),
        #fff7e8;
    color: #111827;
    cursor: pointer;
    transition: background 0.14s ease, box-shadow 0.14s ease;
}

.email-list-item:hover,
.email-list-item:focus-visible {
    background: #eef6fa;
    outline: none;
}

.email-list-item.active {
    background:
        radial-gradient(circle at 12% 18%, rgba(5, 5, 5, 0.025) 0 1px, transparent 1px 6px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.22), transparent 34%),
        #d4e6ee;
    box-shadow: inset 0 0 0 2px rgba(14, 116, 144, 0.9), inset 5px 0 0 #1d9fd3;
}

.email-list-item.unread .email-list-from,
.email-list-item.unread .email-list-subject {
    font-weight: 950;
}

.email-list-item.unread::after {
    content: "";
    position: absolute;
    left: 10px;
    bottom: 9px;
    width: 9px;
    height: 9px;
    border: 2px solid #050505;
    border-radius: 50%;
    background: #dc2626;
}

.email-list-item.priority-urgent {
    background:
        radial-gradient(circle at 82% 22%, rgba(5, 5, 5, 0.034) 0 1px, transparent 1px 6px),
        linear-gradient(90deg, rgba(5, 5, 5, 0.02), transparent 20%),
        radial-gradient(circle at 10% 18%, rgba(5, 5, 5, 0.026) 0 1px, transparent 1px 6px),
        #fff7e8;
}

.email-list-item.priority-important {
    background:
        radial-gradient(circle at 82% 22%, rgba(5, 5, 5, 0.034) 0 1px, transparent 1px 6px),
        linear-gradient(90deg, rgba(5, 5, 5, 0.02), transparent 20%),
        radial-gradient(circle at 10% 18%, rgba(5, 5, 5, 0.026) 0 1px, transparent 1px 6px),
        #fff7e8;
}

.email-source-icon {
    width: 25px;
    height: 25px;
    align-self: start;
    object-fit: contain;
    filter: none;
}

.email-list-main {
    min-width: 0;
}

.email-list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
}

.email-list-from {
    overflow: hidden;
    color: #111827;
    font-size: 12px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-list-from span,
.email-list-from small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-list-from small {
    margin-top: 1px;
    color: #4b5563;
    font-size: 10px;
    font-weight: 760;
}

.email-list-time {
    display: block;
    color: #111827;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.15;
    text-align: right;
    white-space: nowrap;
}

.email-list-time span,
.email-list-time small {
    display: block;
}

.email-list-time small {
    margin-top: 2px;
    color: #5b6470;
    font-size: 9px;
    font-weight: 760;
}

.email-list-subject {
    overflow: hidden;
    margin-top: 4px;
    color: #111827;
    font-size: 12px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-list-subject-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.email-list-snippet {
    overflow: hidden;
    margin-top: 3px;
    color: #374151;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-priority-icon {
    display: block;
    width: auto;
    height: 22px;
    max-width: 86px;
    margin: 0;
    object-fit: contain;
}

.email-list-empty {
    padding: 30px 18px;
    color: #374151;
    font-size: 14px;
    font-weight: 750;
    text-align: center;
}

.email-pane {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 20px 20px 20px;
    background:
        radial-gradient(circle at 20% 18%, rgba(5, 5, 5, 0.042) 0 1px, transparent 1px 6px),
        radial-gradient(circle at 76% 64%, rgba(5, 5, 5, 0.026) 0 1px, transparent 1px 8px),
        linear-gradient(176deg, transparent 0 47%, rgba(5, 5, 5, 0.026) 47% 48%, transparent 48% 100%),
        radial-gradient(circle at 14% 6%, rgba(255, 255, 255, 0.55), transparent 20%),
        linear-gradient(90deg, rgba(5, 5, 5, 0.025), transparent 22%),
        #f5ead3;
    color: #111827;
    border: 2px solid #050505;
    border-radius: 3px;
    box-shadow: 3px 3px 0 rgba(5, 5, 5, 0.82), 0 12px 26px rgba(0, 0, 0, 0.22);
}

.email-back {
    display: none;
}

.email-subject {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 16px 14px 16px;
    padding: 4px 0 12px 0;
    border: 0;
    border-bottom: 2px solid rgba(17, 24, 39, 0.86);
    background: transparent;
    color: #050505;
    font-size: clamp(17px, 1.42vw, 22px);
    font-weight: 950;
    line-height: 1.2;
    word-break: break-word;
}

#email-client .email-subject {
    color: #050505;
}

.email-detail-priority {
    flex: 0 0 auto;
    width: auto;
    height: 28px;
    max-width: 112px;
    object-fit: contain;
}

.email-meta {
    margin-bottom: 20px;
    padding: 0 16px;
}

.email-meta-card {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 12px;
    padding: 0 0 16px 0;
    border-bottom: 1px solid rgba(17, 24, 39, 0.8);
}

.email-meta-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.email-meta-content {
    min-width: 0;
    color: #111827;
}

.email-meta-row {
    display: flex;
    gap: 7px;
    margin-bottom: 5px;
    color: #111827 !important;
    font-size: 13px;
    font-weight: 720;
}

.email-meta-party {
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 16px;
}

.email-meta-party strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #050505 !important;
}

#email-client .email-meta-party strong,
#email-client .email-sensitive strong,
#email-client .email-attachment strong {
    color: #050505;
}

.email-meta-party time {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 850;
}

.email-meta-label {
    flex: 0 0 auto;
    color: #374151;
    font-weight: 950;
}

.email-meta-value {
    min-width: 0;
    overflow-wrap: anywhere;
}

.email-content {
    max-width: 76ch;
    margin: 0 16px;
    color: #111827;
    font-size: 15px;
    font-weight: 520;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.email-message-text {
    white-space: pre-wrap;
}

.email-signature {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.22);
    color: #334155;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.email-empty-state {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 15px;
    font-style: italic;
}

.email-attachments {
    margin: 24px 16px 0 16px;
    padding: 13px;
    border: 1px solid rgba(5, 5, 5, 0.56);
    background: rgba(255, 250, 240, 0.72);
}

.email-attachments[hidden] {
    display: none;
}

.email-attachments h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 950;
    text-transform: uppercase;
}

.email-attachment-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.email-attachment {
    min-width: 0;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid rgba(5, 5, 5, 0.75);
    background: #fffaf0;
}

.email-attachment img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.email-attachment strong {
    display: block;
    overflow: hidden;
    color: #111827;
    font-size: 12px;
    font-weight: 950;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-attachment small {
    display: block;
    margin-top: 3px;
    color: #374151;
    font-size: 11px;
    font-weight: 750;
}

.email-download-icon {
    width: 22px;
    height: 22px;
    background: url("../resources/mail/icon-mail-download.png") center / contain no-repeat;
}

.email-attachment-openable {
    cursor: pointer;
}

.email-attachment-openable:hover,
.email-attachment-openable:focus-visible {
    background: #fff3d6;
}

#email-attachment-viewer {
    position: fixed;
    inset: 0;
    z-index: 60;
}

#email-attachment-viewer.email-attachment-viewer-hidden {
    display: none;
}

.email-attachment-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
}

.email-attachment-viewer-window {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.75);
}

.email-attachment-viewer-window img {
    display: block;
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 4px;
}

.email-pdf-viewer {
    width: min(80vw, 860px);
    max-height: 85vh;
    overflow-y: auto;
    background: #525659;
    border-radius: 4px;
    padding: 12px;
    box-sizing: border-box;
}

.email-pdf-pages canvas {
    display: block;
    margin: 0 auto 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    max-width: 100%;
}

.email-attachment-viewer-caption {
    color: #e8eaed;
    font-size: 13px;
    font-weight: 600;
}

.email-attachment-viewer-close {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2d2e30;
    color: #e8eaed;
    border: 1px solid #3c4043;
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
    transition: background 0.15s ease, color 0.15s ease;
}

.email-attachment-viewer-close:hover {
    background: #3c4043;
    color: #ffffff;
}

.email-sensitive {
    margin: 20px 16px 0 16px;
    padding: 10px 12px 10px 40px;
    border: 1px solid rgba(159, 47, 19, 0.7);
    background:
        url("../resources/general/icon-general-warning.png") 10px 50% / 22px 22px no-repeat,
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent),
        #f5decf;
    color: #111827;
    font-size: 12px;
    font-weight: 760;
}

.email-sensitive[hidden] {
    display: none;
}

@media screen and (max-width: 720px) {
    .email-window {
        width: min(430px, 94vw);
        height: min(820px, 92vh);
        min-width: 0;
        min-height: 0;
        grid-template-rows: auto minmax(0, 1fr);
        border-width: 6px;
        border-radius: 34px;
        background:
            radial-gradient(110% 70% at 50% 0%, rgba(56, 189, 248, 0.13), transparent 60%),
            #06111c;
        box-shadow: 7px 7px 0 #050505, 0 24px 70px rgba(0, 0, 0, 0.82),
                    inset 0 0 0 4px rgba(255, 255, 255, 0.06);
    }

    .email-window::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 13px;
        z-index: 1;
        width: 78px;
        height: 9px;
        transform: translateX(-50%);
        border-radius: 999px;
        background: #050505;
    }

    .email-header {
        position: relative;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "title close"
            "toolbar toolbar";
        gap: 12px;
        padding: 36px 18px 12px 18px;
        background: #071726;
        border-bottom-width: 4px;
    }

    .email-title {
        grid-area: title;
        justify-self: center;
        margin-left: 42px;
        color: #ffffff;
        font-size: 17px;
        font-style: normal;
    }

    .email-toolbar {
        grid-area: toolbar;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .email-view-buttons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: initial;
    }

    .email-folder {
        min-width: 0;
        padding: 11px 6px;
        font-size: 11px;
        box-shadow: none;
    }

    .email-search {
        height: 36px;
        box-shadow: none;
    }

    .email-close {
        grid-area: close;
        width: 36px;
        height: 36px;
        box-shadow: none;
        font-size: 23px;
    }

    .email-body {
        position: relative;
        display: block;
        min-height: 0;
        overflow: hidden;
        background: #fffaf0;
    }

    .email-sidebar,
    .email-pane {
        position: absolute;
        inset: 0;
        border: 0;
    }

    .email-sidebar {
        z-index: 1;
        background: #fffaf0;
    }

    .email-pane {
        z-index: 2;
        display: none;
        padding: 16px 18px 22px 18px;
    }

    #email-client.email-detail-open .email-pane {
        display: block;
    }

    #email-client.email-detail-open .email-sidebar {
        display: none;
    }

    .email-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin: 0 0 14px 0;
        padding: 9px 13px;
        border: 3px solid #050505;
        border-radius: 3px;
        background: #071726;
        color: #dbeafe;
        font: inherit;
        font-size: 12px;
        font-weight: 950;
        text-transform: uppercase;
    }

    .email-list-header {
        min-height: 48px;
        padding: 0 15px;
    }

    .email-list-header h3 {
        font-size: 16px;
    }

    .email-list-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 9px;
        padding: 10px 12px 11px 12px;
    }

    .email-source-icon {
        width: 24px;
        height: 24px;
    }

    .email-list-from {
        font-size: 13px;
    }

    .email-list-subject {
        font-size: 12px;
    }

    .email-list-snippet {
        font-size: 11px;
    }

    .email-subject {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 10px;
        margin: 0 0 14px 0;
        font-size: 19px;
    }

    .email-detail-priority {
        display: block;
        justify-self: end;
        margin-top: 0;
    }

    .email-meta-card {
        grid-template-columns: 30px minmax(0, 1fr);
    }

    .email-meta-icon {
        width: 27px;
        height: 27px;
    }

    .email-content {
        font-size: 14px;
        line-height: 1.55;
    }

    .email-attachment-grid {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 720px) {
    .email-window {
        width: 100vw;
        height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
}
