html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

h1:focus {
    outline: none;
}

.icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-panel);
}

.blazor-error-boundary {
    background: var(--danger);
    padding: 1rem;
    color: #fff;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

/* Keyboard focus is always visible; mouse clicks don't draw a ring. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline-offset: 0;
}

/* Text only screen readers hear. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion (Windows "Animation effects" off): no animations and NO transitions. Transitions get 0s, not the usual
   .01ms: a duration on every element turns every property change of every element into a transition (transition-property
   defaults to all), and its first frame paints the old value: on each tab switch about 150 elements (visibility) and the
   page background layer (above the page for the hexagon backgrounds, below it for the others) were painted a frame out of
   step, the flicker between Tickets and Mail / Chat. Nothing here waits for transitionend. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0s !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }
}

/* Inputs that sit inside a styled box hide their own outline, so the box shows focus instead. */
.search:focus-within, .find:focus-within, .addt:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Borderless title and subject fields: an underline marks keyboard focus. */
input.title:focus-visible, input.subject:focus-visible, input.typing:focus-visible {
    box-shadow: inset 0 -2px 0 var(--accent);
}

/* ✦ AI client tasks: what the AI took from an email (requirement, issue, promise…), on rows, cards and tasks. */
.aik {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 5px;
    background: var(--soft);
    color: var(--accent);
    white-space: nowrap;
}

    .aik.k-change { background: #fff3d6; color: #8a5a00; }
    .aik.k-revert, .aik.k-addition { background: var(--warn); color: #fff; }
    .aik.k-issue { background: #fde2e1; color: #a61b1b; }
    .aik.k-delivered, .aik.k-approval { background: #dcf5e7; color: #16693c; }
    .aik.k-promise { background: #ede9fe; color: #5b21b6; }

.aik-due { font-weight: 700; color: #5b21b6; }
.aik-due.kept { color: #16693c; }
.aik-due.missed { color: var(--danger); }

:root[data-theme="dark"] .aik.k-change { background: #3a2c0c; color: #f3c56b; }
:root[data-theme="dark"] .aik.k-issue { background: #3d1618; color: #f59a9a; }
:root[data-theme="dark"] .aik.k-delivered, :root[data-theme="dark"] .aik.k-approval { background: #10301f; color: #7fd8a6; }
:root[data-theme="dark"] .aik.k-promise { background: #2a2045; color: #c3b0ff; }
:root[data-theme="dark"] .aik-due { color: #c3b0ff; }
:root[data-theme="dark"] .aik-due.kept { color: #7fd8a6; }
:root[data-theme="dark"] .aik-due.missed { color: var(--danger); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .aik.k-change { background: #3a2c0c; color: #f3c56b; }
    :root:not([data-theme]) .aik.k-issue { background: #3d1618; color: #f59a9a; }
    :root:not([data-theme]) .aik.k-delivered, :root:not([data-theme]) .aik.k-approval { background: #10301f; color: #7fd8a6; }
    :root:not([data-theme]) .aik.k-promise { background: #2a2045; color: #c3b0ff; }
    :root:not([data-theme]) .aik-due { color: #c3b0ff; }
    :root:not([data-theme]) .aik-due.kept { color: #7fd8a6; }
    :root:not([data-theme]) .aik-due.missed { color: var(--danger); }
}

/* ---- compose extras (editor-extras.js): table bar, emoji picker, @mention list ---- */

.tw-tablebar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}

    .tw-tablebar button {
        height: 26px;
        padding: 0 9px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--surface);
        color: var(--text);
        font: inherit;
        font-size: 12px;
        cursor: pointer;
    }

        .tw-tablebar button.danger {
            color: var(--danger);
        }

    /* Shown only while the cursor is in a table (editor-extras.js sets hidden). */
    .tw-tablebar[hidden] {
        display: none;
    }

.ql-editor table {
    border-collapse: collapse;
    margin: 6px 0;
}

    .ql-editor table td {
        border: 1px solid #9aa4b2;
        padding: 4px 8px;
        min-width: 40px;
    }

.tw-emoji-pop {
    position: fixed;
    z-index: 200;
    width: 320px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

    .tw-emoji-pop .grp {
        margin: 6px 4px 2px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .05em;
    }

    .tw-emoji-pop .grid {
        display: grid;
        grid-template-columns: repeat(8, 1fr);
    }

        .tw-emoji-pop .grid button {
            height: 34px;
            border: 0;
            border-radius: 8px;
            background: transparent;
            font-size: 20px;
            cursor: pointer;
        }

            .tw-emoji-pop .grid button:hover {
                background: var(--hover);
            }

.tw-mention {
    position: fixed;
    z-index: 200;
    min-width: 240px;
    max-width: 340px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

    .tw-mention button {
        display: block;
        width: 100%;
        padding: 6px 10px;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: var(--text);
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

        .tw-mention button.on, .tw-mention button:hover {
            background: var(--selected);
        }

        .tw-mention button b {
            display: block;
            font-size: 13px;
        }

        .tw-mention button small {
            color: var(--muted);
            font-size: 11.5px;
        }

/* Table add-on (lib/quill-table-better): its menus, size picker and property forms are white panels over the message,
   so they keep dark text in every theme (they'd otherwise inherit the dark theme's light text). */
.ql-table-menus-container,
.ql-table-select-container,
.ql-table-properties-form,
.ql-table-dropdown-list,
.ql-table-dropdown-properties-list,
.ql-table-color-container .color-picker-select {
    color: #1f2937;
    font-size: 13px;
}

    .ql-table-properties-form input,
    .ql-table-properties-form .property-input {
        color: #1f2937;
    }

    .ql-table-menus-container svg .ql-stroke { stroke: #374151; }
    .ql-table-menus-container svg .ql-fill { fill: #374151; }

/* New mail / chat while the tab is in front (notify.js): small toasts, bottom right. */
#tw-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: min(340px, calc(100vw - 32px)); }
.tw-toast { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font: inherit; font-size: 13px; cursor: pointer; animation: tw-toast-in .2s ease-out; transition: opacity .25s, transform .25s; }
    .tw-toast b { font-size: 13.5px; }
    .tw-toast span { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .tw-toast.out { opacity: 0; transform: translateY(8px); }
@keyframes tw-toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 640px) { #tw-toasts { bottom: 80px; } }

/* Native drop-downs follow the theme: the option list is drawn by the browser from the select's colour scheme and the
   options' own colours, so both come from the tokens (otherwise dark pages get white lists with faint text). */
select {
    color-scheme: inherit;
}

select option,
select optgroup {
    background-color: var(--surface);
    color: var(--text);
}

select option:disabled {
    color: var(--faint);
}

/* ---- Mail Full window (desktop and tablet) -------------------------------------------------------------------------
   While the mail page shows its Full window view (.panes.fw, Components/Pages/Mail.razor) and is the page on screen
   (not a workspace tab kept behind another), Connect's title bar, workspace tabs and app rail are hidden and the work
   area loses its padding and gaps: the mail toolbar is the window's top row and the folder rail, list and reading pane
   fill the rest, edge to edge. The toolbar then carries the bell and the account menu. Normal view brings it all back;
   a phone keeps its own layout (Full window is never on there). Pure CSS, so nothing flashes between two renders.
   The title bar's box goes, but not Connect's one search box in it (SearchBox.razor): see "the search box" below. */
@media (min-width: 768px) {
    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .ws-strip,
    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .body > .rail,
    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > :not(.wrap) {
        display: none;
    }

    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar {
        display: contents;
    }

    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .body > main.work {
        padding: 0;
        gap: 0;
    }

    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .body > main.work > .ws-pane {
        gap: 0;
    }

    /* The search box (21 Oct 2026): the same one, never moved in the page nor drawn twice (its text, open panel and
       shortcuts survive the switch), placed over the toolbar's search place (Ribbon.razor, [data-fws-slot]) where
       js/mail-fullwindow.js measures it (--fws-x / --fws-y / --fws-w). Above the list and reading pane like the title
       bar was (57); what opens under it is at least as wide as the box can be. Unseen until first measured. */
    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap {
        position: fixed;
        z-index: 57;
        left: var(--fws-x, 0px);
        top: var(--fws-y, 0px);
        width: var(--fws-w, 0px);
        max-width: none;
        flex: none;
    }

    :root:not([data-fws]) .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap {
        opacity: 0;
        pointer-events: none;
    }

    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap .search {
        height: 32px;
    }

    .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap :is(.recent, .chatpop, .adv) {
        top: calc(100% + 6px);
        left: auto;
        right: 0;
        width: max(100%, min(560px, calc(100vw - 32px)));
    }

    /* Too narrow for the box (data-fws="icon"): the toolbar shows a search icon; the box waits unseen (still focusable,
       so Ctrl+K, "/" and quick search reach it) under the toolbar and opens there (data-fws-pop). */
    :root[data-fws="icon"] .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap {
        left: var(--fws-pop-x, 16px);
        top: var(--fws-pop-y, 48px);
        width: var(--fws-pop-w, 0px);
        opacity: 0;
        pointer-events: none;
        transition: opacity .12s ease;
    }

    :root[data-fws="icon"][data-fws-pop] .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap {
        opacity: 1;
        pointer-events: auto;
    }

    :root[data-fws="icon"][data-fws-pop] .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap .search {
        height: 38px;
        box-shadow: 0 12px 32px rgb(0 0 0 / .22);
    }
}

@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
    :root[data-fws="icon"] .app:has(.panes.fw[data-mail-page]):not(:has(.ws-hidden .panes.fw[data-mail-page])) > .titlebar > .wrap {
        transition: none;
    }
}
