:root {
    --mobile-transition-ms: 300ms;
    --mobile-ease: ease-in-out;
    --mobile-glass-bg: rgba(255, 255, 255, 0.72);
    --mobile-glass-border: rgba(15, 23, 42, 0.08);
    --mobile-bg: #f6f7fb;
    --mobile-surface: #ffffff;
    --mobile-surface-muted: #f1f3f8;
    --mobile-border: rgba(15, 23, 42, 0.08);
    --mobile-text: #0f172a;
    --mobile-muted: #64748b;
    --mobile-accent: #8bb4ff;
    --mobile-accent-strong: #6f9bff;
    --mobile-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    --mobile-shadow-soft: 0 2px 12px rgba(15, 23, 42, 0.08);
    --mobile-radius: 16px;
    /* Safe area with fallback for Dynamic Island (59pt on iPhone 14/15 Pro) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html,
body {
    height: 100%;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

body.mobile-mode {
    background: var(--mobile-bg);
    overflow: hidden;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    --mobile-header-height: calc(56px + max(8px, var(--safe-top)));
}

body.mobile-mode.mobile-keyboard-open {
    height: auto;
    min-height: 100dvh;
    overscroll-behavior: none;
}

body.mobile-mode .app-grid {
    display: none;
}

#mobile-shell {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    min-height: 100svh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: var(--mobile-bg);
}

body.mobile-mode.mobile-keyboard-open #mobile-shell {
    transform: translateY(var(--visual-viewport-translate, 0px));
}

body.mobile-mode.mobile-composer-active #mobile-shell {
    transform: none !important;
}


#mobile-shell.is-active {
    display: flex;
    flex-direction: column;
}

#mobile-nav-header {
    position: sticky;
    top: 0;
    z-index: 20;
    /* Glass background */
    background: rgba(246, 247, 251, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--mobile-border);
    flex-shrink: 0;
    /* Safe area padding - minimum 8px, or safe-area if larger */
    padding-top: max(12px, var(--safe-top));
    padding-left: max(0px, var(--safe-left));
    padding-right: max(0px, var(--safe-right));
}

/* Menu/hamburger button - glass style */
body.mobile-mode #mobile-nav-header #mobile-nav-leading {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--mobile-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--mobile-shadow-soft);
    color: var(--mobile-text);
}

#mobile-nav-header > div {
    height: 60px;
}

#mobile-nav-leading {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--mobile-text);
}

#mobile-nav-leading:hover {
    background: var(--mobile-surface-muted);
}

.mobile-nav-title {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    color: var(--mobile-text);
}

#mobile-nav-subtitle {
    color: var(--mobile-muted);
}

#mobile-nav-actions button {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 12px;
}

#mobile-nav-actions button:hover {
    background: var(--mobile-surface-muted);
}

/* Account dropdown - slides down from nav bar */
.mobile-account-dropdown {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.mobile-account-dropdown__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 250ms ease;
}

.mobile-account-dropdown.is-open .mobile-account-dropdown__scrim {
    background: rgba(0, 0, 0, 0.15);
}

.mobile-account-dropdown__panel {
    position: absolute;
    top: calc(56px + max(8px, env(safe-area-inset-top)));
    left: 16px;
    right: 16px;
    background: var(--mobile-surface);
    border-radius: 14px;
    border: 1px solid var(--mobile-border);
    box-shadow: var(--mobile-shadow);
    overflow: hidden;
    transform: translateY(-10px);
    opacity: 0;
    transition: transform 250ms ease, opacity 250ms ease;
}

.mobile-account-dropdown.is-open .mobile-account-dropdown__panel {
    transform: translateY(0);
    opacity: 1;
}

.mobile-account-dropdown__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--mobile-text);
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    transition: background 150ms ease;
}

.mobile-account-dropdown__item:last-child {
    border-bottom: none;
}

.mobile-account-dropdown__item:active {
    background: var(--mobile-surface-muted);
}

.mobile-account-dropdown__item.is-selected {
    color: var(--mobile-accent-strong);
}

#mobile-view-container {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: var(--mobile-bg);
    min-height: 100svh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    /* Safe area for landscape mode */
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.mobile-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--mobile-bg);
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--mobile-transition-ms) var(--mobile-ease),
        opacity var(--mobile-transition-ms) var(--mobile-ease);
}

.mobile-view[data-state="active"] {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.mobile-view[data-state="left"] {
    transform: translateX(-30%);
    opacity: 0.6;
}

.mobile-view[data-state="right"] {
    transform: translateX(100%);
    opacity: 0;
}

body.mobile-mode.mobile-back-swipe-active .mobile-view {
    transition: none !important;
}

body.mobile-mode #search-modal.mobile-search-view,
body.mobile-mode.mobile-search-open #search-modal {
    position: fixed;
    top: var(--mobile-header-height);
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0;
    background: var(--mobile-bg);
    align-items: stretch;
    justify-content: stretch;
}

body.mobile-mode #search-modal.mobile-search-view .search-modal-content,
body.mobile-mode.mobile-search-open #search-modal .search-modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
    flex-direction: column;
    display: flex;
    background: var(--mobile-bg);
}

body.mobile-mode #search-modal.mobile-search-view #search-preview-panel,
body.mobile-mode.mobile-search-open #search-modal #search-preview-panel {
    display: none;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results {
    min-height: 0;
    padding-bottom: calc(16px + var(--safe-bottom));
    flex: 1 1 auto;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-input,
body.mobile-mode.mobile-search-open #search-modal #search-modal-input {
    font-size: 16px;
    padding-top: 10px;
    padding-bottom: 10px;
}

body.mobile-mode #search-modal.mobile-search-view .search-modal-input,
body.mobile-mode.mobile-search-open #search-modal .search-modal-input {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--mobile-bg);
    padding: 12px 16px 10px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.mobile-mode #search-modal.mobile-search-view .search-modal-input-row,
body.mobile-mode.mobile-search-open #search-modal .search-modal-input-row {
    align-items: center;
}

body.mobile-mode #search-modal.mobile-search-view .search-modal-input-row > .relative,
body.mobile-mode.mobile-search-open #search-modal .search-modal-input-row > .relative {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-input,
body.mobile-mode.mobile-search-open #search-modal #search-modal-input {
    background: transparent;
}

body.mobile-mode #search-modal.mobile-search-view #search-history-gear,
body.mobile-mode #search-modal.mobile-search-view #search-sort-toggle,
body.mobile-mode #search-modal.mobile-search-view #search-history-menu,
body.mobile-mode.mobile-search-open #search-modal #search-history-gear,
body.mobile-mode.mobile-search-open #search-modal #search-sort-toggle,
body.mobile-mode.mobile-search-open #search-modal #search-history-menu {
    display: none !important;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-clear,
body.mobile-mode.mobile-search-open #search-modal #search-modal-clear {
    display: inline-flex;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-clear.hidden,
body.mobile-mode.mobile-search-open #search-modal #search-modal-clear.hidden {
    display: none !important;
}

body.mobile-mode #search-modal.mobile-search-view #search-mobile-controls,
body.mobile-mode.mobile-search-open #search-modal #search-mobile-controls {
    display: block !important;
}

body.mobile-mode #search-modal.mobile-search-view .search-mobile-sort,
body.mobile-mode.mobile-search-open #search-modal .search-mobile-sort {
    background: rgba(148, 163, 184, 0.18);
}

body.mobile-mode #search-modal.mobile-search-view .search-mobile-sort button,
body.mobile-mode.mobile-search-open #search-modal .search-mobile-sort button {
    color: var(--mobile-muted);
    transition: background 150ms ease, color 150ms ease;
}

body.mobile-mode #search-modal.mobile-search-view .search-mobile-sort button.is-active,
body.mobile-mode.mobile-search-open #search-modal .search-mobile-sort button.is-active {
    background: #ffffff;
    color: var(--mobile-accent-strong);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

body.mobile-mode #search-modal.mobile-search-view .search-mobile-chip,
body.mobile-mode.mobile-search-open #search-modal .search-mobile-chip {
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    color: var(--mobile-text);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.mobile-mode #search-modal.mobile-search-view .search-mobile-chip:active,
body.mobile-mode.mobile-search-open #search-modal .search-mobile-chip:active {
    background: rgba(139, 180, 255, 0.18);
    border-color: rgba(102, 137, 230, 0.3);
}

body.mobile-mode #search-modal.mobile-search-view #search-history-suggestions,
body.mobile-mode.mobile-search-open #search-modal #search-history-suggestions {
    position: static;
    margin-top: 8px;
    width: 100%;
    border-radius: 12px;
    box-shadow: none;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results .search-result-item,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results .search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results .search-result-item.search-result-item--mobile,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results .search-result-item.search-result-item--mobile {
    background: transparent;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results .search-result-item.search-result-item--mobile.search-result-item--selected,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results .search-result-item.search-result-item--mobile.search-result-item--selected {
    background: #e2e2e2;
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results .search-result-item.search-result-item--mobile:active,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results .search-result-item.search-result-item--mobile:active {
    background: rgba(102, 137, 230, 0.12);
}

body.mobile-mode #search-modal.mobile-search-view #search-modal-results .search-result-item.search-result-item--mobile .search-result-snippet,
body.mobile-mode.mobile-search-open #search-modal #search-modal-results .search-result-item.search-result-item--mobile .search-result-snippet {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.mobile-mode #search-modal.mobile-search-view .search-modal-footer,
body.mobile-mode.mobile-search-open #search-modal .search-modal-footer {
    display: none;
}

body.mobile-drawer-open #mobile-nav-header {
    pointer-events: none;
}

.mobile-glass {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: var(--mobile-glass-bg);
    border: 1px solid var(--mobile-glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#mobile-bottom-bar {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    padding: 10px 22px;
    border-radius: 28px;
    z-index: 30;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--mobile-border);
    box-shadow: var(--mobile-shadow-soft);
}

#mobile-bottom-bar button {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mobile-muted);
    background: transparent;
}

#mobile-bottom-bar button.is-active {
    background: rgba(139, 180, 255, 0.22);
    color: var(--mobile-accent-strong);
}

#mobile-fab {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 20px);
    right: calc(var(--safe-right) + 20px);
    width: 56px;
    height: 56px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(59, 130, 246, 0.95);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.18);
    z-index: 30;
    transition: transform 150ms ease, opacity 150ms ease;
}

#mobile-fab.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

#mobile-fab.has-drafts::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.9);
}

#mobile-toast {
    position: fixed;
    top: calc(max(16px, var(--safe-top)) + 72px); /* Below nav header + Dynamic Island */
    left: calc(max(0px, var(--safe-left)) + 16px);
    right: calc(max(0px, var(--safe-right)) + 16px);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 40;
    display: none;
}

#mobile-toast.show {
    display: block;
    animation: mobile-toast-drop 300ms ease-out;
}

@keyframes mobile-toast-drop {
    0% {
        transform: translateY(-12px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

body.mobile-mode #thread-list-pane,
body.mobile-mode #reading-pane,
body.mobile-mode #main-sidebar {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
}

body.mobile-mode #thread-list-pane {
    border-right: none;
    background: var(--mobile-bg);
}

body.mobile-mode #thread-list-pane > .h-14 {
    display: none;
}

body.mobile-mode #thread-list {
    padding-bottom: calc(64px + var(--safe-bottom)); /* Room for FAB without huge gap */
    touch-action: pan-y;
}

/* Thread list view: allow content to scroll behind transparent nav */
body.mobile-mode.mobile-thread-list-view #thread-list {
    padding-top: calc(60px + max(12px, var(--safe-top)) + 8px);
}

body.mobile-mode #reading-pane {
    background: var(--mobile-bg);
}

body.mobile-mode #main-sidebar {
    position: relative !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto !important;
    background: var(--mobile-bg);
    font-size: 14px !important;
    line-height: 1.25 !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.mobile-mode #main-sidebar .tauri-traffic-lights {
    display: none !important;
}

/* Hide Compose button (parent container hidden via JS for space reclaim) */
body.mobile-mode #main-sidebar [data-action="open-composer"] {
    display: none !important;
}

/* Labels list keeps its own scroll like desktop */
body.mobile-mode #main-sidebar #labels-list {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    max-height: none !important;
}

/* Hide logout in drawer - moved to settings */
body.mobile-mode #main-sidebar [data-action="logout"] {
    display: none !important;
}

/* ============================================
   Mobile Sidebar Typography Normalization
   ============================================ */

/* Reset Tailwind sizing - use !important to override inline Tailwind classes */
body.mobile-mode #main-sidebar [class*="text-["],
body.mobile-mode #main-sidebar [class*="text-sm"],
body.mobile-mode #main-sidebar [class*="text-xs"],
body.mobile-mode #main-sidebar [class*="text-base"] {
    font-size: inherit !important;
}

/* Reset Tailwind arbitrary sizing - but NOT on SVGs (icons need their sizes) */
body.mobile-mode #main-sidebar span[class*="w-["],
body.mobile-mode #main-sidebar span[class*="h-["],
body.mobile-mode #main-sidebar div[class*="w-["],
body.mobile-mode #main-sidebar div[class*="h-["] {
    width: auto !important;
    height: auto !important;
}

/* Main folder buttons (Inbox, Sent, etc.) */
body.mobile-mode #main-sidebar button[data-action] {
    min-height: 48px !important;
    padding: 12px 12px !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 500 !important;
    gap: 10px !important;
    border-radius: 12px !important;
    color: var(--mobile-text) !important;
    transition: background 150ms ease, color 150ms ease;
}

body.mobile-mode #main-sidebar button[data-action]:active {
    background: var(--mobile-surface-muted) !important;
}

/* Account items nested under folders */
body.mobile-mode #main-sidebar .account-inbox-item {
    min-height: 44px !important;
    padding: 10px 12px 10px 52px !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
    gap: 10px !important;
}

body.mobile-mode #main-sidebar .account-inbox-item span {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

body.mobile-mode #main-sidebar .sidebar-nested-list {
    padding-left: 10px !important;
}

body.mobile-mode #main-sidebar .sidebar-item span,
body.mobile-mode #main-sidebar .sidebar-nested-item span,
body.mobile-mode #main-sidebar .label-link span {
    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 500 !important;
}

/* Folder label text */
body.mobile-mode #main-sidebar button span.text-sm,
body.mobile-mode #main-sidebar button span.tracking-tight {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

/* Icons - consistent 20px size */
body.mobile-mode #main-sidebar svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex-shrink: 0 !important;
}

/* ============================================
   Colored Folder Icons
   Target both .mobile-drawer context and body.mobile-mode
   ============================================ */

/* Inbox - Blue */
.mobile-drawer [data-action="select-inbox"] svg:not([width="10"]):not([width="12"]),
.mobile-drawer [data-action="select-inbox"] svg:not([width="10"]):not([width="12"]) path {
    color: var(--mobile-accent-strong) !important;
    stroke: var(--mobile-accent-strong) !important;
}

/* Sent - Blue */
.mobile-drawer [data-folder="sent"] svg,
.mobile-drawer [data-folder="sent"] svg path {
    color: var(--mobile-accent-strong) !important;
    stroke: var(--mobile-accent-strong) !important;
}

/* Drafts - Gray */
.mobile-drawer [data-folder="drafts"] svg,
.mobile-drawer [data-folder="drafts"] svg path {
    color: #6b7280 !important;
    stroke: #6b7280 !important;
}

/* Pinned/Starred - Orange */
.mobile-drawer [data-folder="starred"] svg,
.mobile-drawer [data-folder="starred"] svg path {
    color: #f59e0b !important;
    stroke: #f59e0b !important;
}

/* Archive - Green */
.mobile-drawer [data-folder="archive"] svg,
.mobile-drawer [data-folder="archive"] svg path {
    color: #10b981 !important;
    stroke: #10b981 !important;
}

/* Trash - Red */
.mobile-drawer [data-folder="trash"] svg,
.mobile-drawer [data-folder="trash"] svg path {
    color: #ef4444 !important;
    stroke: #ef4444 !important;
}

/* Spam - Gray */
.mobile-drawer [data-folder="spam"] svg,
.mobile-drawer [data-folder="spam"] svg path {
    color: #6b7280 !important;
    stroke: #6b7280 !important;
}

/* Recently Viewed - Purple */
.mobile-drawer [data-folder="recently-viewed"] svg,
.mobile-drawer [data-folder="recently-viewed"] svg path {
    color: #8b5cf6 !important;
    stroke: #8b5cf6 !important;
}

/* Keep chevron/toggle arrows neutral gray */
.mobile-drawer button[data-action="toggle-account-list"] svg,
.mobile-drawer button[data-action="toggle-account-list"] svg path,
.mobile-drawer button[data-action="toggle-folder"] svg,
.mobile-drawer button[data-action="toggle-folder"] svg path {
    color: #9ca3af !important;
    stroke: #9ca3af !important;
}

/* Small expand/collapse chevron icons */
.mobile-drawer button[data-action="toggle-account-list"] svg,
.mobile-drawer button[data-action="toggle-folder"] svg {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
}

/* Unread count badges - compact and consistent */
body.mobile-mode #main-sidebar .account-unread-badge,
body.mobile-mode #main-sidebar span[class*="rounded-full"][class*="bg-blue"] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 0 6px !important;
    min-width: 20px !important;
    height: 20px !important;
    line-height: 20px !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    background: #e2e8f0 !important;
    color: #475569 !important;
}

/* Total unread badge (blue-100 bg) */
body.mobile-mode #main-sidebar span.bg-blue-100 {
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 2px 6px !important;
    border-radius: 8px !important;
}

/* Account color dots */
body.mobile-mode #main-sidebar span.rounded-full[style*="background-color"] {
    width: 10px !important;
    height: 10px !important;
    min-width: 10px !important;
    flex-shrink: 0 !important;
}

/* Labels section */
body.mobile-mode #main-sidebar #labels-list {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

body.mobile-mode #main-sidebar #labels-list button,
body.mobile-mode #main-sidebar .label-link {
    min-height: 44px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
}

body.mobile-mode #main-sidebar #labels-list span {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

/* Section headers/details summary */
body.mobile-mode #main-sidebar details > summary,
body.mobile-mode #main-sidebar .section-title {
    font-size: 11px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #9ca3af !important;
    padding: 20px 12px 8px !important;
    min-height: auto !important;
}

/* Sync status footer */
body.mobile-mode #main-sidebar #sync-status-footer,
body.mobile-mode #main-sidebar .sync-status {
    font-size: 12px !important;
    padding: 12px !important;
}

body.mobile-mode #main-sidebar #sync-status-footer * {
    font-size: 12px !important;
}

/* Settings gear button - with label on mobile */
body.mobile-mode #main-sidebar [data-action="open-preferences"],
.mobile-drawer [data-action="open-preferences"] {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
    margin-left: 4px !important;
    color: #6b7280 !important;
}

body.mobile-mode #main-sidebar [data-action="open-preferences"] svg,
.mobile-drawer [data-action="open-preferences"] svg {
    width: 20px !important;
    height: 20px !important;
}

/* Add "Settings" text label after the gear icon */
body.mobile-mode #main-sidebar [data-action="open-preferences"]::after,
.mobile-drawer [data-action="open-preferences"]::after {
    content: "Settings" !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #6b7280 !important;
}

body.mobile-mode #sidebar-backdrop {
    display: none !important;
}

body.mobile-mode #bulk-actions-bar {
    display: none !important;
}

/* ============================================
   Mobile: Show hover-only elements always
   (No hover on touch devices)
   ============================================ */

/* Labels "+" button - always visible */
body.mobile-mode #main-sidebar [data-action="open-create-label-dialog"],
.mobile-drawer [data-action="open-create-label-dialog"] {
    opacity: 1 !important;
}

/* Thread list action buttons - hide on mobile (use swipe gestures instead) */
body.mobile-mode .thread-actions,
body.mobile-mode [class*="group-hover:opacity"] {
    display: none !important;
}

body.mobile-mode .mobile-composer {
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: 100% !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    resize: none !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    overscroll-behavior: contain;
}

body.mobile-mode #sidebar-status-footer {
    display: none !important;
}

body.mobile-mode #sync-pause-btn {
    display: none !important;
}

body.mobile-mode #mobile-connection-indicator #connection-dot {
    width: 8px;
    height: 8px;
}

body.mobile-mode #mobile-connection-indicator #connection-status-text {
    font-size: 11px;
    color: #9ca3af;
}

body.mobile-mode .mobile-composer.mobile-composer-sheet {
    --mobile-composer-top: 40%;
    top: var(--mobile-composer-top) !important;
    bottom: 0 !important;
    height: auto !important;
    border-radius: 16px 16px 0 0 !important;
    transition: top 320ms var(--ease-fluid),
        border-radius 220ms var(--ease-fluid),
        box-shadow 220ms var(--ease-fluid);
    will-change: top;
}

body.mobile-mode .mobile-composer form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(138px + var(--safe-top));
    padding-bottom: calc(var(--keyboard-offset, 0px));
    overscroll-behavior: contain;
    height: 100%;
}

body.mobile-mode .mobile-composer .composer-footer {
    position: sticky;
    bottom: 0;
    background: var(--mobile-surface);
    padding-bottom: 0;
    gap: 10px;
    z-index: 2;
}

body.mobile-mode .mobile-composer .composer-fields {
    overflow: visible;
    padding-bottom: 12px;
}

body.mobile-mode .mobile-composer .composer-footer-actions {
    flex: 1 1 auto;
    min-width: 0;
}

body.mobile-mode .mobile-composer .composer-send-btn {
    display: none;
}

body.mobile-mode .mobile-composer .composer-save-btn {
    display: none;
}

body.mobile-mode .mobile-composer .composer-footer-aux {
    margin-left: 6px;
}

body.mobile-mode .mobile-composer .composer-footer button {
    min-height: 44px;
}

body.mobile-mode .mobile-composer .composer-attach-btn {
    display: none;
}
body.mobile-mode .mobile-composer .composer-discard-btn {
    display: none;
}

body.mobile-mode .mobile-composer .composer-fields > div {
    padding: 12px 18px !important;
    gap: 12px !important;
    min-height: 48px;
}

body.mobile-mode .mobile-composer .composer-from-row {
    display: none !important;
}

body.mobile-mode .mobile-composer .composer-fields > div > .flex-1.relative {
    min-width: 0 !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
}

body.mobile-mode .mobile-composer .composer-fields label {
    font-size: 13px !important;
    line-height: 1.25 !important;
}

body.mobile-mode .mobile-composer .composer-fields input,
body.mobile-mode .mobile-composer .composer-fields select {
    font-size: 16px !important;
    line-height: 1.35 !important;
    min-height: 30px;
}

body.mobile-mode .mobile-composer [data-action="toggle-cc"],
body.mobile-mode .mobile-composer [data-action="toggle-bcc"] {
    font-size: 13px !important;
    padding: 6px 8px !important;
}

body.mobile-mode .mobile-composer [id$="-to-chips"],
body.mobile-mode .mobile-composer [id$="-cc-chips"],
body.mobile-mode .mobile-composer [id$="-bcc-chips"] {
    gap: 6px !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    min-height: 30px;
    min-width: 0 !important;
    flex: 1 1 0 !important;
    overflow: hidden;
}

body.mobile-mode .mobile-composer .email-chip {
    font-size: 13px !important;
    padding: 5px 12px !important;
    border-radius: 999px !important;
    line-height: 1.2 !important;
    height: 30px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(125, 165, 255, 0.18);
    border: 1px solid rgba(125, 165, 255, 0.3);
    box-shadow: 0 6px 14px rgba(102, 137, 230, 0.12);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
}

body.mobile-mode .mobile-composer .email-chip button {
    font-size: 11px !important;
    line-height: 1 !important;
}

body.mobile-mode .mobile-composer [id$="-to"],
body.mobile-mode .mobile-composer [id$="-cc"],
body.mobile-mode .mobile-composer [id$="-bcc"] {
    min-width: 0 !important;
    flex: 1 1 40px !important;
    height: 30px !important;
    line-height: 30px !important;
    padding: 2px 0 !important;
    margin: 0 !important;
    width: 1px !important;
}

body.mobile-mode .mobile-composer [id$="-to-chips"] input,
body.mobile-mode .mobile-composer [id$="-cc-chips"] input,
body.mobile-mode .mobile-composer [id$="-bcc-chips"] input {
    height: 30px !important;
    line-height: 30px !important;
    padding: 2px 0 !important;
    margin: 0 !important;
}

body.mobile-mode .mobile-composer [id$="-editor-container"] {
    flex: 0 0 auto;
    min-height: 260px;
    display: flex;
    flex-direction: column;
}

body.mobile-mode .mobile-composer .tiptap-editor {
    flex: 0 0 auto;
    min-height: 260px;
}

body.mobile-mode .mobile-composer .tiptap-editor .ProseMirror {
    font-size: 16px !important;
    line-height: 1.55 !important;
    padding: 16px 18px !important;
    min-height: 240px;
}

body.mobile-mode .mobile-composer .tiptap-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    scroll-padding-left: 14px;
    transition: max-height 180ms ease, opacity 180ms ease;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

body.mobile-mode .mobile-composer .tiptap-toolbar::-webkit-scrollbar {
    display: none;
}

body.mobile-mode .mobile-composer .tiptap-toolbar.is-visible {
    max-height: 64px;
    opacity: 1;
    pointer-events: auto;
}

body.mobile-mode .mobile-composer .tiptap-toolbar button,
body.mobile-mode .mobile-composer .tiptap-toolbar .dropdown-toggle,
body.mobile-mode .mobile-composer .tiptap-toolbar .color-toggle {
    min-width: 44px;
    height: 44px;
    border-radius: 14px;
    scroll-snap-align: start;
}

body.mobile-mode .mobile-composer .tiptap-toolbar svg {
    width: 22px;
    height: 22px;
}

body.mobile-mode .mobile-composer .mobile-editor-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

body.mobile-mode .mobile-composer.mobile-composer-sheet .mobile-editor-overlay {
    display: block;
}

body.mobile-mode .mobile-composer.mobile-composer-sheet.is-expanded .mobile-editor-overlay {
    display: none;
}

/* Disable drag-drop overlay on mobile (touch-only) */
body.mobile-mode .mobile-composer [id$="-dropzone"] {
    display: none !important;
}

body.mobile-mode .mobile-composer input[type="file"] {
    display: none !important;
}

body.mobile-mode .mobile-composer.mobile-composer-sheet.is-expanded {
    bottom: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
    padding-top: var(--safe-top);
}

body.mobile-mode.mobile-keyboard-open .mobile-composer.mobile-composer-sheet {
    border-radius: 0 !important;
}

body.mobile-mode .mobile-composer [data-action="pop-out-composer"],
body.mobile-mode .mobile-composer [data-action="minimize-composer"],
body.mobile-mode .mobile-composer [data-action="toggle-composer-size"] {
    display: none !important;
}

.composer-header-mobile-actions {
    display: none;
}

body.mobile-mode .mobile-composer .composer-header {
    position: absolute;
    top: calc(62px + var(--safe-top));
    left: 0;
    right: 0;
    z-index: 30;
    flex-shrink: 0;
    padding: 12px 18px !important;
    min-height: 56px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.mobile-mode .mobile-composer.mobile-composer-sheet.is-expanded::before,
body.mobile-mode .mobile-composer.mobile-composer-full::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(120px + var(--safe-top));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    z-index: 25;
    pointer-events: none;
}

body.mobile-mode .mobile-composer .composer-header-controls {
    display: none !important;
}

body.mobile-mode .mobile-composer .composer-header-mobile-actions {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    pointer-events: auto;
}

body.mobile-mode .mobile-composer .composer-header-mobile-left {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.mobile-mode .mobile-composer .composer-header-mobile-center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    min-width: 0;
    padding: 0 8px;
}

body.mobile-mode .mobile-composer .composer-header-account {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    max-width: 70%;
}

body.mobile-mode .mobile-composer .composer-header-account-select {
    appearance: none;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--mobile-text);
    max-width: 220px;
    text-align-last: center;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

body.mobile-mode .mobile-composer .composer-header-account-caret {
    width: 14px;
    height: 14px;
    color: var(--mobile-muted);
    flex-shrink: 0;
}

body.mobile-mode .mobile-composer .composer-header-mobile-actions button {
    cursor: pointer;
}

body.mobile-mode .mobile-composer .composer-header-discard {
    width: 38px;
    height: 38px;
    color: var(--mobile-muted);
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
}

body.mobile-mode .mobile-composer .composer-header-close-icon {
    width: 16px;
    height: 16px;
}

body.mobile-mode .mobile-composer .composer-header-attach {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mobile-muted);
}

body.mobile-mode .mobile-composer .composer-header-attach-icon {
    width: 16px;
    height: 16px;
}

body.mobile-mode .mobile-composer .composer-header-send {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, rgba(111, 155, 255, 0.95), rgba(127, 160, 255, 0.95));
    box-shadow: 0 8px 20px rgba(102, 137, 230, 0.28);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    padding: 8px 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.mobile-mode .mobile-composer .composer-header-send-label {
    display: none;
}

body.mobile-mode .mobile-composer .composer-header-send {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

body.mobile-mode .mobile-composer .composer-header-send-icon {
    width: 16px;
    height: 16px;
}

body.mobile-mode .mobile-composer [id$="-title"] {
    visibility: hidden;
}

body.mobile-mode .mobile-composer .composer-cc-bcc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(125, 165, 255, 0.18);
    border: 1px solid rgba(102, 137, 230, 0.35);
    box-shadow: 0 6px 14px rgba(102, 137, 230, 0.12);
    backdrop-filter: blur(10px) saturate(160%);
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    font-size: 12px;
    font-weight: 600;
    color: var(--mobile-accent-strong);
    white-space: nowrap;
    pointer-events: auto;
    z-index: 2;
}

body.mobile-mode .mobile-composer .composer-cc-bcc button {
    padding: 0;
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit;
    text-decoration: none !important;
    pointer-events: auto;
}

body.mobile-mode .mobile-composer .composer-cc-bcc button:hover {
    text-decoration: none;
}

body.mobile-mode .mobile-composer .composer-mobile-fab-stack {
    position: fixed;
    right: calc(16px + var(--safe-right));
    bottom: calc(16px + var(--safe-bottom));
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 180ms ease, opacity 180ms ease;
}

body.mobile-mode.mobile-keyboard-open .mobile-composer .composer-mobile-fab-stack {
    bottom: calc(var(--keyboard-offset, 0px) + 12px);
}

body.mobile-mode .mobile-composer.mobile-composer-sheet:not(.is-expanded) .composer-mobile-fab-stack {
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
}

body.mobile-mode .mobile-composer .composer-mobile-attach-menu {
    position: relative;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-trigger {
    width: 46px;
    height: 46px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mobile-text);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    transition: transform 150ms ease;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-trigger:active {
    transform: scale(0.96);
}

body.mobile-mode .mobile-composer .composer-mobile-attach-trigger svg,
body.mobile-mode .mobile-composer .composer-mobile-done-fab svg {
    width: 20px;
    height: 20px;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-menu.is-open .composer-mobile-attach-popover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-item {
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--mobile-text);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    text-align: left;
}

body.mobile-mode .mobile-composer .composer-mobile-attach-item:active {
    background: rgba(139, 180, 255, 0.18);
}

body.mobile-mode .mobile-composer .composer-mobile-done-fab {
    display: none;
    width: 46px;
    height: 46px;
    border-radius: 18px;
    background: rgba(125, 165, 255, 0.2);
    border: 1px solid rgba(102, 137, 230, 0.35);
    box-shadow: 0 8px 18px rgba(102, 137, 230, 0.16);
    color: var(--mobile-accent-strong);
    align-items: center;
    justify-content: center;
}

body.mobile-mode.mobile-keyboard-open .mobile-composer .composer-mobile-done-fab {
    display: inline-flex;
}

.mobile-composer-handle {
    width: 52px;
    height: 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
    margin: 0;
    touch-action: none;
    position: relative;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 31;
    flex-shrink: 0;
}

body.mobile-mode .mobile-composer.is-docked {
    display: none !important;
}

body.mobile-mode.mobile-composer-active #mobile-bottom-bar,
body.mobile-mode.mobile-composer-active #mobile-fab {
    display: none !important;
}

body.mobile-mode.mobile-composer-active {
    overflow: hidden;
    height: 100%;
    overscroll-behavior: none;
}

body.mobile-mode.mobile-composer-locked #mobile-view-container {
    pointer-events: none;
}

body.mobile-mode.mobile-composer-locked .mobile-composer {
    pointer-events: auto;
}

#mobile-fab-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 35;
}

#mobile-fab-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

#mobile-fab-menu {
    position: fixed;
    right: calc(var(--safe-right) + 20px);
    bottom: calc(var(--safe-bottom) + 90px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 36;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 220ms var(--ease-fluid), transform 220ms var(--ease-fluid);
}

#mobile-fab-menu.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#mobile-fab-menu .fab-menu-item {
    min-width: 168px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--mobile-border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--mobile-shadow-soft);
    color: var(--mobile-text);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#mobile-fab-menu .fab-menu-item span {
    display: block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-swipe-active {
    transition: none !important;
}

.mobile-swipe-release {
    transition: transform 200ms ease, opacity 200ms ease;
}

body.mobile-mode .swipe-background {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding: 0 16px;
    opacity: 0;
    transition: opacity 150ms ease;
    z-index: 0;
    pointer-events: none;
}

body.mobile-mode .thread-item.swiping .swipe-background,
body.mobile-mode .thread-item.swipe-revealed .swipe-background {
    opacity: 0;
    pointer-events: none;
}

body.mobile-mode .thread-item.swiping.swipe-left-active .swipe-background.swipe-left,
body.mobile-mode .thread-item.swipe-revealed.swipe-left-active .swipe-background.swipe-left {
    opacity: 1;
    pointer-events: auto;
}

body.mobile-mode .thread-item.swiping.swipe-right-active .swipe-background.swipe-right,
body.mobile-mode .thread-item.swipe-revealed.swipe-right-active .swipe-background.swipe-right {
    opacity: 1;
    pointer-events: auto;
}

body.mobile-mode .thread-item {
    background: var(--mobile-surface);
    -webkit-tap-highlight-color: transparent;
    min-height: 76px;
}

body.mobile-mode .thread-item .thread-content {
    padding: 14px 16px;
}

body.mobile-mode .thread-item .thread-header {
    gap: 10px;
    margin-bottom: 4px;
}

body.mobile-mode .thread-item .thread-unread-indicator,
body.mobile-mode .thread-item .thread-unread-placeholder {
    width: 10px;
    height: 10px;
}

body.mobile-mode .thread-item .thread-sender {
    font-size: 15px;
    line-height: 1.3;
}

body.mobile-mode .thread-item .thread-timestamp {
    font-size: 12px;
}

body.mobile-mode .thread-item .thread-subject-line {
    padding-left: 18px;
    margin-bottom: 4px;
}

body.mobile-mode .thread-item .thread-subject {
    font-size: 14px;
    line-height: 1.35;
}

body.mobile-mode .thread-item .thread-preview-line {
    padding-left: 18px;
}

body.mobile-mode .thread-item .thread-snippet {
    font-size: 13px;
    line-height: 1.4;
}

body.mobile-mode .thread-item:hover {
    background-color: transparent;
}

body.mobile-mode .thread-item.selected,
body.mobile-mode .thread-item.selected:hover,
body.mobile-mode .thread-item.selected.active {
    background-color: transparent !important;
    border-left: none !important;
}

.thread-item .thread-content {
    position: relative;
    z-index: 1;
    background: inherit;
}

body.mobile-mode .swipe-background.swipe-left {
    justify-content: flex-end;
    background: #10b981;
}

body.mobile-mode .swipe-background.swipe-right {
    justify-content: flex-start;
    background: #f59e0b;
}

/* Edge swipe zone for message back gesture */
.mobile-edge-back-zone {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 44px;
    z-index: 90;
    pointer-events: auto;
    background: transparent;
    touch-action: pan-y;
}

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

.swipe-actions.right {
    justify-content: flex-start;
}

.swipe-actions.left {
    justify-content: flex-end;
}

.swipe-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 12px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
}

.swipe-action-btn.more {
    background: rgba(107, 114, 128, 0.85);
}

.swipe-action-btn.archive {
    background: rgba(16, 185, 129, 0.9);
}

.swipe-action-btn.star {
    background: rgba(245, 158, 11, 0.9);
}

.mobile-bottom-sheet {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}

.mobile-bottom-sheet.hidden {
    display: none;
}

.mobile-bottom-sheet__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 300ms var(--ease-fluid);
}

.mobile-bottom-sheet__panel {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: var(--mobile-surface);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(24px);
    opacity: 0;
    transition: transform 300ms var(--ease-fluid), opacity 300ms var(--ease-fluid);
}

.mobile-bottom-sheet__handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.2);
    margin: 4px auto 12px auto;
}

.mobile-bottom-sheet.is-open .mobile-bottom-sheet__panel {
    transform: translateY(0);
    opacity: 1;
}

.mobile-bottom-sheet.is-open .mobile-bottom-sheet__scrim {
    opacity: 1;
}

.mobile-drawer {
    position: absolute;
    inset: 0;
    z-index: 120;
    display: flex;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 0s linear 200ms;
}

.mobile-drawer__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 200ms ease;
}

.mobile-drawer__panel {
    position: relative;
    width: min(82vw, 320px);
    height: 100%;
    background: var(--mobile-surface);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    transform: translateX(-100%);
    transition: transform 240ms ease;
    z-index: 1;
    display: flex;
    flex-direction: column;
    /* Safe area for Dynamic Island - minimum 20px, or safe-area if larger */
    padding-top: max(20px, var(--safe-top));
    padding-left: var(--safe-left);
    padding-bottom: max(20px, var(--safe-bottom));
}

.mobile-drawer.is-open .mobile-drawer__scrim {
    opacity: 1;
}

.mobile-drawer.is-open .mobile-drawer__panel {
    transform: translateX(0);
}

.mobile-drawer.is-open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease;
}

/* ============================================
   Drawer Sidebar Styles
   ============================================ */

/* Ensure ALL folder icons are visible in the drawer */
.mobile-drawer button[data-action] svg,
.mobile-drawer__panel button[data-action] svg {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex-shrink: 0 !important;
    flex-basis: 20px !important;
    overflow: visible !important;
    /* Default gray color for icons */
    color: #6b7280 !important;
    stroke: #6b7280 !important;
}

/* Also target buttons to ensure no clipping */
.mobile-drawer button[data-action] {
    overflow: visible !important;
}

/* Folder icon paths need explicit stroke color */
.mobile-drawer button[data-action] svg path,
.mobile-drawer__panel button[data-action] svg path {
    stroke: inherit !important;
    stroke-width: 2 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Chevron arrows should be smaller */
.mobile-drawer #main-sidebar button[data-action="toggle-account-list"] svg,
.mobile-drawer #main-sidebar button[data-action="toggle-folder"] svg {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
    color: #9ca3af !important;
}

/* Sync status section - make it compact */
.mobile-drawer #main-sidebar #sync-status-footer {
    font-size: 11px !important;
    padding: 8px 12px !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
}

.mobile-drawer #main-sidebar #sync-status-footer h3 {
    font-size: 10px !important;
    margin: 0 !important;
}

.mobile-drawer #main-sidebar #sync-status-footer span,
.mobile-drawer #main-sidebar #sync-status-footer button,
.mobile-drawer #main-sidebar #sync-status-footer div {
    font-size: 11px !important;
}

.mobile-drawer #main-sidebar #sync-status-footer svg {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
}

/* Progress bar styling */
.mobile-drawer #main-sidebar #sync-status-footer .bg-blue-100 {
    height: 3px !important;
}

/* ============================================
   Mobile Drawer Sidebar Refresh
   ============================================ */

body.mobile-mode .mobile-drawer__panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 246, 251, 0.98) 100%);
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

body.mobile-mode .mobile-drawer #main-sidebar {
    background: transparent !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.mobile-mode .mobile-drawer #main-sidebar .message-content-surface {
    background: transparent !important;
    border-right: none !important;
    box-shadow: none !important;
}

body.mobile-mode .mobile-drawer #sidebar-nav-container {
    padding: 8px 10px 12px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar button[data-action] {
    min-height: 44px !important;
    padding: 9px 12px !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 520 !important;
    gap: 10px !important;
    border-radius: 10px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .account-inbox-item {
    min-height: 34px !important;
    padding: 6px 10px 6px 52px !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
    gap: 8px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .account-inbox-item span {
    font-size: 14px !important;
    line-height: 1.25 !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .sidebar-nested-list {
    padding-left: 10px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .sidebar-item span,
body.mobile-mode .mobile-drawer #main-sidebar .sidebar-nested-item span,
body.mobile-mode .mobile-drawer #main-sidebar .label-link span {
    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 500 !important;
}

body.mobile-mode .mobile-drawer #main-sidebar svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar button[data-action="toggle-account-list"] svg,
body.mobile-mode .mobile-drawer #main-sidebar button[data-action="toggle-folder"] svg {
    width: 11px !important;
    height: 11px !important;
    min-width: 11px !important;
    min-height: 11px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .account-unread-badge,
body.mobile-mode .mobile-drawer #main-sidebar span[class*="rounded-full"][class*="bg-blue"] {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 18px !important;
    min-width: 18px !important;
    line-height: 18px !important;
    font-size: 10px !important;
    padding: 0 6px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    background: #e2e8f0 !important;
    color: #475569 !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .folder-unread-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 10px !important;
    padding: 0 6px !important;
    height: 18px !important;
    border-radius: 9px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
    background: #e2e8f0 !important;
    color: #475569 !important;
}

body.mobile-mode #main-sidebar .folder-unread-badge {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

body.mobile-mode #main-sidebar .sidebar-item-active .folder-unread-badge,
body.mobile-mode #main-sidebar .sidebar-item-active .account-unread-badge,
body.mobile-mode .mobile-drawer #main-sidebar .sidebar-item-active .folder-unread-badge,
body.mobile-mode .mobile-drawer #main-sidebar .sidebar-item-active .account-unread-badge {
    background: #4f6fbf !important;
    color: #ffffff !important;
}

body.mobile-mode #main-sidebar .folder-unread-badge.mobile-badge-active,
body.mobile-mode #main-sidebar .account-unread-badge.mobile-badge-active,
body.mobile-mode .mobile-drawer #main-sidebar .folder-unread-badge.mobile-badge-active,
body.mobile-mode .mobile-drawer #main-sidebar .account-unread-badge.mobile-badge-active {
    background: #4f6fbf !important;
    color: #ffffff !important;
}

body.mobile-mode #main-sidebar .folder-unread-badge.mobile-badge-inactive,
body.mobile-mode #main-sidebar .account-unread-badge.mobile-badge-inactive,
body.mobile-mode .mobile-drawer #main-sidebar .folder-unread-badge.mobile-badge-inactive,
body.mobile-mode .mobile-drawer #main-sidebar .account-unread-badge.mobile-badge-inactive {
    background: #e2e8f0 !important;
    color: #475569 !important;
}

body.mobile-mode .mobile-drawer #main-sidebar #labels-list {
    padding-top: 2px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar #labels-list button,
body.mobile-mode .mobile-drawer #main-sidebar .label-link {
    min-height: 34px !important;
    padding: 6px 10px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar #labels-list span {
    font-size: 14px !important;
}

body.mobile-mode .mobile-drawer #main-sidebar .section-title,
body.mobile-mode .mobile-drawer #main-sidebar details > summary,
body.mobile-mode .mobile-drawer #main-sidebar h3 {
    font-size: 10px !important;
    font-weight: 650 !important;
    letter-spacing: 0.12em !important;
    padding: 16px 10px 6px !important;
    color: #94a3b8 !important;
}

body.mobile-mode .mobile-drawer .sidebar-item-active {
    background-color: rgba(102, 137, 230, 0.18) !important;
    color: #1f2937 !important;
}

body.mobile-mode .mobile-drawer .sidebar-item-active svg {
    color: #4f6fbf !important;
}

.mobile-action-sheet {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-action-sheet__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    text-align: center;
}

.mobile-action-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mobile-action-sheet__item,
.mobile-action-sheet__cancel {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.mobile-action-sheet__item.is-destructive {
    color: #dc2626;
    background: #fff1f2;
}

.mobile-action-sheet__cancel {
    background: var(--mobile-surface);
    border: 1px solid #e5e7eb;
}

/* ============================================
   Mobile Settings View
   ============================================ */

.mobile-settings-view {
    background: #f8fafc;
}

.mobile-settings-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
}

.mobile-settings-section {
    background: var(--mobile-surface);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.mobile-settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--mobile-border);
}

.mobile-settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    padding: 16px;
    padding-bottom: 8px;
}

.mobile-settings-section-header .mobile-settings-section-title {
    padding: 0;
}

.mobile-settings-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--mobile-accent-strong);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
}

.mobile-settings-add-btn:active {
    background: #5b86e6;
}

/* Settings Items */
.mobile-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    min-height: 56px;
    border-bottom: 1px solid var(--mobile-border);
}

.mobile-settings-item:last-child {
    border-bottom: none;
}

.mobile-settings-item-content {
    flex: 1;
    min-width: 0;
}

.mobile-settings-item-label {
    font-size: 15px;
    font-weight: 500;
    color: #111827;
    display: block;
}

.mobile-settings-item-desc {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.mobile-settings-item-control {
    flex-shrink: 0;
    margin-left: 12px;
}

.mobile-settings-select {
    padding: 8px 28px 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    background: var(--mobile-surface) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") right 8px center no-repeat;
    background-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    max-width: 160px;
}

.mobile-settings-select:focus {
    outline: none;
    border-color: var(--mobile-accent-strong);
    box-shadow: 0 0 0 3px rgba(111, 155, 255, 0.18);
}

/* Navigation Items (Privacy, ToS) */
.mobile-settings-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    min-height: 56px;
    border-bottom: 1px solid var(--mobile-border);
    background: transparent;
    text-align: left;
}

.mobile-settings-nav-item:last-child {
    border-bottom: none;
}

.mobile-settings-nav-item:active {
    background: #f8fafc;
}

/* Accounts */
.mobile-settings-accounts {
    padding: 0;
}

.mobile-settings-account {
    padding: 16px;
    border-bottom: 1px solid var(--mobile-border);
}

.mobile-settings-account:last-child {
    border-bottom: none;
}

.mobile-settings-account-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-settings-color-picker {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.mobile-settings-account-info {
    flex: 1;
    min-width: 0;
}

.mobile-settings-account-email {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-settings-account-badges {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.mobile-settings-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.mobile-settings-badge.badge-primary {
    background: #dbeafe;
    color: #1d4ed8;
}

.mobile-settings-badge.badge-shared {
    background: #fef3c7;
    color: #b45309;
}

.mobile-settings-remove-btn {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 8px;
    flex-shrink: 0;
}

.mobile-settings-remove-btn:active {
    background: #fee2e2;
}

.mobile-settings-account-field {
    margin-top: 14px;
}

.mobile-settings-field-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 6px;
}

.mobile-settings-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    color: #111827;
    background: var(--mobile-surface);
}

.mobile-settings-input:focus {
    outline: none;
    border-color: var(--mobile-accent-strong);
    box-shadow: 0 0 0 3px rgba(111, 155, 255, 0.18);
}

.mobile-settings-account-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--mobile-border);
}

/* Toggle Switch */
.mobile-settings-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
}

.mobile-settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mobile-settings-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #e5e7eb;
    border-radius: 32px;
    transition: background-color 150ms ease;
}

.mobile-settings-toggle-slider::before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 150ms ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mobile-settings-toggle input:checked + .mobile-settings-toggle-slider {
    background-color: var(--mobile-accent-strong);
}

.mobile-settings-toggle input:checked + .mobile-settings-toggle-slider::before {
    transform: translateX(20px);
}

/* Security Section */
.mobile-settings-vault-status {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mobile-settings-vault-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #dcfce7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-settings-actions {
    display: flex;
    gap: 10px;
    padding: 0 16px 16px;
    flex-wrap: wrap;
}

.mobile-settings-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    background: #f3f4f6;
    border-radius: 10px;
}

.mobile-settings-action-btn:active {
    background: #e5e7eb;
}

.mobile-settings-action-btn.mobile-settings-action-danger {
    color: #dc2626;
    background: #fef2f2;
}

.mobile-settings-action-btn.mobile-settings-action-danger:active {
    background: #fee2e2;
}

/* Sign Out Button */
.mobile-settings-signout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    color: #dc2626;
    background: transparent;
}

.mobile-settings-signout-btn:active {
    background: #fef2f2;
}

.mobile-settings-empty {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* ============================================
   Mobile Legal Views (Privacy, ToS)
   ============================================ */

.mobile-legal-view {
    background: var(--mobile-surface);
}

.mobile-legal-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-legal-content {
    padding: 20px 16px;
    font-size: 15px;
    line-height: 1.6;
    color: #374151;
}

.mobile-legal-content h1,
.mobile-legal-content h2,
.mobile-legal-content h3 {
    color: #111827;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
}

.mobile-legal-content h1 {
    font-size: 22px;
    margin-top: 0;
}

.mobile-legal-content h2 {
    font-size: 18px;
}

.mobile-legal-content h3 {
    font-size: 16px;
}

.mobile-legal-content p {
    margin-bottom: 12px;
}

.mobile-legal-content ul,
.mobile-legal-content ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.mobile-legal-content li {
    margin-bottom: 6px;
}

.mobile-legal-content a {
    color: var(--mobile-accent-strong);
    text-decoration: underline;
}

.mobile-legal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
    font-size: 14px;
}

.mobile-legal-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--mobile-accent-strong);
    border-radius: 50%;
    animation: mobile-spinner 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes mobile-spinner {
    to {
        transform: rotate(360deg);
    }
}

.mobile-legal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 24px;
}

.mobile-legal-retry {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background: var(--mobile-accent-strong);
    border-radius: 8px;
}

.mobile-legal-retry:active {
    background: #5b86e6;
}

/* Safe area padding utility */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ============================================
   Mobile Thread/Message View
   ============================================ */

/* Hide the sticky desktop header completely on mobile */
body.mobile-mode #message-content > div.sticky,
body.mobile-mode #message-content > .sticky,
body.mobile-mode #message-content > div:first-child.min-h-14,
body.mobile-mode #message-content [class*="sticky top-0"],
body.mobile-mode #reading-pane .sticky {
    display: none !important;
}

/* Show mobile subject (inside scroll area) */
body.mobile-mode .mobile-thread-subject {
    display: block !important;
    /* Extra top padding so subject starts below floating nav buttons */
    padding: calc(56px + max(8px, var(--safe-top)) + 12px) 16px 20px 16px;
    margin: 0 !important;
}

body.mobile-mode .mobile-thread-subject h1 {
    font-size: 20px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    color: var(--mobile-text) !important;
    margin: 0 !important;
}

/* Message content scrolls from top in message view */
body.mobile-mode.mobile-message-view .mobile-view[data-view="message"] {
    padding-top: 0 !important;
}

/* Remove left-right padding from message content area */
body.mobile-mode #message-content .overflow-y-auto.px-6,
body.mobile-mode #reading-pane .overflow-y-auto.px-6 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Footer action buttons (Reply, Reply All, Forward) - prevent text wrapping */
body.mobile-mode .footer-actions {
    flex-wrap: nowrap !important;
}

body.mobile-mode .footer-actions button {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* Hide inline Reply/Reply All/Forward buttons - actions in bottom bar */
body.mobile-mode .reply-buttons,
body.mobile-mode [data-reply-buttons],
body.mobile-mode .flex.justify-center.gap-2.py-4,
body.mobile-mode .flex.justify-center.gap-3.py-4,
body.mobile-mode .flex.items-center.justify-center.gap-2,
body.mobile-mode .flex.items-center.justify-center.gap-3 {
    display: none !important;
}

/* Calendar invite - hide day view hour grid on mobile */
body.mobile-mode .day-view-wrapper,
body.mobile-mode .day-view-container,
body.mobile-mode .day-view-grid,
body.mobile-mode .day-view-header {
    display: none !important;
}

/* Calendar invite - make it more compact on mobile */
body.mobile-mode .ics-preview,
body.mobile-mode [class*="calendar-invite"],
body.mobile-mode [class*="invitation"] {
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 12px !important;
}

/* Calendar invite - remove height constraints on mobile so content can flow */
body.mobile-mode .invite-content {
    max-height: none !important;
    min-height: auto !important;
    flex-direction: column !important;
}

/* Calendar invite - let event details take full width and flow naturally */
body.mobile-mode .event-details-wrapper {
    width: 100% !important;
    overflow: visible !important;
}

body.mobile-mode .event-details-container {
    height: auto !important;
}

body.mobile-mode .event-content {
    overflow: visible !important;
    max-height: none !important;
}

/* Add padding at bottom for floating action bar - content scrolls behind */
body.mobile-mode.mobile-message-view #message-content,
body.mobile-mode.mobile-message-view #reading-pane {
    padding-bottom: 0 !important;
}

body.mobile-mode.mobile-message-view #message-content .overflow-y-auto,
body.mobile-mode.mobile-message-view #message-content > .flex-1 {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
}

body.mobile-mode.mobile-composer-active.mobile-message-view #message-content .overflow-y-auto,
body.mobile-mode.mobile-composer-active.mobile-message-view #message-content > .flex-1 {
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
}

/* Mobile nav header - fully transparent in message view, content scrolls behind */
body.mobile-mode.mobile-message-view #mobile-nav-header,
body.mobile-mode.mobile-message-view #mobile-nav-header.mobile-glass {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
    background: transparent !important;
    background-color: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* Mobile nav header - transparent in thread list view, content scrolls behind */
body.mobile-mode.mobile-thread-list-view #mobile-nav-header,
body.mobile-mode.mobile-thread-list-view #mobile-nav-header.mobile-glass {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
    background: transparent !important;
    background-color: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

body.mobile-mode.mobile-thread-list-view #mobile-nav-header button,
body.mobile-mode.mobile-thread-list-view #mobile-nav-header .mobile-nav-actions-pill {
    pointer-events: auto !important;
}

body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-leading {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    color: #ffffff;
}

body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-leading:active {
    background: rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
}

body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-title-btn {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 999px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-title,
body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-dropdown,
body.mobile-mode.mobile-thread-list-view #mobile-nav-header #mobile-nav-subtitle {
    color: #ffffff !important;
}

/* Allow buttons inside nav to receive clicks */
body.mobile-mode.mobile-message-view #mobile-nav-header button,
body.mobile-mode.mobile-message-view #mobile-nav-header .mobile-nav-actions-pill {
    pointer-events: auto !important;
}

/* Back button - glass pill style */
body.mobile-mode.mobile-message-view #mobile-nav-header #mobile-nav-leading {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    color: #ffffff;
}

body.mobile-mode.mobile-message-view #mobile-nav-header #mobile-nav-leading:active {
    background: rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
}

/* Hide title in message view (subject shown in content area) */
body.mobile-mode.mobile-message-view #mobile-nav-header #mobile-nav-title-btn {
    display: none !important;
}

/* Mobile nav header - glass pill style for message view actions */
body.mobile-mode #mobile-nav-header .mobile-nav-actions-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 6px 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

body.mobile-mode #mobile-nav-header .mobile-nav-actions-pill button {
    padding: 10px;
    border-radius: 50%;
    transition: all 150ms ease;
    color: #ffffff;
}

body.mobile-mode #mobile-nav-header .mobile-nav-actions-pill button:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.95);
}

body.mobile-mode #mobile-nav-header .mobile-nav-actions-pill button svg {
    width: 22px;
    height: 22px;
}

/* Floating bottom action bar for message view */
#mobile-message-actions {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-top: 20px;
    /* Transparent background - content scrolls behind */
    background: transparent !important;
    pointer-events: none;
    /* Flex to center the pill */
    justify-content: center;
}

body.mobile-mode.mobile-message-view #mobile-message-actions {
    display: flex;
}

body.mobile-mode.mobile-composer-active #mobile-message-actions {
    display: none !important;
}

#mobile-message-actions .action-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    /* Higher opacity ensures readability on any background */
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 4px 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
}

#mobile-message-actions .action-bar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #ffffff;
    transition: all 150ms ease;
}

#mobile-message-actions .action-bar button:active {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.92);
}

#mobile-message-actions .action-bar button svg {
    width: 20px;
    height: 20px;
}

#mobile-message-actions .action-bar button.is-active {
    color: #ffffff;
}

/* Simplify nav header title for message view - just show back + pill */
body.mobile-mode.mobile-message-view #mobile-nav-title {
    font-size: 13px !important;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
