* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f6f6f4;
    color: #181818;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app {
    height: 100vh;
    display: grid;
    grid-template-columns: 246px minmax(0, 1fr);
}

.sidebar {
    background: #111;
    color: white;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand strong,
.login-brand strong {
    display: block;
    letter-spacing: .08em;
}

.brand span,
.login-brand span {
    display: block;
    font-size: 11px;
    letter-spacing: .25em;
    opacity: .65;
}

.mark {
    height: 42px;
    min-width: 42px;
    border-radius: 11px;
    background: #f6c500;
    color: #111;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 12px;
}

.compose {
    margin: 28px 0 18px;
    display: block;
    background: #f6c500;
    color: #111;
    padding: 14px 18px;
    border-radius: 12px;
    font-weight: 800;
}

nav {
    overflow-y: auto;
}

nav a {
    padding: 10px 12px;
    border-radius: 9px;
    display: block;
    margin: 2px 0;
    color: #d6d6d6;
    font-size: 14px;
}

nav a:hover,
nav a.active {
    background: #252525;
    color: white;
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid #2b2b2b;
    padding-top: 16px;
    font-size: 12px;
}

.sidebar-bottom .user {
    color: #aaa;
    margin-bottom: 10px;
    overflow-wrap: anywhere;
}

.workspace {
    min-width: 0;
    height: 100vh;
    overflow-y: auto;
}

.topbar {
    height: 72px;
    background: white;
    border-bottom: 1px solid #e7e7e3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search {
    background: #f2f2ef;
    width: min(680px, 70%);
    border-radius: 12px;
    display: flex;
}

.search input {
    border: 0;
    outline: 0;
    background: transparent;
    padding: 13px 16px;
    width: 100%;
}

.search button {
    border: 0;
    background: transparent;
    padding: 0 16px;
    font-weight: 700;
}

.identity {
    font-size: 13px;
    color: #666;
}

.mail-list,
.message,
.compose-panel {
    margin: 26px;
    background: white;
    border-radius: 16px;
    border: 1px solid #e7e7e3;
    overflow: hidden;
}

.mail-list-heading,
.panel-heading {
    padding: 22px 24px;
    border-bottom: 1px solid #ecece8;
    display: flex;
    justify-content: space-between;
}

.mail-list-heading h1,
.panel-heading h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

.mail-list-heading span,
.panel-heading p {
    color: #777;
    font-size: 13px;
    margin: 0;
}

.mail-row {
    min-height: 62px;
    display: grid;
    grid-template-columns:
        40px
        minmax(170px, 240px)
        minmax(220px, 1fr)
        120px;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid #efefec;
    font-size: 14px;
}

.mail-row:hover {
    background: #fafaf7;
}

.mail-row.unread {
    background: #fffdf3;
    font-weight: 700;
}

.mail-star {
    color: #c99f00;
    font-size: 18px;
}

.mail-from,
.mail-subject {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mail-subject {
    color: #444;
}

.mail-meta {
    text-align: right;
    font-size: 12px;
    color: #777;
}

.message-toolbar {
    min-height: 60px;
    padding: 10px 20px;
    border-bottom: 1px solid #ecece8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toolbar-actions {
    display: flex;
    gap: 7px;
}

.toolbar-actions form {
    margin: 0;
}

.toolbar-actions button,
.message-toolbar > a {
    border: 1px solid #ddd;
    background: white;
    border-radius: 8px;
    padding: 8px 11px;
}

.message-header {
    padding: 28px 34px 18px;
}

.message-header h1 {
    margin: 0 0 24px;
    font-size: 25px;
}

.sender {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.sender span,
.recipients {
    color: #777;
    font-size: 13px;
}

.recipients {
    margin-top: 5px;
}

.mail-body {
    padding: 20px 34px 42px;
    line-height: 1.62;
    min-height: 250px;
    overflow-wrap: anywhere;
}

.attachments {
    border-top: 1px solid #ecece8;
    padding: 22px 34px 32px;
}

.attachment-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.attachment-card {
    border: 1px solid #deded9;
    border-radius: 11px;
    padding: 12px 14px;
    min-width: 190px;
}

.attachment-card strong {
    display: block;
    font-size: 13px;
}

.attachment-card span {
    color: #777;
    font-size: 11px;
}

.compose-panel form {
    padding: 8px 24px 24px;
}

.compose-field {
    display: grid;
    grid-template-columns: 75px 1fr;
    border-bottom: 1px solid #ecece8;
    align-items: center;
}

.compose-field label {
    color: #777;
    font-size: 13px;
}

.compose-field input {
    border: 0;
    outline: 0;
    padding: 13px 0;
}

.composer {
    width: 100%;
    min-height: 360px;
    resize: vertical;
    border: 0;
    outline: 0;
    padding: 22px 0;
    line-height: 1.6;
}

.compose-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #ecece8;
    padding-top: 18px;
}

.attachment {
    font-size: 13px;
    cursor: pointer;
}

.attachment input {
    display: block;
    margin-top: 8px;
}

.primary {
    border: 0;
    background: #f6c500;
    color: #111;
    font-weight: 800;
    border-radius: 10px;
    padding: 12px 20px;
}

.full {
    width: 100%;
}

.alert {
    margin: 16px 26px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
}

.alert.error {
    background: #fff0f0;
    color: #8c1616;
}

.alert.success {
    background: #effbf1;
    color: #176129;
}

.empty {
    padding: 70px 24px;
    text-align: center;
    color: #777;
}

.pagination {
    padding: 18px 22px;
    display: flex;
    justify-content: center;
    gap: 30px;
    color: #555;
    font-size: 13px;
}

.login-page {
    background: #111;
}

.login-shell {
    min-height: 100vh;
    padding: 50px 24px;
    display: grid;
    place-content: center;
    gap: 26px;
}

.login-brand {
    color: white;
    justify-content: center;
}

.login-card {
    width: min(440px, 92vw);
    background: white;
    padding: 34px;
    border-radius: 18px;
}

.login-card h1 {
    margin: 0;
}

.muted {
    color: #777;
    margin: 8px 0 26px;
}

.login-card label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin: 16px 0 6px;
}

.login-card input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #ddd;
    border-radius: 9px;
    outline: none;
}

.login-card button {
    margin-top: 22px;
}

.close {
    font-size: 28px;
    color: #777;
}


/* =========================================================
   HOLIBETA MAIL — AUTHORITATIVE MOBILE LAYOUT
   ========================================================= */

.mobile-menu-button,
.mobile-menu-backdrop,
.mobile-compose-fab {
    display: none;
}


/* ---------------------------------------------------------
   TABLETS + PHONES
   --------------------------------------------------------- */

@media (max-width: 900px) {

    html,
    body {
        width: 100%;
        max-width: 100%;
        min-height: 100%;
        overflow-x: hidden;
    }

    body {
        background: #f6f6f4;
    }

    body.mobile-mail-menu-open {
        overflow: hidden;
    }


    /* APP SHELL */

    .app {
        display: block;
        width: 100%;
        height: auto;
        min-height: 100dvh;
    }

    .workspace {
        width: 100%;
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }


    /* OFF-CANVAS SIDEBAR */

    .sidebar {
        display: flex;

        position: fixed;

        z-index: 10020;

        top: 0;
        bottom: 0;
        left: 0;

        width: min(320px, 84vw);
        min-height: 100dvh;

        padding:
            max(20px, env(safe-area-inset-top))
            16px
            max(18px, env(safe-area-inset-bottom));

        transform: translateX(-105%);

        transition:
            transform .22s ease;

        box-shadow:
            20px 0 55px
            rgba(0,0,0,.32);
    }

    body.mobile-mail-menu-open .sidebar {
        transform: translateX(0);
    }

    .sidebar .brand {
        display: flex;
    }

    .sidebar .brand > div:not(.mark) {
        display: block;
    }

    .sidebar .brand strong {
        display: block;
        font-size: 14px;
    }

    .sidebar .brand span {
        display: block;
        font-size: 10px;
    }

    .sidebar .compose {
        display: block;

        margin: 28px 0 18px;

        padding: 14px 18px;

        text-align: left;

        font-size: 14px;
    }

    .sidebar .compose::first-letter {
        font-size: inherit;
    }

    .sidebar nav span {
        display: inline;
        font-size: 14px;
    }

    .sidebar nav a {
        min-height: 44px;

        display: flex;
        align-items: center;

        padding: 11px 12px;

        font-size: 14px;
    }

    .sidebar-bottom {
        display: block;

        font-size: 12px;
    }


    /* DRAWER BACKDROP */

    .mobile-menu-backdrop {
        display: block;

        position: fixed;

        z-index: 10010;

        inset: 0;

        width: 100%;
        height: 100%;

        border: 0;
        padding: 0;

        background:
            rgba(0,0,0,.48);

        opacity: 0;

        visibility: hidden;

        pointer-events: none;

        transition:
            opacity .2s ease,
            visibility .2s ease;
    }

    body.mobile-mail-menu-open
    .mobile-menu-backdrop {
        opacity: 1;

        visibility: visible;

        pointer-events: auto;
    }


    /* TOPBAR */

    .topbar {
        width: 100%;

        min-height: 66px;
        height: auto;

        position: sticky;

        top: 0;

        z-index: 9000;

        display: flex;
        align-items: center;

        gap: 9px;

        padding:
            max(9px, env(safe-area-inset-top))
            10px
            9px;

        background:
            rgba(255,255,255,.97);

        border-bottom:
            1px solid #e7e7e3;

        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    .mobile-menu-button {
        display: grid;

        flex: 0 0 44px;

        width: 44px;
        height: 44px;

        place-items: center;

        border: 0;

        border-radius: 12px;

        background: #111;
        color: #fff;

        font-size: 21px;
        line-height: 1;
    }

    .search {
        flex: 1 1 auto;

        width: auto;
        min-width: 0;

        display: flex;

        border-radius: 13px;
    }

    .search input {
        flex: 1 1 auto;

        min-width: 0;
        width: 1%;

        height: 46px;

        padding: 0 13px;

        font-size: 15px;
    }

    .search button {
        flex: 0 0 auto;

        height: 46px;

        padding: 0 13px;

        font-size: 13px;
    }

    .identity {
        display: none;
    }


    /* PANELS */

    .mail-list,
    .message,
    .compose-panel {
        width: auto;

        margin:
            10px
            10px
            88px;

        border-radius: 15px;
    }

    .mail-list-heading,
    .panel-heading {
        padding: 18px 17px;
    }

    .mail-list-heading h1,
    .panel-heading h1 {
        margin-bottom: 4px;

        font-size: 22px;
    }


    /* INBOX ROW */

    .mail-row {
        min-height: 78px;

        display: grid;

        grid-template-columns:
            27px
            minmax(0, 1fr)
            auto;

        grid-template-areas:
            "star from meta"
            "star subject subject";

        column-gap: 9px;
        row-gap: 4px;

        align-items: center;

        padding: 11px 13px;

        font-size: 14px;
    }

    .mail-star {
        grid-area: star;

        align-self: start;

        padding-top: 2px;

        font-size: 20px;
    }

    .mail-from {
        grid-area: from;

        min-width: 0;

        overflow: hidden;

        white-space: nowrap;

        text-overflow: ellipsis;

        font-size: 14px;
        line-height: 1.3;
    }

    .mail-subject {
        grid-area: subject;

        min-width: 0;

        overflow: hidden;

        white-space: nowrap;

        text-overflow: ellipsis;

        color: #626262;

        font-size: 13px;
        line-height: 1.35;
    }

    .mail-meta {
        display: block;

        grid-area: meta;

        align-self: start;

        white-space: nowrap;

        color: #888;

        font-size: 10px;
    }

    .mail-row.unread {
        background: #fffdf3;
    }

    .mail-row.unread .mail-from {
        font-weight: 800;
    }

    .mail-row.unread .mail-subject {
        color: #222;
        font-weight: 650;
    }


    /* PAGINATION */

    .pagination {
        min-height: 58px;

        padding: 14px;

        gap: 24px;

        align-items: center;
    }


    /* MESSAGE VIEW */

    .message-toolbar {
        min-height: 58px;

        display: flex;

        padding: 8px 12px;

        gap: 8px;

        overflow: hidden;
    }

    .message-toolbar > a {
        flex: 0 0 auto;
    }

    .toolbar-actions {
        min-width: 0;

        display: flex;

        overflow-x: auto;

        overscroll-behavior-x:
            contain;

        scrollbar-width: none;
    }

    .toolbar-actions::-webkit-scrollbar {
        display: none;
    }

    .toolbar-actions form {
        flex: 0 0 auto;
    }

    .toolbar-actions button {
        white-space: nowrap;
    }

    .message-header {
        padding: 20px 17px 12px;
    }

    .message-header h1 {
        margin: 0 0 18px;

        font-size: 21px;
        line-height: 1.3;

        overflow-wrap: anywhere;
    }

    .sender {
        display: block;
    }

    .sender strong {
        display: block;

        overflow-wrap: anywhere;
    }

    .sender span {
        display: block;

        margin-top: 4px;
    }

    .recipients {
        margin-top: 8px;

        overflow-wrap: anywhere;
    }

    .mail-body {
        min-height: 180px;

        padding: 16px 17px 30px;

        overflow-x: auto;

        font-size: 15px;
        line-height: 1.58;
    }

    .mail-body img {
        max-width: 100% !important;
        height: auto !important;
    }

    .mail-body table {
        max-width: 100% !important;
    }

    .attachments {
        padding: 18px 17px 25px;
    }

    .attachment-grid {
        display: grid;

        grid-template-columns: 1fr;

        gap: 9px;
    }

    .attachment-card {
        width: 100%;
        min-width: 0;
    }


    /* COMPOSER */

    .compose-panel form {
        padding: 5px 16px 18px;
    }

    .compose-field {
        grid-template-columns:
            60px
            minmax(0, 1fr);
    }

    .compose-field input {
        min-width: 0;

        font-size: 16px;
    }

    .composer {
        width: 100%;

        min-height: 44vh;

        padding: 18px 0;

        font-size: 16px;
    }

    .compose-footer {
        display: flex;

        gap: 12px;

        align-items: flex-end;
    }

    .compose-footer .attachment {
        min-width: 0;

        overflow-wrap: anywhere;
    }

    .compose-footer .primary {
        flex: 0 0 auto;
    }


    /* MOBILE COMPOSE BUTTON */

    .mobile-compose-fab {
        display: grid;

        position: fixed;

        z-index: 9990;

        right:
            max(
                18px,
                env(safe-area-inset-right)
            );

        bottom:
            calc(
                18px +
                env(safe-area-inset-bottom)
            );

        width: 58px;
        height: 58px;

        place-items: center;

        border-radius: 18px;

        background: #f6c500;
        color: #111;

        box-shadow:
            0 12px 32px
            rgba(0,0,0,.24);

        font-size: 34px;
        font-weight: 400;
        line-height: 1;
    }

    body.mobile-mail-menu-open
    .mobile-compose-fab {
        visibility: hidden;
    }


    /* ALERTS */

    .alert {
        margin: 10px;

        padding: 11px 13px;
    }

}


/* ---------------------------------------------------------
   SMALL PHONES
   --------------------------------------------------------- */

@media (max-width: 520px) {

    .topbar {
        gap: 7px;

        padding-left: 8px;
        padding-right: 8px;
    }

    .mobile-menu-button {
        flex-basis: 42px;

        width: 42px;
        height: 42px;
    }

    .search input {
        font-size: 14px;
    }

    .search button {
        padding: 0 10px;

        font-size: 12px;
    }

    .mail-list,
    .message,
    .compose-panel {
        margin-left: 7px;
        margin-right: 7px;
    }

    .mail-row {
        padding-left: 10px;
        padding-right: 10px;
    }

    .mail-list-heading,
    .panel-heading {
        padding-left: 14px;
        padding-right: 14px;
    }

}


/* ---------------------------------------------------------
   INSTALLED PWA
   --------------------------------------------------------- */

@media (display-mode: standalone)
       and (max-width: 900px) {

    .topbar {
        padding-top:
            max(
                10px,
                env(safe-area-inset-top)
            );
    }

    .mobile-compose-fab {
        bottom:
            calc(
                16px +
                env(safe-area-inset-bottom)
            );
    }

}



/* =========================================================
   HOLIBETA MAIL PWA INSTALL
   ========================================================= */

.hll-pwa-install[hidden] {
    display: none !important;
}

.hll-pwa-install {
    position: fixed;
    z-index: 10000;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: min(720px, calc(100vw - 32px));
    background: #111;
    color: #fff;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 46px minmax(0,1fr) auto;
    gap: 13px;
    align-items: center;
    box-shadow:
        0 18px 55px rgba(0,0,0,.28);
}

.hll-pwa-install-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #f6c500;
    color: #111;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .03em;
}

.hll-pwa-install-copy {
    min-width: 0;
}

.hll-pwa-install-copy strong {
    display: block;
    font-size: 14px;
    margin-bottom: 3px;
}

.hll-pwa-install-copy span {
    display: block;
    color: #aaa;
    font-size: 12px;
    line-height: 1.35;
}

.hll-pwa-install-button {
    border: 0;
    background: #f6c500;
    color: #111;
    border-radius: 10px;
    padding: 11px 15px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

@media (max-width: 620px) {
    .hll-pwa-install {
        bottom: 10px;
        width: calc(100vw - 20px);
        grid-template-columns: 42px minmax(0,1fr);
    }

    .hll-pwa-install-icon {
        width: 42px;
        height: 42px;
    }

    .hll-pwa-install-button {
        grid-column: 1 / -1;
        width: 100%;
        padding: 12px;
    }
}

@media (display-mode: standalone) {
    .hll-pwa-install {
        display: none !important;
    }
}
