/* ? - ?? */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh; /* ????? */
    overflow: hidden; /*  */
}

.mail-list {
    flex: 1; /* ??? */
    padding: 20px 32px;
    overflow-y: auto; /* ?? */
    scroll-behavior: smooth; /* ?§¹ */
    max-height: calc(100vh - 170px); /* ????100vh - toolbar height(100px) - padding(40px) - header padding(30px) */
    
    /* ? */
    -ms-overflow-style: none;  /* IEEdge */
    scrollbar-width: none;  /* Firefox */
}

/* Chrome, Safari  Opera */
.mail-list::-webkit-scrollbar {
    display: none;
}

/* ?? */
:root {
    --bg-base: #fbfcfe;
    --bg-elev-1: #ffffff;
    --bg-elev-2: #f8f9fc;
    --text-primary: #1a1f36;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --accent-primary: #6a5af9;
    --accent-secondary: #00d4ff;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    --border-soft: #e0e7ff;
    --shadow-hard: 0 25px 60px rgba(16, 24, 40, 0.25);
    --radius-xl: 28px;
    --transition-spring: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-smooth: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-base);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
    display: flex;
    height: 100vh;
}

/*  */
.sidebar {
    width: 320px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(250,251,255,0.98));
    border-right: 1px solid var(--border-soft);
    padding: 36px 28px;
    overflow-y: auto;
    transition: var(--transition-spring);
    position: relative;
    z-index: 20;
    transform: perspective(1000px);
}

.sidebar:hover {
    transform: perspective(1000px) rotateY(1.5deg) translateX(8px);
    box-shadow: 0 20px 50px rgba(16, 24, 40, 0.15);
}

.sidebar:hover .nav-item {
    transform: rotateY(-1.5deg) !important;
    position: relative;
}

/* ??? */
.brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 40px;
}

.logo {
    font-size: 26px;
    font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
}

.brand-desc {
    color: var(--text-tertiary);
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* ?§Õ? */
.compose-btn {
    width: 100%;
    padding: 18px 20px;
    border-radius: 20px;
    border: 2px solid var(--border-soft);
    background: var(--accent-gradient);
    color: white;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(106,90,255,0.18);
    transition: var(--transition-spring);
    position: relative;
    overflow: hidden;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
}

.compose-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 50px rgba(106,90,255,0.25);
}

.compose-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--accent-gradient);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.4s ease;
}

.compose-btn:hover::before {
    transform: scaleY(1);
}

/*  */
.nav-section-title {
    color: var(--text-tertiary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    padding: 0 8px 16px;
    margin-bottom: 8px;
    border-bottom: 1px dashed var(--border-soft);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 16px;
    margin-bottom: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    border: 1px solid var(--border-soft);
    transition: var(--transition-spring);
    background: transparent;
    outline: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(106,90,255,0.06);
    transform: translateX(8px);
    border-color: var(--accent-primary);
    box-shadow: 0 8px 20px rgba(106,90,255,0.12);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(106,90,255,0.12), rgba(0,212,255,0.06));
    color: var(--accent-primary);
    font-weight: 700;
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.3);
}

.nav-item-content {
    display: flex;
    flex-direction: column;
}

.nav-item-title {
    font-weight: 700;
}

.nav-item-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}

.nav-item-count {
    margin-left: auto;
    background: rgba(106,90,255,0.12);
    color: var(--accent-primary);
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
}

.nav-space {
    height: 24px;
}

/*  */
.toolbar {
    padding: 26px 32px 20px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,251,255,0.95));
    height: 100px;
    box-sizing: border-box;
}

/*  */
.search-container {
    position: relative;
    flex: 1;
    max-width: 680px;
    margin-right: 24px;
}

.search-input {
    width: 100%;
    padding: 16px 20px 16px 56px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elev-2);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition-spring);
    outline: none;
}

.search-input:focus {
    border-color: rgba(106,90,255,0.35);
    box-shadow: 0 6px 20px rgba(106,90,255,0.12);
    transform: translateY(-1px);
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    transition: var(--transition-spring);
    font-size: 18px;
}

.search-input:focus + .search-icon {
    color: var(--accent-primary);
    transform: translateY(-50%) scale(1.08);
}

/* ?§Ý? */
.view-buttons {
    display: flex;
    gap: 10px;
}

.view-btn {
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elev-2);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 14px;
}

.view-btn.active {
    background: rgba(106,90,255,0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ?? */
.mail-card {
    display: grid;
    grid-template-columns: 68px 1fr auto;
    gap: 20px;
    padding: 20px 22px;
    border-radius: 18px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: var(--transition-spring);
    background: var(--bg-elev-1);
    border: 1px solid var(--border-soft);
    position: relative;
}

.mail-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 40px rgba(16, 24, 40, 0.1);
}

/* ¦Ä?? */
.unread-indicator {
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: 0 8px 8px 0;
    box-shadow: 0 4px 14px rgba(106,90,255,0.25);
}

/* ?? */
.avatar {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    color: white;
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-align: center;
    line-height: 1;
}

/* ? */
.mail-content {
    display: flex;
    flex-direction: column;
}

.sender {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.subject {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    line-height: 1.45;
}

.preview {
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ?? */
.mail-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.time {
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 500;
}

.mail-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elev-2);
    color: var(--text-tertiary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    background: rgba(106,90,255,0.06);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/*  */
.detail-overlay {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh !important;
    width: 87.5%;
    max-width: calc(100vw - 320px);
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(253,254,255,0.99));
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-hard);
    border-left: 1px solid var(--border-soft);
    overflow: hidden;
}

.detail-body {
    flex: 1;
    padding: 30px 32px;
    overflow-y: auto;
    background: white;
    line-height: 1.85;
    font-size: 16px;
    color: #2d3748;
    -webkit-overflow-scrolling: touch;
}

.detail-body::-webkit-scrollbar {
    display: none;
}
.detail-body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ? */
.detail-header {
    padding: 26px 32px 22px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 20px;
    background: white;
}

.back-btn {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    background: var(--bg-elev-2);
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: var(--transition-spring);
    position: relative;
    overflow: hidden;
    font-size: 18px;
}

.back-btn:hover {
    background: rgba(106,90,255,0.06);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.detail-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-secondary);
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.detail-subject {
    padding: 24px 32px 20px;
    border-bottom: 1px solid var(--border-soft);
    background: white;
}

#detailSubject {
    font-size: 22px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.detail-meta {
    display: flex;
    gap: 22px;
    align-items: center;
    flex-wrap: wrap;
}

.meta-badge {
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    background: rgba(106,90,255,0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(106,90,255,0.2);
}

.meta-time {
    color: var(--text-tertiary);
}

/* ?? */
.star-icon {
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.starred .star-icon {
    fill: #ffcc00;
    transform: scale(1.15);
    filter: drop-shadow(0 2px 8px rgba(255, 204, 0, 0.4));
}

/* ? */
.overlay-mask {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 35, 0.35);
    backdrop-filter: blur(8px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.overlay-mask.visible {
    opacity: 1;
    pointer-events: all;
}

/* ?§¹ */
.ripple-btn {
    position: relative;
    overflow: hidden;
}

.ripple-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    transform: scale(0);
    animation: ripple-pulse 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.2);
    pointer-events: none;
    opacity: 0;
}

.back-btn .ripple {
    background: rgba(106,90,255,0.18);
}

/* ??§¹ */
.nav-item, .compose-btn, .back-btn, .view-btn, .action-btn {
    position: relative;
    transition: var(--transition-smooth);
}

.nav-item::after, .compose-btn::after, 
.back-btn::after, .view-btn::after, 
.action-btn::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 2px solid transparent;
    transition: all 0.4s ease;
    pointer-events: none;
}

.nav-item:hover::after, 
.compose-btn:hover::after,
.back-btn:hover::after,
.view-btn:hover::after,
.action-btn:hover::after {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(106, 90, 255, 0.15);
}

.nav-item.active::after {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(106, 90, 255, 0.2);
}

/* ? */
.error-message {
    color: #dc3545;
    padding: 20px;
    background-color: #f8d7da;
    border-radius: 12px;
    margin: 20px;
    text-align: center;
}

/*  */
@keyframes ripple-pulse {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ?? */
@media (max-width: 1024px) {
    .detail-overlay {
        width: 100%;
        max-width: unset;
        border-left: none;
        border-radius: 24px 0 0 24px;
    }
    
    .toolbar {
        flex-direction: column;
        height: auto;
        padding: 16px 20px;
        gap: 12px;
    }
    
    .search-container {
        margin-right: 0;
        width: 100%;
        max-width: unset;
    }
}

/* SVG??? */
.nav-icon, .action-icon, .search-icon svg, .compose-btn svg {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle;
    fill: currentColor;
}