* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
    background: #f4f5f7;
    color: #222;
}

.login-box {
    max-width: 320px; margin: 100px auto; background: white; padding: 30px;
    border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-align: center;
}
.login-box h1 { font-size: 18px; margin-bottom: 20px; }
.login-box input {
    width: 100%; padding: 10px; margin-bottom: 12px;
    border: 1px solid #ddd; border-radius: 6px; font-size: 15px;
}
.login-box button {
    width: 100%; padding: 10px; background: #2a3eb1; color: white;
    border: none; border-radius: 6px; font-size: 15px; cursor: pointer;
}
.error { color: #d33; font-size: 13px; margin-bottom: 10px; }

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

.sidebar { width: 220px; flex-shrink: 0; background: #fff; border-right: 1px solid #e5e5e5; }
.sidebar-header { padding: 16px; background: #2a3eb1; color: white; }
.sidebar-header h1 { font-size: 16px; margin: 0 0 6px 0; }
.sidebar-header .logout { color: white; opacity: 0.85; font-size: 12px; text-decoration: none; }

.sidebar-section-title {
    padding: 14px 16px 4px; font-size: 12px; font-weight: 700; color: #999;
}

.channel-list { padding: 8px; }
.channel-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: 8px; text-decoration: none;
    color: #333; font-size: 14px; margin-bottom: 2px; position: relative;
}
.channel-item:hover { background: #f0f1fb; }
.channel-item.active { background: #2a3eb1; color: white; font-weight: 600; }
.channel-item .count { font-size: 12px; color: #999; }
.channel-item.active .count { color: #dfe2fb; }
.channel-item .unread-badge {
    position: absolute; right: -4px; top: -4px; background: #e0432d; color: white;
    font-size: 10px; padding: 1px 5px; border-radius: 10px;
}

.channel-item-wrap { display: flex; align-items: center; gap: 4px; }
.channel-item-wrap .channel-item { flex: 1; margin-bottom: 2px; }
.folder-delete {
    flex-shrink: 0; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    color: #bbb; text-decoration: none; font-size: 14px; border-radius: 50%;
}
.folder-delete:hover { background: #fbe4e0; color: #e0432d; }

.new-folder-form { display: flex; gap: 6px; padding: 8px 16px 16px; }
.new-folder-form input {
    flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px;
}
.new-folder-form button {
    padding: 6px 10px; background: #2a3eb1; color: white; border: none; border-radius: 6px;
    font-size: 12px; cursor: pointer; flex-shrink: 0;
}

.main { flex: 1; min-width: 0; }

.mobile-appbar { display: none; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
    gap: 8px; padding: 14px 20px; background: white; border-bottom: 1px solid #e5e5e5;
    position: sticky; top: 0; z-index: 5;
}
.filter-bar { display: flex; gap: 8px; }
.filter-bar input[type="text"] { padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.filter-bar button { padding: 8px 14px; background: #2a3eb1; color: white; border: none; border-radius: 6px; cursor: pointer; }
.reset-link { display: flex; align-items: center; color: #888; font-size: 13px; text-decoration: none; }

.mail-count { font-size: 13px; color: #666; display: flex; align-items: center; gap: 10px; }
.mail-count .unread-num { font-weight: 700; color: #2a3eb1; }
.refresh-link { color: #2a3eb1; text-decoration: none; font-size: 12px; }

.bulk-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 20px; background: #fbfbfe; border-bottom: 1px solid #eee; font-size: 13px;
}
.select-all-label { display: flex; align-items: center; gap: 4px; color: #555; }
.bulk-bar button {
    padding: 6px 12px; border: 1px solid #ddd; background: white; border-radius: 6px;
    font-size: 13px; cursor: pointer; color: #333;
}
.bulk-bar button:hover { background: #f0f1fb; }
.bulk-bar select { padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

.date-header {
    display: flex; align-items: center; margin: 18px 20px 6px; padding: 8px 14px;
    background: #eef0fb; border-left: 4px solid #2a3eb1; border-radius: 6px;
    font-size: 13px; font-weight: 700; color: #2a3eb1;
}

.mail-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; background: white; border-bottom: 1px solid #eee;
}
.mail-row.unread { background: #f7f8ff; }
.mail-row.unread .sender, .mail-row.unread .subject { font-weight: 700; }

.row-checkbox { flex-shrink: 0; }

.star { text-decoration: none; color: #ccc; font-size: 16px; line-height: 1; flex-shrink: 0; }
.star.starred { color: #f5a623; }

.avatar { display: none; }

.mail-main { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.desktop-line { display: flex; align-items: baseline; gap: 6px; font-size: 14px; white-space: nowrap; overflow: hidden; }
.sender { color: #2a3eb1; flex-shrink: 0; }
.subject { color: #222; flex-shrink: 0; }
.preview-inline { color: #999; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-time { font-size: 12px; color: #999; flex-shrink: 0; white-space: nowrap; }

.mobile-block { display: none; }

.channel-tag { background: #eef0fb; color: #2a3eb1; font-size: 11px; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }

.empty { text-align: center; color: #999; margin-top: 40px; }

footer { padding: 24px 20px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-link {
    padding: 6px 11px; border-radius: 6px; text-decoration: none; color: #2a3eb1;
    font-size: 13px; border: 1px solid #ddd; background: white;
}
.page-link:hover { background: #f0f1fb; }
.page-link.current { background: #2a3eb1; color: white; border-color: #2a3eb1; font-weight: 700; }
.page-ellipsis { color: #999; font-size: 13px; padding: 0 4px; }

header {
    background: #2a3eb1; color: white; padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
header h1 { font-size: 18px; margin: 0; }
header .logout { color: white; text-decoration: none; font-size: 14px; opacity: 0.85; }

.detail-main { max-width: 680px; margin: 0 auto; padding: 16px; }
.back-link { display: inline-block; margin-bottom: 12px; color: #2a3eb1; text-decoration: none; font-size: 14px; }
.detail-card { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.detail-card .meta { display: flex; justify-content: space-between; font-size: 12px; color: #888; margin-bottom: 10px; }
.detail-card .text { white-space: pre-wrap; word-break: break-word; line-height: 1.6; font-size: 15px; }
.detail-card audio { width: 100%; margin-top: 10px; }
.detail-card .photo { max-width: 100%; border-radius: 8px; margin-top: 10px; }
.detail-card .file-link { display: inline-block; margin-top: 10px; color: #2a3eb1; }

.select-mode-toggle { display: none; }
.lbl-done { display: none; }

/* ===================== 모바일 전용 (앱 스타일) ===================== */
@media (max-width: 720px) {
    .app { flex-direction: column; }

    .sidebar { display: none; }

    .mobile-appbar {
        display: flex; align-items: center; justify-content: space-between;
        padding: 14px 16px; background: white; border-bottom: 1px solid #eee;
        position: sticky; top: 0; z-index: 6;
    }
    .mobile-back { font-size: 22px; color: #333; text-decoration: none; width: 30px; }
    .mobile-title { flex: 1; text-align: center; }
    .mobile-title .t-main { font-size: 17px; font-weight: 700; color: #111; }
    .mobile-title .t-sub { font-size: 12px; color: #999; margin-top: 2px; }
    .mobile-select-label {
        width: 44px; text-align: right; color: #2a3eb1; font-size: 14px; cursor: pointer;
    }

    .topbar { display: none; }

    .bulk-bar { display: none; padding: 10px 16px; }
    #select-mode:checked ~ #bulk-form .bulk-bar { display: flex; }

    .row-checkbox { display: none; }
    #select-mode:checked ~ #bulk-form .row-checkbox { display: inline-block; }

    #select-mode:checked ~ .mobile-appbar .lbl-select { display: none; }
    #select-mode:checked ~ .mobile-appbar .lbl-done { display: inline; }

    .star { display: none; }

    .date-header { margin: 14px 12px 6px; font-size: 12px; }

    .mail-row { padding: 12px 16px; align-items: flex-start; position: relative; }

    .avatar {
        display: flex; align-items: center; justify-content: center;
        width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
        color: white; font-weight: 700; font-size: 16px;
    }

    .desktop-line { display: none; }
    .mobile-block { display: block; flex: 1; min-width: 0; }
    .mobile-row1 { display: flex; align-items: center; gap: 6px; }
    .unread-dot { width: 7px; height: 7px; border-radius: 50%; background: #2a3eb1; flex-shrink: 0; }
    .mobile-sender { font-size: 14px; font-weight: 700; color: #111; }
    .mobile-subject {
        font-size: 14px; color: #333; margin-top: 2px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .mobile-preview {
        font-size: 13px; color: #999; margin-top: 2px;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }

    .mail-time {
        position: absolute; top: 12px; right: 16px; font-size: 11px; color: #999;
    }

    footer { padding: 20px 16px 70px; }
}
