
:root {
    --bg-page: #f3f4f6;
    --bg-card: #ffffff;
    --primary: #4f46e5;
    --primary-soft: #eef2ff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-soft: #e5e7eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e0e7ff, #f9fafb 40%, #e5e7eb 90%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-x: hidden;
}

.mail-shell {
    width: 100%;
    max-width: 720px;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    border-radius: 24px;
    padding: 1px;
    box-shadow:
        0 24px 60px rgba(15, 23, 42, 0.25),
        0 0 0 1px rgba(15, 23, 42, 0.04);
}

.mail-card {
    background: var(--bg-card);
    border-radius: 23px;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mail-header {
    display: flex;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.subject {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
    word-break: break-word;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meta-label {
    font-weight: 500;
}

.badge {
    margin-left: auto;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.divider {
    border-bottom: 1px solid var(--border-soft);
    margin-top: 4px;
}

.mail-body {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-main);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.mail-body img,
.mail-body table {
    max-width: 100%;
    height: auto;
}

.mail-body p {
    margin: 0 0 0.75em;
}

.mail-body small {
    color: var(--text-muted);
}

.footer-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-note span {
    white-space: nowrap;
}

@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .mail-card {
        padding: 16px 14px 18px;
        border-radius: 20px;
    }

    .mail-shell {
        border-radius: 20px;
    }

    .badge {
        margin-left: 0;
    }

    .subject {
        font-size: 0.95rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* จำกัดความสูงเนื้อหา ไม่ให้ยาวเกินจอ ทั้งยังเลื่อนอ่านได้ */
    .mail-body {
        max-height: calc(100vh - 210px);
        overflow-y: auto;
        width: 100%;
    }
}