/* ---------- Tokens ---------- */
:root {
    --bg: #f6f6f8;
    --surface: #ffffff;
    --sidebar: #f0f0f3;
    --text: #18181b;
    --muted: #6b6b76;
    --faint: #a1a1aa;
    --border: #e4e4e7;
    --hover: rgba(24, 24, 27, .05);
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: rgba(99, 102, 241, .12);
    --danger: #e5484d;
    --success: #16a34a;
    --p3: #e5484d; /* high */
    --p2: #f59e0b; /* medium */
    --p1: #3b82f6; /* low */
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .03);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .05), 0 8px 20px rgba(0, 0, 0, .06);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .18);
    --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111113;
        --surface: #1a1a1d;
        --sidebar: #161618;
        --text: #ededef;
        --muted: #a1a1aa;
        --faint: #6b6b74;
        --border: #2a2a2f;
        --hover: rgba(255, 255, 255, .05);
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: rgba(129, 140, 248, .16);
        --danger: #ff6369;
        --success: #4ade80;
        --p3: #ff6369;
        --p2: #fbbf24;
        --p1: #60a5fa;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-hover: 0 4px 14px rgba(0, 0, 0, .4);
        --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg { flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 40px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px;
    border: 1px solid transparent; border-radius: 8px;
    background: var(--hover); color: var(--text);
    font-weight: 550; cursor: pointer; white-space: nowrap;
    transition: background .15s, color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger-ghost { background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn.block { width: 100%; height: 40px; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px; padding: 0;
    border: 0; border-radius: 7px;
    background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; }
.link:hover { color: var(--text); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; }
.brand-mark {
    width: 24px; height: 24px; border-radius: 7px; background: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 16.5l4.5 4.5L23 11.5' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: cover;
}
.brand-lg { font-size: 18px; padding: 0 0 8px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    padding: 18px 12px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.search { position: relative; display: flex; align-items: center; margin: 0 0 12px; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 32px !important; padding-right: 30px !important; height: 36px; background: var(--surface); }
.search kbd {
    position: absolute; right: 8px; padding: 0 6px; border: 1px solid var(--border); border-radius: 5px;
    font: 11px/18px var(--font); color: var(--faint); pointer-events: none;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.nav, .labels { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 0; list-style: none; }
.nav a, .labels a {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 10px;
    border-radius: 8px; color: var(--text);
}
.nav a svg { color: var(--muted); }
.nav a:hover, .labels a:hover { background: var(--hover); }
.nav a.active, .labels a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav a.active svg { color: var(--accent); }
.nav .name, .labels .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.hash { width: 18px; text-align: center; font-weight: 700; color: var(--c, var(--faint)); }

.section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 22px 0 4px; padding: 0 4px 0 10px;
    font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.labels li { position: relative; }
.labels .edit { position: absolute; right: 4px; top: 3px; opacity: 0; }
.labels li:hover .edit, .labels .edit:focus-visible { opacity: 1; }
.labels li:hover .count { visibility: hidden; }
.labels .empty-note { padding: 6px 10px; color: var(--faint); font-size: 13px; }

.sidebar-foot {
    margin-top: auto; padding: 14px 10px 0;
    display: flex; align-items: center; gap: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.sidebar-foot .user { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.main { width: 100%; max-width: 820px; margin: 0 auto; padding: 36px 32px 100px; }
.main-head { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; min-height: 34px; }
.main-head h1 { font-size: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-head .switch { margin-left: auto; }
.menu-btn { display: none; }
.backdrop { display: none; }

/* ---------- Switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 30px; height: 18px; border-radius: 9px; background: var(--border); transition: background .15s; }
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Quick add ---------- */
.quick-add {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 26px;
    transition: border-color .15s, box-shadow .15s;
}
.quick-add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qa-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px 14px; }
.qa-plus { display: grid; color: var(--accent); }
.quick-add .qa-row input { border: 0; box-shadow: none; padding: 8px 2px; background: transparent; font-size: 16px; }
.quick-add .qa-row input::placeholder { color: var(--faint); }
.qa-submit { height: 32px; }
.quick-add textarea { display: block; width: calc(100% - 28px); margin: 2px 14px 6px; }
.qa-tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 10px 40px; }
.tool {
    display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
    height: 30px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: 8px;
    background: transparent; color: var(--muted);
    font-size: 13px; cursor: pointer; white-space: nowrap;
    transition: all .12s;
}
.tool span { overflow: hidden; text-overflow: ellipsis; }
.tool svg { width: 15px; height: 15px; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool.active { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); color: var(--accent); }
.tool.active.today { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.tool.active.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.tool.active.p1, .tool.active.p2, .tool.active.p3 { color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, transparent); border-color: color-mix(in srgb, var(--pc) 35%, transparent); }

/* Priority color variable */
.p1 { --pc: var(--p1); }
.p2 { --pc: var(--p2); }
.p3 { --pc: var(--p3); }
.prio { color: var(--pc, var(--faint)); display: inline-grid; }

/* ---------- Tasks ---------- */
.group + .group { margin-top: 24px; }
.group-title { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 650; padding: 0 4px 10px; }
.group-title.danger { color: var(--danger); }
.group-count { font-weight: 500; color: var(--faint); font-size: 12px; }
.tasks {
    list-style: none; margin: 0; padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.task {
    position: relative;
    display: flex; align-items: flex-start; gap: 14px;
    padding: 12px 18px 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: opacity .25s, transform .25s, background .12s;
}
.task:last-child { border-bottom: 0; }
.task:hover { background: color-mix(in srgb, var(--surface) 97%, var(--text)); }
.task.leaving { opacity: 0; transform: translateX(10px); }
/* Label color stripe on the left edge; split into segments when a task has several labels. */
.task::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stripe, transparent); }
.task.done::before { opacity: .45; }
.check {
    flex: none; display: grid; place-items: center;
    width: 22px; height: 22px; margin-top: 1px; padding: 0;
    border: 2px solid var(--pc, var(--faint)); border-radius: 50%;
    background: color-mix(in srgb, var(--pc, transparent) 10%, transparent);
    color: transparent; cursor: pointer;
    transition: all .15s;
}
.check:hover { color: var(--pc, var(--accent)); border-color: var(--pc, var(--accent)); }
.task.done .check, .task.leaving .check, .subtask.done .check, .subtask-editor .done .check {
    background: var(--pc, var(--accent)); border-color: var(--pc, var(--accent)); color: #fff;
}
.check svg { width: 13px; height: 13px; stroke-width: 3; }
.check.sm { width: 18px; height: 18px; border-width: 1.5px; margin-top: 0; }
.check.sm svg { width: 11px; height: 11px; }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-size: 15.5px; line-height: 1.45; font-weight: 500; overflow-wrap: anywhere; }
.task.done .task-title { color: var(--faint); text-decoration: line-through; font-weight: 400; }
.task-desc { margin-top: 2px; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.chip svg { width: 14px; height: 14px; }
.chip.overdue { color: var(--danger); }
.chip.today { color: var(--success); }
.chip.prio { color: var(--pc); font-weight: 550; }
.chip-btn { border: 0; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; cursor: pointer; }
.chip-btn:hover, .chip-btn.open { background: var(--hover); color: var(--text); }
.tag {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 1px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 550;
    color: var(--c);
    background: color-mix(in srgb, var(--c) 13%, transparent);
}
.tag button { display: grid; place-items: center; width: 16px; height: 16px; margin-right: -4px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.tag button:hover { background: color-mix(in srgb, var(--c) 25%, transparent); }
.tag button svg { width: 11px; height: 11px; }

.subtasks { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; }
.subtask { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.subtask.done span { color: var(--faint); text-decoration: line-through; }

/* Drag & drop */
.drag-ghost { opacity: .4; }
.drag-chosen { box-shadow: var(--shadow-lg); background: var(--surface); }
.task:not(.timed):not(.done) { cursor: grab; }
.task .task-body { cursor: pointer; }

.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty-mark {
    display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 8px;
    border-radius: 50%; background: var(--accent-soft); color: var(--accent);
}
.empty-mark svg { width: 26px; height: 26px; }

/* ---------- Popover ---------- */
.popover {
    inset: auto; margin: 0; position: fixed;
    width: 260px; max-height: 360px; overflow-y: auto; padding: 6px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-lg);
}
.pop-list { display: flex; flex-direction: column; }
.pick {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 8px;
    background: none; text-align: left; cursor: pointer;
}
.pick span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { color: var(--faint); font-size: 12px; }
.pick > svg:last-child { width: 15px; height: 15px; color: var(--accent); }
.pick:hover { background: var(--hover); }
.pick.on { font-weight: 550; }
.pick:disabled { opacity: .7; cursor: default; }
.pick.create { color: var(--accent); }
.pick.create svg { width: 15px; height: 15px; }
.pick .prio svg { width: 15px; height: 15px; }
.pop-search { margin-bottom: 4px; }
.pop-row { display: flex; gap: 6px; padding: 6px 4px 2px; border-top: 1px solid var(--border); margin-top: 4px; }
.pop-row input { padding: 6px 8px !important; font-size: 13px; }
.pop-empty { padding: 10px; color: var(--faint); font-size: 13px; text-align: center; }

/* ---------- Modals ---------- */
.modal {
    width: min(600px, calc(100vw - 24px)); padding: 0;
    border: 1px solid var(--border); border-radius: 16px;
    background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(10, 10, 15, .4); backdrop-filter: blur(2px); }
.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal-body { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
.modal-body h2 { font-size: 17px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--border); }
.modal .title-input { font-size: 19px; font-weight: 600; border-color: transparent; padding: 6px 8px; margin: -6px -8px -8px; width: calc(100% + 16px) !important; }
.modal textarea { border-color: transparent; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px) !important; }
.modal .title-input:hover, .modal textarea:hover { border-color: var(--border); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field > span em { font-style: normal; font-weight: 500; color: var(--faint); margin-left: 4px; }

.segmented { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--hover); }
.segmented button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    height: 30px; border: 0; border-radius: 7px; background: none; color: var(--muted);
    font-size: 13px; cursor: pointer;
}
.segmented button svg { width: 14px; height: 14px; color: var(--pc); }
.segmented button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.label-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.label-chips .tag { padding: 3px 10px; font-size: 13px; }
.add-chip {
    display: inline-flex; align-items: center; gap: 4px;
    height: 26px; padding: 0 10px; border: 1px dashed var(--border); border-radius: 999px;
    background: none; color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.add-chip:hover { color: var(--accent); border-color: var(--accent); }
.add-chip svg { width: 13px; height: 13px; }

.subtask-editor { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.subtask-editor li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.subtask-editor .grip { display: grid; color: var(--faint); cursor: grab; opacity: 0; }
.subtask-editor li:hover .grip { opacity: 1; }
.subtask-editor .grip svg { width: 14px; height: 14px; }
.subtask-editor input { border-color: transparent !important; padding: 5px 6px !important; background: transparent !important; }
.subtask-editor input:focus { border-color: var(--accent) !important; }
.subtask-editor .done input { color: var(--faint); text-decoration: line-through; }
.subtask-editor .icon-btn { opacity: 0; }
.subtask-editor li:hover .icon-btn, .subtask-editor .icon-btn:focus-visible { opacity: 1; }
.subtask-add { display: flex; align-items: center; gap: 8px; padding-left: 22px; color: var(--faint); }
.subtask-add svg { width: 16px; height: 16px; }
.subtask-add input { border-style: dashed !important; padding: 6px 8px !important; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { position: relative; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--c); transition: transform .12s; }
.swatches label:hover span { transform: scale(1.1); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 14px; border-radius: 10px;
    background: #18181b; color: #fafafa; box-shadow: var(--shadow-lg);
    font-size: 13px; white-space: nowrap; animation: pop .16s ease-out;
}
.toast.error { background: var(--danger); }
.toast button { border: 0; background: none; color: #a5b4fc; font-weight: 600; cursor: pointer; padding: 0; }
.toast.out { opacity: 0; transition: opacity .2s; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: min(380px, 100%);
    display: flex; flex-direction: column; gap: 14px;
    padding: 28px; border: 1px solid var(--border); border-radius: 16px;
    background: var(--surface); box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 20px; }
.auth-card p { margin: -6px 0 0; }
.alert { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 13px; }

/* ---------- Mobile ---------- */
@media (max-width: 800px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; z-index: 50; left: 0; top: 0; width: 290px;
        padding-top: max(18px, env(safe-area-inset-top));
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .backdrop.open { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .3); }
    .menu-btn { display: inline-grid; margin-left: -6px; }
    .main { padding: max(16px, env(safe-area-inset-top)) 14px 100px; }
    .main-head h1 { font-size: 22px; }
    .labels .edit { opacity: 1; }
    .labels li .count { visibility: hidden; }
    .search kbd { display: none; }
    .qa-tools { padding-left: 10px; }
    .tool { padding: 0 9px; }
    .tool:not(.active) span { display: none; }
    .task { padding: 12px 14px 12px 16px; gap: 12px; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-3 .field:last-child { grid-column: 1 / -1; }
    .segmented button { font-size: 12px; gap: 3px; }
    .switch > span:last-child { display: none; }
    .hide-sm { display: none; }
    .modal-body { padding: 18px; }
    .modal-foot { padding: 12px 18px; }
}

/* Subtasks never inherit the parent's priority color. */
.subtasks, .subtask-editor { --pc: initial; }
.pick .hash { flex: none; }

/* #label autocomplete */
.qa-row { position: relative; }
.suggest {
    position: absolute; top: calc(100% - 2px); z-index: 30;
    width: 240px; padding: 6px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); box-shadow: var(--shadow-lg);
}
.suggest .pick b { color: var(--accent); font-weight: 650; }
.suggest .pick.active { background: var(--accent-soft); }
.suggest kbd { padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; font: 11px/16px var(--font); color: var(--faint); }

/* =====================================================================
   Suite shell: app rail (bottom tab bar on phones), user menu, timer chip
   ===================================================================== */
:root { --rail: #e9e9ee; --rail-w: 68px; }
@media (prefers-color-scheme: dark) { :root { --rail: #0c0c0e; } }

.suite { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }
.suite > .app { min-width: 0; }

.rail {
    position: sticky; top: 0; height: 100vh; z-index: 45;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 0;
    background: var(--rail);
    border-right: 1px solid var(--border);
}
.rail-logo { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 10px; }
.rail-logo .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
.rail-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    width: 56px; height: 56px; padding: 0;
    border: 0; border-radius: 12px; background: none; cursor: pointer;
    color: var(--muted); font-size: 11px; font-weight: 550;
}
.rail-item:hover { background: var(--hover); color: var(--text); }
.rail-item.active { background: var(--accent-soft); color: var(--accent); }
.rail-spacer { flex: 1; }
.rail-avatar {
    width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer;
    background: var(--accent); color: #fff; font-weight: 650; font-size: 13px;
}

.menu {
    inset: auto; left: calc(var(--rail-w) + 8px); bottom: 14px; margin: 0; position: fixed;
    min-width: 220px; padding: 6px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head span { color: var(--muted); font-size: 12.5px; }
.menu-foot { margin-top: 4px; padding: 8px 10px 4px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.menu-foot a { color: inherit; }
.menu-item { width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.notify-kinds { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; }
.notify-kinds .check-field { align-items: flex-start; }
#notify-allow { margin-top: 4px; }

.module-title { padding: 6px 10px 14px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }

.timer-chip {
    position: fixed; right: 20px; bottom: 20px; z-index: 60;
    display: flex; align-items: center; gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); box-shadow: var(--shadow-lg);
}
.tc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.tc-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; color: var(--text); }
.tc-clock { font-variant-numeric: tabular-nums; font-size: 15px; }
.tc-task { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.tc-stop {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer;
    background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger);
}
.tc-stop:hover { background: var(--danger); color: #fff; }
.timer-chip.long { border-color: var(--p2); background: color-mix(in srgb, var(--p2) 14%, var(--surface)); }
.timer-chip.long .tc-clock::after { content: " · still running?"; font-weight: 500; font-size: 12px; color: var(--p2); }
body.has-timer .toasts { bottom: 76px; }

@media (max-width: 800px) {
    .suite { grid-template-columns: 1fr; }
    .rail {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto;
        flex-direction: row; justify-content: space-around; gap: 0;
        padding: 6px 8px max(6px, env(safe-area-inset-bottom));
        border-right: 0; border-top: 1px solid var(--border);
    }
    .rail-logo, .rail-spacer { display: none; }
    .rail-item { flex: 1; max-width: 96px; height: 50px; }
    .menu { left: auto; right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); }
    .main { padding-bottom: 150px; }
    .timer-chip { right: 12px; left: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }
    .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
    body.has-timer .toasts { bottom: calc(130px + env(safe-area-inset-bottom)); }
}

/* =====================================================================
   Time module
   ===================================================================== */
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.today-stats { display: flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.today-stats strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.today-stats .sep { color: var(--faint); }

.btn.icon-only { width: 34px; padding: 0; }
.tqa .qa-row { padding-bottom: 8px; }
.tqa .tool { flex: none; max-width: 200px; }

.proj-icon { display: grid; width: 18px; place-items: center; color: var(--muted); }
.proj-icon svg { width: 15px; height: 15px; }
.archived { margin-top: 14px; }
.archived summary { padding: 6px 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }

.tgroup {
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.tgroup-head {
    display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; cursor: pointer; user-select: none;
    /* Tinted so project headers stand apart from the task rows. */
    background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.tgroup-head:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.tgroup-head .chev, .tgroup-head .tg-name small { color: color-mix(in srgb, var(--accent) 45%, var(--muted)); }
.tgroup-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chev { display: grid; color: var(--muted); transition: transform .2s; transform: rotate(-90deg); }
.tgroup.open .chev { transform: none; }
.tg-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tg-name strong { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-name small { color: var(--muted); font-size: 12.5px; }
.tg-time, .tg-amount { font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; }
.tg-time { font-weight: 600; }
.tg-amount { color: var(--accent); font-weight: 600; min-width: 84px; text-align: right; }
.tgroup .tasks { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }

.trow, .rrow { align-items: center; }
.tcell { font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; text-align: right; }
.ttime { min-width: 88px; display: flex; flex-direction: column; align-items: flex-end; }
.ttime small { color: var(--muted); font-size: 11.5px; }
.ttime .live { color: var(--accent); font-size: 15px; }
.tamount { min-width: 84px; color: var(--muted); }
.rhours { min-width: 64px; font-weight: 600; font-size: 14.5px; }
.tbtn {
    display: grid; place-items: center; flex: none;
    width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer;
    background: var(--accent-soft); color: var(--accent);
}
.tbtn svg { width: 15px; height: 15px; }
.tbtn:hover { background: var(--accent); color: #fff; }
.tbtn.stop { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.tbtn.stop:hover { background: var(--danger); color: #fff; }
.trow.running { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.trow.running::before { background: var(--accent); }
.tempty { padding: 14px 20px; color: var(--muted); font-size: 13.5px; list-style: none; }
.rrow .check, .trow .check { margin-top: 0; }

.report-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.report-summary > div {
    display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.report-summary small { color: var(--muted); font-size: 12px; }
.report-summary strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }
.modal .hint { margin: -6px 0 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.setting-check { margin-top: 14px; font-weight: 550; }
.switch-field { height: 38px; }

.entry-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; max-height: 280px; overflow-y: auto; }
.entry-list li {
    display: grid; grid-template-columns: 1.3fr 1fr .9fr 1fr; gap: 2px 10px; align-items: baseline;
    padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer;
    font-variant-numeric: tabular-nums;
}
.entry-list li:last-child { border-bottom: 0; }
.entry-list li:hover { background: var(--hover); }
.entry-list li.running { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.entry-list .e-dur { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.entry-list .e-amount { text-align: right; color: var(--muted); }
.entry-list .e-note { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.entry-list .warn { display: inline-grid; color: var(--p2); }
.entry-list .warn svg { width: 14px; height: 14px; }
.entry-list .e-empty { display: block; color: var(--muted); cursor: default; }
.entry-list .e-empty:hover { background: none; }

@media (max-width: 800px) {
    .today-stats > span:first-child { display: none; }
    .tg-amount, .tamount { display: none; }
    .report-summary { grid-template-columns: 1fr 1fr; }
    .trow .icon-btn[data-action="add-entry"] { display: none; }
    .tqa .tool span { display: none; }
}

/* Shared icons (core.js) have no intrinsic size. */
.icon-btn > svg { width: 18px; height: 18px; }
.icon-btn.sm > svg { width: 14px; height: 14px; }
.chev svg, .proj-icon svg { width: 16px; height: 16px; }
.empty .btn { margin-top: 6px; }

/* =====================================================================
   Calendar module (FullCalendar themed with the suite's tokens)
   ===================================================================== */
.module-calendar .main.main-wide { max-width: none; height: 100vh; display: flex; flex-direction: column; padding: 18px 24px 20px; }
.cal-head { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cal-head h1 { font-size: 21px; margin-left: 6px; min-width: 0; }
.cal-head .cal-views { margin-left: auto; width: auto; }
.cal-views button { flex: none; padding: 0 12px; }
.calendar { flex: 1; min-height: 0; }

.new-event { width: 100%; margin-bottom: 14px; height: 38px; }
.new-event svg { width: 16px; height: 16px; }

.mini-month { margin-bottom: 6px; padding: 0 4px; }
.mm-head { display: flex; align-items: center; gap: 2px; padding: 0 2px 6px 6px; }
.mm-head strong { flex: 1; font-size: 13px; }
.mm-head [data-mm="-1"] svg { transform: rotate(90deg); }
.mm-head [data-mm="1"] svg { transform: rotate(-90deg); }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.mm-grid span { font-size: 11px; color: var(--faint); padding: 2px 0 4px; }
.mm-grid button {
    height: 28px; border: 0; border-radius: 7px; background: none; cursor: pointer;
    font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text);
}
.mm-grid button:hover { background: var(--hover); }
.mm-grid button.out { color: var(--faint); }
.mm-grid button.in-view { background: var(--accent-soft); border-radius: 0; }
.mm-grid button.today { background: var(--accent); color: #fff; font-weight: 650; border-radius: 50%; }

.cal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.cal-list li { position: relative; }
.cal-toggle { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 8px; cursor: pointer; }
.cal-toggle:hover { background: var(--hover); }
.cal-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cal-box {
    flex: none; width: 16px; height: 16px; border-radius: 5px;
    border: 2px solid var(--c); background: var(--c);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    background-size: 12px; background-position: center; background-repeat: no-repeat;
}
.cal-toggle input:not(:checked) + .cal-box { background: transparent; }
.cal-toggle input:focus-visible + .cal-box { outline: 2px solid var(--accent); outline-offset: 2px; }
.cal-toggle .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-toggle small { color: var(--faint); font-size: 11px; }
.cal-list .edit { position: absolute; right: 4px; top: 2px; opacity: 0; }
.cal-list li:hover .edit, .cal-list .edit:focus-visible { opacity: 1; }

.event-times { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr 1fr; gap: 10px; }
.item-kind { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
#item-dialog .modal-body { gap: 6px; }
#item-dialog p { margin: 0; }

/* FullCalendar theme */
.calendar {
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--surface);
    --fc-neutral-bg-color: var(--bg);
    --fc-neutral-text-color: var(--muted);
    --fc-today-bg-color: color-mix(in srgb, var(--accent) 6%, transparent);
    --fc-now-indicator-color: var(--danger);
    --fc-event-bg-color: var(--accent);
    --fc-event-border-color: var(--accent);
    --fc-highlight-color: var(--accent-soft);
    --fc-list-event-hover-bg-color: var(--hover);
    --fc-small-font-size: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    font-size: 13px;
}
.calendar .fc-theme-standard .fc-scrollgrid { border: 0; }
.calendar .fc-col-header-cell-cushion, .calendar .fc-daygrid-day-number { color: var(--text); font-weight: 550; padding: 6px 8px; }
.calendar .fc-day-today .fc-daygrid-day-number {
    background: var(--accent); color: #fff; border-radius: 999px; min-width: 24px; text-align: center; margin: 3px;
    padding: 2px 6px;
}
.calendar .fc-timegrid-slot-label-cushion, .calendar .fc-timegrid-axis-cushion { color: var(--muted); font-size: 11.5px; }
.calendar .fc-timegrid-slot { height: 2.6em; }
.calendar .fc-event { border-radius: 6px; font-size: 12px; }
.calendar .fc-timegrid-event .fc-event-main { padding: 3px 5px; }
.calendar .fc-daygrid-event { padding: 1px 3px; }
.calendar .fc-list-day-cushion { background: var(--bg); }
.calendar .fc-list-event-title, .calendar .fc-list-event-time { color: var(--text); }
.calendar a { color: inherit; }
.calendar .fc-popover { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); }

/* Tasks layer: a check circle + title, colored by the task's first label. */
.fc-item { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; color: var(--text); }
.fc-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar .fc-task { background: color-mix(in srgb, var(--c, var(--success)) 10%, var(--surface)) !important; }
.fc-item-task { padding: 1px 3px; border-left: 3px solid var(--c); border-radius: 4px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.fc-check { flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--c); }
.fc-task.p3 .fc-check { border-color: var(--p3); }
.fc-task.p2 .fc-check { border-color: var(--p2); }
.calendar .fc-list-event.fc-task .fc-list-event-dot { display: none; }

/* Time layer: muted, dashed blocks — what you actually worked on. */
.calendar .fc-timeentry {
    background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--muted) 14%, var(--surface)) 0 6px, color-mix(in srgb, var(--muted) 8%, var(--surface)) 6px 12px) !important;
    border: 1px dashed color-mix(in srgb, var(--muted) 50%, transparent) !important;
}
.calendar .fc-timeentry.running { border-color: var(--accent) !important; }
.fc-item-time { flex-direction: column; align-items: flex-start; gap: 0; padding: 1px 2px; }
.fc-item-time svg { display: none; }
.fc-item-time small { color: var(--muted); font-size: 11px; }
.fc-daygrid-event .fc-item-time { flex-direction: row; gap: 4px; }
.fc-daygrid-event .fc-item-time svg { display: inline; width: 11px; height: 11px; color: var(--muted); }

@media (max-width: 800px) {
    .module-calendar .main.main-wide { height: calc(100vh - 64px - env(safe-area-inset-bottom)); padding: 12px 10px 8px; }
    .cal-head h1 { font-size: 17px; order: 5; width: 100%; margin: 4px 0 0; }
    .cal-head .cal-views { margin-left: auto; }
    .cal-views button { padding: 0 8px; font-size: 12px; }
    .event-times { grid-template-columns: 1.4fr 1fr; }
    .calendar .fc-timegrid-slot { height: 2.2em; }
}
.calendar .fc-list-event.fc-task { background: none !important; }

/* Connected calendar accounts */
.account { margin-top: 10px; }
.account-head { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; }
.account-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account-name strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name small { color: var(--faint); font-size: 11.5px; }
.account-name small .warn { display: inline-flex; align-items: center; gap: 3px; color: var(--p2); }
.account-name small .warn svg { width: 12px; height: 12px; }
.account-name small a { color: var(--danger); font-weight: 600; }
.connect-google { width: 100%; margin-top: 10px; justify-content: flex-start; border: 1px dashed var(--border); color: var(--text); }
.connect-google:hover { border-color: var(--accent); }
.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Collapsible sidebar section (Calendar → Calendars) */
.section-head.collapsible { cursor: pointer; user-select: none; border-radius: 8px; }
.section-head.collapsible:hover { background: var(--hover); }
.section-head.collapsible:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sh-label { display: inline-flex; align-items: center; gap: 4px; }
.sh-chev { display: grid; margin-left: -6px; transition: transform .15s; }
.sh-chev svg { width: 14px; height: 14px; }
.section-head.collapsed .sh-chev { transform: rotate(-90deg); }
.cal-dots { display: none; flex: 1; gap: 4px; margin: 0 8px; overflow: hidden; }
.section-head.collapsed .cal-dots { display: flex; }
.cal-dots i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.connect-google.quiet { height: 30px; border-style: dashed; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.connect-google.quiet svg { width: 14px; height: 14px; }

/* Invitations: guests, answers, Meet */
.guest-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.guest { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.guest .avatar {
    position: relative; flex: none; display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 13px;
}
.guest .status {
    position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center;
    width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--surface);
    font-style: normal; font-size: 9px; font-weight: 800; color: #fff; background: var(--faint);
}
.guest.accepted .status { background: var(--success); }
.guest.declined .status { background: var(--danger); }
.guest.tentative .status { background: var(--p2); }
.guest.needsAction .status { background: var(--border); }
.guest .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.guest .who > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest .who small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest.declined .who > span { text-decoration: line-through; color: var(--muted); }
.guest-input-wrap { position: relative; }
.guest-input-wrap .suggest { top: calc(100% + 4px); left: 0; width: 100%; }
.guest-input-wrap .pick { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.guest-input-wrap .pick small { color: var(--muted); font-size: 12px; }

.meet-row { display: flex; align-items: center; gap: 10px; }
.meet-join { background: #1a73e8; color: #fff; }
.meet-join:hover { background: #1765cc; }

.rsvp {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; background: var(--accent-soft);
}
.rsvp-label { font-weight: 600; }
.rsvp .segmented { background: var(--surface); }
.rsvp .segmented button { padding: 0 14px; }
.rsvp small { flex-basis: 100%; }

/* Calendar markings: declined = faded and struck through; unanswered invitation = outlined */
.calendar .fc-declined { opacity: .45; }
.calendar .fc-declined .fc-event-title { text-decoration: line-through; }
.calendar .fc-unanswered { background: var(--surface) !important; border-style: dashed !important; }
.calendar .fc-unanswered .fc-event-main, .calendar .fc-unanswered .fc-event-title, .calendar .fc-unanswered .fc-event-time { color: var(--text) !important; }

/* Swatches: brand colors first, then a custom picker */
.swatches label.brand-swatch + label:not(.brand-swatch) { margin-left: 10px; }
.swatches label.custom { position: relative; }
.swatches label.custom span { background: conic-gradient(#ef4444, #eab308, #22c55e, #0ea5e9, #a855f7, #ef4444); }
.swatches label.custom.picked span { background: var(--c); }
.swatches label.custom input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* =====================================================================
   Mail module
   ===================================================================== */
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.sm svg { width: 15px; height: 15px; }
.mail-title { display: flex; align-items: center; gap: 2px; }
.mail-title-text { flex: 1; min-width: 0; }
.mail-sidebar > * { flex-shrink: 0; } /* a long label list scrolls the panel instead of squeezing the rows */
.mail-account {
    justify-content: flex-start; gap: 8px; margin-top: 4px; height: 30px;
    text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500;
}
.mail-account .sh-chev { margin-left: -4px; }
.mail-account { position: relative; }
.mail-account.inactive { color: var(--muted); }
.mail-account.inactive .sh-chev { transform: rotate(-90deg); }
.mail-account + .mail-account, .nav + .mail-account { margin-top: 6px; }
.account-edit { margin-left: auto; width: 24px; height: 24px; opacity: 0; }
.account-edit svg { width: 13px; height: 13px; }
.mail-account:hover .account-edit, .account-edit:focus-visible { opacity: 1; }
.account-dot {
    flex: none; width: 12px; height: 12px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    background: var(--c, var(--accent)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12);
}
.account-dot:hover { transform: scale(1.2); }
.pop-swatches { padding: 10px; max-width: 250px; }
.mail-fav-head { justify-content: flex-start; height: 28px; margin-top: 4px; }
.mail-fav-head .sh-chev { margin-left: -4px; }
#mail-favorites { margin-bottom: 8px; }
.mail-sidebar .nested { margin-left: 14px; }
.mail-sidebar .labels.nested { margin-bottom: 6px; }
.mail-labels-head.nested { margin-top: 8px; }
.add-account { display: inline-flex; align-items: center; gap: 6px; margin: 14px 10px 4px; color: var(--muted); font-size: 12.5px; }
.add-account:hover { color: var(--accent); }
.add-account svg { width: 14px; height: 14px; }

/* Snooze */
.snooze-pop .pop-title { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.snooze-pop .pick { display: flex; justify-content: space-between; gap: 16px; }
.snooze-pop .pick small { color: var(--muted); }
.snooze-pick { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.snooze-pick input { flex: 1; min-width: 0; width: auto !important; height: 30px; font-size: 13px; }
.snooze-pick .btn { flex: none; }
.popover:has(.snooze-pop) { width: 310px; max-height: none; overflow: visible; }
.mdate.msnoozed { display: inline-flex; align-items: center; gap: 4px; color: #d97706; font-weight: 600; }
.mdate.msnoozed svg { width: 13px; height: 13px; }

.cf-quote-bar { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.cf-quote-hint { font-size: 12.5px; }
.cf-quote-remove { color: var(--muted); font-size: 12.5px; }
.cf-quote-remove:hover { color: var(--danger); }
#cf-quote-preview { margin-top: 6px; outline: 1px dashed var(--border); outline-offset: 2px; }

.time-modes { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 10px; }

/* Snippets */
.snippet-list { list-style: none; margin: 4px 0 14px; padding: 0; border-top: 1px solid var(--border); max-height: 260px; overflow-y: auto; }
.snippet { display: flex; align-items: flex-start; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.snippet.editing { background: var(--accent-soft); }
.snippet-main { flex: 1; min-width: 0; cursor: pointer; font-size: 13.5px; }
.snippet-main .tag { margin-left: 6px; font-size: 11px; padding: 0 6px; }
.snippet-main .tag, .snippet-suggest .tag { --c: #64748b; }
.snippet-preview { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-list .empty-note { padding: 10px 2px; color: var(--faint); font-size: 13px; }
.snippet-form { padding: 12px; border-radius: 10px; background: var(--hover); }
#snippet-form textarea { border-color: var(--border); margin: 0; width: 100% !important; padding: 8px 10px; background: var(--surface); }
.snippet-form-foot { display: flex; align-items: center; gap: 8px; }
.snippet-suggest { position: fixed; z-index: 90; width: 340px; max-width: calc(100vw - 16px); }
.snippet-suggest .pick { display: flex; flex-direction: column; align-items: stretch; gap: 1px; }
.snippet-suggest .pick small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.snippet-suggest .pick .tag { font-size: 10.5px; padding: 0 5px; color: var(--muted); }
.snippet-suggest .manage { border-top: 1px solid var(--border); color: var(--accent); font-size: 12.5px; }
.snippet-suggest .pick-empty { padding: 8px 10px; color: var(--faint); font-size: 13px; }

/* Rules */
.rule-list { list-style: none; margin: 4px 0 14px; padding: 0; border-top: 1px solid var(--border); }
.rule { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.rule.off .rule-text { color: var(--faint); }
.rule-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rule-list .empty-note { padding: 10px 2px; color: var(--faint); font-size: 13px; }
.rule-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 12px; border-radius: 10px; background: var(--hover); }
.rule-form select, .rule-form input { width: auto !important; height: 32px; margin: 0; font-size: 13px; }
.rule-form input[name="value"] { flex: 1 1 160px; min-width: 120px; }
.rule-form #rule-account { max-width: 200px; }
.rule-form .rule-break { flex-basis: 100%; height: 0; }
.rule-form #rule-add { margin-left: auto; }
.rule-word { font-size: 13px; color: var(--muted); }

/* IMAP account dialog */
.account-servers { margin: 4px 0 12px; }
.account-servers summary { cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px 0; }
.server-grid { display: grid; grid-template-columns: auto 1fr 84px 110px; gap: 8px; align-items: center; margin: 8px 0 12px; }
.server-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.alias-list { display: flex; flex-direction: column; gap: 8px; }
.alias { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.alias-main { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 6px; align-items: center; }
.alias-login { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.alias-bcc { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.alias-bcc input { flex: 1; }
.alias input { height: 32px; margin: 0; font-size: 13px; }
#account-form .alias textarea { min-height: 52px; font-size: 13px; }
.alias-signature { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.alias-signature textarea { color: var(--text); }
.alias .check-field { font-size: 13px; color: var(--muted); }
.alias-add { align-self: flex-start; margin-top: 6px; font-size: 13px; }
#account-form textarea, #mail-settings-form textarea { border-color: var(--border); margin: 0; width: 100% !important; padding: 8px 10px; }
.form-error { margin: 0; padding: 9px 12px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 13px; }
@media (max-width: 600px) {
    .server-grid { grid-template-columns: 1fr 84px; }
    .server-label { grid-column: 1 / -1; }
}
.account-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-labels-head { justify-content: flex-start; height: 28px; }
.mail-labels-head .sh-chev { margin-left: -4px; }

/* Panel collapsed sideways: icons only */
.mail-app { transition: grid-template-columns .15s ease; }
@media (min-width: 801px) {
    .mail-app.sb-collapsed { grid-template-columns: 60px 1fr; }
    .sb-collapsed .mail-sidebar { padding: 18px 8px; overflow-x: hidden; }
    .sb-collapsed .mail-title { justify-content: center; }
    .sb-collapsed .mail-title-text, .sb-collapsed #mail-settings,
    .sb-collapsed .mail-account, .sb-collapsed .mail-labels-head, .sb-collapsed .mail-fav-head, .sb-collapsed #mail-labels, .sb-collapsed .add-account { display: none; }
    .sb-collapsed #mail-folders { display: flex !important; margin-top: 10px; margin-left: 0; }
    .sb-collapsed .sb-collapse svg { transform: scaleX(-1); }
    .sb-collapsed .nav a { position: relative; justify-content: center; padding: 0; }
    .sb-collapsed .nav .name { display: none; }
    .sb-collapsed .nav .count { display: none; } /* no unread badges in the folded panel */
    /* With Favorites, the folded panel shows only them; with one account, its folders. */
    .sb-collapsed.has-favorites #mail-folders { display: none !important; }
    .sb-collapsed.has-favorites #mail-favorites { display: flex !important; margin-top: 10px; }
}

/* Floating compose button */
.fab {
    position: fixed; right: 24px; bottom: 24px; z-index: 55;
    display: grid; place-items: center; width: 56px; height: 56px; padding: 0;
    border: 0; border-radius: 18px; background: var(--accent); color: #fff;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent), var(--shadow-lg);
    cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.fab:hover { transform: translateY(-1px); box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow-lg); }
.fab:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 2px; }
body.has-timer .fab { bottom: 84px; }
body.composing .fab { display: none; }

/* "Unread only" filter */
.filter-chip {
    flex: none; height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-weight: 550; cursor: pointer;
}
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.mail-bulk:has(.bulk-actions:not([hidden])) .filter-chip { display: none; }
.g-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); }

.module-mail .main.mail-main {
    position: relative; max-width: none; height: 100vh; padding: 0;
    display: grid; grid-template-columns: minmax(320px, 400px) 1fr;
}
.mail-list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.mail-list-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 8px; }
.mail-search { flex: 1; margin: 0; }
.mail-bulk { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--border); }
.mail-folder-title { flex: 1; font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-actions { display: inline-flex; align-items: center; gap: 2px; }
.bulk-count { color: var(--muted); font-size: 12px; margin-left: 4px; }
.mail-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.mail-list-foot { padding: 8px; text-align: center; }
.mail-loading { padding: 24px; color: var(--muted); text-align: center; list-style: none; }
.mail-loading.error { color: var(--danger); }

.mrow {
    position: relative; display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 4px 10px;
    padding: 7px 12px 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; line-height: 1.35;
}
.mrow:hover { background: color-mix(in srgb, var(--surface) 96%, var(--text)); }
.mrow.open { background: var(--accent-soft); }
.mrow.selected { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.msel { margin: 2px 0 0 4px; cursor: pointer; }
.mstar { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; background: none; color: var(--faint); cursor: pointer; }
.mstar svg { width: 16px; height: 16px; }
.mstar.on { color: #f5b301; }
.mstar.on svg { fill: currentColor; }
.mrow-main { min-width: 0; }
.mrow-top { display: flex; align-items: baseline; gap: 6px; }
.mfrom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mfrom small { margin-left: 5px; color: var(--muted); font-size: 12px; }
.mclip svg { width: 13px; height: 13px; color: var(--muted); }
.mmark { display: inline-grid; color: var(--muted); }
.mmark svg { width: 13px; height: 13px; }
.msg-head .mmark { align-self: center; margin-right: 2px; }
/* The list header keeps its height but shows no select-all box or title (the sidebar shows the folder). */
.mail-bulk > .check-field, .mail-folder-title { visibility: hidden; }
.mdate { flex: none; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msubject { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msnippet { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow.unread .mfrom, .mrow.unread .msubject { font-weight: 700; }
.mrow.unread .mdate { color: var(--accent); font-weight: 650; }
.mrow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stripe, var(--accent)); opacity: .3; }
.mrow.unread::before { opacity: 1; }
.mlabels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.mlabels .tag { font-size: 10.5px; padding: 0 6px; line-height: 1.5; }
.mrow-actions { position: absolute; right: 8px; top: 30px; display: none; gap: 2px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.mrow:hover .mrow-actions { display: flex; }

.mail-reader { position: relative; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }

.reader-empty { height: 100%; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.reader-body { padding: 0 24px 40px; }
.reader-head { position: sticky; top: 0; z-index: 5; padding: 12px 0 10px; background: var(--bg); }
.reader-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0 -6px 8px; }
.toolbar-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--border); }
.reader-back { display: none; }
.reader-subject { font-size: 21px; line-height: 1.3; overflow-wrap: anywhere; }
.reader-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reader-labels:empty { display: none; }
.outlook-note {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px;
    padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #0078d4 10%, var(--surface)); font-size: 13px;
}
.outlook-btn { background: #0078d4; color: #fff; margin-left: auto; }
.outlook-btn:hover { background: #106ebe; }

.messages { display: flex; flex-direction: column; gap: 10px; }
.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.msg-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; cursor: pointer; }
.msg .avatar {
    flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); font-weight: 650;
}
.msg-who { flex: 1; min-width: 0; font-size: 13.5px; }
.msg-who > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-to, .msg-snippet { font-size: 12.5px; }
.msg-who > .msg-to { white-space: normal; overflow: visible; }
.addr-line { overflow-wrap: anywhere; line-height: 1.45; }
.addr-label { color: var(--faint); }
.addr-email { color: var(--faint); }
.msg.expanded .msg-snippet, .msg.collapsed .msg-to { display: none; }
.msg-date { flex: none; font-size: 12px; }
.msg.collapsed .msg-body { display: none; }
.msg-body { padding: 0 14px 14px; }
.mail-paper { background: #fff; border-radius: 8px; padding: 6px 8px; }
.mail-frame { display: block; width: 100%; height: 60px; border: 0; }
.images-note {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 10px;
    border-radius: 8px; background: var(--hover); color: var(--muted); font-size: 12.5px;
}
.images-note svg { width: 15px; height: 15px; }
.images-note .link { color: var(--accent); font-weight: 600; }
.images-note { flex-wrap: wrap; }
.images-text { flex: 1 1 220px; }
.images-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* Invitations (.ics) above the message */
.invite-card {
    display: flex; gap: 14px; margin-bottom: 10px; padding: 12px 14px;
    border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface);
}
.invite-card.cancelled { border-left-color: var(--muted); }
.invite-card.cancelled .invite-title, .invite-card.cancelled .invite-when { text-decoration: line-through; text-decoration-color: var(--muted); }
.invite-date {
    flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 48px; height: 52px; border-radius: 8px; background: var(--hover); line-height: 1.1;
}
.invite-date span { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--accent); }
.invite-date b { font-size: 21px; }
.invite-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.invite-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.invite-flag {
    display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 4px;
    background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; vertical-align: 1px;
}
.invite-when { font-size: 13.5px; }
.invite-line { font-size: 12.5px; overflow-wrap: anywhere; }
.invite-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.invite-rsvp { display: inline-flex; gap: 1px; }
.invite-rsvp .btn { border-radius: 0; }
.invite-rsvp .btn:first-child { border-radius: 6px 0 0 6px; }
.invite-rsvp .btn:last-child { border-radius: 0 6px 6px 0; }
.invite-rsvp .btn.on { background: var(--accent); color: #fff; }
.cal-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.images-links .link { white-space: nowrap; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachment {
    display: inline-flex; align-items: center; gap: 6px; max-width: 280px;
    padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px;
}
.attachment:hover { border-color: var(--accent); background: var(--accent-soft); }
button.attachment { background: var(--surface); font: inherit; font-size: 13px; cursor: pointer; }
.attachment.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.attachment:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Attachment card (hover / click) */
.att-card {
    position: fixed; z-index: 80; display: flex; gap: 12px; width: 380px; padding: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.att-preview {
    flex: none; display: grid; place-items: center; width: 120px; height: 90px; overflow: hidden;
    border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.att-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.att-type { font-weight: 700; font-size: 15px; color: var(--muted); letter-spacing: .04em; }
.att-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.att-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att-actions .btn { border: 1px solid var(--border); background: var(--surface); }
.att-actions .btn:hover { border-color: var(--accent); }
.att-actions svg { width: 14px; height: 14px; }
.att-actions kbd { margin-left: 2px; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; font-size: 10.5px; color: var(--muted); }

/* Quick Look */
.quicklook {
    width: min(1100px, 94vw); height: min(860px, 92vh); max-width: none; max-height: none; padding: 0;
    border: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden;
}
.quicklook[open] { display: flex; flex-direction: column; }
.quicklook::backdrop { background: rgb(0 0 0 / .55); }
.ql-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.ql-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-head .btn { border: 1px solid var(--border); }
.ql-body { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; background: var(--bg); }
.ql-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ql-pdf, .ql-text { place-items: stretch; }
.ql-pdf iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.ql-text pre { margin: 0; padding: 16px 20px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); }
@media (max-width: 600px) {
    .att-card { width: calc(100vw - 16px); }
    .quicklook { width: 100vw; height: 100vh; border-radius: 0; }
}
.attachment svg { width: 15px; height: 15px; color: var(--muted); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment small { color: var(--muted); }

.mail-gate { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.gate-card {
    max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
    padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.gate-card p { margin: 0; }

@media (max-width: 900px) {
    .module-mail .main.mail-main { grid-template-columns: 1fr; height: calc(100vh - 64px - env(safe-area-inset-bottom)); }
    .mail-reader { display: none; }
    .mail-main.reading .mail-list-pane { display: none; }
    .mail-main.reading .mail-reader { display: block; }
    .reader-back { display: inline-grid; }
    .reader-body { padding: 0 12px 30px; }
    .reader-toolbar .btn.sm { padding: 0 8px; }
    .mrow-actions { display: none !important; }
    .sb-collapse { display: none; }
    .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
    body.has-timer .fab { bottom: calc(132px + env(safe-area-inset-bottom)); }
    .mail-main.reading ~ .fab { display: none; }
}
.nav a > svg { flex: none; width: 18px; height: 18px; }

/* Mail composer */
.reply-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.reply-bar .btn { border: 1px solid var(--border); }
.draft-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px 12px; color: var(--danger); font-weight: 600; font-size: 13px; }
.composer {
    position: fixed; right: 24px; bottom: 0; z-index: 70;
    width: min(620px, calc(100vw - 32px)); height: min(640px, calc(100vh - 40px));
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-bottom: 0;
    border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg);
}
.composer.min { height: auto; }
.composer.min .composer-inner { display: none; }
.composer.dropping { outline: 3px dashed var(--accent); outline-offset: -6px; }
.composer-head {
    display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px;
    background: var(--sidebar); border-radius: 14px 14px 0 0; cursor: default; user-select: none;
}
.composer-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cf-row { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.cf-label { flex: none; width: 34px; color: var(--muted); font-size: 13px; }
.cf-row select, .cf-row > input { border: 0 !important; box-shadow: none !important; padding: 8px 0 !important; background: transparent !important; }
.cf-row select { width: auto; max-width: 100%; }
.recipients { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 0; cursor: text; }
.recipients input { flex: 1; min-width: 120px; border: 0 !important; box-shadow: none !important; padding: 4px 2px !important; background: transparent !important; }
.rchip {
    display: inline-flex; align-items: center; gap: 2px; max-width: 260px;
    padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rchip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.rchip button:hover { color: var(--danger); }
.cf-ccbcc { font-size: 13px; }
.cf-toolbar { display: flex; gap: 2px; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.cf-toolbar button {
    display: grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px;
    border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-size: 14px;
}
.cf-toolbar button:hover { background: var(--hover); color: var(--text); }
.cf-editor { flex: 1; min-height: 120px; overflow-y: auto; padding: 14px 16px; outline: none; font-size: 14.5px; line-height: 1.55; }
.cf-editor blockquote { margin: 0 0 0 .8ex; border-left: 2px solid var(--border); padding-left: 1ex; color: var(--muted); }
.cf-editor code, .cf-editor pre { color: var(--text); }
@media (prefers-color-scheme: dark) { .cf-editor code, .cf-editor pre { background: var(--hover) !important; border-color: var(--border) !important; } }
.cf-editor [data-signature] { color: var(--muted); }
.cf-quote { padding: 0 16px 8px; }
.cf-quote .link { color: var(--accent); font-size: 13px; }
.cf-quote .mail-paper { margin-top: 6px; max-height: 260px; overflow-y: auto; }
.cf-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.cf-attachments:not(:empty) { padding-bottom: 8px; }
.cf-file {
    position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 260px; overflow: hidden;
    padding: 5px 6px 5px 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px;
}
.cf-file svg { width: 14px; height: 14px; color: var(--muted); }
.cf-file small { color: var(--muted); }
.cf-file button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.cf-file .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width .2s; }
.cf-file.uploading { opacity: .85; }
.composer-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.cf-status { color: var(--faint); font-size: 12px; }
.cf-suggest { position: absolute; width: 300px; }
body.composing .toasts { bottom: 24px; left: auto; right: 660px; transform: none; }

@media (max-width: 900px) {
    .composer { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
    .composer-head { border-radius: 0; }
    body.composing .toasts { right: auto; left: 50%; transform: translateX(-50%); bottom: 80px; }
}

/* Privacy page and the Microsoft 365 connect button */
.auth-card.privacy { width: min(680px, 100%); gap: 10px; }
.auth-card.privacy h2 { font-size: 15px; margin-top: 8px; }
.auth-card.privacy p, .auth-card.privacy li { margin: 0; line-height: 1.55; color: var(--text); }
.auth-card.privacy ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.connect-microsoft { margin-top: 6px; }

/* Mail: the refresh icon turns while the list reloads */
#mail-refresh.spinning svg { animation: mail-spin .8s linear infinite; }
@keyframes mail-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #mail-refresh.spinning svg { animation-duration: 2.4s; } }

/* Standby server (read-only copy) */
.standby-banner {
    position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 1000;
    padding: 6px 14px; border-radius: 999px; background: #b45309; color: #fff; font-size: 13px; font-weight: 600;
    box-shadow: 0 4px 14px rgb(0 0 0 / .2); pointer-events: none; white-space: nowrap;
}
