@font-face { font-family: 'Rethink Sans'; src: url('/assets/rethink-sans.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  color-scheme: light;
  --page: #fafbff; --panel: #fff; --panel-top: #fff; --canvas: #eef2f8; --surface: #f2f5fb;
  --ink: #152139; --text: #56657c; --muted: #5d6c84; --faint: #5d6c84;
  --line: #dce3ef; --strong-line: #8191aa; --accent: #1466dc; --accent-hover: #1058c2;
  --accent-ink: #1761c7; --accent-light: #e8f0ff;
  --header-wave-opacity: .38; --sidebar-wave-opacity: .24; --workspace-wave-opacity: .12;
  --danger: #b52f48; --danger-bg: #fde8ed; --gold: #875900;
  --shadow: 0 20px 60px #1d315929; --shadow-raised: 0 4px 20px #1d31590b;
  --backdrop: #0c172b6b;
  --accent-border: color-mix(in srgb, var(--accent-ink) 17%, transparent);
  --card-background: linear-gradient(145deg, var(--panel-top), var(--panel) 55%);
  --lower-waves: url('/assets/ambient-waves-lower.svg') left bottom / 640px 300px no-repeat fixed;
  font: 14px/22px 'Rethink Sans', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --page: #0b1322; --panel: #101a2b; --panel-top: #142035; --canvas: #070d18; --surface: #142035;
  --ink: #f0f4fc; --text: #adbad0; --muted: #91a2bd; --faint: #91a2bd;
  --line: #253249; --strong-line: #657b9a; --accent: #126edf; --accent-hover: #1472e3;
  --accent-ink: #6aafff; --accent-light: #102e57;
  --header-wave-opacity: .19; --sidebar-wave-opacity: .23; --workspace-wave-opacity: .08;
  --danger: #ff91a5; --danger-bg: #3d1e2b; --gold: #ffce82;
  --shadow: 0 20px 60px #0006; --shadow-raised: 0 6px 24px #00000021;
  --backdrop: #02060ea6;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .46; cursor: default; }
a { color: var(--accent-ink); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 18px; height: 18px; stroke-width: 1.75; flex: none; }
.subtle { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 3px; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 8px; color: var(--text); }
.icon-button:not(:disabled):hover { color: var(--accent-ink); background: var(--accent-light); }
.primary, .secondary, .text-button { min-height: 40px; padding: 6px 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { background: var(--panel); border-color: var(--line); color: var(--ink); }
.secondary:hover:not(:disabled), .text-button:hover { background: var(--accent-light); color: var(--accent-ink); }
.text-button { color: var(--accent-ink); }
.notice { background: var(--danger-bg); color: var(--danger); padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.brand-logo { display: block; width: 112px; height: auto; }
:root[data-theme=dark] .brand-logo { filter: brightness(0) invert(1); }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: var(--canvas);
  padding: 22px;
}
.login-card { width: min(100%, 390px); background: var(--card-background); border: 1px solid var(--line); border-radius: 12px; padding: 32px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card .brand-logo { width: 142px; margin-bottom: 8px; }
.login-card h1, .page-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -.04em; line-height: 36px; }
.login-card p { color: var(--muted); margin-bottom: 5px; }
.login-card label, .field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-card button { margin-top: 4px; }
.login-card input, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--strong-line); border-radius: 8px; min-height: 40px;
  background: var(--panel); color: var(--ink); padding: 6px 12px; font-weight: 400;
}
.field textarea { min-height: 85px; resize: vertical; }
.select-control { position: relative; display: block; min-width: 0; }
.select-control select { appearance: none; padding-inline-end: 34px; text-overflow: ellipsis; }
.select-control svg {
  position: absolute;
  inset-inline-end: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}

.workspace { display: grid; grid-template-columns: 216px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr); height: 100dvh; overflow: hidden; background: var(--canvas); }
.workspace-header {
  grid-column: 1 / -1;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(115deg, var(--page), var(--panel));
}
.workspace-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--header-wave-opacity);
  background: url('/assets/ambient-waves.svg') center top / max(1600px, 100vw) 1000px no-repeat;
}
.workspace-brand { display: flex; align-items: center; gap: 16px; font-weight: 700; }
.workspace-brand span { border-inline-start: 1px solid var(--strong-line); padding-inline-start: 16px; }
.account-button { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 3px 7px; border-radius: 8px; }
.account-button:hover { background: var(--surface); }
.account-button > svg { width: 13px; height: 13px; color: var(--muted); }
.account-address { max-width: min(28vw, 250px); font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-nav { display: grid; gap: 5px; padding: 22px 12px 16px; }
.section-button { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; text-align: start; border-radius: 7px; color: var(--text); font-weight: 500; }
.section-button:hover, .folder-line:hover { color: var(--accent-ink); background: var(--surface); }
.section-button.active, .folder-line.active {
  position: relative;
  color: var(--accent-ink);
  background: linear-gradient(90deg, var(--accent-light), color-mix(in srgb, var(--accent-light) 85%, var(--page)));
  box-shadow: inset 0 0 0 1px var(--accent-border);
}
.section-button.active::before, .folder-line.active::before { content: ''; position: absolute; inset-block: 30%; inset-inline-start: 0; width: 3px; border-radius: 2px; background: var(--accent-ink); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; background: var(--avatar-bg, var(--accent-light)); color: var(--avatar-ink, var(--accent-ink)); font-size: 11px; font-weight: 680; }
.account-avatar { width: 28px; height: 28px; color: #fff; background: linear-gradient(135deg, var(--accent), #7749c0); }
.mail {
  --divider-width: 10px;
  --mail-footer-height: 56px;
  --default-list-share: .41;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--message-list-width, minmax(0, .82fr)) var(--divider-width) minmax(0, 1.18fr);
}
.sidebar, .folder-pane, .message-list, .reader { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.sidebar, .page, .login { position: relative; isolation: isolate; }
.sidebar::before, .page::before, .login::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  clip-path: inset(0);
  background: var(--lower-waves);
  opacity: var(--workspace-wave-opacity);
}
.sidebar { border-inline-end: 1px solid var(--line); background: linear-gradient(165deg, var(--page), var(--canvas)); }
.sidebar::before { opacity: var(--sidebar-wave-opacity); }
.folder-pane { flex: 1; border-top: 1px solid var(--line); }
.sidebar-top { padding: 16px 12px 12px; }
.compose-button { width: 100%; justify-content: flex-start; gap: 10px; }
.compose-button svg { width: 16px; height: 16px; }
.folders { padding: 0 12px 12px; overflow: auto; flex: 1; }
.folder-heading { padding: 0 8px; margin-bottom: 5px; height: 28px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 640; }
.custom-heading { margin-top: 21px; }
.custom-heading .icon-button { width: 25px; height: 25px; }
.custom-heading .icon-button svg { width: 15px; height: 15px; }
.folder-line {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  padding-inline-start: calc(4px + var(--folder-depth) * 14px);
  margin-bottom: 4px;
  border-radius: 7px;
}
.folder-line.drag-over { background: var(--accent-light); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.folder-line > .folder-toggle { grid-area: 1 / 1; width: 18px; height: 27px; border-radius: 5px; }
.folder-line > .folder-toggle svg { width: 13px; height: 13px; }
.folder {
  grid-area: 1 / 2;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 36px;
  padding: 4px 8px 4px 3px;
  color: var(--text);
  text-align: start;
  font-size: 13px;
}
.folder svg { width: 16px; height: 16px; color: var(--muted); }
.folder-line:is(.active, .drag-over) :is(.folder, .folder svg, .folder-toggle) { color: inherit; }
.folder-line.active .folder { font-weight: 650; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { flex: none; margin-inline-start: auto; font-size: 10px; font-weight: 650; padding: 1px 6px; border-radius: 5px; background: var(--line); }
.folder-line.active .count { background: var(--accent-border); }
.sidebar-footer { margin: auto 10px 12px; padding: 10px 8px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); text-align: left; }
.sidebar-footer:hover { color: var(--ink); }
.sidebar-footer svg { width: 16px; height: 16px; }

.message-list { container-type: inline-size; background: var(--page); }
.mail-divider { position: relative; cursor: col-resize; touch-action: none; color: var(--strong-line); }
.mail-divider::before, .mail-divider::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); }
.mail-divider::before { inset-block: 0; width: 1px; background: var(--line); }
.mail-divider::after { top: calc(50% - 14px); width: 3px; height: 28px; border-radius: 3px; background: currentColor; }
.mail-divider:is(:hover, :focus-visible), .mail[data-resizing] .mail-divider { color: var(--accent); background: var(--accent-light); }
.mail-divider:focus-visible { outline-offset: -2px; }
.mail[data-resizing] { cursor: col-resize; user-select: none; }
.mail[data-resizing] iframe { pointer-events: none; }
@media (pointer: coarse) { .mail { --divider-width: 16px; } }
.list-header { min-height: 78px; padding: 14px 16px 12px 19px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.list-heading { min-width: 0; display: flex; align-items: center; gap: 4px; }
.list-heading > div { min-width: 0; }
.list-heading h1 { font-size: 28px; font-weight: 700; letter-spacing: -.04em; line-height: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-heading .subtle { margin-top: 3px; }
.searchbar { display: flex; align-items: center; min-height: 40px; margin: 0 16px 8px 18px; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--panel); }
.searchbar label { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 9px; color: var(--muted); }
.searchbar input { border: 0; background: none; padding: 6px 2px; min-width: 0; width: 100%; color: var(--ink); outline: 0; }
.searchbar:focus-within { border-color: var(--accent); }
.searchbar .icon-button { width: 32px; height: 32px; border-radius: 7px; }
.searchbar svg { width: 15px; height: 15px; }
.list-controls { display: flex; justify-content: space-between; align-items: center; padding: 4px 16px 8px 18px; border-bottom: 1px solid var(--line); }
.list-controls .icon-button { width: 28px; height: 28px; }
.list-controls svg { width: 16px; height: 16px; }
.filters { display: flex; gap: 4px; }
.filters button { padding: 3px 10px; border-radius: 8px; color: var(--text); font-size: 12px; font-weight: 600; }
.filters button:hover, .filters button[aria-pressed=true] { color: var(--accent-ink); background: var(--accent-light); }
.bulk-toolbar { padding: 4px 12px 4px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--accent-border); background: var(--accent-light); color: var(--accent-ink); font-size: 12px; }

.messages { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
.message { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 1px 10px; padding: 12px 14px 12px 18px; min-height: 72px; border-bottom: 1px solid var(--line); cursor: pointer; }
.message:hover { background: var(--surface); }
.message.unread { background: var(--panel); }
.message.active, .message.checked { background: var(--accent-light); }
.message.active::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.message-marker { grid-area: 1 / 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 8px; }
.message-marker .check {
  display: none;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid var(--faint);
  border-radius: 5px;
  background: var(--page);
}
:is(.message:hover, .message:focus-within, .messages.selecting .message) .message-marker .avatar { display: none; }
:is(.message:hover, .message:focus-within, .messages.selecting .message) .message-marker .check { display: grid; }
.message-marker[aria-pressed=true] .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.message-marker .check svg { width: 14px; height: 14px; stroke-width: 2.25; }
.sender, .subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45; }
.sender { grid-column: 2; grid-row: 1; color: var(--ink); font-weight: 600; }
.subject { grid-column: 2; grid-row: 2; font-size: 13px; color: var(--text); }
.unread .sender, .unread .subject { color: var(--ink); font-weight: 680; }
.message-meta { grid-column: 3; grid-row: 1; display: flex; align-items: center; justify-content: flex-end; gap: 5px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.message-actions { grid-column: 3; grid-row: 2; display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.message-actions .icon-button { width: 21px; height: 21px; opacity: 0; }
.message-actions svg { width: 14px; height: 14px; color: var(--muted); }
.message:hover .icon-button, .message:focus-within .icon-button, .message .starred { opacity: 1; }
.starred svg { fill: var(--gold); color: var(--gold); }
.unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.thread-count { background: var(--accent-border); color: var(--accent-ink); border-radius: 4px; padding: 0 4px; }
.pagination, .reply-area { flex: 0 0 var(--mail-footer-height); display: flex; align-items: center; border-top: 1px solid var(--line); }
.pagination { justify-content: space-between; padding-inline: 18px 13px; color: var(--muted); font-size: 11px; }
.pagination .icon-button { width: 28px; height: 28px; }
.pagination svg { width: 16px; height: 16px; }
.mobile-only { display: none; }

.reader { background: var(--panel); container-type: inline-size; }
.reader-toolbar { min-height: 58px; border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.reader-toolbar .toolbar { min-width: 0; }
.toolbar-divider { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex: none; }
.reader-content { overflow: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.reader-heading { padding: 25px 28px 20px; border-bottom: 1px solid var(--line); }
.subject-line { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 17px; }
.subject-line h1 { font-size: clamp(20px, 2.05vw, 28px); font-weight: 700; letter-spacing: -.04em; line-height: 1.29; overflow-wrap: anywhere; }
.subject-line .icon-button { width: 28px; height: 30px; }
.sender-card { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.sender-card .avatar { width: 40px; height: 40px; font-size: 12px; }
.sender-info { flex: 1; min-width: 0; }
.sender-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; font-size: 12.5px; }
.sender-line strong { font-weight: 680; }
.email-address { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.recipient-line { color: var(--muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.reader-time { color: var(--muted); font-size: 10.5px; white-space: nowrap; margin-top: 2px; }
.details-button { color: var(--accent-ink); padding: 1px 5px; font-size: 11px; }
.message-details { padding: 9px 11px; margin-top: 9px; background: var(--surface); border-radius: 8px; font-size: 11px; color: var(--muted); display: grid; gap: 3px; overflow-wrap: anywhere; }
.attachment-section { border-bottom: 1px solid var(--line); padding: 14px 28px 16px; }
.attachment-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; margin-bottom: 9px; }
.attachment-label svg { width: 15px; height: 15px; }
.attachment-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; padding: 7px 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; color: var(--text); }
.attachment > svg { width: 16px; height: 16px; color: var(--accent-ink); }
.attachment strong, .attachment small { display: block; max-width: 185px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment strong { font-size: 11.5px; }
.attachment small { color: var(--muted); font-size: 10px; }
.attachment .icon-button { width: 25px; height: 25px; }
.attachment .icon-button svg { width: 14px; height: 14px; }
.reader-text { margin: 0; padding: 21px 28px; white-space: pre-wrap; font: inherit; color: var(--text); line-height: 1.75; overflow-wrap: anywhere; }
.reader-frame { display: block; width: calc(100% - 56px); min-height: 320px; height: 62dvh; margin: 21px 28px; border: 0; background: var(--panel); }
.reader-notice { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin: 12px 28px 0; padding: 3px 8px; border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 11px; }
.reader-notice .text-button { min-height: 27px; padding: 0 6px; font-size: 11px; }
.reply-area { padding-inline: 28px; }
.reply-area button { width: 100%; min-height: 40px; text-align: left; background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.reply-area button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-area button:hover { background: var(--accent-light); color: var(--accent-ink); }
.empty { display: grid; place-content: center; justify-items: center; text-align: center; gap: 5px; padding: 30px 20px; min-height: 200px; height: 100%; color: var(--muted); }
.empty .empty-icon { display: grid; place-items: center; background: var(--accent-light); color: var(--accent-ink); width: 40px; height: 40px; border-radius: 8px; margin-bottom: 8px; }
.empty .empty-icon svg { width: 23px; height: 23px; stroke-width: 1.5; }
.empty h2 { color: var(--ink); font-size: 15px; letter-spacing: -.018em; font-weight: 680; }
.empty p { max-width: 260px; font-size: 12px; }
.mail[data-layout=list] { grid-template-columns: minmax(0, 1fr); }
.mail[data-layout=list] :is(.reader, .mail-divider), .mail[data-layout=list][data-mobile=reader] .message-list { display: none; }
.mail[data-layout=list][data-mobile=reader] .reader { display: flex; }
.mail[data-layout=list] [data-action=back-list] { display: grid; }

.page { min-width: 0; overflow: auto; background: var(--canvas); }
.page-inner { max-width: 1344px; padding: 32px 32px 60px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header h1 { display: flex; align-items: center; gap: 12px; }
.page-header h1 svg { width: 20px; height: 20px; color: var(--accent-ink); }
.page-header .toolbar { gap: 8px; flex-wrap: wrap; }
.records, .settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-background);
  box-shadow: var(--shadow-raised);
}
.records { overflow: hidden; }
.record { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 58px; }
.record + .record { border-top: 1px solid var(--line); }
.record > div:nth-child(2), .record-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.record strong { font-size: 13px; }
.record .secondary, .record .text-button { min-height: 30px; padding: 0 8px; font-size: 11px; }
.record .record-tag { font-size: 11px; color: var(--muted); }
#settings .page-inner { --settings-control-width: min(44%, 236px); }
.settings-group { margin-bottom: 20px; padding: 20px; }
.settings-group .records { background: var(--panel); box-shadow: none; }
.settings-group h2 { font-size: 18px; line-height: 24px; font-weight: 700; margin-bottom: 12px; }
.settings-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.settings-list li + li { border-top: 1px solid var(--line); }
.settings-list :is(.field, .check-label) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--settings-control-width);
  align-items: center;
  gap: 12px;
  min-height: 45px;
  margin: 0;
  padding-block: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.settings-list :is(input, select) { min-width: 0; }
.settings-list :is(input:not([type=checkbox]), select) { min-height: 36px; padding-block: 4px; }
.settings-list .check-label span { grid-area: 1 / 1; }
.settings-list input[type=checkbox] { grid-area: 1 / 2; justify-self: end; width: 16px; height: 16px; margin: 0 8px; }
.settings-actions { gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.settings-actions button { white-space: normal; }
#settings-form > .settings-group:last-of-type { margin-bottom: 0; }
#settings-form { margin-bottom: 30px; }
.check-label { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 13px; }
input[type=checkbox] { accent-color: var(--accent); }

dialog { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 14px; padding: 0; box-shadow: var(--shadow); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: var(--backdrop); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 10px 14px 10px 17px; gap: 12px; background: var(--card-background); }
.dialog-header h2 { font-size: 18px; line-height: 24px; letter-spacing: -.02em; }
.form-dialog { width: min(460px, calc(100vw - 24px)); }
.form-dialog #dialog-fields { display: grid; gap: 11px; padding: 16px; }
.form-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.form-dialog .notice { margin: 0 12px 10px; }
.composer, .compose-dock {
  --compose-right: max(14px, 4vw);
  --compose-bottom: max(14px, 4vh);
  position: fixed;
  inset-block: auto var(--compose-bottom);
  inset-inline: auto var(--compose-right);
  z-index: 7;
}
.composer {
  --compose-inset: 20px;
  --compose-max-width: calc(100vw - 2 * var(--compose-right));
  --compose-max-height: calc(100dvh - var(--compose-bottom) - 12px);
  width: var(--compose-width, 670px);
  min-width: min(340px, var(--compose-max-width));
  max-width: var(--compose-max-width);
  max-height: var(--compose-max-height);
  margin: 0;
}
.composer form { display: flex; flex-direction: column; max-height: calc(var(--compose-max-height) - 2px); }
.composer[data-sized] { height: var(--compose-height); min-height: min(420px, var(--compose-max-height)); }
.composer:is([data-sized], [data-maximized]) form { height: 100%; }
.composer:is([data-sized], [data-maximized]) .editor { min-height: 72px; }
.composer[data-maximized] {
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
}
.composer[data-maximized] form { max-height: none; }
.compose-resize {
  position: absolute;
  inset: 0 auto auto 0;
  width: 22px;
  height: 18px;
  padding: 0;
  border-top-left-radius: 13px;
  color: var(--faint);
  cursor: nwse-resize;
  touch-action: none;
}
.compose-resize::before, .compose-resize::after {
  content: '';
  position: absolute;
  left: 5px;
  border-top: 2px solid currentColor;
  border-radius: 2px;
  transform: rotate(-45deg);
  transform-origin: left center;
}
.compose-resize::before { top: 9px; width: 7px; }
.compose-resize::after { top: 15px; width: 15px; }
.compose-resize:is(:hover, :focus-visible), .composer[data-resizing] .compose-resize { color: var(--accent-ink); }
.compose-resize:focus-visible { outline-offset: -2px; }
.composer[data-maximized] .compose-resize { display: none; }
.composer[data-resizing] { user-select: none; }
.compose-dock {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(270px, calc(100vw - 2 * var(--compose-right)));
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--strong-line);
  border-radius: 9px;
  background: var(--page);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  text-align: start;
}
.compose-dock:hover { background: var(--surface); }
.compose-dock span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-dock svg { width: 16px; height: 16px; color: var(--muted); }
.composer :is(.dialog-header, .compose-fields, .compose-format, .editor, .compose-attachments, .compose-footer) {
  padding-inline: var(--compose-inset);
}
.composer .notice { margin: 0 var(--compose-inset) 10px; }
.compose-row {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.compose-control { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; padding-inline: 8px; border-radius: 5px; }
.compose-control:focus-within { background: var(--surface); box-shadow: inset 0 -2px var(--accent); }
.compose-control :is(input, select) { flex: 1; min-width: 0; min-height: 34px; border: 0; padding: 4px 0; background: transparent; color: var(--ink); }
.compose-control :is(input, select):focus-visible { outline: none; }
.compose-control select { appearance: none; padding-inline-end: 24px; }
.compose-select-chevron { position: absolute; inset-inline-end: 11px; width: 14px; height: 14px; pointer-events: none; }
.compose-control .text-button { min-height: 30px; padding-inline: 5px; font-size: 11px; }
.compose-format { padding-block: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface); }
.compose-format .icon-button { width: 29px; height: 29px; }
.compose-format .text-button { min-height: 29px; padding-inline: 8px; font-size: 12px; }
.compose-format svg { width: 15px; height: 15px; }
.editor { min-height: min(230px, 30dvh); flex: 1; overflow: auto; padding-block: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.editor:focus { outline: 0; }
.compose-attachments { display: flex; flex-wrap: wrap; gap: 5px; padding-block: 8px; border-top: 1px solid var(--line); }
.compose-footer { display: flex; align-items: center; gap: 8px; padding-block: 10px; border-top: 1px solid var(--line); }
.compose-footer .save-draft { margin-inline-start: auto; }
.popover { position: fixed; z-index: 5; min-width: 164px; max-width: min(330px, calc(100vw - 16px)); padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); }
.popover button, .popover a { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; border-radius: 5px; padding: 7px 8px; font-size: 12px; color: var(--text); }
.popover button:hover, .popover a:hover { background: var(--surface); color: var(--ink); }
.popover svg { width: 15px; height: 15px; }
.toast { position: fixed; z-index: 10; bottom: 16px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 28px); padding: 10px 15px; background: var(--ink); color: var(--page); border-radius: 9px; box-shadow: var(--shadow); font-size: 12px; }
.drop-preview {
  position: fixed;
  z-index: 9;
  display: grid;
  gap: 2px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 7px 11px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--page);
  box-shadow: var(--shadow);
  pointer-events: none;
  overflow-wrap: anywhere;
}
.drop-preview-label { color: var(--muted); font-size: 11px; }
.drop-preview strong { color: var(--accent-ink); font-size: 13px; font-weight: 640; }

@media (max-width: 1120px) {
  .mail { --default-list-share: .42; }
  .reader-heading, .attachment-section, .reader-text, .reply-area { padding-inline: 18px; }
  .reader-frame { width: calc(100% - 36px); margin-inline: 18px; }
  .reader-notice { margin-inline: 18px; }
  .reader-toolbar { padding-inline: 12px; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 62px minmax(0, 1fr); }
  .mail { --default-list-share: .455; grid-template-columns: var(--message-list-width, minmax(0, 1fr)) var(--divider-width) minmax(0, 1.2fr); }
  .mobile-only { display: inline-grid; }
  .workspace:not(:has(#mail:not([hidden])[data-mobile=folders])) .folder-pane,
  .workspace:not(:has(#mail:not([hidden])[data-mobile=folders])) .section-button span { display: none; }
  .section-nav { padding-inline: 10px; }
  .section-button { justify-content: center; padding-inline: 8px; }
  .workspace:has(#mail:not([hidden])[data-mobile=folders]) { grid-template-columns: minmax(0, 1fr); }
  .workspace:has(#mail:not([hidden])[data-mobile=folders]) .section-button { justify-content: flex-start; }
  .mail[data-mobile=folders] { display: none; }
}
@media (max-width: 620px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 48px minmax(0, 1fr) 51px; }
  .workspace-header { padding-inline: 12px; }
  .workspace-brand { gap: 9px; }
  .workspace-brand span { padding-inline-start: 9px; }
  .workspace-brand .brand-logo { width: 90px; }
  .account-address { display: none; }
  .sidebar { grid-row: 3; border: 0; border-top: 1px solid var(--line); }
  .section-nav { display: flex; justify-content: space-around; padding: 5px 12px; }
  .section-button { min-width: 40px; }
  .workspace:has(#mail:not([hidden])[data-mobile=folders]) .sidebar { grid-row: 2 / -1; }
  .workspace:has(#mail:not([hidden])[data-mobile=folders]) .section-nav { justify-content: flex-start; flex-wrap: wrap; }
  .mail, .mail[data-layout=list] { grid-template-columns: minmax(0, 1fr); }
  .mail:not([data-mobile=reader]) .reader, .mail[data-mobile=reader] .message-list { display: none; }
  .mail-divider { display: none; }
  .list-header { min-height: 66px; padding: 8px; }
  .list-heading h1 { font-size: 21px; }
  .searchbar { margin-inline: 12px; }
  .list-controls { padding-inline: 12px; }
  .message { padding-left: 13px; }
  .reader-toolbar { padding-inline: 6px; min-height: 46px; }
  .reader-toolbar .icon-button { width: 30px; }
  .reader-heading { padding-top: 18px; }
  .reader-time { white-space: normal; max-width: 80px; text-align: right; }
  .page-inner { padding: 17px 12px 45px; }
  .settings-group { padding: 14px; }
  .record .record-tag { display: none; }
  .composer, .compose-dock { --compose-right: 12px; --compose-bottom: 60px; }
  .composer { --compose-inset: 14px; }
  .compose-row { grid-template-columns: 54px minmax(0, 1fr); }
}

.avatar-sky { --avatar-bg: #e2effa; --avatar-ink: #286093; }
.avatar-teal { --avatar-bg: #dcf0ed; --avatar-ink: #2a6e68; }
.avatar-sand { --avatar-bg: #f5ecdb; --avatar-ink: #805b28; }
.avatar-rose { --avatar-bg: #f6e6ee; --avatar-ink: #95506f; }
.avatar-slate { --avatar-bg: #e8ecf4; --avatar-ink: #4a6083; }
:root[data-theme=dark] .avatar:not(.account-avatar) { --avatar-bg: #1a3552; --avatar-ink: #a6c9ee; }
.contact-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px); gap: 12px; margin-bottom: 12px; }
.contact-search:has(> :nth-child(3)) { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(0, 220px)); }
.contact-search .field { min-width: 0; }
.settings-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.settings-title h2 { margin-bottom: 0; }
@media (max-width: 380px) {
  .reader-pages { display: none; }
}

.mail-quota { display: grid; gap: 2px; padding: 4px 17px 8px; font-size: 10px; color: var(--muted); }
.mail-quota meter { width: 100%; height: 8px; }
.thread-indent { display: inline-block; width: 11px; height: 8px; border-left: 1px solid var(--strong-line); }
.message.deleted .subject { text-decoration: line-through; }
.row-extra { color: var(--faint); font-size: 10px; }
.check-list { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; }
.check-list legend { padding: 0 4px; font-size: 12px; font-weight: 650; }
.check-list .check-label { margin: 2px 0; }
.message-source { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; margin: 0; }
.reader-thumbnails { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 28px; }
.reader-thumbnails img { display: block; max-width: 120px; max-height: 100px; object-fit: contain; }
.standalone-reader { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
.standalone-reader .mail { display: flex; }
.standalone-reader .reader { display: flex; flex: 1; }
.standalone-reader :is(.workspace-header, .sidebar, .message-list, .mail-divider, .reader-pages, [data-action=back-list]) { display: none !important; }
.contact-bulk { margin-bottom: 14px; flex-wrap: wrap; }
.contact-bulk strong { margin-right: 6px; font-size: 12px; }
.contact-record .avatar { object-fit: cover; }
.editor blockquote { border-left: 2px solid var(--strong-line); padding-left: 14px; margin-left: 0; color: var(--muted); }
.editor img { max-width: 100%; }
@media (max-width: 620px) {
  .contact-search, .contact-search:has(> :nth-child(3)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-search:has(> :nth-child(3)) > :first-child { grid-column: 1 / -1; }
}
@media print {
  body.printing > :not(#print-message) { display: none !important; }
  #print-message { color: #000; background: #fff; padding: 1cm; }
  #print-message pre { white-space: pre-wrap; font: inherit; }
  #print-message img { max-width: 100%; }
}

.popover { max-height: calc(100dvh - 16px); overflow: auto; }

@container (max-width: 395px) {
  .reader-toolbar { padding: 4px 8px; gap: 4px; }
  .reader-toolbar .toolbar:first-child { flex-wrap: wrap; }
  .reader-toolbar .icon-button { width: 30px; }
  .reader-toolbar .reader-pages { flex: none; }
}
@container (max-width: 330px) {
  .bulk-toolbar { flex-wrap: wrap; gap: 2px; }
  .bulk-toolbar .icon-button { width: 30px; height: 30px; }
}
