:root {
    --background: #0b1220;
    --sidebar: #111b2d;
    --panel: #162238;
    --panel-light: #1b2a43;
    --border: #293951;
    --text: #e8eef8;
    --muted: #8c9bb1;
    --blue: #3985f7;
    --blue-hover: #2672e5;
    --danger: #ff6678;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}


/* LOGIN */

.login-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at 50% 20%,
            #1b355a 0,
            transparent 42%
        ),
        var(--background);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 42px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(17, 27, 45, 0.96);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
}

.logo {
    font-size: 27px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffffff;
}

.logo span {
    margin-left: 7px;
    color: var(--blue);
}

.login-subtitle {
    margin: 10px 0 32px;
    color: var(--muted);
    font-size: 14px;
}

.login-card label {
    display: block;
    margin: 18px 0 8px;
    color: #c7d2e2;
    font-size: 13px;
}

.login-card input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    color: var(--text);
    background: #0c1729;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}

.login-card input:focus {
    border-color: var(--blue);
}

.login-card button {
    width: 100%;
    height: 46px;
    margin-top: 24px;
    color: #ffffff;
    background: var(--blue);
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

.login-card button:hover {
    background: var(--blue-hover);
}

.login-card button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.login-footer {
    margin-top: 28px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.error-message {
    min-height: 18px;
    margin-top: 12px;
    color: var(--danger);
    font-size: 13px;
}


/* APPLICATION */

.mail-screen {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 255px;
    min-width: 255px;
    display: flex;
    flex-direction: column;
    padding: 25px 16px 16px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
}

.sidebar-logo {
    padding: 0 12px 28px;
}

.sidebar-logo .logo {
    font-size: 22px;
}

.compose-button {
    width: 100%;
    height: 48px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--blue);
    border: none;
    border-radius: 9px;
    text-align: left;
    font-weight: 600;
}

.compose-button span {
    margin-right: 9px;
    font-size: 21px;
    vertical-align: -2px;
}

.compose-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 28px;
}

.folder {
    width: 100%;
    padding: 13px 14px;
    color: #b4c1d4;
    background: transparent;
    border: none;
    border-radius: 8px;
    text-align: left;
    transition: 0.15s;
}

.folder:hover {
    color: white;
    background: var(--panel-light);
}

.folder.active {
    color: white;
    background: #203c65;
}

.folder-icon {
    display: inline-block;
    width: 28px;
    color: #76aaff;
}

.sidebar-bottom {
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 4px;
    border-top: 1px solid var(--border);
}

.avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    background: #315d9d;
    border-radius: 50%;
    font-weight: 700;
}

.user-email {
    overflow: hidden;
    color: #c4d0e0;
    font-size: 12px;
    text-overflow: ellipsis;
}

.logout-button {
    width: 100%;
    padding: 11px;
    color: #ff8793;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.logout-button:hover {
    background: rgba(255, 102, 120, 0.08);
}


/* MAIN */

.main-area {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #42cf8a;
    border-radius: 50%;
}

.content-area {
    flex: 1;
    min-height: 0;
    padding: 24px;
}

.message-panel,
.reading-panel {
    min-height: calc(100vh - 123px);
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.message-toolbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    border-bottom: 1px solid var(--border);
}

.message-count {
    color: #dce6f4;
    font-size: 14px;
    font-weight: 600;
}

.refresh-button,
.back-button {
    padding: 9px 13px;
    color: #b8c8dd;
    background: var(--panel-light);
    border: 1px solid var(--border);
    border-radius: 7px;
}

.refresh-button:hover,
.back-button:hover {
    color: white;
    border-color: #5275a4;
}

.message-list {
    display: flex;
    flex-direction: column;
}

.message-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 17px 22px;
    border-bottom: 1px solid rgba(41, 57, 81, 0.75);
    cursor: pointer;
    transition: background 0.15s;
}

.message-item:hover {
    background: var(--panel-light);
}

.message-item-top {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.message-sender {
    overflow: hidden;
    color: #e2eaf5;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-date {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 11px;
}

.message-subject {
    overflow: hidden;
    color: #c5d7ef;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-snippet {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    padding: 70px 20px;
    color: var(--muted);
    text-align: center;
}


/* READING */

.reading-toolbar {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}

.reading-content {
    padding: 30px;
}

.reading-content h1 {
    margin: 0 0 25px;
    color: #f0f4fb;
    font-size: 24px;
    overflow-wrap: anywhere;
}

.reading-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--border);
}

.reading-sender {
    color: #dce6f4;
    font-size: 13px;
    font-weight: 600;
}

.reading-date {
    color: var(--muted);
    font-size: 12px;
}

.reading-recipient {
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.reading-body {
    margin-top: 30px;
    color: #d5dfed;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}


/* MOBILE */

@media (max-width: 760px) {
    .sidebar {
        width: 76px;
        min-width: 76px;
        padding: 18px 8px;
    }

    .sidebar-logo {
        padding: 0 0 22px;
    }

    .sidebar-logo .logo {
        overflow: hidden;
        font-size: 0;
    }

    .sidebar-logo .logo::before {
        content: "CG";
        color: white;
        font-size: 19px;
    }

    .sidebar-logo .logo span {
        display: none;
    }

    .compose-button {
        padding: 0;
        text-align: center;
        font-size: 0;
    }

    .compose-button span {
        margin: 0;
        font-size: 25px;
    }

    .folder {
        padding: 14px 0;
        font-size: 0;
        text-align: center;
    }

    .folder-icon {
        width: auto;
        font-size: 19px;
    }

    .user-info {
        justify-content: center;
    }

    .user-email {
        display: none;
    }

    .logout-button {
        padding: 9px 2px;
        font-size: 11px;
    }

    .topbar {
        height: 62px;
        padding: 0 16px;
    }

    .content-area {
        padding: 12px;
    }

    .message-panel,
    .reading-panel {
        min-height: calc(100vh - 86px);
    }

    .reading-content {
        padding: 20px;
    }

    .reading-content h1 {
        font-size: 20px;
    }
}

/* MODERN EMAIL EDITOR */

.compose-dialog {
    width: min(900px, calc(100% - 32px));
    max-width: 900px;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    color: var(--text);
    background: #111d30;
    border: 1px solid #344966;
    border-radius: 18px;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}

.compose-dialog::backdrop {
    background: rgba(3, 8, 18, 0.78);
    backdrop-filter: blur(6px);
}

.compose-form {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.compose-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 26px;
    border-bottom: 1px solid var(--border);
}

.compose-header h2 {
    margin: 0;
    font-size: 21px;
}

.compose-subtitle {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.compose-close {
    width: 36px;
    height: 36px;
    color: #aebdd0;
    background: var(--panel-light);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.compose-close:hover {
    color: white;
    background: #293c59;
}

.compose-fields {
    padding: 12px 26px;
}

.compose-field {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 52px;
    border-bottom: 1px solid var(--border);
}

.compose-field label {
    width: 105px;
    flex-shrink: 0;
    color: var(--muted);
    font-size: 13px;
}

.compose-field input {
    width: 100%;
    height: 42px;
    color: var(--text);
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
}

.compose-field input:focus {
    box-shadow: none;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px;
    background: #17263c;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.editor-select {
    height: 34px;
    max-width: 150px;
    padding: 0 8px;
    color: #dce6f4;
    background: #0e192a;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
}

.editor-size {
    width: 78px;
}

.editor-tool {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    color: #c6d4e6;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
}

.editor-tool:hover {
    color: white;
    background: #2b4261;
    border-color: #456487;
}

.editor-divider {
    width: 1px;
    height: 23px;
    margin: 0 4px;
    background: #35465e;
}

.color-tool {
    position: relative;
    display: flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    color: #e3ebf7;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
}

.color-tool:hover {
    background: #2b4261;
}

.color-tool input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.editor-wrapper {
    min-height: 320px;
    padding: 20px 26px;
    overflow-y: auto;
    background: #f8fafc;
}

.compose-editor {
    min-height: 280px;
    outline: none;
    color: #26364d;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.compose-editor:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

.compose-editor a {
    color: #2563eb;
    text-decoration: underline;
}

.compose-editor ul,
.compose-editor ol {
    padding-left: 25px;
}

.compose-error {
    min-height: 0;
    padding: 0 26px;
    color: var(--danger);
    font-size: 13px;
}

.compose-error:not(:empty) {
    padding-top: 10px;
}

.compose-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 17px 26px;
    border-top: 1px solid var(--border);
}

.editor-footer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.compose-actions {
    display: flex;
    gap: 10px;
}

.compose-secondary,
.compose-send {
    height: 42px;
    padding: 0 17px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
}

.compose-secondary {
    color: #bdc9d9;
    background: #1b2a43;
    border: 1px solid var(--border);
}

.compose-send {
    color: white;
    background: var(--blue);
    border: none;
}

.compose-send:hover {
    background: var(--blue-hover);
}

.compose-send:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 600px) {
    .compose-dialog {
        width: calc(100% - 16px);
        max-height: 95vh;
        border-radius: 12px;
    }

    .compose-form {
        max-height: 95vh;
    }

    .compose-header,
    .compose-fields {
        padding-left: 15px;
        padding-right: 15px;
    }

    .editor-toolbar {
        padding: 10px;
        gap: 4px;
    }

    .editor-select {
        max-width: 125px;
    }

    .editor-wrapper {
        min-height: 250px;
        padding: 15px;
    }

    .compose-editor {
        min-height: 220px;
    }

    .compose-footer {
        padding: 12px;
        flex-wrap: wrap;
    }

    .editor-footer-info {
        display: none;
    }

    .compose-actions {
        width: 100%;
    }

    .compose-secondary,
    .compose-send {
        flex: 1;
        padding: 0 9px;
    }
}

.compose-editor {
    display: block;
    width: 100%;
    min-height: 280px;
    padding: 0;
    outline: none;
    cursor: text;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.compose-editor:focus {
    outline: none;
}

.editor-wrapper {
    position: relative;
    z-index: 1;
}

.compose-editor {
    display: block;
    width: 100%;
    min-height: 280px;
    padding: 0;
    color: #26364d;
    background: transparent;
    outline: none;
    cursor: text;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.compose-editor:focus {
    outline: none;
}

/* HTML EMAIL VIEWER */

.reading-body {
    margin-top: 30px;
    color: #d5dfed;
    font-size: 14px;
    line-height: 1.7;
    white-space: normal;
    overflow-wrap: anywhere;
}

.email-html-frame {
    display: block;
    width: 100%;
    min-height: 500px;
    border: none;
    border-radius: 6px;
    background: #ffffff;
}

.email-plain-text {
    color: #d5dfed;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.reading-body iframe {
    max-width: 100%;
}