:root {
    --brand: #D5A522;
    --brand-strong: #E4B72E;
    --brand-soft: rgba(213, 165, 34, .14);
    --brand-border: rgba(213, 165, 34, .28);
    --bg: #0f1012;
    --bg-elevated: #151619;
    --panel: #191a1e;
    --panel-2: #202126;
    --panel-3: #282a30;
    --text: #f7f7f8;
    --text-soft: #c7c8cd;
    --muted: #8f929b;
    --border: rgba(255,255,255,.09);
    --border-strong: rgba(255,255,255,.15);
    --danger: #ef6b6b;
    --success: #5fd39b;
    --shadow: 0 22px 60px rgba(0,0,0,.34);
    --sidebar: 252px;
    --list: 430px;
    --topbar: 72px;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --transition: 180ms ease;
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #f3f3f1;
    --bg-elevated: #ffffff;
    --panel: #ffffff;
    --panel-2: #f7f7f5;
    --panel-3: #eeeeeb;
    --text: #191a1d;
    --text-soft: #4e5057;
    --muted: #747780;
    --border: rgba(0,0,0,.08);
    --border-strong: rgba(0,0,0,.14);
    --shadow: 0 22px 60px rgba(33,33,33,.13);
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: rgba(213,165,34,.32); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(145,148,157,.28); border: 3px solid transparent; background-clip: padding-box; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(145,148,157,.46); border: 3px solid transparent; background-clip: padding-box; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.noscript { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: var(--bg); padding: 30px; text-align: center; }

/* Login */
.login-page { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(440px, .92fr); background: var(--bg); }
.login-brand { position: relative; overflow: hidden; padding: clamp(38px, 5vw, 76px); display: flex; flex-direction: column; isolation: isolate; background:
    radial-gradient(circle at 20% 22%, rgba(213,165,34,.19), transparent 34%),
    linear-gradient(145deg, #101113 0%, #1a1b1f 58%, #111214 100%); }
.login-brand::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .16; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 52px 52px; mask-image: linear-gradient(to bottom, black, transparent 85%); }
.login-brand::after { content: ""; position: absolute; width: 460px; aspect-ratio: 1; border: 1px solid rgba(213,165,34,.25); border-radius: 50%; right: -170px; bottom: -170px; box-shadow: 0 0 0 45px rgba(213,165,34,.035), 0 0 0 90px rgba(213,165,34,.02); z-index: -1; }
.login-brand__glow { position: absolute; width: 280px; height: 280px; border-radius: 50%; filter: blur(80px); background: rgba(213,165,34,.16); right: 8%; top: 18%; z-index: -1; }
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-lockup .brand-logo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }
.brand-lockup > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-lockup strong { letter-spacing: .08em; font-size: 17px; }
.brand-lockup span { color: var(--muted); font-size: 15px; }
.brand-lockup--large .brand-logo { width: 54px; height: 54px; }
.brand-lockup--large strong { font-size: 20px; }
.login-copy { margin: auto 0; max-width: 700px; padding: 80px 0 55px; }
.eyebrow { display: block; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.login-copy h1 { margin: 18px 0 22px; font-size: clamp(38px, 4.4vw, 68px); line-height: 1.02; letter-spacing: -.045em; max-width: 780px; }
.login-copy p { max-width: 620px; color: #bbbcc1; font-size: clamp(17px, 1.5vw, 21px); line-height: 1.65; margin: 0; }
.login-features { display: grid; gap: 12px; color: #aeb0b6; font-size: 14px; }
.login-features > div { display: flex; align-items: center; gap: 10px; }
.feature-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 5px rgba(213,165,34,.1); }
.login-panel { min-height: 100dvh; background: var(--bg-elevated); display: grid; place-items: center; padding: 44px; position: relative; }
.login-card { width: min(100%, 460px); }
.login-card__mobile-brand { display: none; margin-bottom: 50px; }
.login-card h2 { margin: 10px 0 8px; font-size: 36px; letter-spacing: -.035em; }
.login-subtitle { margin: 0 0 34px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.input-shell { min-height: 54px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 14px; display: flex; align-items: center; gap: 12px; padding: 0 15px; transition: border var(--transition), box-shadow var(--transition), background var(--transition); }
.input-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(213,165,34,.1); background: var(--panel); }
.input-shell > .icon { color: var(--muted); }
.input-shell input { min-width: 0; flex: 1; height: 52px; border: 0; outline: 0; background: transparent; color: var(--text); }
.input-shell input[readonly] { color: var(--text-soft); cursor: default; }
.input-action { width: 36px !important; height: 36px !important; }
.primary-button, .secondary-button, .toolbar-button, .icon-button, .compose-button, .filter-chip, .text-button { border: 0; cursor: pointer; transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), opacity var(--transition); }
.primary-button { min-height: 44px; border-radius: 12px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--brand); color: #151515; font-weight: 800; box-shadow: 0 10px 28px rgba(213,165,34,.18); }
.primary-button:hover { background: var(--brand-strong); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.login-submit { min-height: 56px; margin-top: 5px; }
.form-error { border: 1px solid rgba(239,107,107,.3); background: rgba(239,107,107,.09); color: #ffb3b3; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.privacy-note { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; margin: 24px 0 0; }
.privacy-note .icon { width: 17px; height: 17px; color: var(--brand); margin-top: 1px; }
.login-footer { position: absolute; left: 44px; right: 44px; bottom: 28px; color: var(--muted); font-size: 11px; text-align: center; }
.system-alert { display: grid; gap: 5px; border-radius: 12px; padding: 13px 14px; margin-bottom: 20px; font-size: 12px; line-height: 1.45; }
.system-alert--danger { background: rgba(239,107,107,.09); border: 1px solid rgba(239,107,107,.25); color: #ffc0c0; }
.system-alert code { font-weight: 800; color: inherit; }

/* App shell */
.mail-app { width: 100vw; height: 100dvh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); overflow: hidden; background: var(--bg); }
.sidebar { min-width: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--bg-elevated); border-right: 1px solid var(--border); padding: 18px 14px 14px; position: relative; z-index: 30; }
.sidebar-brand { min-height: 46px; padding: 0 8px 14px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand .brand-lockup .brand-logo { width: 36px; height: 36px; }
.sidebar-brand .brand-lockup strong { font-size: 15px; }
.sidebar-brand .brand-lockup span { font-size: 13px; }
.compose-button { width: 100%; min-height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--brand); color: #141414; font-weight: 800; margin: 10px 0 18px; box-shadow: 0 10px 24px rgba(213,165,34,.15); }
.compose-button:hover { background: var(--brand-strong); transform: translateY(-1px); }
.folder-nav { display: grid; gap: 4px; overflow: auto; padding-right: 2px; }
.folder-button { width: 100%; min-height: 43px; border-radius: 11px; padding: 0 10px; border: 0; background: transparent; color: var(--text-soft); display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: left; }
.folder-button:hover { background: var(--panel-2); color: var(--text); }
.folder-button.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.folder-button .icon { width: 19px; height: 19px; }
.folder-label { min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 650; font-size: 13px; }
.folder-count { min-width: 24px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--panel-3); color: var(--muted); font-size: 11px; font-weight: 800; }
.folder-button.is-active .folder-count { background: rgba(213,165,34,.18); color: var(--brand-strong); }
.sidebar-spacer { flex: 1; min-height: 20px; }
.account-card { min-height: 62px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 14px; padding: 10px; display: flex; align-items: center; gap: 9px; position: relative; }
.avatar, .top-avatar, .sender-avatar { display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, var(--brand), #a8780f); color: #171717; font-weight: 900; text-transform: uppercase; }
.avatar { width: 34px; height: 34px; font-size: 13px; }
.account-card__copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.account-card__copy strong, .account-card__copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-card__copy strong { font-size: 12px; }
.account-card__copy span { color: var(--muted); font-size: 10px; }
.account-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); border: 1px solid var(--border); background: var(--panel); box-shadow: var(--shadow); border-radius: 12px; padding: 6px; z-index: 100; }
.account-menu button, .account-menu a { width: 100%; border: 0; background: transparent; color: var(--text-soft); min-height: 40px; padding: 0 10px; display: flex; align-items: center; gap: 10px; border-radius: 9px; cursor: pointer; font-size: 12px; }
.account-menu button:hover, .account-menu a:hover { background: var(--panel-3); color: var(--text); }
.nav-skeleton { height: 43px; border-radius: 10px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

.workspace { min-width: 0; height: 100dvh; display: grid; grid-template-rows: var(--topbar) minmax(0,1fr); }
.topbar { min-width: 0; height: var(--topbar); padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 620px) minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-elevated) 93%, transparent); backdrop-filter: blur(18px); position: relative; z-index: 20; }
.topbar-left { display: flex; align-items: center; }
.search-box { height: 44px; border: 1px solid var(--border); border-radius: 13px; background: var(--panel-2); display: flex; align-items: center; gap: 10px; padding: 0 12px; transition: border var(--transition), box-shadow var(--transition), background var(--transition); }
.search-box:focus-within { border-color: var(--brand-border); background: var(--panel); box-shadow: 0 0 0 4px rgba(213,165,34,.08); }
.search-box > .icon { color: var(--muted); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); outline: 0; font-size: 13px; }
.search-box kbd, .shortcut-hint kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--panel-3); color: var(--muted); border-radius: 6px; padding: 2px 6px; font-size: 10px; font-family: inherit; }
.search-box .icon-button { width: 28px; height: 28px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.top-avatar { width: 34px; height: 34px; font-size: 12px; margin-left: 4px; }
.icon-button { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; background: transparent; color: var(--text-soft); padding: 0; }
.icon-button:hover { background: var(--panel-3); color: var(--text); }
.icon-button.is-active, .icon-button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); }
.icon-button:disabled { opacity: .45; cursor: not-allowed; }
.danger-hover:hover { color: var(--danger); background: rgba(239,107,107,.1); }

.mail-grid { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(330px, var(--list)) minmax(0, 1fr); background: var(--bg); }
.list-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; border-right: 1px solid var(--border); background: var(--bg-elevated); }
.list-header { min-height: 92px; padding: 22px 20px 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.list-header h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.025em; }
.list-header-actions { display: flex; align-items: center; gap: 4px; }
.filter-row { display: flex; gap: 7px; padding: 0 18px 14px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip { min-height: 31px; padding: 0 12px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid transparent; font-size: 11px; font-weight: 750; white-space: nowrap; }
.filter-chip:hover { color: var(--text); border-color: var(--border); }
.filter-chip.is-active { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand-border); }
.message-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px 12px; }
.message-item { width: 100%; min-height: 106px; border: 1px solid transparent; border-bottom-color: var(--border); background: transparent; color: var(--text); display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 10px; padding: 14px 10px; text-align: left; cursor: pointer; position: relative; border-radius: 12px; }
.message-item:hover { background: var(--panel-2); border-color: var(--border); }
.message-item.is-selected { background: var(--brand-soft); border-color: var(--brand-border); }
.message-item.is-unread::before { content: ""; position: absolute; left: 1px; top: 22px; width: 3px; height: 28px; border-radius: 4px; background: var(--brand); }
.message-star { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; border-radius: 8px; padding: 0; cursor: pointer; }
.message-star:hover { background: var(--panel-3); color: var(--brand); }
.message-star.is-starred { color: var(--brand); }
.message-star.is-starred .icon { fill: currentColor; }
.message-main { min-width: 0; display: grid; gap: 5px; }
.message-topline, .message-subject-line { min-width: 0; display: flex; align-items: center; gap: 8px; }
.message-sender { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.message-item.is-unread .message-sender, .message-item.is-unread .message-subject { font-weight: 850; }
.message-time { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.message-subject { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); font-size: 12px; }
.message-paperclip { width: 14px; height: 14px; color: var(--muted); }
.message-preview { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.message-empty, .message-error { min-height: 260px; padding: 30px 24px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.message-empty .empty-icon, .message-error .empty-icon { width: 54px; height: 54px; }
.message-empty h3, .message-error h3 { color: var(--text); margin: 14px 0 6px; font-size: 16px; }
.message-empty p, .message-error p { margin: 0; font-size: 12px; max-width: 260px; line-height: 1.5; }
.message-skeleton { height: 104px; margin: 0 4px; border-bottom: 1px solid var(--border); position: relative; overflow: hidden; }
.message-skeleton::after { content: ""; position: absolute; inset: 15px 10px; border-radius: 10px; background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.pagination { min-height: 48px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 11px; }
.pagination .icon-button { width: 32px; height: 32px; }

.reader-pane { min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.reader-empty { height: 100%; display: grid; place-content: center; justify-items: center; padding: 34px; text-align: center; color: var(--muted); }
.empty-icon { width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; background: var(--panel-2); color: var(--brand); border: 1px solid var(--border); }
.empty-icon .icon { width: 30px; height: 30px; }
.reader-empty h2 { margin: 18px 0 7px; color: var(--text); font-size: 20px; }
.reader-empty p { margin: 0 0 20px; font-size: 13px; }
.shortcut-hint { font-size: 10px; display: flex; align-items: center; gap: 7px; }
.reader-content { height: 100%; display: grid; grid-template-rows: auto minmax(0,1fr); }
.reader-toolbar { min-height: 58px; padding: 0 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--bg-elevated); }
.reader-toolbar__left, .reader-toolbar__right { display: flex; align-items: center; gap: 5px; }
.toolbar-button { min-height: 36px; padding: 0 11px; border-radius: 9px; background: transparent; color: var(--text-soft); display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; }
.toolbar-button:hover { background: var(--panel-3); color: var(--text); }
.toolbar-button .icon { width: 17px; height: 17px; }
.reader-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.message-heading { padding: 30px clamp(24px, 4vw, 58px) 20px; max-width: 1120px; margin: 0 auto; }
.message-heading__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.message-heading h2 { margin: 0; font-size: clamp(23px, 2.2vw, 34px); line-height: 1.22; letter-spacing: -.03em; }
.message-heading time { flex: 0 0 auto; color: var(--muted); font-size: 11px; padding-top: 7px; }
.sender-row { margin-top: 24px; display: flex; align-items: center; gap: 12px; }
.sender-avatar { width: 42px; height: 42px; font-size: 14px; }
.sender-copy { min-width: 0; display: grid; gap: 3px; }
.sender-copy strong { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.address-summary { border: 0; background: transparent; color: var(--muted); padding: 0; text-align: left; cursor: pointer; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.address-summary:hover { color: var(--brand-strong); }
.message-details { margin-top: 14px; padding: 12px 14px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 11px; line-height: 1.7; }
.message-details strong { color: var(--text-soft); }
.remote-images-notice { max-width: 1120px; margin: 0 auto 12px; width: calc(100% - clamp(48px, 8vw, 116px)); min-height: 42px; border: 1px solid var(--brand-border); background: var(--brand-soft); color: var(--text-soft); border-radius: 11px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; font-size: 11px; }
.remote-images-notice .icon { color: var(--brand); width: 17px; height: 17px; }
.remote-images-notice span { flex: 1; }
.remote-images-notice button { border: 0; background: transparent; color: var(--brand-strong); font-weight: 800; cursor: pointer; white-space: nowrap; }
.attachment-list { max-width: 1120px; margin: 0 auto 16px; width: calc(100% - clamp(48px, 8vw, 116px)); display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-card { min-width: 190px; max-width: 320px; flex: 0 1 auto; min-height: 52px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 12px; padding: 9px 11px; display: flex; align-items: center; gap: 10px; }
.attachment-card:hover { border-color: var(--brand-border); }
.attachment-card .icon { color: var(--brand); }
.attachment-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.attachment-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.attachment-copy span { color: var(--muted); font-size: 9px; }
.message-body-shell { max-width: 1120px; min-height: 360px; margin: 0 auto; padding: 0 clamp(24px, 4vw, 58px) 36px; }
.message-frame { display: block; width: 100%; min-height: 420px; border: 0; background: #fff; border-radius: 14px; box-shadow: 0 0 0 1px var(--border); }
.message-bottom-actions { max-width: 1120px; margin: 0 auto; padding: 0 clamp(24px, 4vw, 58px) 46px; display: flex; gap: 10px; }
.secondary-button { min-height: 40px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-soft); display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 750; }
.secondary-button:hover { border-color: var(--brand-border); color: var(--brand-strong); }
.secondary-button .icon { width: 17px; height: 17px; }
.reader-loading { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }

/* Compose */
.compose-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.54); backdrop-filter: blur(8px); display: flex; align-items: flex-end; justify-content: flex-end; padding: 24px; }
.compose-window { width: min(760px, calc(100vw - 48px)); height: min(760px, calc(100dvh - 48px)); border: 1px solid var(--border-strong); background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); display: grid; grid-template-rows: auto minmax(0,1fr); overflow: hidden; animation: composeIn .22s ease both; }
.compose-window.is-minimized { height: 66px; width: 360px; }
.compose-window.is-minimized .compose-form { display: none; }
.compose-header { min-height: 66px; padding: 0 16px 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.compose-header h2 { margin: 3px 0 0; font-size: 16px; }
.compose-header-actions { display: flex; align-items: center; gap: 3px; }
.compose-form { min-height: 0; display: grid; grid-template-rows: auto auto auto minmax(0,1fr) auto auto; }
.recipient-row, .subject-row { min-height: 48px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 18px; }
.recipient-row > span { width: 34px; color: var(--muted); font-size: 11px; font-weight: 750; }
.recipient-row input, .subject-row input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.text-button { background: transparent; color: var(--brand-strong); font-size: 10px; font-weight: 800; padding: 8px; border-radius: 8px; }
.text-button:hover { background: var(--brand-soft); }
.compose-editor-wrap { min-height: 0; overflow: auto; }
.compose-editor { min-height: 100%; outline: 0; padding: 22px 20px 40px; color: var(--text); line-height: 1.65; font-size: 14px; }
.compose-editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.selected-files { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 7px; max-height: 110px; overflow: auto; }
.file-pill { min-height: 34px; max-width: 260px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 9px; display: flex; align-items: center; gap: 7px; padding: 0 9px; font-size: 10px; color: var(--text-soft); }
.file-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pill button { border: 0; background: transparent; color: var(--muted); padding: 0; display: grid; cursor: pointer; }
.compose-footer { min-height: 64px; border-top: 1px solid var(--border); padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compose-footer__left, .compose-footer__right { display: flex; align-items: center; gap: 7px; }
.compose-footer .primary-button { min-width: 110px; }
.file-button { cursor: pointer; }
.compose-status { color: var(--muted); font-size: 10px; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Toast */
.toast-region { position: fixed; z-index: 2000; top: 18px; right: 18px; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); pointer-events: none; }
.toast { min-height: 50px; border: 1px solid var(--border-strong); background: var(--panel); box-shadow: var(--shadow); border-radius: 12px; padding: 11px 13px; display: flex; align-items: flex-start; gap: 10px; pointer-events: auto; animation: toastIn .2s ease both; }
.toast .toast-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.toast .toast-icon .icon { width: 16px; height: 16px; }
.toast-copy { min-width: 0; flex: 1; display: grid; gap: 2px; }
.toast-copy strong { font-size: 12px; }
.toast-copy span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.toast.is-error .toast-icon { background: rgba(239,107,107,.11); color: var(--danger); }
.toast.is-success .toast-icon { background: rgba(95,211,155,.11); color: var(--success); }

.mobile-only { display: none !important; }
.mobile-backdrop, .mobile-bottom-nav { display: none; }
.mobile-brand { align-items: center; gap: 8px; }
.mobile-brand img { width: 30px; height: 30px; border-radius: 50%; }
.mobile-brand strong { font-size: 13px; }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes composeIn { from { opacity: 0; transform: translateY(20px) scale(.985); } }

@media (max-width: 1180px) {
    :root { --sidebar: 224px; --list: 390px; }
    .sidebar { padding-left: 10px; padding-right: 10px; }
    .toolbar-button span { display: none; }
    .toolbar-button { width: 38px; padding: 0; justify-content: center; }
}

@media (max-width: 900px) {
    :root { --sidebar: 82px; --list: 360px; }
    .sidebar-brand .brand-lockup > div, .compose-button span, .folder-label, .account-card__copy, .account-card > .icon-button { display: none; }
    .sidebar-brand { justify-content: center; padding-inline: 0; }
    .compose-button { width: 50px; margin-inline: auto; }
    .folder-button { width: 50px; margin-inline: auto; justify-content: center; padding: 0; position: relative; }
    .folder-count { position: absolute; right: -3px; top: 2px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 9px; }
    .account-card { width: 50px; margin-inline: auto; justify-content: center; padding: 7px; border: 0; background: transparent; }
    .topbar { grid-template-columns: 1fr minmax(280px, 520px) 1fr; }
}

@media (max-width: 760px) {
    :root { --topbar: 60px; }
    body { overflow: hidden; }
    .desktop-only { display: none !important; }
    .mobile-only { display: inline-grid !important; }
    .login-page { display: block; min-height: 100dvh; overflow-y: auto; }
    .login-brand { display: none; }
    .login-panel { min-height: 100dvh; padding: 28px 22px 82px; place-items: center; }
    .login-card__mobile-brand { display: inline-flex; }
    .login-card h2 { font-size: 31px; }
    .login-footer { left: 20px; right: 20px; bottom: 22px; }

    .mail-app { display: block; height: 100dvh; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
    .workspace { height: calc(100dvh - 66px - env(safe-area-inset-bottom)); grid-template-rows: var(--topbar) minmax(0,1fr); }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 330px); height: 100dvh; transform: translateX(-105%); transition: transform .24s ease; box-shadow: var(--shadow); padding: 16px 14px calc(18px + env(safe-area-inset-bottom)); z-index: 120; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-brand { justify-content: space-between; padding: 0 6px 14px; }
    .sidebar-brand .brand-lockup > div, .compose-button span, .folder-label, .account-card__copy, .account-card > .icon-button { display: flex; }
    .sidebar-brand .brand-lockup > div { display: flex; }
    .compose-button { width: 100%; margin: 10px 0 18px; }
    .folder-button { width: 100%; margin: 0; justify-content: flex-start; padding: 0 10px; }
    .folder-count { position: static; min-width: 24px; height: 22px; font-size: 11px; }
    .account-card { width: 100%; margin: 0; justify-content: flex-start; padding: 10px; border: 1px solid var(--border); background: var(--panel-2); }
    .mobile-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.58); backdrop-filter: blur(3px); }
    .mobile-backdrop.is-visible { display: block; }

    .topbar { height: var(--topbar); padding: 0 12px; display: flex; justify-content: space-between; gap: 10px; }
    .topbar-left { min-width: 0; gap: 8px; }
    .mobile-brand { display: flex !important; }
    .search-box { position: fixed; top: 8px; left: 10px; right: 10px; height: 45px; z-index: 150; transform: translateY(-75px); opacity: 0; pointer-events: none; transition: transform .2s ease, opacity .2s ease; box-shadow: var(--shadow); }
    .search-box.is-mobile-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
    .search-box kbd { display: none; }
    .topbar-actions { margin-left: auto; }
    .topbar-actions #refreshButton { display: none; }

    .mail-grid { display: block; height: 100%; }
    .list-pane { width: 100%; height: 100%; border-right: 0; grid-template-rows: auto auto minmax(0,1fr) auto; }
    .list-header { min-height: 78px; padding: 16px 16px 12px; }
    .list-header h1 { font-size: 21px; }
    .filter-row { padding: 0 14px 12px; }
    .message-list { padding: 0 6px 10px; }
    .message-item { min-height: 99px; padding: 12px 9px; }
    .reader-pane { position: fixed; inset: 0 0 calc(66px + env(safe-area-inset-bottom)) 0; z-index: 80; background: var(--bg); transform: translateX(105%); transition: transform .24s ease; }
    .reader-pane.is-mobile-open { transform: translateX(0); }
    .reader-toolbar { min-height: 58px; padding: 0 10px; }
    .reader-toolbar__left { gap: 2px; }
    .reader-toolbar .toolbar-button { width: 36px; }
    .message-heading { padding: 24px 18px 18px; }
    .message-heading__top { display: grid; gap: 9px; }
    .message-heading h2 { font-size: 24px; }
    .message-heading time { padding: 0; }
    .remote-images-notice, .attachment-list { width: calc(100% - 36px); }
    .remote-images-notice { align-items: flex-start; flex-wrap: wrap; }
    .remote-images-notice span { min-width: calc(100% - 30px); }
    .remote-images-notice button { margin-left: 27px; }
    .message-body-shell { padding: 0 14px 28px; min-height: 300px; }
    .message-frame { min-height: 400px; border-radius: 12px; }
    .message-bottom-actions { padding: 0 14px 34px; }

    .mobile-bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; height: calc(66px + env(safe-area-inset-bottom)); padding: 5px 16px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--bg-elevated) 94%, transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr 1fr; }
    .mobile-bottom-nav button { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 9px; font-weight: 750; }
    .mobile-bottom-nav button.is-active { color: var(--brand-strong); }
    .mobile-bottom-nav .icon { width: 20px; height: 20px; }
    .mobile-compose-circle { width: 40px; height: 32px; display: grid; place-items: center; border-radius: 99px; background: var(--brand); color: #151515; }

    .compose-overlay { inset: 0; padding: 0; align-items: stretch; justify-content: stretch; background: var(--bg); }
    .compose-window { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
    .compose-header { padding-top: env(safe-area-inset-top); min-height: calc(62px + env(safe-area-inset-top)); }
    .compose-form { grid-template-rows: auto auto auto minmax(0,1fr) auto auto; }
    .compose-footer { padding-bottom: env(safe-area-inset-bottom); min-height: calc(64px + env(safe-area-inset-bottom)); }
    .compose-status { max-width: 130px; }
    .toast-region { top: calc(10px + env(safe-area-inset-top)); right: 10px; width: calc(100vw - 20px); }
}

@media (max-width: 430px) {
    .login-panel { padding-inline: 18px; }
    .login-card__mobile-brand { margin-bottom: 38px; }
    .input-shell { min-height: 52px; }
    .message-item { grid-template-columns: 27px minmax(0,1fr); gap: 8px; }
    .message-preview { -webkit-line-clamp: 1; }
    .compose-footer .primary-button { min-width: 96px; padding-inline: 14px; }
    .compose-footer__left, .compose-footer__right { gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* DMTEI Mail 1.1 — navegación y acciones de carpetas */
.folder-loading {
    min-height: 43px;
    border-radius: 11px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--muted);
    opacity: .68;
}
.folder-loading .icon { width: 19px; height: 19px; }
.folder-loading span { font-size: 13px; font-weight: 650; }
.folder-loading.is-error { opacity: .5; }
.folder-section-label {
    padding: 17px 10px 5px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.folder-nav-error { padding: 16px 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.quota-card { margin: 0 4px 10px; padding: 10px 9px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); }
.quota-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; }
.quota-row strong { color: var(--text-soft); font-size: 9px; font-weight: 750; }
.quota-track { height: 4px; margin-top: 8px; border-radius: 99px; overflow: hidden; background: var(--panel-3); }
.quota-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .25s ease; }
.folder-action-button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-2);
    color: var(--text-soft);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 750;
}
.folder-action-button .icon { width: 15px; height: 15px; }
.folder-action-button:hover { border-color: var(--border-strong); background: var(--panel-3); color: var(--text); }
.folder-action-button.is-danger { color: var(--danger); }
.folder-action-button.is-danger:hover { border-color: rgba(239,107,107,.3); background: rgba(239,107,107,.09); }
.folder-action-button:disabled { opacity: .45; cursor: wait; }
.message-badge {
    flex: 0 0 auto;
    border-radius: 99px;
    padding: 2px 6px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 8px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.icon-button.is-permanent { color: var(--danger); background: rgba(239,107,107,.08); }
.icon-button.is-permanent:hover { background: rgba(239,107,107,.16); }

@media (max-width: 900px) and (min-width: 761px) {
    .folder-loading { width: 50px; margin-inline: auto; justify-content: center; padding: 0; }
    .folder-loading span, .folder-section-label, .quota-card { display: none; }
}

@media (max-width: 760px) {
    .folder-action-button span { display: none; }
    .folder-action-button { width: 36px; padding: 0; justify-content: center; }
    .quota-card { margin-bottom: 10px; }
    .reader-toolbar__left, .reader-toolbar__right { max-width: 68%; overflow-x: auto; scrollbar-width: none; }
    .reader-toolbar__left::-webkit-scrollbar, .reader-toolbar__right::-webkit-scrollbar { display: none; }
}

/* Selección múltiple */
.list-pane { grid-template-rows: auto auto auto minmax(0,1fr) auto; }
.select-all-button {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.select-all-button .icon { width: 15px; height: 15px; opacity: 0; }
.select-all-button:hover { background: var(--panel-2); color: var(--text); }
.select-all-button.is-active { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand-strong); }
.select-all-button.is-active .icon { opacity: 1; }
.bulk-toolbar {
    min-height: 46px;
    margin: 0 10px 8px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--brand-border);
    border-radius: 11px;
    background: var(--brand-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.bulk-toolbar > strong { color: var(--brand-strong); font-size: 10px; white-space: nowrap; }
.bulk-actions { min-width: 0; display: flex; align-items: center; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.bulk-actions::-webkit-scrollbar { display: none; }
.bulk-actions button {
    min-height: 31px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 750;
    white-space: nowrap;
}
.bulk-actions button:hover { background: var(--panel-3); color: var(--text); }
.bulk-actions button:disabled { opacity: .45; cursor: wait; }
.bulk-actions .icon { width: 15px; height: 15px; }
.bulk-actions .bulk-danger { color: var(--danger); }
.message-item { grid-template-columns: 28px 30px minmax(0,1fr); gap: 7px; }
.message-select {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: transparent;
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
}
.message-select .icon { width: 14px; height: 14px; }
.message-select:hover { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand-strong); }
.message-select.is-checked { border-color: var(--brand); background: var(--brand); color: #171717; }
.message-item.is-bulk-selected { background: var(--brand-soft); border-color: var(--brand-border); }

@media (max-width: 760px) {
    .list-pane { grid-template-rows: auto auto auto minmax(0,1fr) auto; }
    .bulk-toolbar { margin-inline: 8px; }
    .bulk-actions button span { display: none; }
    .bulk-actions button { width: 31px; padding: 0; }
    .message-item { grid-template-columns: 26px 27px minmax(0,1fr); gap: 5px; }
}

/* Herramientas de formato del redactor */
.compose-form { grid-template-rows: auto auto auto auto minmax(0,1fr) auto auto; }
.compose-formatbar {
    min-height: 40px;
    padding: 5px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--panel-2) 70%, transparent);
}
.compose-formatbar::-webkit-scrollbar { display: none; }
.compose-formatbar button {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
}
.compose-formatbar button:hover { background: var(--panel-3); color: var(--text); }
.compose-formatbar button .icon { width: 15px; height: 15px; vertical-align: middle; }
.format-divider { width: 1px; height: 20px; margin: 0 3px; background: var(--border); flex: 0 0 auto; }

@media (max-width: 760px) {
    .compose-form { grid-template-rows: auto auto auto auto minmax(0,1fr) auto auto; }
    .compose-formatbar { padding-inline: 10px; }
}

/* =========================================================
   DMTEI Mail 1.3 · bandeja amplia y lector lateral
   ========================================================= */
.mail-grid {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
}
.list-pane {
    width: 100%;
    border-right: 0;
    background: var(--bg-elevated);
}
.message-list { padding: 0; }
.message-item {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 0 18px;
    display: grid;
    grid-template-columns: 28px 30px minmax(170px, 28%) minmax(0, 1fr) 86px;
    align-items: center;
    gap: 9px;
    background: transparent;
}
.message-item:hover { background: var(--panel-2); border-color: var(--border); }
.message-item.is-selected { background: rgba(213,165,34,.10); border-color: var(--border); }
.message-item.is-bulk-selected { background: var(--brand-soft); }
.message-item.is-unread::before { display: none; }
.message-sender {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 620;
}
.message-subject-line {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}
.message-subject {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-soft);
    font-size: 13px;
}
.message-item.is-unread .message-sender,
.message-item.is-unread .message-subject { color: var(--text); font-weight: 820; }
.message-unread-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 4px rgba(213,165,34,.08);
}
.message-time {
    justify-self: end;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}
.message-preview, .message-main, .message-topline { display: none; }
.message-skeleton { height: 54px; margin: 0; }
.message-skeleton::after { inset: 10px 18px; border-radius: 8px; }

.reader-backdrop {
    position: fixed;
    inset: 0 0 0 var(--sidebar);
    z-index: 180;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .2s ease;
}
.reader-backdrop.is-visible { opacity: 1; }
.reader-pane {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(1180px, calc(100vw - var(--sidebar)));
    max-width: 92vw;
    z-index: 190;
    background: var(--bg);
    border-left: 1px solid var(--border-strong);
    box-shadow: -24px 0 70px rgba(0,0,0,.42);
    transform: translateX(106%);
    visibility: hidden;
    transition: transform .32s cubic-bezier(.4,0,.2,1), visibility 0s linear .32s;
    will-change: transform;
    overflow: hidden;
}
.reader-pane.is-open {
    visibility: visible;
    transform: translateX(0);
    transition: transform .52s cubic-bezier(.18,1.22,.28,1), visibility 0s;
}
.reader-empty { height: 100%; background: var(--bg); }
.reader-content { height: 100%; background: var(--bg); }
.reader-toolbar {
    position: relative;
    z-index: 2;
    min-height: 62px;
    padding: 0 18px;
    background: var(--bg-elevated);
    box-shadow: 0 1px 0 var(--border);
}
.reader-close-button {
    display: grid !important;
    width: 38px;
    height: 38px;
    margin-right: 4px;
    color: var(--text);
}
.reader-close-button:hover { background: var(--panel-3); }
.reader-scroll {
    min-height: 0;
    overflow-y: auto;
    background: var(--bg);
    padding-bottom: 22px;
}
.message-heading {
    max-width: 100%;
    margin: 0;
    padding: 28px clamp(20px, 4vw, 54px) 18px;
}
.message-heading h2 { font-size: clamp(22px, 2.2vw, 32px); }
.remote-images-notice,
.attachment-list {
    max-width: none;
    width: auto;
    margin: 0 clamp(20px, 4vw, 54px) 14px;
}
.attachment-list { align-items: flex-start; }
.attachment-preview-card {
    width: min(260px, 100%);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel-2);
}
.attachment-image-button {
    width: 100%;
    height: 150px;
    padding: 0;
    border: 0;
    background: #0a0a0b;
    cursor: zoom-in;
    overflow: hidden;
    display: block;
}
.attachment-image-button img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .22s ease;
}
.attachment-image-button:hover img { transform: scale(1.025); }
.attachment-preview-meta {
    min-height: 54px;
    padding: 9px 10px 9px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.attachment-preview-meta > div { min-width: 0; flex: 1; display: grid; gap: 2px; }
.attachment-preview-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.attachment-preview-meta span { color: var(--muted); font-size: 9px; }
.attachment-preview-meta > a {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: var(--brand);
}
.attachment-preview-meta > a:hover { background: var(--panel-3); }
.message-body-shell {
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0 clamp(20px, 4vw, 54px);
}
.message-frame {
    display: block;
    width: 100%;
    min-height: 0;
    height: 80px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #111214;
    box-shadow: none;
    transition: background .18s ease, border-color .18s ease;
}
.message-frame.is-light-message { background: #fff; border-color: rgba(0,0,0,.13); }
.message-frame.is-dark-message { background: #111214; border-color: var(--border); }
.message-bottom-actions {
    max-width: none;
    margin: 14px 0 0;
    padding: 0 clamp(20px, 4vw, 54px) 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
#readerViewToggle.is-active { color: var(--brand); background: var(--brand-soft); }

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: grid;
    place-items: center;
    padding: 28px;
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity .18s ease;
}
.image-lightbox.is-open { opacity: 1; }
.image-lightbox__close {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,.1);
    color: #fff;
}
.image-lightbox__figure {
    width: min(1100px, 100%);
    max-height: calc(100dvh - 56px);
    margin: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 18px;
    background: #101113;
    box-shadow: 0 28px 90px rgba(0,0,0,.55);
    transform: scale(.97);
    transition: transform .18s ease;
}
.image-lightbox.is-open .image-lightbox__figure { transform: scale(1); }
.image-lightbox__figure > img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: calc(100dvh - 130px);
    object-fit: contain;
    background: #08090a;
}
.image-lightbox__figure figcaption {
    min-height: 66px;
    padding: 10px 14px 10px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}
.image-lightbox__figure figcaption strong { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1050px) and (min-width: 761px) {
    .message-item { grid-template-columns: 28px 30px minmax(145px, 30%) minmax(0,1fr) 68px; padding-inline: 12px; }
    .reader-pane { width: calc(100vw - 76px); max-width: none; }
    .reader-backdrop { left: 76px; }
}

@media (max-width: 760px) {
    .message-list { padding: 0; }
    .message-item {
        min-height: 82px;
        padding: 10px 12px;
        grid-template-columns: 26px 27px minmax(0,1fr) auto;
        grid-template-areas:
            "select star sender time"
            "select star subject subject";
        align-items: center;
        gap: 4px 7px;
    }
    .message-select { grid-area: select; align-self: start; margin-top: 2px; }
    .message-star { grid-area: star; align-self: start; margin-top: 1px; }
    .message-sender { grid-area: sender; font-size: 12px; }
    .message-subject-line { grid-area: subject; }
    .message-subject { font-size: 11px; line-height: 1.35; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .message-time { grid-area: time; font-size: 9px; }
    .message-unread-dot { width: 6px; height: 6px; }

    .reader-backdrop { inset: 0; z-index: 180; }
    .reader-pane {
        inset: 0;
        width: 100%;
        max-width: none;
        z-index: 190;
        border-left: 0;
        padding-bottom: env(safe-area-inset-bottom);
        transform: translateX(106%);
    }
    .reader-pane.is-open { transform: translateX(0); }
    .reader-toolbar { min-height: 58px; padding: 0 8px; }
    .reader-toolbar__left, .reader-toolbar__right { max-width: none; }
    .reader-toolbar__left { flex: 1; }
    .reader-toolbar__right { flex: 0 1 auto; justify-content: flex-end; }
    .reader-toolbar .toolbar-button { width: 36px; padding: 0; justify-content: center; }
    .reader-toolbar .toolbar-button span { display: none; }
    .reader-close-button { flex: 0 0 auto; }
    .message-heading { padding: 21px 16px 15px; }
    .message-heading h2 { font-size: 22px; }
    .sender-row { margin-top: 18px; }
    .remote-images-notice,
    .attachment-list { width: auto; margin-inline: 16px; }
    .attachment-preview-card { width: 100%; }
    .attachment-image-button { height: min(52vw, 220px); }
    .message-body-shell { padding: 0 12px; }
    .message-frame { border-radius: 12px; }
    .message-bottom-actions { margin-top: 12px; padding: 0 12px 26px; }
    .image-lightbox { padding: 10px; }
    .image-lightbox__figure { max-height: calc(100dvh - 20px); border-radius: 14px; }
    .image-lightbox__figure > img { max-height: calc(100dvh - 88px); }
    .image-lightbox__close { top: 14px; right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .reader-pane, .reader-backdrop, .image-lightbox, .image-lightbox__figure { transition-duration: .01ms !important; }
}
