:root {
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --bg-gradient-start: #eef2ff;
    /* Indigo 50 */
    --bg-gradient-end: #e0e7ff;
    /* Indigo 100 */
    --text-main: #1f2937;
    /* Gray 800 */
    --text-secondary: #6b7280;
    /* Gray 500 */
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Utilities */
.container {
    width: 100%;
    max-width: 800px;
    /* Optimal reading width */
    margin: 0 auto;
    padding: 20px;
}

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}

.login-card h1 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.error-msg {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    text-align: center;
}

/* Email List Page */
.app-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mailbox-section {
    margin-bottom: 2rem;
}

.mailbox-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.email-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.email-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
    display: block;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.email-card:hover {
    box-shadow: var(--shadow-md);
    background: rgba(255, 255, 255, 0.95);
}

.email-card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.email-info {
    flex: 1;
    min-width: 0;
    /* Enable text truncation */
}

.email-subject {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text;
    /* Explicitly allow selection */
    cursor: text;
}

.email-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.email-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.email-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-bottom: 0rem;
    color: var(--text-main);
}

.btn-view {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 1px 3px 0 rgba(59, 130, 246, 0.2);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-view:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px 0 rgba(59, 130, 246, 0.3);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    border: 2px dashed rgba(0, 0, 0, 0.05);
}

/* Email Detail Page */
.detail-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
}

.detail-header {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-back {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
    background: transparent;
}

.nav-back:hover {
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
    /* Very subtle primary tint */
}

.detail-subject {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-row {
    display: flex;
    gap: 0.5rem;
}

.meta-label {
    font-weight: 600;
    color: var(--text-main);
    min-width: 3rem;
}

.detail-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    background: white;
    /* Ensure readability */
    font-size: 1rem;
    line-height: 1.6;
    color: #374151;
}

.detail-body img {
    max-width: 100%;
    height: auto;
}

.detail-links {
    padding: 1.5rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.links-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

.link-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.link-item a {
    display: block;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.2s;
}

.link-item a:hover {
    border-color: var(--primary-color);
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .container {
        padding: 15px;
    }

    .login-card {
        padding: 1.5rem;
    }

    .detail-subject {
        font-size: 1.25rem;
    }

    .detail-body {
        padding: 1.5rem;
    }
}