:root {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #edf0f3;
    --border: #dfe3e8;
    --text: #202733;
    --muted: #66717f;
    --primary: #2563c7;
    --primary-strong: #1d4fa3;
    --primary-soft: #eaf2ff;
    --danger: #b42335;
    --success: #177245;
    --warning: #9a6700;
    --shadow: 0 12px 28px rgba(25, 39, 56, .14);
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-width: 232px;
    --list-width: 420px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f7f8fa;
    --surface-3: #edf0f3;
    --border: #dfe3e8;
    --text: #202733;
    --muted: #66717f;
    --primary: #2563c7;
    --primary-strong: #1d4fa3;
    --primary-soft: #eaf2ff;
    --danger: #c53e53;
    --success: #187e61;
    --warning: #9a6700;
    --shadow: 0 12px 28px rgba(25, 39, 56, .14);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #20252c;
    --surface: #292f37;
    --surface-2: #323943;
    --surface-3: #3c4550;
    --border: #46515d;
    --text: #f1f4f7;
    --muted: #aab4bf;
    --primary: #83b5f2;
    --primary-strong: #a3c9fa;
    --primary-soft: #334a68;
    --danger: #f18a98;
    --success: #78d3a4;
    --warning: #e7bc67;
    --shadow: 0 14px 32px rgba(0, 0, 0, .28);
}

html[data-theme="light"][data-accent="slate"] { --primary: #536b86; --primary-strong: #40566e; --primary-soft: #e9eef4; }
html[data-theme="light"][data-accent="green"] { --primary: #267653; --primary-strong: #1d5e41; --primary-soft: #e6f3ec; }
html[data-theme="light"][data-accent="violet"] { --primary: #7657a8; --primary-strong: #60448d; --primary-soft: #f0ebfa; }
html[data-theme="light"][data-accent="amber"] { --primary: #9a6910; --primary-strong: #7b520b; --primary-soft: #fff4d9; }
html[data-theme="dark"][data-accent="slate"] { --primary: #a5b9d0; --primary-strong: #c2d2e4; --primary-soft: #354558; }
html[data-theme="dark"][data-accent="green"] { --primary: #86d3a9; --primary-strong: #a3e3bf; --primary-soft: #29483a; }
html[data-theme="dark"][data-accent="violet"] { --primary: #c5adf2; --primary-strong: #d8c7fa; --primary-soft: #463b5f; }
html[data-theme="dark"][data-accent="amber"] { --primary: #e6bd70; --primary-strong: #f0d08d; --primary-soft: #4c4029; }
html[data-theme="dark"] .button-primary { color: #18212b; }
html[data-theme="dark"] .avatar { color: #18212b; }

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [contenteditable="true"]:focus-visible { outline: 3px solid rgba(131, 185, 255, .4); outline-offset: 2px; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.auth-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: min(100%, 410px); padding: 36px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.04em; }
.auth-card > .muted { margin: 0 0 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; color: var(--text); font-size: 18px; font-weight: 750; }
.auth-brand .brand-mark { margin: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 22px; color: #fff; background: var(--primary); border-radius: 7px; font-size: 21px; }
.brand-mark.small { width: 28px; height: 28px; margin: 0; border-radius: 6px; font-size: 15px; }
.stack-form { display: grid; gap: 9px; }
.stack-form label, .compose-body label, .account-form label, .rule-form label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stack-form input, .compose-body input, .compose-body select, .account-form input, .account-form select, .rule-form input, .rule-form select, .filter-row select { width: 100%; min-height: 42px; padding: 10px 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.stack-form input + label { margin-top: 7px; }
.auth-footnote { margin: 26px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.alert { padding: 11px 13px; margin: 0 0 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.alert-error { color: var(--danger); background: rgba(255, 141, 154, .09); }

.app-body { min-height: 100dvh; overflow: hidden; }
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 8px minmax(0, 1fr); min-height: 100dvh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: 18px; min-height: 0; height: 100dvh; overflow: hidden; padding: 18px 12px 12px; background: var(--surface); border-right: 1px solid var(--border); z-index: 20; }
.sidebar-top, .topbar, .pane-heading, .message-header-top, .sender-line, .dialog-header, .dialog-footer, .section-heading, .form-actions, .user-chip { display: flex; align-items: center; }
.sidebar-top { justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; text-decoration: none; letter-spacing: -.02em; }
.compose-button { justify-content: center; width: 100%; border-radius: 6px; }
.nav-stack { display: grid; flex: 1 1 0; gap: 4px; min-height: 0; overflow-y: auto; overflow-x: hidden; align-content: start; scrollbar-gutter: stable; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; text-align: left; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--primary-soft); }
.nav-icon { width: 18px; color: currentColor; font-size: 17px; text-align: center; }
.nav-count { margin-left: auto; color: var(--primary); font-size: 11px; font-weight: 800; }
.nav-heading { padding: 14px 12px 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.nav-heading-spaced { margin-top: 6px; }
.account-nav-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px 8px 20px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; text-align: left; }
.account-nav-item:hover { color: var(--text); background: var(--surface-2); }
.account-nav-section { display: grid; gap: 2px; }
.account-nav-heading { padding-left: 12px; }
.account-nav-copy { display: grid; min-width: 0; gap: 1px; }
.account-nav-copy strong, .account-nav-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-nav-copy strong { color: var(--text); font-size: 12px; }
.account-nav-copy small { color: var(--muted); font-size: 11px; }
.account-folder-label { padding: 7px 12px 2px 32px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.folder-nav-item { padding-left: 20px; }
.folder-nav-item.folder-depth-1 { padding-left: 36px; }
.folder-nav-item.folder-depth-2 { padding-left: 52px; }
.folder-nav-item.folder-depth-3 { padding-left: 68px; }
.folder-branch { width: 12px; flex: 0 0 auto; color: var(--primary); font-size: 12px; text-align: center; }
.account-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 99px; background: var(--success); }
.sidebar-bottom { display: grid; flex: 0 0 auto; gap: 7px; margin-top: auto; }
.sidebar-bottom .nav-item { padding-left: 12px; }
.user-chip { gap: 9px; padding: 10px 9px; border-top: 1px solid var(--border); color: var(--muted); }
.user-chip-name { overflow: hidden; flex: 1; color: var(--text); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.user-chip form { margin-left: auto; }
.avatar { display: inline-grid; flex: 0 0 auto; place-items: center; width: 30px; height: 30px; color: #fff; background: var(--primary); border-radius: 50%; font-size: 12px; font-weight: 800; }

.main-area { grid-column: 3; min-width: 0; }
.topbar { gap: 14px; height: 60px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-box { display: flex; align-items: center; gap: 10px; width: min(560px, 100%); min-height: 38px; padding: 0 8px 0 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.search-box input { min-width: 0; flex: 1; color: var(--text); background: transparent; border: 0; outline: 0; }
.search-box input::placeholder { color: var(--muted); }
.topbar-actions { display: flex; gap: 5px; margin-left: 0; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 10px; font-size: 18px; }
.icon-button:hover { color: var(--text); background: var(--surface-2); }
.menu-button, .sidebar-close, .mobile-back { display: none; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sync-indicator { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.sync-running { color: var(--primary); }
.sync-running .sync-indicator { background: var(--primary); animation: sync-pulse 1.2s ease-in-out infinite; }
.sync-idle .sync-indicator { background: var(--success); }
.sync-error .sync-indicator { background: var(--danger); }
.sync-empty .sync-indicator { background: var(--muted); }
@keyframes sync-pulse { 50% { opacity: .35; } }
.content-grid { display: grid; grid-template-columns: var(--list-width) 8px minmax(0, 1fr); height: calc(100dvh - 60px); }
.message-pane { min-width: 0; overflow: auto; background: var(--surface); border-right: 1px solid var(--border); }
.viewer-pane { min-width: 0; overflow: auto; background: var(--bg); }
.resize-handle { position: relative; z-index: 25; width: 8px; background: transparent; cursor: col-resize; touch-action: none; }
.resize-handle::after { position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; content: ''; }
.resize-handle:hover::after, .is-resizing .resize-handle::after { background: var(--primary); }
.sidebar-resizer { grid-column: 2; grid-row: 1; }
.message-resizer { grid-column: 2; }
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none !important; }
.pane-heading { justify-content: space-between; padding: 27px 20px 17px; }
.pane-heading h1 { margin: 0; font-size: 25px; letter-spacing: -.04em; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 20px 15px; }
.filter-row select { min-height: 36px; padding: 7px 8px; font-size: 12px; }
.message-list { display: grid; }
.message-item { display: grid; grid-template-columns: 37px minmax(0, 1fr) auto; gap: 10px; width: 100%; padding: 15px 20px; color: var(--text); background: transparent; border: 0; border-top: 1px solid var(--border); text-align: left; }
.message-item:hover, .message-item.selected { background: var(--surface-2); }
.message-item.unread { background: var(--primary-soft); }
.message-item.unread .message-subject, .message-item.unread .message-sender { font-weight: 800; }
.message-item .avatar { margin-top: 2px; }
.message-main { display: grid; min-width: 0; gap: 3px; }
.message-sender, .message-address, .message-subject, .message-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-sender { font-size: 12px; }
.message-address { color: var(--muted); font-size: 11px; }
.message-subject { font-size: 13px; }
.message-preview { color: var(--muted); font-size: 12px; }
.message-meta { display: grid; justify-items: end; gap: 8px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; max-width: 100px; padding: 3px 6px; overflow: hidden; color: var(--primary); background: var(--primary-soft); border-radius: 4px; font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.message-flags { color: var(--primary); }
.empty-state { display: grid; place-items: center; min-height: 180px; padding: 25px; color: var(--muted); text-align: center; }
.loading-state { min-height: 220px; }
.load-more { display: block; width: calc(100% - 40px); margin: 15px 20px 25px; padding: 10px; color: var(--primary); background: var(--primary-soft); border: 0; border-radius: 10px; }

.viewer-empty { display: grid; place-items: center; align-content: center; min-height: 100%; padding: 30px; color: var(--muted); text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 16px; color: var(--primary); background: var(--primary-soft); border-radius: 8px; font-size: 25px; }
.viewer-empty h2 { margin: 0 0 7px; color: var(--text); font-size: 20px; }
.viewer-empty p { max-width: 300px; margin: 0; line-height: 1.5; }
.message-view { min-height: 100%; }
.message-header { padding: 28px 34px 23px; border-bottom: 1px solid var(--border); }
.message-header-top { gap: 12px; }
.message-title-wrap { min-width: 0; flex: 1; }
.message-title-wrap h2 { margin: 0; overflow: hidden; font-size: 25px; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.message-actions { display: flex; gap: 3px; }
.sender-line { gap: 11px; margin-top: 20px; }
.avatar-message { width: 38px; height: 38px; }
.sender-details { display: grid; gap: 3px; min-width: 0; }
.sender-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-email, .recipient-line { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sender-line time { margin-left: auto; white-space: nowrap; }
.external-content-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 20px 34px 0; padding: 12px 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.external-content-toolbar > div:first-child { display: grid; gap: 4px; min-width: 0; }
.external-content-toolbar .muted { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.external-content-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.external-content-actions .button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.message-content { max-width: 900px; padding: 32px 34px; font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-content .mail-html { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; white-space: normal; }
.message-content a { color: var(--primary); }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 34px 26px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; font-size: 12px; text-decoration: none; }
.viewer-footer { display: flex; flex-wrap: wrap; gap: 8px; padding: 20px 34px 34px; border-top: 1px solid var(--border); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-weight: 650; }
.button:hover { background: var(--surface-3); }
.button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.button-wide { width: 100%; margin-top: 14px; }

dialog { padding: 0; color: var(--text); background: transparent; border: 0; }
dialog::backdrop { background: rgba(20, 30, 42, .48); }
.compose-dialog { width: min(660px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); margin: auto; }
.settings-dialog { width: min(820px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); margin: auto; }
.dialog-card { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.compose-card { max-height: calc(100dvh - 28px); }
.dialog-header { justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 20px; }
.compose-body, .settings-panel { display: grid; gap: 9px; padding: 20px 22px; }
.compose-body label { margin-top: 2px; }
.dialog-footer { justify-content: flex-end; gap: 8px; padding: 15px 22px; border-top: 1px solid var(--border); }
.editor-toolbar { display: flex; gap: 3px; padding: 7px; margin-top: 5px; background: var(--surface-2); border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; }
.editor-toolbar button { min-width: 30px; padding: 5px 8px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; }
.editor-toolbar button:hover { color: var(--text); background: var(--surface-3); }
.rich-editor { min-height: 150px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 0 10px 10px; line-height: 1.6; }
.rich-editor:empty::before { color: var(--muted); content: attr(data-placeholder); }
.upload-label { margin-top: 5px; }
.settings-tabs { display: flex; gap: 3px; padding: 12px 22px 0; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 12px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.section-heading { justify-content: space-between; gap: 12px; }
.section-heading h3, .settings-panel h3 { margin: 0; }
.section-heading p { margin: 4px 0 0; }
.design-section { display: grid; gap: 6px; max-width: 360px; padding: 4px 0; }
.field-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.design-section select { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.settings-list { display: grid; gap: 8px; }
.trusted-domain-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.trusted-domain-item { min-height: 58px; }
.settings-empty { margin: 0; padding: 10px 0; }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.settings-item strong, .settings-item span { display: block; }
.settings-item strong { margin-bottom: 3px; }
.settings-item span { color: var(--muted); font-size: 12px; }
.status-good { color: var(--success) !important; }
.status-bad { color: var(--danger) !important; }
.status-neutral { color: var(--muted) !important; }
.account-form, .rule-form { display: grid; gap: 12px; padding: 16px; margin-top: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; }
.account-form h3, .rule-form h3 { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: grid; gap: 5px; }
.account-form-heading { display: flex; align-items: flex-start; gap: 10px; }
.account-form-heading h3 { margin: 0; }
.account-form-heading p { margin: 4px 0 0; }
.step-number { display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; color: #fff; background: var(--primary); border-radius: 50%; font-size: 12px; font-weight: 800; }
.provider-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0; border: 0; }
.provider-choices legend { grid-column: 1 / -1; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 700; }
.provider-option { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 9px; min-width: 0; padding: 12px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.provider-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.provider-option input { margin-top: 3px; accent-color: var(--primary); }
.provider-option-copy { display: grid; gap: 2px; }
.provider-option-copy strong, .provider-option-copy small { overflow: hidden; text-overflow: ellipsis; }
.provider-option-copy strong { white-space: nowrap; }
.provider-option-copy small { color: var(--muted); font-size: 11px; }
.account-main-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-main-fields label { display: grid; gap: 5px; }
.account-main-fields label:last-child { grid-column: 1 / -1; }
.account-advanced { border-top: 1px solid var(--border); padding-top: 10px; }
.account-advanced summary { color: var(--primary); cursor: pointer; font-size: 12px; font-weight: 700; }
.account-advanced[open] summary { margin-bottom: 12px; }
.form-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.status-syncing { color: var(--primary) !important; }
.button-spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: button-spin .7s linear infinite; }
@keyframes button-spin { to { transform: rotate(360deg); } }
html[data-motion="subtle"] .nav-item,
html[data-motion="subtle"] .account-nav-item,
html[data-motion="subtle"] .message-item,
html[data-motion="subtle"] .button { transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease; }
html[data-motion="subtle"] .button:hover { transform: translateY(-1px); }
html[data-motion="lively"] .app-shell { animation: app-enter .38s ease both; }
html[data-motion="lively"] .brand-mark.small { animation: brand-breathe 3s ease-in-out infinite; }
html[data-motion="lively"] .message-item { animation: message-enter .32s ease both; }
html[data-motion="lively"] .message-item:nth-child(2) { animation-delay: .04s; }
html[data-motion="lively"] .message-item:nth-child(3) { animation-delay: .08s; }
html[data-motion="lively"] .message-item:nth-child(4) { animation-delay: .12s; }
html[data-motion="lively"] .sync-running .sync-indicator { animation-duration: .65s; }
@keyframes app-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes brand-breathe { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 18%, transparent); } }
@keyframes message-enter { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
.rule-form > label { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 7px; }
.form-actions { justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.toggle-row input { position: absolute; opacity: 0; }
.toggle { width: 42px; height: 24px; padding: 3px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 99px; transition: .2s; }
.toggle::after { display: block; width: 16px; height: 16px; background: var(--muted); border-radius: 50%; content: ''; transition: .2s; }
.toggle-row input:checked + .toggle { background: var(--primary); }
.toggle-row input:checked + .toggle::after { margin-left: 16px; background: #07101d; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--danger); }

/* Consistent floating labels for text fields and selects. */
.floating-field,
.account-form label.floating-field,
.form-grid label.floating-field,
.account-main-fields label.floating-field,
.compose-body label.floating-field,
.rule-form > label.floating-field { position: relative; display: block; min-width: 0; margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.floating-field > input:not([type="hidden"]),
.floating-field > select,
.floating-field > textarea,
.floating-field > .rich-editor { width: 100%; min-height: 48px; padding: 17px 12px 6px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.floating-field > span { position: absolute; top: 14px; left: 12px; z-index: 1; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1; pointer-events: none; transition: top .16s ease, color .16s ease, font-size .16s ease; }
.floating-field > input:focus ~ span,
.floating-field > input:not(:placeholder-shown) ~ span,
.floating-field > select ~ span,
.floating-field > textarea:focus ~ span,
.floating-field > textarea:not(:placeholder-shown) ~ span,
.editor-field:focus-within > span,
.editor-field:has(.rich-editor:not(:empty)) > span { top: 6px; color: var(--primary); font-size: 10px; font-weight: 750; }
.floating-field > input:focus,
.floating-field > select:focus,
.floating-field > textarea:focus,
.floating-field > .rich-editor:focus { border-color: var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 22%, transparent); outline-offset: 0; }
.floating-field > span small { font-size: 10px; font-weight: 500; }
.editor-field > .rich-editor { min-height: 150px; padding-top: 20px; border-radius: 0 0 10px 10px; }
.editor-field > span { top: 14px; }
.search-box .floating-field { flex: 1; }
.search-box .floating-field > input { min-height: 36px; padding: 15px 0 3px; background: transparent; border: 0; border-radius: 0; }
.search-box .floating-field > span { top: 11px; left: 0; }
.search-box .floating-field > input:focus ~ span,
.search-box .floating-field > input:not(:placeholder-shown) ~ span { top: 2px; font-size: 9px; }
.filter-row .floating-field { min-width: 0; }
.filter-row .floating-field > select { min-height: 42px; padding-top: 16px; }
.viewer-folder-field { width: min(210px, 100%); }
.viewer-folder-field > select { min-height: 36px; padding-top: 15px; }
.viewer-folder-field > span { top: 5px; font-size: 9px; }
.rule-field-group { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); align-items: end; gap: 8px; }
.rule-field-group + .rule-field-group { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.4fr); }
.rule-group-label { padding: 0 2px 16px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}

@media (max-width: 1050px) {
    :root { --sidebar-width: 224px; --list-width: 330px; }
    .message-header, .message-content, .viewer-footer, .attachment-list { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 800px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
    .app-body.sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-close, .menu-button { display: inline-grid; }
    .topbar { padding: 12px 15px; }
    .content-grid { display: block; height: calc(100dvh - 60px); }
    .resize-handle { display: none; }
    .message-pane { height: 100%; border-right: 0; }
    .viewer-pane { position: fixed; inset: 66px 0 0; z-index: 10; display: none; height: auto; }
    .app-body.message-open .viewer-pane { display: block; }
    .viewer-empty { min-height: 100%; }
    .mobile-back { display: inline-grid; }
    .message-header { padding: 18px 17px; }
    .message-content, .viewer-footer, .attachment-list { padding-left: 17px; padding-right: 17px; }
    .external-content-toolbar { align-items: stretch; flex-direction: column; margin: 17px; }
    .external-content-actions { justify-content: flex-start; }
    .message-title-wrap h2 { font-size: 20px; }
    .sender-line time { display: none; }
}
@media (max-width: 560px) {
    .sync-status { max-width: 8px; overflow: hidden; }
    .topbar-actions .icon-button:not(:first-child) { display: none; }
    .pane-heading { padding: 20px 15px 14px; }
    .filter-row { padding-left: 15px; padding-right: 15px; }
    .message-item { padding: 14px 15px; }
    .message-meta .badge { display: none; }
    .form-grid, .account-main-fields, .provider-choices { grid-template-columns: 1fr; }
    .account-main-fields label:last-child { grid-column: auto; }
    .rule-form > label { grid-template-columns: 1fr; }
    .rule-field-group, .rule-field-group + .rule-field-group { grid-template-columns: 1fr; }
    .rule-group-label { padding-bottom: 0; }
    .trusted-domain-form { grid-template-columns: 1fr; }
    .settings-tabs { overflow-x: auto; }
    .auth-card { padding: 28px 22px; }
    .settings-dialog, .compose-dialog { width: calc(100vw - 14px); max-height: calc(100dvh - 14px); }
    .dialog-header, .compose-body, .settings-panel, .dialog-footer { padding-left: 15px; padding-right: 15px; }
    .viewer-footer .button { flex: 1; }
}
