/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-subtle: #f6f8fa;
    --bg-muted: #eef1f5;
    --border: #d8dde4;
    --border-light: #e8ecf0;
    --text: #1a1d23;
    --text-secondary: #5a6170;
    --text-muted: #8a91a0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --spring: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --bottom-nav-h: 56px;
    --topbar-h: 52px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-subtle);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }

/* === Touch Ripple Effect === */
.ripple {
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(0,0,0,0.08) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}
.ripple:active::after { opacity: 1; transition: opacity 0s; }

/* === App Shell === */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    background: var(--bg);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    will-change: transform;
}
.sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 199;
    transition: background 0.3s;
    pointer-events: none;
}
.sidebar.open + .sidebar-overlay {
    display: block;
    background: rgba(0,0,0,0.4);
    pointer-events: auto;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand h1 { font-size: 1.15rem; font-weight: 700; }
.sidebar-brand .brand-icon {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    animation: brandPulse 3s ease-in-out infinite;
}
@keyframes brandPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nav-section { margin-bottom: 20px; }
.nav-label {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 10px;
    color: var(--text-secondary); font-weight: 500;
    transition: all var(--transition);
    text-decoration: none; font-size: 0.95rem;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item:active { transform: scale(0.97); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; transition: transform var(--spring); }
.nav-item:active svg { transform: scale(1.15); }

.sidebar-footer {
    padding: 14px 16px; border-top: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 10px;
    font-size: 0.88rem; color: var(--text-secondary);
    padding-bottom: calc(14px + var(--safe-bottom));
}
.sidebar-footer .avatar {
    width: 34px; height: 34px;
    background: var(--bg-muted); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; color: var(--text-muted);
    transition: transform var(--spring);
}
.sidebar-footer .avatar:active { transform: scale(0.9); }

/* === Main Content === */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    min-height: 100vh; min-height: 100dvh;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

/* === Topbar === */
.topbar {
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 12px; gap: 8px;
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* === Page Body === */
.page-body { flex: 1; padding: 12px; background: var(--bg-subtle); }

/* === Page Entrance Animation === */
.page-body > .card { animation: cardSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; }
.page-body > .card:nth-child(2) { animation-delay: 0.06s; }
.page-body > .card:nth-child(3) { animation-delay: 0.12s; }
.page-body > .card:nth-child(4) { animation-delay: 0.18s; }
.page-body > .card:nth-child(5) { animation-delay: 0.24s; }

@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 12px;
    color: var(--text-muted); font-size: 0.65rem; font-weight: 600;
    text-decoration: none; transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.bottom-nav-item:hover { text-decoration: none; color: var(--text-muted); }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item svg {
    width: 22px; height: 22px;
    transition: transform var(--spring);
}
.bottom-nav-item:active svg { transform: scale(1.2) translateY(-1px); }
.bottom-nav-item .dot {
    position: absolute; top: 4px; right: 8px;
    width: 7px; height: 7px;
    background: var(--danger); border-radius: 50%;
    border: 1.5px solid var(--bg);
    animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Active indicator bar */
.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px; left: 50%; transform: translateX(-50%);
    width: 24px; height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
    animation: activeBar 0.3s var(--spring);
}
@keyframes activeBar {
    from { width: 0; opacity: 0; }
    to { width: 24px; opacity: 1; }
}

/* === Standalone Auth Page === */
.standalone-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); padding: 20px;
}
.auth-card {
    width: 100%; max-width: 380px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px; box-shadow: var(--shadow-md);
    animation: authEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes authEnter {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.auth-card .subtitle { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.9rem; }
.auth-card .brand-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-card .brand-mark .icon {
    width: 40px; height: 40px;
    background: var(--primary); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
}

/* === Forms === */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-weight: 600; font-size: 0.85rem;
    color: var(--text); margin-bottom: 6px;
}
.form-group .hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px; font-size: 1rem;
    font-family: inherit; color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    outline: none; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    transform: scale(1.005);
}
input:active, select:active, textarea:active {
    transform: scale(0.998);
}
textarea { resize: vertical; min-height: 150px; }
select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235a6170' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 10px 18px;
    border: 1.5px solid transparent; border-radius: 10px;
    font-size: 0.92rem; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    position: relative; overflow: hidden;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; transition: transform var(--spring); }
.btn:active { transform: scale(0.96); }
.btn:active svg { transform: scale(1.1); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.btn-primary:active { background: #1e40af; box-shadow: none; }

.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-secondary:active { background: var(--bg-muted); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }

.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-ghost:active { background: var(--bg-muted); }

.btn-sm { padding: 7px 12px; font-size: 0.82rem; min-height: 36px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 40px; height: 40px; min-height: 40px; }

/* Button loading state */
.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after {
    content: '';
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    margin-left: 6px;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* === Alert === */
.alert {
    padding: 11px 14px; border-radius: 10px;
    font-size: 0.88rem; margin-bottom: 12px;
    display: flex; align-items: flex-start; gap: 8px;
    line-height: 1.5;
    animation: alertSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.3s, max-height 0.3s, margin 0.3s, padding 0.3s;
}
@keyframes alertSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert.dismissing {
    opacity: 0; max-height: 0; margin-bottom: 0;
    padding-top: 0; padding-bottom: 0; overflow: hidden;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* === Cards === */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:active { box-shadow: var(--shadow); }
.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 16px; }

/* === Email List === */
.email-list { list-style: none; }

.email-item {
    display: flex; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition), transform 0.15s, opacity 0.15s;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    animation: emailItemIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
    position: relative;
}
.email-item:nth-child(1) { animation-delay: 0s; }
.email-item:nth-child(2) { animation-delay: 0.03s; }
.email-item:nth-child(3) { animation-delay: 0.06s; }
.email-item:nth-child(4) { animation-delay: 0.09s; }
.email-item:nth-child(5) { animation-delay: 0.12s; }
.email-item:nth-child(6) { animation-delay: 0.15s; }
.email-item:nth-child(7) { animation-delay: 0.18s; }
.email-item:nth-child(8) { animation-delay: 0.21s; }
.email-item:nth-child(9) { animation-delay: 0.24s; }
.email-item:nth-child(10) { animation-delay: 0.27s; }

@keyframes emailItemIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.email-item:hover { background: var(--bg-subtle); }
.email-item:active { background: var(--bg-muted); transform: scale(0.99); }
.email-item:last-child { border-bottom: none; }

.email-item.unread { background: var(--primary-light); }
.email-item.unread:hover { background: #dbeafe; }
.email-item.unread:active { background: #bfdbfe; }

/* Swipe delete animation */
.email-item.swiping { transition: none; }
.email-item.swipe-delete {
    animation: swipeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes swipeOut {
    to { transform: translateX(-100%); opacity: 0; max-height: 0; padding: 0 16px; margin: 0; overflow: hidden; }
}

.email-item .email-status {
    flex-shrink: 0; width: 8px; height: 8px;
    border-radius: 50%; background: transparent;
    transition: background var(--transition), transform var(--spring);
}
.email-item.unread .email-status { background: var(--primary); }

.email-item .email-content {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 2px;
}
.email-item .email-top-row {
    display: flex; align-items: center;
    justify-content: space-between; gap: 8px;
}
.email-item .email-sender {
    font-weight: 500; font-size: 0.92rem; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.email-item.unread .email-sender { font-weight: 700; }
.email-item .email-date {
    flex-shrink: 0; font-size: 0.72rem; color: var(--text-muted);
}
.email-item .email-subject {
    font-size: 0.85rem; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.email-item.unread .email-subject { color: var(--text); font-weight: 500; }

/* Swipe hint */
.email-item .swipe-bg {
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 80px; background: var(--danger);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.8rem; font-weight: 600;
    opacity: 0; transition: opacity 0.15s;
    border-radius: 0 0 var(--radius-lg) 0;
}
.email-item.swiping .swipe-bg { opacity: 1; }

/* === Email View === */
.email-view-header { margin-bottom: 20px; }
.email-view-header h2 {
    font-size: 1.15rem; font-weight: 700;
    margin-bottom: 14px; line-height: 1.4;
    animation: fadeInUp 0.3s ease both;
}
.email-meta {
    display: flex; flex-direction: column; gap: 6px;
    animation: fadeInUp 0.3s ease 0.1s both;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.email-meta-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.88rem; }
.email-meta-label { color: var(--text-muted); min-width: 36px; flex-shrink: 0; font-size: 0.82rem; }
.email-meta-value { color: var(--text); word-break: break-all; }

.email-body-content {
    padding: 16px 0; line-height: 1.8; font-size: 0.95rem;
    animation: fadeInUp 0.3s ease 0.2s both;
}
.email-body-content pre { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; }
.email-html-body {
    border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 16px;
    margin-top: 12px; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.email-html-body * { max-width: 100% !important; word-wrap: break-word; }

/* === Attachments === */
.attachments-list {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px;
    animation: fadeInUp 0.3s ease 0.15s both;
}
.attachment-item {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; background: var(--bg-subtle);
    border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.82rem; color: var(--text-secondary);
    transition: all var(--transition);
}
.attachment-item:active { background: var(--bg-muted); transform: scale(0.97); }

/* === Compose === */
.compose-form textarea { min-height: 200px; font-size: 0.95rem; line-height: 1.6; }
.compose-toolbar {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 0; border-top: 1px solid var(--border-light);
    margin-top: 14px;
}
.compose-toolbar .spacer { flex: 1; }

/* === Settings === */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.settings-card {
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; background: var(--bg);
    transition: all var(--transition);
}
.settings-card:active { transform: scale(0.99); box-shadow: var(--shadow); }
.settings-card h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.settings-card p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 10px; }
.settings-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* === Check Page === */
.check-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.check-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg);
    animation: fadeInUp 0.3s ease both;
}
.check-item:nth-child(1) { animation-delay: 0s; }
.check-item:nth-child(2) { animation-delay: 0.05s; }
.check-item:nth-child(3) { animation-delay: 0.1s; }
.check-item:nth-child(4) { animation-delay: 0.15s; }
.check-item:nth-child(5) { animation-delay: 0.2s; }
.check-item:nth-child(6) { animation-delay: 0.25s; }
.check-item:nth-child(7) { animation-delay: 0.3s; }
.check-item:nth-child(8) { animation-delay: 0.35s; }
.check-item:nth-child(9) { animation-delay: 0.4s; }
.check-item:nth-child(10) { animation-delay: 0.45s; }

.check-item .check-icon {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform var(--spring);
}
.check-item .check-icon.ok { background: #f0fdf4; color: var(--success); }
.check-item .check-icon.error { background: #fef2f2; color: var(--danger); }
.check-item .check-info h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: 2px; }
.check-item .check-info p { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4; }

/* === Empty State === */
.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-muted);
    animation: fadeInUp 0.4s ease;
}
.empty-state svg {
    width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4;
    animation: emptyFloat 3s ease-in-out infinite;
}
@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 0.88rem; }

/* === Pagination === */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; padding: 14px 0;
}
.pagination a, .pagination span {
    padding: 8px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.82rem; color: var(--text-secondary);
    transition: all var(--transition);
}
.pagination a:active { transform: scale(0.95); background: var(--bg-subtle); }
.pagination span.current { background: var(--primary); color: white; border-color: var(--primary); }

/* === Action bar === */
.email-actions {
    display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0;
    animation: fadeInUp 0.3s ease 0.1s both;
}
.email-actions .btn {
    flex: 1; min-width: 0; font-size: 0.8rem;
    padding: 8px 6px;
}

/* === Search === */
.topbar-search { flex: 1; max-width: 240px; }
.topbar-search input {
    width: 100%; padding: 7px 12px;
    font-size: 0.88rem; border-radius: 20px;
    border: 1.5px solid var(--border); background: var(--bg-subtle);
    transition: all var(--transition);
}
.topbar-search input:focus {
    background: var(--bg); border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* === Cache tag === */
.cache-tag {
    font-size: 0.68rem; color: var(--text-muted);
    background: var(--bg-muted); padding: 2px 8px;
    border-radius: 10px; animation: fadeInUp 0.3s ease;
}

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-subtle) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-item {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--border-light);
}
.skeleton-dot { width: 8px; height: 8px; border-radius: 50%; }
.skeleton-line { height: 14px; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-30 { width: 30%; }

/* === Toast Notification === */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
    left: 50%; transform: translateX(-50%) translateY(100px);
    background: var(--text); color: white;
    padding: 10px 20px; border-radius: 24px;
    font-size: 0.85rem; font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 300; opacity: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; white-space: nowrap;
}
.toast.show {
    opacity: 1; transform: translateX(-50%) translateY(0);
}

/* === Pull to Refresh === */
.ptr-indicator {
    position: absolute; top: -48px; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    opacity: 0; transition: opacity 0.2s, top 0.2s;
}
.ptr-indicator.active {
    opacity: 1; top: 8px;
    animation: ptrSpin 0.8s linear infinite;
}
@keyframes ptrSpin { to { transform: translateX(-50%) rotate(360deg); } }

/* === Utility === */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.font-mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }

/* Hide labels on small screens */
@media (max-width: 400px) {
    .email-actions .btn .btn-label { display: none; }
    .email-actions .btn { padding: 8px 10px; }
    .topbar-search { max-width: 140px; }
}

/* === Tablet+ === */
@media (min-width: 768px) {
    :root { --sidebar-w: 240px; }
    .sidebar {
        transform: translateX(0); box-shadow: none;
        border-right: 1px solid var(--border);
    }
    .sidebar-overlay { display: none !important; }
    .main-content { margin-left: var(--sidebar-w); padding-bottom: 0; }
    .bottom-nav { display: none; }
    .page-body { padding: 24px; }
    .settings-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
    .check-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
    .email-item .email-sender { max-width: 180px; }
}
