/* Nullify WebMail — single stylesheet, no external fonts or frameworks. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --surface-3: #eceef2;
    --sidebar: #fafbfc;
    --text: #151a23;
    --text-2: #3d4556;
    --muted: #6b7385;
    --faint: #9aa1b0;
    --border: #e4e7ec;
    --border-strong: #d2d6de;
    --accent: #3b5bdb;
    --accent-hover: #3049c0;
    --accent-soft: #edf1fd;
    --accent-text: #ffffff;
    --selected: #e8edfc;
    --danger: #d23f3f;
    --danger-soft: #fdeeee;
    --star: #e8a317;
    --ok-bg: #e9f7ef;
    --ok-text: #1b6b3e;
    --err-bg: #fdecec;
    --err-text: #9b1c1c;
    --warn-bg: #fff7e6;
    --warn-text: #8a5a00;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
    --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
    --sidebar-w: 248px;
    --list-w: 400px;
    color-scheme: light;
    font-family: var(--font);
    font-size: 14px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1115;
        --surface: #16191f;
        --surface-2: #1b1f26;
        --surface-3: #232831;
        --sidebar: #13161b;
        --text: #e7e9ee;
        --text-2: #c3c8d2;
        --muted: #8f97a8;
        --faint: #687083;
        --border: #262b34;
        --border-strong: #343a46;
        --accent: #6d8cff;
        --accent-hover: #8aa3ff;
        --accent-soft: #1d2540;
        --accent-text: #0b0f1d;
        --selected: #1e2640;
        --danger: #ff7272;
        --danger-soft: #3a1c1f;
        --star: #f5b83d;
        --ok-bg: #12301f;
        --ok-text: #86e3ae;
        --err-bg: #3a1717;
        --err-text: #ffb0b0;
        --warn-bg: #33270f;
        --warn-text: #f3c873;
        --shadow-sm: none;
        --shadow: 0 1px 3px rgba(0, 0, 0, .4);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #16191f;
    --surface-2: #1b1f26;
    --surface-3: #232831;
    --sidebar: #13161b;
    --text: #e7e9ee;
    --text-2: #c3c8d2;
    --muted: #8f97a8;
    --faint: #687083;
    --border: #262b34;
    --border-strong: #343a46;
    --accent: #6d8cff;
    --accent-hover: #8aa3ff;
    --accent-soft: #1d2540;
    --accent-text: #0b0f1d;
    --selected: #1e2640;
    --danger: #ff7272;
    --danger-soft: #3a1c1f;
    --star: #f5b83d;
    --ok-bg: #12301f;
    --ok-text: #86e3ae;
    --err-bg: #3a1717;
    --err-text: #ffb0b0;
    --warn-bg: #33270f;
    --warn-text: #f3c873;
    --shadow-sm: none;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); line-height: 1.5; font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
button:disabled { cursor: default; opacity: .55; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 650; }
.icon { flex-shrink: 0; display: block; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: .5rem .65rem; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; padding: 0; box-shadow: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ------------------------------------------------------------------ buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    height: 34px; padding: 0 .85rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font-size: .9rem; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--faint); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }
.btn.small { height: 28px; padding: 0 .6rem; font-size: .82rem; }
.btn.block { width: 100%; height: 40px; }
.btn.icon, .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
    border: none; background: transparent; color: var(--muted); transition: background .12s, color .12s;
}
.btn.icon:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.active { color: var(--accent); }
.icon-btn.star.on { color: var(--star); }
.btn-group { display: inline-flex; align-items: center; gap: 2px; }
.divider-v { width: 1px; height: 20px; background: var(--border); margin: 0 .25rem; }

/* ------------------------------------------------------------------ shell */

.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.main-area { flex: 1; display: flex; min-width: 0; min-height: 0; }
/* drag handles between panes (the 1px line is the visible border) */
.splitter {
    flex: 0 0 1px; width: 1px; position: relative; z-index: 20; background: var(--border);
    cursor: col-resize; touch-action: none; outline: none;
}
.splitter::before { content: ""; position: absolute; inset: 0 -5px; }
.splitter::after { content: ""; position: absolute; inset: 0 -1px; background: transparent; transition: background .12s; }
.splitter:hover::after, .splitter:focus-visible::after, .resizing .splitter::after { background: var(--accent); }
.resizing, .resizing * { cursor: col-resize !important; user-select: none !important; }
.resizing iframe { pointer-events: none; }
.rail-toggle { color: var(--faint); }

/* collapsed sidebar: an icon rail */
:root[data-sidebar="collapsed"] .sidebar { width: 64px; min-width: 64px; }
:root[data-sidebar="collapsed"] .sidebar .brand { flex-direction: column; padding: .85rem 0 .5rem; gap: .5rem; }
:root[data-sidebar="collapsed"] .sidebar .brand-text,
:root[data-sidebar="collapsed"] .sidebar .label,
:root[data-sidebar="collapsed"] .sidebar .nav-label,
:root[data-sidebar="collapsed"] .sidebar .inline-form,
:root[data-sidebar="collapsed"] .sidebar .folder-actions,
:root[data-sidebar="collapsed"] .sidebar .user-chip .who,
:root[data-sidebar="collapsed"] .sidebar .sidebar-error { display: none !important; }
:root[data-sidebar="collapsed"] .sidebar .compose-btn { margin: .25rem auto .75rem; width: 40px; padding: 0; }
:root[data-sidebar="collapsed"] .sidebar .nav-section { padding: .5rem .5rem 0; }
:root[data-sidebar="collapsed"] .sidebar .nav-item { justify-content: center; padding: 0 !important; }
:root[data-sidebar="collapsed"] .sidebar .nav-item .count {
    position: absolute; top: 2px; right: 4px; display: block !important; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: .62rem; line-height: 16px; text-align: center;
}
:root[data-sidebar="collapsed"] .sidebar .nav-item .count.muted { display: none !important; }
:root[data-sidebar="collapsed"] .sidebar .user-chip { flex-direction: column; padding: .6rem 0; gap: .35rem; }

.list-pane {
    flex: 0 1 var(--list-w); width: var(--list-w); min-width: 280px; display: flex; flex-direction: column;
    background: var(--surface); min-height: 0;
}
.detail-panel { flex: 1; display: flex; flex-direction: column; min-width: 320px; background: var(--surface); overflow: hidden; }
.detail-panel.message-window { position: fixed; inset: 0; min-width: 0; }
.page-pane { flex: 1; min-width: 0; overflow-y: auto; background: var(--bg); }

/* ------------------------------------------------------------------ sidebar */

.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--sidebar); display: flex; flex-direction: column; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .75rem; font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
    color: #fff; box-shadow: var(--shadow-sm);
}
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.compose-btn { margin: .25rem .75rem .75rem; height: 40px; border-radius: var(--radius); font-weight: 600; box-shadow: var(--shadow-sm); }

.nav-section { padding: 0 .5rem; }
.nav-label {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem .6rem .3rem; font-size: .7rem; font-weight: 650; text-transform: uppercase;
    letter-spacing: .06em; color: var(--faint);
}
.nav-label .icon-btn { width: 22px; height: 22px; color: var(--faint); }
.folder-list { flex: 1; overflow-y: auto; padding-bottom: .5rem; }
.nav-item {
    display: flex; align-items: center; gap: .6rem; width: 100%;
    height: 34px; padding: 0 .6rem; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: .9rem; text-align: left; cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--selected); color: var(--accent); font-weight: 600; }
.nav-item .icon { color: var(--muted); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: .75rem; font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.nav-item .count.muted { color: var(--faint); font-weight: 500; }
.nav-item.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
/* Re-ordering folders: a line where the dragged folder will land. */
.nav-item.drop-before::before, .nav-item.drop-after::after {
    content: ""; position: absolute; left: .4rem; right: .4rem; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none;
}
.nav-item.drop-before::before { top: -1px; }
.nav-item.drop-after::after { bottom: -1px; }
.nav-item.context, .msg-row.context, .note-row.context { box-shadow: inset 0 0 0 1px var(--accent); }
/* Shift-click selects messages, not the text under the pointer. */
.msg-row { user-select: none; }
.folder-actions { display: none; gap: 2px; }
.nav-item:hover .folder-actions { display: inline-flex; }
.nav-item:hover .count { display: none; }
.folder-actions .icon-btn { width: 24px; height: 24px; }

.inline-form { display: flex; gap: .35rem; padding: .35rem .6rem .5rem; }
.inline-form input { flex: 1; min-width: 0; height: 32px; padding: .3rem .55rem; font-size: .85rem; }

.sidebar-nav { border-top: 1px solid var(--border); padding: .5rem; display: flex; flex-direction: column; gap: 1px; }
.user-chip {
    display: flex; align-items: center; gap: .6rem; padding: .65rem .85rem;
    border-top: 1px solid var(--border); min-width: 0;
}
.user-chip .who { flex: 1; min-width: 0; font-size: .82rem; line-height: 1.3; }
.user-chip .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.user-chip .who span { color: var(--muted); font-size: .75rem; }

.sidebar-error { margin: .5rem .75rem; }

/* ------------------------------------------------------------------ avatars */

.avatar {
    --hue: 220;
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-size: .8rem; font-weight: 650; letter-spacing: .02em;
    color: hsl(var(--hue) 55% 32%); background: hsl(var(--hue) 70% 90%);
}
.avatar.lg { width: 42px; height: 42px; font-size: .9rem; }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .avatar { color: hsl(var(--hue) 70% 82%); background: hsl(var(--hue) 35% 24%); }
}
:root[data-theme="dark"] .avatar { color: hsl(var(--hue) 70% 82%); background: hsl(var(--hue) 35% 24%); }

/* ------------------------------------------------------------------ message list */

.list-header { padding: .85rem 1rem .6rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .6rem; flex-shrink: 0; }
.list-title { display: flex; align-items: center; gap: .5rem; min-height: 34px; }
.list-title h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-title .sub { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.list-search { position: relative; display: flex; align-items: center; }
.list-search .icon { position: absolute; left: .65rem; color: var(--faint); pointer-events: none; }
.list-search input { width: 100%; height: 36px; padding-left: 2.1rem; padding-right: 2rem; background: var(--surface-2); border-color: transparent; }
.list-search input:focus { background: var(--surface); }
.list-search .clear { position: absolute; right: .25rem; }

.list-toolbar { display: flex; align-items: center; gap: .25rem; padding: .35rem .75rem .35rem 1rem; border-bottom: 1px solid var(--border); min-height: 44px; flex-shrink: 0; }
.list-toolbar .sel-count { font-size: .82rem; font-weight: 600; margin-left: .35rem; }
.list-toolbar .pager { display: flex; align-items: center; gap: 2px; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.message-list { flex: 1; overflow-y: auto; min-height: 0; }
.msg-row {
    display: grid; grid-template-columns: 36px 1fr; gap: .75rem; align-items: start;
    padding: .7rem 1rem .7rem .85rem; cursor: pointer; position: relative;
    border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
    transition: background .08s;
}
.msg-row:hover { background: var(--surface-2); }
.msg-row.active { background: var(--selected); border-left-color: var(--accent); }
.msg-row.checked { background: var(--accent-soft); }
.msg-row .lead { position: relative; width: 36px; height: 36px; }
.msg-row .lead .avatar { transition: opacity .1s; }
.msg-row .lead input { position: absolute; inset: 10px; opacity: 0; }
.msg-row:hover .lead input, .msg-row.checked .lead input, .message-list.selecting .lead input { opacity: 1; }
.msg-row:hover .lead .avatar, .msg-row.checked .lead .avatar, .message-list.selecting .lead .avatar { opacity: 0; }
.msg-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.msg-line { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: .9rem; }
.msg-date { color: var(--muted); font-size: .76rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .86rem; }
.msg-row.unread .msg-from { color: var(--text); font-weight: 650; }
.msg-row.unread .msg-subject { color: var(--text); font-weight: 550; }
.msg-row.unread::before {
    content: ""; position: absolute; left: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
    border-radius: 50%; background: var(--accent);
}
.msg-badges { display: inline-flex; align-items: center; gap: 2px; color: var(--faint); }
.msg-badges .icon-btn { width: 24px; height: 24px; color: var(--faint); }
.msg-badges .icon-btn.star { opacity: 0; }
.msg-row:hover .msg-badges .icon-btn.star, .msg-badges .icon-btn.star.on { opacity: 1; }
.msg-badges .icon-btn.star.on { color: var(--star); }
.msg-badges .important { color: var(--danger); display: inline-flex; }
.important-banner { display: flex; align-items: center; gap: .45rem; margin: -.5rem 0 1rem; font-size: .84rem; font-weight: 600; color: var(--danger); }
.msg-hover-actions {
    position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
    display: none; gap: 2px; padding: 2px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.msg-row:hover .msg-hover-actions { display: inline-flex; }
.msg-hover-actions .icon-btn { width: 28px; height: 28px; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 .4rem; border-radius: 4px; font-size: .68rem; font-weight: 650; background: var(--surface-3); color: var(--muted); }
.tag.draft { background: var(--danger-soft); color: var(--danger); }

.list-footer { padding: .75rem; display: flex; justify-content: center; }

/* skeleton loading rows */
.skeleton-row { display: grid; grid-template-columns: 36px 1fr; gap: .75rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 4px; }
.skeleton.circle { width: 36px; height: 36px; border-radius: 50%; }
.skeleton.line { height: 10px; margin: 5px 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    gap: .4rem; padding: 3rem 1.5rem; color: var(--muted); flex: 1;
}
.empty-state .empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); margin-bottom: .5rem; }
.empty-state h3 { color: var(--text); font-size: 1rem; }
.empty-state p { font-size: .86rem; max-width: 300px; }
.kbd-hint { font-size: .78rem; color: var(--faint); margin-top: .5rem; }
kbd {
    font-family: var(--mono); font-size: .72rem; padding: .05rem .35rem; border-radius: 4px;
    border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-2);
}

/* ------------------------------------------------------------------ reading pane */

.pane-toolbar {
    display: flex; align-items: center; gap: 2px; padding: .35rem .75rem; min-height: 50px;
    border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface);
}
.pane-toolbar .mobile-only { display: none; }
.reader { flex: 1; overflow-y: auto; min-height: 0; }
.reader-inner { max-width: 920px; margin: 0 auto; padding: 1.25rem 1.75rem 2.5rem; }
.reader-subject { font-size: 1.35rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.3; margin-bottom: 1rem; word-break: break-word; display: flex; gap: .5rem; align-items: flex-start; }
.reader-subject .icon-btn { margin-top: -2px; }
.sender { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; }
.sender-meta { flex: 1; min-width: 0; }
.sender-name { display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; }
.sender-name strong { font-weight: 650; }
.sender-name .addr { color: var(--muted); font-size: .85rem; word-break: break-all; }
/* Sender authentication (DKIM/SPF) as recorded by the user's own mail server. */
.auth-mark { display: inline-flex; align-self: center; padding: 1px; border: 0; border-radius: 4px; background: none; cursor: pointer; line-height: 0; }
.auth-mark.ok { color: var(--ok-text); opacity: .75; }
.auth-mark.ok:hover { opacity: 1; }
.auth-mark.bad { color: var(--warn-text); }
.auth-check { display: block; color: var(--muted); font-size: .8rem; }
.auth-warning { display: flex; align-items: flex-start; gap: .65rem; padding: .65rem .85rem; margin-bottom: 1rem; border-radius: var(--radius-sm); font-size: .86rem; background: var(--warn-bg); color: var(--warn-text); }
.auth-warning .icon { margin-top: 2px; flex-shrink: 0; }
.auth-warning .lines { display: flex; flex-direction: column; gap: .2rem; }
.recipients { font-size: .82rem; color: var(--muted); margin-top: 1px; word-break: break-word; }
.recipients button { color: var(--muted); font-size: .82rem; display: inline-flex; align-items: center; vertical-align: middle; }
.recipients button:hover { color: var(--text); }
.header-details { margin-top: .4rem; padding: .6rem .75rem; background: var(--surface-2); border-radius: var(--radius-sm); font-size: .8rem; display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; }
.header-details dt { color: var(--muted); }
.header-details dd { word-break: break-word; }
.sender-date { color: var(--muted); font-size: .8rem; white-space: nowrap; }

.notice {
    display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; margin-bottom: 1rem;
    border-radius: var(--radius-sm); font-size: .85rem; background: var(--surface-2); color: var(--text-2);
    border: 1px solid var(--border);
}
.notice .icon { color: var(--muted); }
.notice .spacer { flex: 1; }

.attachments { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
.attachment {
    display: inline-flex; align-items: center; gap: .6rem; max-width: 280px; padding: .5rem .7rem;
    border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface);
    transition: border-color .12s, background .12s;
}
.attachment:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.attachment .file-ext {
    width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0;
    font-size: .62rem; font-weight: 750; text-transform: uppercase; background: var(--accent-soft); color: var(--accent);
}
.attachment .file-info { min-width: 0; line-height: 1.3; }
.attachment .file-name { display: block; font-size: .84rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .file-size { font-size: .74rem; color: var(--muted); }
.attachment .icon { color: var(--muted); }

.mail-frame-wrap { border-radius: var(--radius); overflow: hidden; background: #fff; }
.mail-frame { display: block; width: 100%; height: 360px; border: none; background: #fff; color-scheme: light; }
.msg-body-text { white-space: pre-wrap; word-break: break-word; font-size: .95rem; line-height: 1.65; color: var(--text); }
.msg-body-text blockquote { border-left: 3px solid var(--border-strong); padding-left: .85rem; margin: .25rem 0; color: var(--muted); white-space: pre-wrap; }
.msg-source { font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); }

.quick-reply { display: flex; gap: .5rem; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* menus */
.menu-anchor { position: relative; }
.menu {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 50; min-width: 220px; max-height: 360px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .3rem;
}
.menu.left { left: 0; right: auto; }
.menu-title { padding: .4rem .6rem .25rem; font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.menu-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .6rem; border-radius: var(--radius-sm); font-size: .87rem; text-align: left; color: var(--text-2); }
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item .icon { color: var(--muted); }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item:disabled { opacity: .45; pointer-events: none; }
.menu-item .spacer { flex: 1; }
a.menu-item { text-decoration: none; }
.menu-sep { height: 1px; margin: .3rem .2rem; background: var(--border); }
.menu-note { padding: .45rem .6rem; font-size: .82rem; color: var(--muted); }
.menu-scroll { max-height: 280px; overflow-y: auto; }
/* Right-click menus sit at the pointer; app.js keeps them inside the window. */
.context-menu { position: fixed; top: 0; left: 0; right: auto; max-height: calc(100vh - 16px); width: max-content; max-width: min(300px, calc(100vw - 16px)); }
.tag-menu { width: 260px; max-height: none; overflow: visible; }
.menu-search { display: flex; align-items: center; gap: .45rem; padding: .3rem .55rem .4rem; color: var(--faint); }
.menu-search input { flex: 1; min-width: 0; height: 30px; padding: 0 .45rem; font-size: .85rem; }
.tag-item[aria-checked="true"] { color: var(--text); font-weight: 600; }
.tag-swatch { width: 15px; height: 15px; border-radius: 4px; flex-shrink: 0; }
.tag-swatch.none { background: none; }

/* Tags: IMAP keywords, coloured from the name (see MailTags). */
.tag-chip {
    display: inline-flex; align-items: center; gap: .2rem; height: 18px; padding: 0 .4rem; border-radius: 9px; flex-shrink: 0;
    font-size: .68rem; font-weight: 650; white-space: nowrap; max-width: 9rem; overflow: hidden; text-overflow: ellipsis;
    color: var(--tag, var(--muted)); background: color-mix(in srgb, var(--tag, var(--muted)) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--tag, var(--muted)) 35%, transparent);
}
.tag-chip.more { --tag: var(--muted); }
.tag-chip button { display: inline-grid; place-items: center; color: inherit; opacity: .7; border-radius: 50%; }
.tag-chip button:hover { opacity: 1; }
.reader-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.4rem 0 1rem; }
.reader-tags .tag-chip { height: 22px; font-size: .74rem; max-width: none; }

/* ------------------------------------------------------------------ compose */

.compose-form { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.compose-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem .6rem 1.25rem; border-bottom: 1px solid var(--border); min-height: 50px; }
.compose-head h2 { font-size: 1rem; font-weight: 650; }
.compose-fields { flex-shrink: 0; padding: 0 1.25rem; }
.compose-field { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); min-height: 42px; }
.compose-field label { width: 56px; flex-shrink: 0; font-size: .84rem; color: var(--muted); }
.compose-field input { flex: 1; min-width: 0; border: none; background: transparent; padding: .55rem 0; box-shadow: none; }
.compose-field input:focus { box-shadow: none; }
.compose-field .from-value { flex: 1; font-size: .9rem; color: var(--text-2); padding: .55rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-field .from-select { flex: 1; min-width: 0; border: none; background: transparent; box-shadow: none; padding: .55rem 0; font-size: .9rem; color: var(--text-2); }
.compose-field .toggles { display: flex; gap: .15rem; }
.compose-field .toggles button { font-size: .8rem; color: var(--muted); padding: .2rem .4rem; border-radius: 4px; }
.compose-field .toggles button:hover { color: var(--text); background: var(--surface-3); }
.compose-subject input { font-weight: 600; font-size: .95rem; }
.compose-editor { flex: 1; display: flex; min-height: 160px; overflow: hidden; }
.compose-body { flex: 1; overflow-y: auto; padding: .85rem 1.25rem; outline: none; font-size: .95rem; line-height: 1.6; overflow-wrap: anywhere; }
.compose-body.mono { font-family: var(--mono); font-size: .88rem; }
.compose-body > div:only-child:has(> br:only-child)::before { content: "Write your message…"; float: left; width: 0; white-space: nowrap; color: var(--faint); pointer-events: none; }
.compose-body blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--border-strong); padding-left: 1ex; color: var(--text-2); }
.compose-body ul, .compose-body ol { margin: .2rem 0; padding-left: 1.6rem; }
.compose-body img { max-width: 100%; height: auto; border-radius: 4px; }
.compose-body a { color: var(--accent); }
.compose-form { position: relative; }
.compose-form[data-drop]::after {
    content: "Drop files to attach them"; position: absolute; inset: .5rem; z-index: 5; display: grid; place-items: center;
    border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--accent); font-weight: 600; pointer-events: none;
}
.compose-form[data-drop="inline"]::after { content: "Drop photos to put them in the message"; }

/* formatting toolbar */
.fmt-toolbar { display: flex; align-items: center; gap: .1rem; padding: .3rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.fmt-toolbar > button, .fmt-menu > button { height: 30px; min-width: 30px; padding: 0 .35rem; display: inline-flex; align-items: center; justify-content: center; gap: .1rem; border-radius: var(--radius-sm); color: var(--text-2); }
.fmt-toolbar button:hover { background: var(--surface-3); color: var(--text); }
.fmt-toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.fmt-toolbar button[aria-expanded="true"] { background: var(--surface-3); }
.fmt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 .3rem; }
.fmt-toolbar .spacer { flex: 1; }
.fmt-important { gap: .3rem !important; font-size: .82rem; }
.fmt-important.on { color: var(--danger, #c92a2a) !important; background: color-mix(in srgb, var(--danger, #c92a2a) 12%, transparent) !important; font-weight: 600; }
.fmt-menu { position: relative; display: inline-flex; }
.fmt-panel {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 252px; padding: .75rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.fmt-panel[hidden] { display: none; }
.fmt-selects { display: flex; gap: .4rem; margin-bottom: .6rem; }
.fmt-selects select { height: 30px; padding: 0 .4rem; font-size: .84rem; }
.fmt-selects select[data-font] { flex: 1; min-width: 0; }
.fmt-selects select[data-size] { width: 64px; }
.fmt-label { font-size: .8rem; color: var(--muted); margin: .35rem 0 .35rem; }
.fmt-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.fmt-swatches button { width: 100%; aspect-ratio: 1; min-width: 0; padding: 0; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .12); }
.fmt-swatches button:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.fmt-swatches button:nth-child(n+9):nth-child(-n+16) { margin-bottom: 4px; }
.fmt-custom, .fmt-none { display: flex; align-items: center; gap: .5rem; margin-top: .45rem; font-size: .84rem; color: var(--accent); cursor: pointer; padding: 0; height: auto !important; }
.fmt-custom input[type="color"] { width: 22px; height: 22px; padding: 0; border: 1px solid var(--border-strong); border-radius: 3px; background: none; cursor: pointer; }
.fmt-none:hover { background: none !important; text-decoration: underline; }
.fmt-none-box { width: 20px; height: 20px; border: 1px dashed var(--border-strong); border-radius: 3px; }
.compose-attachments { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.25rem .6rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; height: 28px; padding: 0 .3rem 0 .6rem; border-radius: 999px; background: var(--surface-3); font-size: .8rem; max-width: 260px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .muted { font-size: .74rem; }
.chip button { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.chip button:hover { background: var(--border-strong); color: var(--text); }
.compose-actions { display: flex; align-items: center; gap: .4rem; padding: .7rem 1.25rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.compose-actions .hint { font-size: .76rem; color: var(--faint); margin-left: .35rem; }
.file-picker { position: relative; overflow: hidden; }
.file-picker input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ------------------------------------------------------------------ toasts */

.toasts { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: .6rem; min-width: 240px; max-width: min(520px, calc(100vw - 2rem));
    padding: .6rem .6rem .6rem 1rem; border-radius: var(--radius); background: #1d222b; color: #f1f3f6;
    box-shadow: var(--shadow-lg); font-size: .88rem; animation: toast-in .18s ease-out;
}
.toast.error { background: #8f1f1f; }
.toast .spacer { flex: 1; }
.toast button { color: inherit; opacity: .7; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; }
.toast button:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ alerts */

.alert { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem .8rem; border-radius: var(--radius-sm); margin-bottom: .75rem; font-size: .86rem; }
.alert.err { background: var(--err-bg); color: var(--err-text); }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.alert .icon { margin-top: 2px; }

/* ------------------------------------------------------------------ auth pages */

.login-page {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 1.5rem 1rem;
    overflow-y: auto; height: 100%;
    background:
        radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #8b5cf6 12%, transparent), transparent 60%),
        var(--bg);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 2rem; width: 100%; max-width: 400px; margin: auto;
}
.login-card.wide { max-width: 520px; }
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; }
.login-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.login-brand h1 { font-size: 1.25rem; letter-spacing: -.015em; }
.login-brand p { color: var(--muted); font-size: .86rem; }
.login-card .lead { color: var(--muted); font-size: .88rem; margin-bottom: 1.25rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .82rem; color: var(--text-2); }
.field input, .field select { width: 100%; height: 40px; }
.field .help { font-size: .76rem; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.input-row { display: flex; gap: .5rem; }
.input-row input { flex: 1; min-width: 0; }
.card .help { font-size: .78rem; color: var(--muted); }
.sub-head { font-size: .88rem; margin: 1.1rem 0 .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.alias-row .desc .tag { margin-left: .35rem; }
.folder-subs { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .25rem; }
.folder-sub { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem; border-radius: var(--radius-sm); font-size: .88rem; color: var(--text-2); cursor: pointer; }
.folder-sub:hover { background: var(--surface-2); }
.folder-sub .icon { color: var(--muted); }
.folder-sub input:disabled + .icon + span { color: var(--muted); }
.form-section { margin: 1.25rem 0 .75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.form-section h3 { font-size: .88rem; display: flex; align-items: center; gap: .45rem; margin-bottom: .75rem; }
.form-section h3 .icon { color: var(--muted); }
.form-section h3 small { font-weight: 500; color: var(--muted); font-size: .78rem; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 2.5rem; }
.password-wrap .icon-btn { position: absolute; right: 3px; top: 3px; }
.fine-print { display: flex; gap: .5rem; align-items: flex-start; color: var(--muted); font-size: .76rem; margin-top: 1rem; }
.fine-print .icon { margin-top: 1px; }

/* Signing in a computer from a phone (QR code) */
.login-divider { display: flex; align-items: center; gap: .75rem; margin: 1.1rem 0; color: var(--muted); font-size: .8rem; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-alt { margin-top: .9rem; }
.login-alt-gap { margin-top: .5rem; }
.login-alt-help { font-size: .76rem; color: var(--muted); margin-top: .4rem; text-align: center; }
.qr-signin { display: flex; flex-direction: column; align-items: stretch; }
.qr-code { width: 224px; height: 224px; margin: 0 auto; border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-code.placeholder { display: flex; align-items: center; justify-content: center; background: var(--surface-2, var(--bg)); color: var(--muted); }
.qr-match { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .9rem; color: var(--muted); font-size: .84rem; }
.qr-match strong { font-size: 1.6rem; letter-spacing: .08em; color: var(--text); font-variant-numeric: tabular-nums; }
.qr-status { text-align: center; color: var(--text-2); font-size: .86rem; margin: .5rem 0 0; min-height: 1.3em; }
.qr-steps { margin: 1rem 0 0 1.2rem; color: var(--text-2); font-size: .84rem; display: grid; gap: .25rem; }
.qr-desktop { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.qr-desktop .icon { margin-top: 2px; color: var(--muted); }
.qr-desktop div, .qr-sessions li > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.qr-desktop span, .qr-sessions span { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.qr-question { font-weight: 600; margin: 1.1rem 0 .6rem; }
.qr-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.qr-choices .btn { height: 56px; font-size: 1.4rem; font-variant-numeric: tabular-nums; justify-content: center; }
.qr-sessions-head { font-size: .9rem; margin: 1.5rem 0 .5rem; }
.qr-sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.qr-sessions li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.qr-sessions .btn { flex-shrink: 0; }
.boot.inline { height: auto; padding: 1.5rem 0; }

/* "I trust this computer" */
.check-row.trust-row { align-items: flex-start; margin: .1rem 0 1rem; }
.notify-options { display: grid; margin-top: .5rem; }
.notify-options .check-row.trust-row { margin-bottom: .6rem; }
.trust-row input { margin-top: .2rem; }
.trust-row span { display: flex; flex-direction: column; gap: .15rem; font-weight: 600; font-size: .86rem; }
.trust-row small { font-weight: 400; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.trusted-devices { margin-bottom: 1rem; }
.trusted-devices h4 { font-size: .9rem; margin-bottom: .35rem; }
.device-list { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .5rem; }
.device-list li { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.device-list li > .icon { color: var(--muted); flex-shrink: 0; }
.device-list li > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.device-list li span { color: var(--muted); font-size: .78rem; }
.device-list .tag { margin-left: .35rem; }
.device-list .tag.warn { color: var(--danger); }
.device-list li .btn + .btn { margin-left: .35rem; }
.device-list + .btn { margin-top: .5rem; }
.login-key-new { display: grid; gap: .5rem; margin: .6rem 0; padding: .75rem; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); }
.login-key-code { font: 600 1.3rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; user-select: all; overflow-wrap: anywhere; }
.login-key-actions { display: flex; gap: .4rem; }
.login-key-make { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.login-key-make label { font-size: .85rem; color: var(--muted); }
.login-key-make select { width: auto; }
.passkey-add { margin-top: .6rem; }
.page-footer { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .8rem; padding: 1rem; }
.footer-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.footer-link:hover { color: var(--text); text-decoration: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--muted); gap: .6rem; }

/* ------------------------------------------------------------------ settings / admin pages */

.settings-page { padding: 1.75rem 2rem 3rem; max-width: 820px; margin: 0 auto; }
.settings-page > h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.015em; margin-bottom: .25rem; }
.settings-page > .lead { color: var(--muted); margin-bottom: 1.5rem; }
.settings-page h3 { font-size: 1rem; margin: 0 0 .25rem; }
.settings-page .muted { font-size: .86rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.card-head .icon-tile { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.card-head p { color: var(--muted); font-size: .84rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.setting-row:first-of-type { border-top: none; }
.setting-row label { font-size: .9rem; font-weight: 500; }
.setting-row .desc { font-size: .8rem; color: var(--muted); }
.setting-row select { min-width: 160px; }
.setting-stack { display: flex; flex-direction: column; gap: .4rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.setting-stack textarea { width: 100%; min-height: 90px; resize: vertical; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-3); }
.segmented button { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 5px; font-size: .84rem; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.card-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .4rem 1.5rem; font-size: .85rem; }
.shortcut-grid div { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem 0; color: var(--text-2); }

.key-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .5rem; background: var(--surface); }
.key-card .key-id { font-family: var(--mono); font-weight: 600; font-size: .88rem; }
.key-card .key-users { color: var(--muted); font-size: .84rem; }
.key-card .btn { margin-top: .5rem; }

.sieve-page { display: flex; flex-direction: column; height: 600px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sieve-toolbar { display: flex; align-items: center; gap: .4rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface-2); }
.sieve-editor-area { flex: 1; display: flex; min-height: 0; }
.sieve-scripts-sidebar { width: 170px; border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; background: var(--surface-2); padding: .3rem; }
.sieve-script-item { padding: .4rem .6rem; cursor: pointer; font-size: .85rem; border-radius: var(--radius-sm); }
.sieve-script-item:hover { background: var(--surface-3); }
.sieve-script-item.active { background: var(--selected); color: var(--accent); font-weight: 600; }
.sieve-editor-area textarea { flex: 1; font-family: var(--mono); font-size: .84rem; padding: .85rem; border: none; border-radius: 0; resize: none; background: var(--surface); color: var(--text); }
.sieve-editor-area textarea:focus { box-shadow: none; }
.sieve-script-pane, .sieve-rules-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sieve-rules-pane { overflow-y: auto; background: var(--surface); }
.sieve-note { padding: .5rem .85rem; font-size: .82rem; background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--border); }
.sieve-rules { display: flex; flex-direction: column; gap: .5rem; padding: .75rem; }
.sieve-rules-empty { display: flex; align-items: center; gap: .6rem; padding: .75rem; color: var(--muted); font-size: .86rem; }
.sieve-rule { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sieve-rule.open { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.sieve-rule.off .sieve-rule-title { opacity: .55; }
.sieve-rule-head { display: flex; align-items: center; gap: .65rem; padding: .5rem .5rem .5rem .7rem; cursor: pointer; }
.sieve-rule-head:hover { background: var(--surface-2); border-radius: var(--radius); }
.sieve-rule-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .05rem; font-size: .86rem; }
.sieve-rule-title span { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sieve-rule-tools { display: flex; gap: 2px; flex-shrink: 0; }
.sieve-rule-body { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; padding: .25rem .85rem .85rem; border-top: 1px solid var(--border); }
.sieve-label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; font-weight: 600; color: var(--muted); width: min(100%, 320px); margin-top: .5rem; }
.sieve-label input { font-weight: 400; }
.sieve-section { display: flex; align-items: center; gap: .4rem; margin-top: .6rem; font-size: .84rem; font-weight: 600; }
.sieve-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: .35rem; width: 100%; }
.sieve-row.tight { flex-wrap: nowrap; align-items: center; }
.sieve-row select, .sieve-row input, .sieve-section select { height: 32px; font-size: .84rem; }
.sieve-row .grow, .sieve-values { flex: 1; min-width: 180px; }
.sieve-values { display: flex; flex-direction: column; gap: .3rem; }
.sieve-value { display: flex; align-items: center; gap: .3rem; }
.sieve-value input { flex: 1; min-width: 0; }
.sieve-or { font-size: .78rem; width: 1.2rem; }
.sieve-header-name { width: 140px; }
.sieve-size { width: 90px; }
select.compact { width: auto; }
.sieve-vacation { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: .35rem; }
.sieve-vacation label { display: flex; align-items: center; gap: .3rem; font-size: .8rem; white-space: nowrap; }
.sieve-editor-area .sieve-vacation textarea {
    flex: none; width: 100%; font-family: inherit; font-size: .84rem; padding: .45rem .6rem; resize: vertical;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.sieve-editor-area .sieve-vacation textarea:focus { box-shadow: var(--focus); }
.sieve-check { display: flex; align-items: center; gap: .45rem; font-size: .84rem; margin-top: .5rem; cursor: pointer; }
@media (max-width: 720px) {
    .sieve-page { height: auto; min-height: 600px; }
    .sieve-editor-area { flex-direction: column; }
    .sieve-scripts-sidebar { width: auto; max-height: 120px; border-right: none; border-bottom: 1px solid var(--border); }
    .sieve-editor-area textarea { min-height: 420px; }
    .sieve-toolbar { flex-wrap: wrap; }
}

/* calendar & contacts placeholders */
.calendar-page, .contacts-page { padding: 1.5rem 2rem; max-width: 1100px; margin: 0 auto; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.calendar-header-cell { padding: .5rem; text-align: center; font-weight: 650; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.calendar-cell { padding: .4rem .5rem; min-height: 92px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); font-size: .82rem; }
.calendar-cell:nth-child(7n) { border-right: none; }
.calendar-cell.muted { color: var(--faint); background: var(--surface-2); }
.calendar-cell.today .day-num { background: var(--accent); color: var(--accent-text); }
.calendar-cell .day-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 600; }
.calendar-cell .event-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin: 1px; }
.contact-row { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border-bottom: 1px solid var(--border); }
.contact-row .contact-name { font-weight: 600; }
.contact-row .contact-detail { color: var(--muted); font-size: .85rem; }
.page-head { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.page-head h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.015em; }

/* ------------------------------------------------------------------ mobile */

.mobile-tabs { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1180px) {
    :root { --list-w: 340px; }
    .msg-hover-actions { display: none !important; }
}

@media (max-width: 960px) {
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 200; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); width: 280px !important; min-width: 280px !important; }
    .splitter[data-resize="sidebar"], .rail-toggle { display: none; }
    /* The drawer always shows the full sidebar, even if the desktop rail is collapsed. */
    :root[data-sidebar="collapsed"] .sidebar .brand { flex-direction: row; padding: 1rem 1rem .75rem; }
    :root[data-sidebar="collapsed"] .sidebar .brand-text, :root[data-sidebar="collapsed"] .sidebar .label,
    :root[data-sidebar="collapsed"] .sidebar .nav-label, :root[data-sidebar="collapsed"] .sidebar .user-chip .who { display: revert !important; }
    :root[data-sidebar="collapsed"] .sidebar .nav-label { display: flex !important; }
    :root[data-sidebar="collapsed"] .sidebar .compose-btn { width: auto; margin: .25rem .75rem .75rem; padding: 0 .85rem; }
    :root[data-sidebar="collapsed"] .sidebar .nav-item { justify-content: flex-start; padding: 0 .6rem !important; }
    :root[data-sidebar="collapsed"] .sidebar .user-chip { flex-direction: row; padding: .65rem .85rem; }
    .sidebar.open { transform: none; }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(10, 12, 16, .4); }
    .show-menu { display: inline-flex !important; }
}
@media (min-width: 961px) { .show-menu { display: none !important; } }

@media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .main-area { flex-direction: column; }
    .list-pane { width: 100%; min-width: 0; border-right: none; flex: 1; }
    .splitter { display: none; }
    .detail-panel { display: none; }
    .detail-panel.mobile-visible { display: flex; position: fixed; inset: 0; z-index: 120; }
    .detail-panel.desktop-empty { display: none !important; }
    .pane-toolbar .mobile-only { display: inline-flex; }
    .reader-inner { padding: 1rem 1rem 2rem; }
    .reader-subject { font-size: 1.15rem; }
    .settings-page, .calendar-page, .contacts-page { padding: 1rem; }
    .mobile-tabs { display: flex; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom); }
    .mobile-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem 0 .4rem; color: var(--muted); font-size: .68rem; }
    .mobile-tab.active { color: var(--accent); }
    .compose-actions .hint, .pane-toolbar .hide-sm { display: none; }
    .field-row { grid-template-columns: 1fr; gap: 0; }
    .calendar-cell { min-height: 56px; }
    .toasts { bottom: 4.5rem; }
}

/* ------------------------------------------------------------------ framework */

#blazor-error-ui {
    display: none; position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 2000;
    padding: .7rem 1rem; border-radius: var(--radius); background: #8f1f1f; color: #fff; box-shadow: var(--shadow-lg); font-size: .9rem;
}
#blazor-error-ui .reload { color: #fff; font-weight: 600; margin-left: .75rem; text-decoration: underline; }

.spin { animation: spin .8s linear infinite; }

.link-btn { color: var(--accent); font-size: inherit; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }
.calendar-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.calendar-chips .chip { background: color-mix(in srgb, currentColor 12%, transparent); padding: 0 .6rem; }

/* ------------------------------------------------------------------ calendar */

.calendar-page { max-width: 1320px; container-type: inline-size; outline: none; }
.calendar-page .page-head { flex-wrap: wrap; row-gap: .5rem; }
.cal-layout {
    display: grid; gap: 1rem; align-items: start;
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-areas: "grid filters" "grid agenda";
    grid-template-rows: auto 1fr;
}
.cal-layout > .calendar-grid { grid-area: grid; }
.cal-layout > .cal-filters { grid-area: filters; }
.cal-layout > .agenda { grid-area: agenda; }
.calendar-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-cell { position: relative; min-height: 108px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; outline: none; user-select: none; }
.calendar-cell:hover { background: var(--surface-2); }
.calendar-cell:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-cell.selected { background: var(--accent-soft); }
.calendar-cell.muted .ev-chip { opacity: .6; }
.cell-head { display: flex; align-items: center; justify-content: space-between; }
.cell-add { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .1s; }
.calendar-cell:hover .cell-add, .calendar-cell.selected .cell-add, .cell-add:focus-visible { opacity: 1; }
.cell-add:hover { background: var(--surface-3); color: var(--accent); }
.cell-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-chip {
    --cal: var(--accent);
    display: flex; align-items: center; gap: .3rem; width: 100%; min-width: 0; padding: 1px .35rem; border-radius: 4px;
    font-size: .74rem; line-height: 1.45; text-align: left; color: var(--text-2);
}
.ev-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cal); flex-shrink: 0; }
.ev-chip:hover { background: color-mix(in srgb, var(--cal) 14%, transparent); }
.ev-chip.allday { background: color-mix(in srgb, var(--cal) 18%, transparent); color: var(--text); font-weight: 550; }
.ev-chip.allday::before { display: none; }
.ev-time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-more { font-size: .72rem; color: var(--muted); padding: 0 .35rem; font-weight: 600; }
.ev-dots { display: none; gap: 3px; justify-content: center; margin-top: auto; }
.ev-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cal); }

/* calendar filters: a card of colour-keyed switches */
.cal-filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .75rem; }
.cal-filters-head { display: flex; align-items: center; justify-content: space-between; padding: 0 .25rem .4rem; }
.cal-filters-head h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; }
.cal-filters-head .link-btn { font-size: .78rem; }
.cal-filter-list { display: flex; flex-direction: column; gap: 2px; }
.cal-filter {
    --cal: var(--accent);
    display: flex; align-items: center; gap: .6rem; width: 100%; padding: .4rem .45rem; border-radius: var(--radius-sm);
    text-align: left; font-size: .88rem; color: var(--text); transition: background .1s, color .1s;
}
.cal-filter:hover { background: var(--surface-2); }
.cal-check {
    width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--cal); border: 2px solid var(--cal); color: #fff; transition: background .12s;
}
.cal-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-count {
    min-width: 22px; height: 20px; padding: 0 .4rem; border-radius: 999px; font-size: .72rem; font-weight: 650;
    display: grid; place-items: center; font-variant-numeric: tabular-nums;
    background: color-mix(in srgb, var(--cal) 14%, transparent); color: color-mix(in srgb, var(--cal) 75%, var(--text));
}
.cal-filter.off { color: var(--muted); }
.cal-filter.off .cal-check { background: transparent; color: transparent; border-color: color-mix(in srgb, var(--cal) 55%, var(--border-strong)); }
.cal-filter.off .cal-name { text-decoration: line-through; text-decoration-color: var(--faint); }
.cal-filter.off .cal-count { background: var(--surface-3); color: var(--faint); }

/* calendar sections (mine / shared with me / subscribed) and per-calendar actions */
.cal-section + .cal-section { margin-top: .6rem; }
.cal-section h4 { font-size: .7rem; font-weight: 650; color: var(--faint); padding: .2rem .45rem; }
.cal-filters-head { gap: .25rem; }
.cal-filters-head .spacer { flex: 1; }
.cal-filter-row { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.cal-filter-row:hover { background: var(--surface-2); }
.cal-filter-row .cal-filter { flex: 1; min-width: 0; }
.cal-filter-row .cal-filter:hover { background: transparent; }
.cal-action { flex-shrink: 0; color: var(--muted); opacity: 0; transition: opacity .1s; }
.cal-filter-row:hover .cal-action, .cal-action:focus-visible { opacity: 1; }
.cal-label { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cal-label .cal-name { flex: none; }
.cal-origin { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: none) { .cal-action { opacity: 1; } }

/* highlighted days / times, and the toolbar that floats over them */
.calendar-cell.in-range, .calendar-cell.sel-drag, .tg-allday-cell.in-range, .tg-allday-cell.sel-drag { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.calendar-cell.in-range.muted { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
/* :hover too, or the slot under the pointer would look left out of the highlight */
.tg-slot.sel-drag, .tg-slot.sel-drag:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.sel-toolbar {
    position: absolute; z-index: 6; display: inline-flex; align-items: center; gap: 4px; padding: 3px 3px 3px .6rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    white-space: nowrap; cursor: default; animation: pop-in .1s ease-out;
}
.sel-toolbar .sel-label { font-size: .78rem; font-weight: 600; color: var(--text-2); margin-right: .2rem; font-variant-numeric: tabular-nums; }
.sel-toolbar .btn.small { height: 28px; }
.sel-toolbar .icon-btn.small { width: 26px; height: 26px; }
.calendar-cell > .sel-toolbar { right: 4px; bottom: 4px; }
.tg-allday-cell > .sel-toolbar { right: 4px; top: calc(100% + 4px); }

/* week and day views: an all-day row above a scrolling grid of half hours */
.cal-layout > .time-grid { grid-area: grid; }
.time-grid {
    --slot-h: 22px; --gutter: 52px;
    position: relative; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); min-width: 0;
}
.tg-row { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0, 1fr)); }
.tg-gutter { font-size: .7rem; color: var(--faint); text-align: right; padding: .35rem .45rem 0 0; }
.tg-head { background: var(--surface-2); border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.tg-dayhead { display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .45rem .25rem; border-left: 1px solid var(--border); min-width: 0; }
.tg-dayhead:hover { background: var(--surface-3); }
.tg-dayhead .tg-dow { font-weight: 650; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tg-dayhead .day-num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%; font-weight: 650; font-size: .9rem; }
.tg-dayhead.today .day-num { background: var(--accent); color: var(--accent-text); }
.tg-dayhead.selected:not(.today) .day-num { background: var(--accent-soft); color: var(--accent); }
.one-day .tg-dayhead { justify-content: flex-start; padding-left: .75rem; cursor: default; }
.one-day .tg-dayhead:hover { background: none; }
.tg-allday { border-bottom: 1px solid var(--border-strong); }
.tg-allday .tg-gutter { padding-top: .45rem; }
.tg-allday-cell { position: relative; min-height: 34px; padding: 3px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; user-select: none; }
.tg-allday-cell:hover { background: var(--surface-2); }
.tg-scroll { max-height: max(360px, calc(100dvh - 240px)); overflow-x: hidden; overflow-y: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.tg-body { position: relative; height: calc(var(--slot-h) * 48); }
.tg-hours { position: relative; padding: 0; }
.tg-hours span { position: absolute; right: .45rem; transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.tg-col { position: relative; border-left: 1px solid var(--border); min-width: 0; user-select: none; }
.tg-col.today { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.tg-slot { height: var(--slot-h); cursor: pointer; }
.tg-slot.hour { border-top: 1px solid var(--border); }
.tg-slot:not(.hour) { border-top: 1px dashed color-mix(in srgb, var(--border) 60%, transparent); }
.tg-slot:first-child { border-top: none; }
.tg-slot:hover { background: var(--surface-2); }
.tg-sel {
    position: absolute; left: 1px; right: 1px; z-index: 5; border-radius: 4px; pointer-events: none;
    background: color-mix(in srgb, var(--accent) 18%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent);
}
.tg-sel-anchor { position: absolute; right: 2px; top: calc(100% + 4px); pointer-events: auto; }
.tg-sel-anchor.above { top: auto; bottom: calc(100% + 4px); }
.tg-sel-anchor .sel-toolbar { position: static; }
.tg-sel-anchor.start { right: auto; left: 2px; }
.tg-event {
    --cal: var(--accent);
    position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 0; overflow: hidden;
    padding: 2px .4rem; border-radius: 5px; text-align: left; font-size: .74rem; line-height: 1.3; min-height: 18px;
    background: color-mix(in srgb, var(--cal) 18%, var(--surface)); border-left: 3px solid var(--cal); color: var(--text);
    box-shadow: 0 0 0 1px var(--surface);
}
.tg-event:hover, .tg-event.open { background: color-mix(in srgb, var(--cal) 28%, var(--surface)); z-index: 4; }
.tg-event > span { flex-shrink: 0; } /* short events clip the time, not the title */
.tg-event .ev-title { font-weight: 600; max-width: 100%; }
.tg-event .ev-time { font-size: .7rem; }
/* moving and resizing events */
.tg-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.tg-resize::after {
    content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px;
    background: color-mix(in srgb, var(--cal) 70%, var(--text)); opacity: 0; transition: opacity .1s;
}
.tg-event:hover .tg-resize::after, .tg-event.open .tg-resize::after { opacity: .8; }
.drag-src { opacity: .35; }
.cal-ghost {
    --cal: var(--accent);
    position: fixed; z-index: 600; pointer-events: none; display: flex; align-items: center; gap: .3rem; min-width: 0; overflow: hidden;
    padding: 1px .35rem; border-radius: 5px; font-size: .74rem; line-height: 1.45; color: var(--text);
    background: color-mix(in srgb, var(--cal) 30%, var(--surface)); box-shadow: var(--shadow-lg); opacity: .95;
}
.cal-ghost.timed { flex-direction: column; align-items: flex-start; padding: 2px .4rem; line-height: 1.3; border-left: 3px solid var(--cal); }
.cal-ghost .ev-title { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ghost .ev-time { font-size: .7rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.calendar-cell.drop-target, .tg-allday-cell.drop-target { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
:root.cal-moving, :root.cal-moving * { cursor: grabbing !important; user-select: none; }
:root.cal-resizing, :root.cal-resizing * { cursor: ns-resize !important; user-select: none; }
.tg-now { position: absolute; left: 0; right: 0; z-index: 4; height: 2px; background: var(--danger); pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.agenda { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; position: sticky; top: 1rem; }
.agenda-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.agenda h3 { font-size: .95rem; }
.agenda .muted { font-size: .86rem; }
.agenda-item { --cal: var(--accent); border-left: 3px solid var(--cal); border-radius: 4px; margin-bottom: .4rem; background: var(--surface-2); }
.agenda-head { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: .45rem .6rem; text-align: left; }
.agenda-head:hover { background: var(--surface-3); }
.agenda-time { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda-title { font-size: .88rem; font-weight: 600; color: var(--text); }
.agenda-loc { font-size: .78rem; color: var(--muted); }
.agenda-detail { padding: 0 .6rem .6rem; font-size: .84rem; display: flex; flex-direction: column; gap: .5rem; }
.agenda-detail .msg-body-text { font-size: .84rem; line-height: 1.5; }

/* Narrower: filters become a row of chips above the grid, agenda below. */
@container (max-width: 900px) {
    .cal-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "filters" "grid" "agenda"; grid-template-rows: auto; }
    .cal-filters { background: none; border: none; padding: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
    .cal-filters-head { padding: 0; order: 2; }
    .cal-filters-head h3 { display: none; }
    .cal-filter-list { flex-direction: row; flex-wrap: wrap; gap: .4rem; }
    .cal-filter { width: auto; padding: .3rem .65rem .3rem .4rem; border-radius: 999px; }
    .cal-filter-row { border: 1px solid var(--border); border-radius: 999px; background: var(--surface); padding-right: 2px; }
    .cal-section { display: contents; }
    .cal-section h4, .cal-origin { display: none; }
    .cal-action { opacity: 1; }
    .agenda { position: static; }
}
@container (max-width: 560px) {
    .calendar-cell { min-height: 58px; align-items: center; padding: .3rem .1rem; }
    .cell-head { justify-content: center; }
    .cell-add, .cell-events { display: none; }
    .ev-dots { display: flex; }
    .cal-count { display: none; }
    .time-grid { --gutter: 40px; }
    .tg-dayhead { flex-direction: column; gap: 0; padding: .3rem 0; }
    .tg-dayhead .tg-dow { font-size: .62rem; letter-spacing: 0; }
    .tg-event { padding: 1px 2px; font-size: .66rem; }
    .tg-event .ev-time { display: none; }
    .sel-toolbar .sel-label { display: none; }
}

/* ------------------------------------------------------------------ dialogs */

.modal-backdrop { position: fixed; inset: 0; z-index: 400; background: rgba(10, 12, 16, .45); display: grid; place-items: center; padding: 1rem; animation: fade-in .12s ease-out; }
.modal {
    width: 100%; max-width: 560px; max-height: calc(100dvh - 2rem); display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    animation: pop-in .14s ease-out;
}
.modal-head { display: flex; align-items: center; gap: .5rem; padding: .85rem .85rem .5rem 1.25rem; }
.modal-head h3 { font-size: 1.05rem; }
.modal-body { padding: .25rem 1.25rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
/* Create a rule from a message */
.rule-from-message .rule-heading { font-size: .86rem; margin: .9rem 0 .5rem; color: var(--text-2); }
.rule-match { display: grid; grid-template-columns: auto 1fr; gap: .5rem .75rem; align-items: center; }
.rule-match .check-row { margin: 0; }
.rule-match input:not([type]) { width: 100%; height: 34px; }
.rule-from-message .rule-folder { width: 100%; height: 34px; margin: -.35rem 0 .75rem; }
@media (max-width: 520px) { .rule-match { grid-template-columns: 1fr; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.event-editor .title-input { width: 100%; font-size: 1.15rem; font-weight: 600; border: none; border-bottom: 2px solid var(--border); border-radius: 0; padding: .4rem 0; margin-bottom: 1rem; background: transparent; }
.event-editor .title-input:focus { box-shadow: none; border-bottom-color: var(--accent); }
.event-editor .field select, .event-editor .field input { width: 100%; }
.event-editor textarea { width: 100%; resize: vertical; }
.select-with-dot { --cal: var(--accent); position: relative; }
.select-with-dot .dot { position: absolute; left: .7rem; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--cal); pointer-events: none; }
.select-with-dot select { padding-left: 1.75rem; height: 40px; }
.guest-add { display: flex; gap: .5rem; align-items: center; }
.guest-add .recipient-input { flex: 1; min-width: 0; }
.guest-add .btn { flex: none; height: 36px; }
.field .help.err { color: var(--err-text); }
.guest-list { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.guest-list li { display: flex; align-items: center; gap: .5rem; min-height: 32px; padding: .1rem .25rem; border-radius: var(--radius-sm); font-size: .88rem; }
.guest-list li:hover { background: var(--surface-2); }
.guest-list.compact li { min-height: 24px; padding: 0; font-size: .82rem; }
.guest-list.compact li:hover { background: none; }
.guest-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-name .muted { margin-left: .35rem; font-size: .8rem; }
.guest-status { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: .72rem; font-weight: 700; line-height: 1;
    background: var(--surface-3); color: var(--muted); }
.guest-status.accepted { background: var(--ok-bg); color: var(--ok-text); }
.guest-status.declined { background: var(--err-bg); color: var(--err-text); }
.guest-status.tentative { background: var(--warn-bg); color: var(--warn-text); }
.guest-optional { flex: none; border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: .1rem .55rem; font-size: .74rem; cursor: pointer; }
.guest-optional.on { background: var(--surface-3); color: var(--text-2); }
.guest-optional:hover { border-color: var(--border-strong); color: var(--text); }
.invite-card { display: flex; gap: .9rem; align-items: flex-start; padding: .85rem 1rem; margin-bottom: 1rem; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); font-size: .86rem; }
.invite-card.cancelled { border-left-color: var(--danger); }
.invite-card.cancelled .invite-title { text-decoration: line-through; text-decoration-color: var(--faint); }
.invite-date { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; padding: .3rem 0; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text-2); line-height: 1.1; }
.invite-date .month { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.invite-card.cancelled .invite-date .month { color: var(--danger); }
.invite-date .day { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.invite-date .weekday { font-size: .68rem; color: var(--muted); }
.invite-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.invite-kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.invite-title { font-size: 1rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.invite-when, .invite-where { color: var(--text-2); }
.invite-status { margin-top: .3rem; color: var(--text-2); display: flex; align-items: center; gap: .4rem; }
.invite-status.err { color: var(--err-text); }
.invite-actions { margin-top: .45rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.invite-actions select { height: 32px; max-width: 220px; }
.agenda-guests { display: flex; flex-direction: column; gap: .25rem; }
.rsvp { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rsvp > span { font-weight: 600; color: var(--text-2); margin-right: .2rem; }
.delete-confirm .muted { font-size: .8rem; }
.check-row { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; margin-bottom: .75rem; cursor: pointer; }
.when-grid { display: grid; grid-template-columns: 56px minmax(0, 1fr) 120px; gap: .45rem .5rem; align-items: center; margin-bottom: .9rem; }
.when-grid label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.when-grid input { height: 38px; min-width: 0; }
.when-grid.all-day { grid-template-columns: 56px minmax(0, 1fr); }
.delete-confirm { display: inline-flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.btn.ghost.danger { color: var(--danger); }

/* ------------------------------------------------------------------ contacts */

/* The contacts page fills the pane like Mail: list | details, each scrolling on its own. */
.page-pane.fill { display: flex; flex-direction: column; overflow: hidden; }
.page-pane.fill > .contacts-shell { flex: 1; min-height: 0; }
.contacts-shell { container-type: inline-size; height: 100%; }
.contacts-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); height: 100%; }
.contacts-pane-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.contacts-pane-detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.pane-head { display: flex; align-items: center; gap: .5rem; padding: .85rem 1rem .5rem; min-height: 56px; }
.pane-head h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.pane-pad { padding: 0 1rem .5rem; }
.contact-rows-wrap { flex: 1; min-height: 0; display: flex; }
.contact-rows { flex: 1; min-width: 0; overflow-y: auto; padding: 0 .5rem .75rem; }
.letter-rail { flex: none; display: flex; flex-direction: column; justify-content: center; padding: .25rem .2rem .25rem 0; overflow: hidden; }
.letter-rail button {
    flex: 0 1 auto; min-height: 0; padding: 1px 5px; border-radius: 4px; line-height: 1.15;
    font-size: .66rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums;
}
.letter-rail button:hover:not(:disabled) { background: var(--accent-soft); }
.letter-rail button:disabled { color: var(--faint); opacity: .55; cursor: default; }
.contact-letter { position: sticky; top: 0; background: var(--surface); padding: .55rem .5rem .2rem; font-size: .72rem; font-weight: 700; color: var(--faint); letter-spacing: .05em; z-index: 1; }
.contact-row { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .45rem .5rem; border-radius: var(--radius-sm); border: none; text-align: left; }
.contact-row:hover { background: var(--surface-2); }
.contact-row.active { background: var(--selected); }
.contact-row.active .contact-name { color: var(--accent); }
.contact-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.contact-row .contact-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row .contact-detail { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
img.avatar { object-fit: cover; background: var(--surface-3); }
.avatar.xl { width: 72px; height: 72px; font-size: 1.4rem; }
.detail-scroll { flex: 1; overflow-y: auto; }
.detail-inner { max-width: 720px; margin: 0 auto; padding: 1.5rem 1.75rem 2.5rem; }
.contacts-pane-detail .pane-toolbar { background: var(--surface); }
.contact-hero { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.5rem; }
.contact-hero h3 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.015em; margin: 0; }
.contact-section { border-top: 1px solid var(--border); padding: .85rem 0; }
.contact-section h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: .4rem; }
.contact-value { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .25rem 0; font-size: .92rem; word-break: break-word; }
.contact-value .label { display: inline-block; min-width: 70px; color: var(--muted); font-size: .8rem; margin-right: .5rem; }
.narrow-back { display: none !important; }

/* editor */
.contact-editor { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.editor-head { margin-bottom: 1rem; }
.editor-head h3 { font-size: 1.1rem; }
.contact-editor textarea { width: 100%; resize: vertical; }
.multi-field { border: none; margin: 0 0 .9rem; padding: 0; }
.multi-field legend { font-weight: 600; font-size: .82rem; color: var(--text-2); margin-bottom: .3rem; }
.multi-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.multi-row input, .multi-row select { height: 38px; min-width: 0; }
.editor-actions { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Not enough room for two panes: show the list, or the contact with a back button. */
@container (max-width: 680px) {
    .contacts-grid { grid-template-columns: minmax(0, 1fr); }
    .contacts-grid.show-detail .contacts-pane-list { display: none; }
    .contacts-grid:not(.show-detail) .contacts-pane-detail { display: none; }
    .contacts-pane-list { border-right: none; }
    .narrow-back { display: inline-flex !important; }
    .detail-inner { padding: 1rem 1rem 2rem; }
    .contact-editor .narrow-back { margin-bottom: .75rem; }
}
@container (max-width: 420px) {
    .multi-row { grid-template-columns: 90px minmax(0, 1fr) auto; }
}

/* ------------------------------------------------------------------ notes */

.note-row { display: flex; flex-direction: column; gap: .15rem; width: 100%; padding: .55rem .6rem; border: none; border-radius: var(--radius-sm); text-align: left; }
.note-row:hover { background: var(--surface-2); }
.note-row.active { background: var(--selected); }
.note-row.active .note-title { color: var(--accent); }
.note-line { display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
.note-title { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-date { flex: none; color: var(--faint); font-size: .74rem; }
.note-snippet { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-pane-detail .pane-toolbar { gap: .5rem; }
.compact-select { height: 32px; max-width: 200px; font-size: .85rem; }
.save-state { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.save-state.dirty { color: var(--accent); font-weight: 600; }
.note-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 820px; margin: 0 auto; padding: 0 0 1rem; }
.note-title-input { margin: 1.25rem 1.75rem .25rem; padding: .3rem 0; border: none; border-radius: 0; background: transparent; font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; }
.note-title-input:focus, .note-body-input:focus { box-shadow: none; }
.note-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 1.75rem .5rem; }
.note-body-input { flex: 1; min-height: 240px; margin: 0 1.75rem; padding: .3rem 0; border: none; border-radius: 0; background: transparent; resize: none; font: inherit; font-size: .95rem; line-height: 1.6; }

/* ------------------------------------------------------------------ tasks */

.quick-add { display: flex; align-items: center; gap: .35rem; margin-bottom: .1rem; }
.quick-add input { flex: 1; min-width: 0; height: 36px; background: var(--surface-2); border-color: transparent; }
.quick-add input:focus { background: var(--surface); }
.contact-letter.overdue { color: var(--danger); }
.task-row { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem .5rem; border-radius: var(--radius-sm); }
.task-row:hover { background: var(--surface-2); }
.task-row.active { background: var(--selected); }
.task-check { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; padding: 0; border: 2px solid var(--faint); border-radius: 50%; background: transparent; color: transparent; }
.task-check:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.task-check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; padding: 0; border: none; background: none; text-align: left; }
.task-title { font-size: .9rem; font-weight: 550; overflow-wrap: anywhere; }
.task-row.active .task-title { color: var(--accent); }
.task-row.done .task-title { color: var(--muted); text-decoration: line-through; font-weight: 450; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .65rem; font-size: .75rem; color: var(--muted); }
.task-meta .icon { vertical-align: -1px; }
.task-meta .overdue, .task-meta .prio-high { color: var(--danger); font-weight: 600; }
.task-meta .prio-medium { color: #e8590c; }
.due-input { display: flex; align-items: center; gap: .35rem; }
.due-input input { flex: 1; min-width: 0; }
.task-editor textarea { width: 100%; resize: vertical; }

@container (max-width: 680px) {
    .note-title-input, .note-body-input, .note-tags { margin-left: 1rem; margin-right: 1rem; }
}

/* shared filter chips (address books) */
.filter-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.filter-chip { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; height: 28px; padding: 0 .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .8rem; color: var(--muted); }
.filter-chip:hover { border-color: var(--faint); color: var(--text); }
.filter-chip.on { background: var(--selected); border-color: transparent; color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------------ recipient suggestions */

.recipient-input { position: relative; flex: 1; min-width: 0; display: flex; }
.recipient-input input { flex: 1; min-width: 0; border: none; background: transparent; padding: .55rem 0; box-shadow: none; }
.recipient-input input:focus { box-shadow: none; }
.suggest-menu {
    /* As wide as the field (never past the pane's edge), but readable in a narrow field. */
    position: absolute; top: calc(100% + 2px); left: calc(-56px - .5rem); right: 0; z-index: 60;
    max-height: 320px; overflow-y: auto; padding: .3rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.suggest-item { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; border-radius: var(--radius-sm); cursor: pointer; }
.suggest-item.active { background: var(--selected); }
.suggest-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.suggest-name { font-size: .88rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-email { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item b { color: var(--accent); font-weight: 700; }
.suggest-label { margin-left: .4rem; padding: 0 .35rem; border-radius: 4px; background: var(--surface-3); font-size: .68rem; }

/* user chip: avatar + name open Settings */
.user-link { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; padding: .25rem; margin: -.25rem; border-radius: var(--radius-sm); text-align: left; }
.user-link:hover { background: var(--surface-3); }
.user-link .who { display: block; }
:root[data-sidebar="collapsed"] .sidebar .user-link { flex: none; justify-content: center; margin: 0; }

/* ------------------------------------------------------------------ documents */

.page-pane.fill > .docs-shell { flex: 1; min-height: 0; }
.docs-shell { position: relative; display: flex; flex-direction: column; height: 100%; background: var(--surface); }
.docs-head { display: flex; align-items: center; gap: .5rem; padding: .85rem 1.25rem .6rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.docs-pad { padding: 1rem 1.25rem 0; }
.crumbs { display: flex; align-items: center; gap: .15rem; min-width: 0; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .45rem; border-radius: var(--radius-sm); font-size: 1rem; font-weight: 600; color: var(--muted); max-width: 240px; }
.crumb span, .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:last-child { color: var(--text); }
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb-sep { color: var(--faint); }
.quota { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.25rem; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.quota .quota-bar { flex: 0 0 160px; }
.quota-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.quota-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.upload-status { display: flex; align-items: center; gap: .75rem; padding: .55rem 1.25rem; background: var(--accent-soft); font-size: .85rem; }
.upload-status .upload-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status .quota-bar { flex: 1; min-width: 80px; }
.docs-table-wrap { flex: 1; overflow-y: auto; }
.docs-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.docs-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: left; font-weight: 600; font-size: .76rem; color: var(--muted); border-bottom: 1px solid var(--border); padding: 0; }
.docs-table thead button { width: 100%; text-align: inherit; padding: .55rem .75rem; color: inherit; font-weight: inherit; }
.docs-table thead button:hover { color: var(--text); }
.sort-mark { color: var(--accent); margin-left: .15rem; }
.docs-table td { padding: 0 .75rem; height: 44px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.docs-table tbody tr:hover { background: var(--surface-2); }
.docs-table tbody tr.context td { box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.docs-table tbody tr.context td:first-child { box-shadow: inset 1px 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.docs-table tbody tr.context td:last-child { box-shadow: inset -1px 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.docs-table th:first-child button, .docs-table td:first-child { padding-left: 1.25rem; }
.docs-table .col-name { width: 100%; max-width: 0; }
.docs-table .col-mod, .docs-table .col-size { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.docs-table .col-size { text-align: right; }
.docs-table th.col-size button { text-align: right; }
.docs-table .col-act { width: 1%; padding-right: 1rem; }
.doc-name { display: flex; align-items: center; gap: .6rem; min-width: 0; width: 100%; color: var(--text); text-align: left; text-decoration: none !important; }
.doc-name span { overflow: hidden; text-overflow: ellipsis; }
.doc-name .icon { color: var(--muted); }
.doc-name .ic-folder { color: var(--accent); }
.doc-name:hover span { color: var(--accent); text-decoration: underline; }
.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.docs-table tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.docs-table tr.editing td { background: var(--accent-soft); }
.rename-row { display: flex; align-items: center; gap: .5rem; }
.rename-row input { flex: 1; max-width: 420px; height: 32px; }
.drop-overlay { position: absolute; inset: 0; z-index: 30; background: color-mix(in srgb, var(--accent) 10%, var(--surface) 85%); border: 2px dashed var(--accent); border-radius: var(--radius); display: none; place-items: center; pointer-events: none; }
.docs-shell[data-drop] .drop-overlay { display: grid; }
.upload-status .upload-pct { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.docs-table tr.just-added td { animation: just-added 2.5s ease-out; }
@keyframes just-added { from, 40% { background: var(--accent-soft); } }
.drop-hint { display: flex; flex-direction: column; align-items: center; gap: .5rem; color: var(--accent); font-weight: 600; pointer-events: none; }
.docs-shell { container-type: inline-size; }
@container (max-width: 560px) {
    .docs-table .col-mod { display: none; }
    .row-actions { opacity: 1; }
    .quota .quota-bar { flex-basis: 90px; }
}

/* toggle switch for boolean settings */
input[type="checkbox"].switch {
    appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong);
    position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; border: none;
}
input[type="checkbox"].switch::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::after { transform: translateX(16px); }
input[type="checkbox"].switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ OpenPGP */

.pgp-key { display: flex; align-items: center; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; background: var(--surface); }
.pgp-key.default { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.pgp-key-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.pgp-key-title { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.pgp-key-title strong { overflow: hidden; text-overflow: ellipsis; }
.fpr { font-family: var(--mono); font-size: .78rem; color: var(--text-2); letter-spacing: .02em; word-break: break-all; }
.pgp-key-meta { font-size: .78rem; }
.pgp-key-actions { display: flex; align-items: center; gap: .25rem; flex-shrink: 0; }
.pgp-form { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: .5rem 0; background: var(--surface-2); }
.pgp-form h4 { font-size: .95rem; margin-bottom: .75rem; }
.pgp-form .field input, .pgp-form .field select { width: 100%; }
.mono-input { width: 100%; font-family: var(--mono); font-size: .78rem; resize: vertical; }
.protection-chooser { border: none; padding: 0; margin: .25rem 0 .5rem; }
.protection-chooser legend { font-weight: 600; font-size: .82rem; color: var(--text-2); margin-bottom: .35rem; }
.protection-chooser .segmented { flex-wrap: wrap; }
.protection-chooser .help { font-size: .78rem; color: var(--muted); }
.key-chip { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.key-chip .key-uid { font-weight: 600; font-size: .9rem; }
.key-chip code { font-family: var(--mono); font-size: .75rem; color: var(--muted); word-break: break-all; }
.unlock-dialog { max-width: 440px; }
.unlock-dialog .modal-head .icon-tile { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.unlock-dialog .field input { width: 100%; }

.pgp-banner { display: flex; align-items: flex-start; gap: .65rem; padding: .65rem .85rem; margin-bottom: 1rem; border-radius: var(--radius-sm); font-size: .86rem; border: 1px solid var(--border); background: var(--surface-2); }
.pgp-banner .icon { margin-top: 2px; flex-shrink: 0; }
.pgp-banner.good { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
.pgp-banner.bad { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.pgp-banner.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.pgp-banner .spacer { flex: 1; }
.pgp-banner .lines { display: flex; flex-direction: column; gap: .1rem; }
.pgp-banner small { opacity: .85; }

.compose-pgp { display: flex; align-items: center; gap: .35rem; }
.toggle-btn { display: inline-flex; align-items: center; gap: .35rem; height: 30px; padding: 0 .6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: .82rem; color: var(--muted); background: var(--surface); }
.toggle-btn:hover:not(:disabled) { color: var(--text); border-color: var(--faint); }
.toggle-btn.on { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 600; }
.pgp-status { font-size: .78rem; color: var(--muted); padding: .35rem 1.25rem 0; display: flex; align-items: center; gap: .35rem; }
.pgp-status.warn { color: var(--warn-text); }

/* Offer to save an attached OpenPGP key to a contact */
.key-offer { align-items: center; }
.key-offer .lines { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.key-offer .key-chip { margin: 0; }
.key-offer .key-warning { display: flex; align-items: flex-start; gap: .3rem; color: var(--warn-text); }
.key-offer-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* Importing .ics files opened with the installed app */
.small-print { font-size: .8rem; margin: 0 0 .75rem; }
.cal-share .modal-head h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--cal); flex-shrink: 0; }
.share-add { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.share-add input { flex: 1; min-width: 0; height: 38px; }
.share-add select, .share-add .btn { height: 38px; }
.share-heading { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 1rem 0 .4rem; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.share-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem .25rem; border-radius: var(--radius-sm); }
.share-list li:hover { background: var(--surface-2); }
.share-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; }
.share-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.share-status { font-size: .7rem; font-weight: 650; padding: 0 .4rem; border-radius: 4px; background: var(--surface-3); color: var(--muted); flex-shrink: 0; }
.share-status.declined, .share-status.invalid { background: var(--danger-soft); color: var(--danger); }
.share-list select { height: 32px; font-size: .84rem; }
@media (max-width: 480px) { .share-add { flex-wrap: wrap; } .share-add input { flex-basis: 100%; } }

.ics-import .ics-files { color: var(--muted); font-size: .86rem; margin-bottom: .75rem; overflow-wrap: anywhere; }
.ics-import .ics-events { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.ics-import .ics-events li { display: flex; flex-direction: column; gap: .1rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ics-import .ics-events .muted { font-size: .84rem; }

/* Documents: choosing where to move a file or folder. */
.doc-move { width: min(440px, 100%); }
.move-tree { max-height: min(50vh, 380px); overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: .25rem; }
.move-node { display: flex; align-items: center; gap: .15rem; padding-left: calc(var(--depth) * 1.1rem); border-radius: 6px; }
.move-node.selected { background: var(--accent-soft); }
.move-toggle { width: 24px; height: 28px; flex-shrink: 0; display: grid; place-items: center; color: var(--muted); background: none; border: 0; border-radius: 5px; cursor: pointer; }
span.move-toggle { cursor: default; }
.move-toggle:hover { color: var(--text); }
.move-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: .45rem; height: 30px; padding: 0 .4rem; background: none; border: 0; border-radius: 5px; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.move-name span:not(.move-here) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-node:not(.selected):not(.disabled) .move-name:hover { background: var(--surface-2); }
.move-node.disabled .move-name { color: var(--faint); cursor: default; }
.move-here { margin-left: auto; font-size: .78rem; }
