: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;
}

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);
}

#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(8px, 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: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--mobile-shadow-soft);
    color: var(--mobile-text);
}

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

#mobile-nav-leading {
    width: 36px;
    height: 36px;
    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: 6px;
    border-radius: 10px;
}

#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;
}

.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: 44px;
    height: 44px;
    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-toast {
    position: fixed;
    top: calc(max(8px, var(--safe-top)) + 64px); /* Below nav header */
    left: calc(max(0px, var(--safe-left)) + 16px);
    right: calc(max(0px, var(--safe-right)) + 16px);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    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(56px + max(8px, 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: 15px !important;
}

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;
}

/* Make labels scroll with folders (single scrollable area) */
body.mobile-mode #main-sidebar #labels-list {
    overflow-y: visible !important;
    flex: none !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: 15px !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 24px !important;
    font-size: 14px !important;
    gap: 10px !important;
}

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

/* Folder label text */
body.mobile-mode #main-sidebar button span.text-sm,
body.mobile-mode #main-sidebar button span.tracking-tight {
    font-size: 15px !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"] {
    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;
}

/* 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;
}

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;
}

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

/* Section headers/details summary */
body.mobile-mode #main-sidebar details > summary,
body.mobile-mode #main-sidebar .section-title {
    font-size: 11px !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 [id^="mail-composer-"] {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
}

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 [id^="mail-composer-"].mobile-composer-sheet {
    top: 40% !important;
    height: 60% !important;
    border-radius: 16px 16px 0 0 !important;
}

body.mobile-mode [id^="mail-composer-"].mobile-composer-sheet.is-expanded {
    top: 0 !important;
    height: 100% !important;
    border-radius: 0 !important;
}

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

.mobile-composer-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.18);
    margin: 6px auto;
}

.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: 1;
    pointer-events: auto;
}

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

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);
}

.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);
}

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

.mobile-drawer {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: none;
    pointer-events: none;
}

.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 {
    display: flex;
    pointer-events: auto;
}

/* ============================================
   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-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;
}

/* 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: 6px 12px;
    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: 2px;
    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 16px rgba(0, 0, 0, 0.12);
}

body.mobile-mode #mobile-nav-header .mobile-nav-actions-pill button {
    padding: 8px;
    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: 20px;
    height: 20px;
}

/* 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;
}

#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;
}
