/* GENERATED by build-css.js from styles.src.css – do not edit.
 * Edit the partials in this directory and re-run `npm run build`. */

@import url('../../elastic/styles/styles.min.css');

/* ===== _tokens.css ===== */
/* =============================================================================
 * Design tokens – mirrors cloudweb.sk (public/css/cloudweb.css).
 * Use `--cw-*` prefix to avoid clashes with Roundcube/Bootstrap/elastic vars.
 *
 * Every colour, shadow and density value in the skin resolves through a token
 * declared here. Dark mode and compact density are token swaps only – see
 * `_theme.css`. A raw hex or rgba() anywhere else in the skin is a bug: it
 * cannot follow the theme.
 * ============================================================================= */

:root {
    color-scheme: light;

    /* ---- Brand ---------------------------------------------------------- */
    --cw-primary:       #1437FF;
    --cw-primary-deep:  #001dc0;
    --cw-primary-hover: #001a9f;
    --cw-primary-50:    #EEF1FF;
    --cw-primary-100:   #D9E0FF;
    --cw-accent-2:      #5C79FF;
    --cw-on-primary:    #FFFFFF;
    /* Foreground for anything sitting on the --cw-primary-50 tint or on a
     * card in a hover/active state. Kept separate from --cw-primary-deep,
     * which is a fill colour and has to stay dark enough for white text –
     * the two cannot be the same value in a dark theme. */
    --cw-on-tint:       var(--cw-primary-deep);
    /* Foreground on a SATURATED fill. --cw-on-primary sits on the deep
     * brand fill; --cw-on-accent sits on --cw-primary itself, which is a
     * light blue in dark mode and cannot carry white text. */
    --cw-on-accent:     #FFFFFF;

    /* ---- Status --------------------------------------------------------- */
    --cw-success:        #80c700;
    --cw-success-soft:   #EBF7D1;
    --cw-success-ink:    #3f6212;
    --cw-success-border: #bef264;
    --cw-on-success:     #1E2A12;
    --cw-danger:         #dc2626;
    --cw-danger-soft:    #FEE2E2;
    --cw-danger-ink:     #991b1b;
    --cw-danger-border:  #fecaca;
    --cw-warning:        #F59E0B;
    --cw-warning-soft:   #FEF3C7;
    --cw-warning-ink:    #92400e;
    --cw-warning-border: #fde68a;

    /* ---- Surfaces / text ------------------------------------------------ */
    --cw-bg:          #F9FBFC;
    --cw-bg-soft:     #F3F6FA;
    --cw-card:        #FFFFFF;
    --cw-ink:         #0F1419;
    --cw-ink-2:       #2B3339;
    --cw-muted:       #697079;
    --cw-muted-2:     #858E9D;
    --cw-border:      #E5E7EB;
    --cw-border-soft: #EEF0F3;

    /* Sender HTML is authored for a white page. In dark mode these two stay
     * light so third-party mail stays readable instead of being inverted. */
    --cw-paper:     #FFFFFF;
    --cw-paper-ink: #0F1419;

    /* Code blocks invert against the surrounding surface in both themes. */
    --cw-code-bg:  #0F1419;
    --cw-code-ink: #E6E9EF;

    /* ---- Effects -------------------------------------------------------- */
    --cw-ring:        0 0 0 4px rgba(20, 55, 255, 0.14);
    --cw-shadow-sm:   0 1px 2px rgba(15, 20, 25, 0.04), 0 1px 3px rgba(15, 20, 25, 0.06);
    --cw-shadow:      0 6px 14px -6px rgba(15, 20, 25, 0.08), 0 12px 28px -12px rgba(15, 20, 25, 0.12);
    --cw-shadow-lg:   0 18px 40px -12px rgba(15, 20, 25, 0.12), 0 30px 60px -20px rgba(20, 55, 255, 0.18);
    --cw-shadow-up:   0 -4px 12px -8px rgba(15, 20, 25, 0.10);
    --cw-shadow-rail: 0 -4px 18px -8px rgba(15, 20, 25, 0.12);

    --cw-btn-shadow:        0 1px 2px rgba(0, 29, 192, 0.20);
    --cw-btn-shadow-hover:  0 6px 14px -4px rgba(0, 29, 192, 0.40);
    --cw-btn-inset:         inset 0 1px 0 var(--cw-hilite);
    --cw-btn-inset-hover:   inset 0 1px 0 var(--cw-hilite-strong);

    /* Bare colours, for rules that compose their own shadow offsets. */
    --cw-btn-glow:        rgba(0, 29, 192, 0.20);
    --cw-btn-glow-hover:  rgba(0, 29, 192, 0.40);
    --cw-btn-glow-strong: rgba(0, 29, 192, 0.45);
    --cw-hilite:          rgba(255, 255, 255, 0.16);
    --cw-hilite-strong:   rgba(255, 255, 255, 0.20);

    --cw-overlay:            rgba(15, 20, 25, 0.42);
    --cw-scroll-thumb:       rgba(15, 20, 25, 0.15);
    --cw-scroll-thumb-hover: rgba(15, 20, 25, 0.28);

    /* Login hero texture */
    --cw-grid-line:    rgba(15, 20, 25, 0.04);
    --cw-glow-primary: rgba(20, 55, 255, 0.10);
    --cw-glow-primary-soft: rgba(20, 55, 255, 0.08);
    --cw-glow-success: rgba(128, 199, 0, 0.06);

    /* ---- Type ----------------------------------------------------------- */
    --cw-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --cw-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* ---- Geometry ------------------------------------------------------- */
    --cw-radius-sm: 6px;
    --cw-radius:    10px;
    --cw-radius-lg: 14px;
    --cw-radius-xl: 20px;
    --cw-easing:    cubic-bezier(0.16, 1, 0.3, 1);

    /* Height of the fixed bottom task rail on phones; other fixed layers
     * (drawers, toasts, the reading pane) offset themselves by it. */
    --cw-rail-h: 64px;
    --cw-rail-total: calc(var(--cw-rail-h) + env(safe-area-inset-bottom, 0px));

    /* ---- Density (swapped by [data-cw-density="compact"]) ---------------- */
    --cw-msg-row-pad:      10px;
    --cw-msg-row-gap:      3px;
    --cw-msg-from-size:    0.86rem;
    --cw-msg-subject-size: 0.82rem;
    --cw-msg-date-size:    0.72rem;
    --cw-tree-row-h:       32px;
    --cw-tree-font:        0.825rem;
    --cw-list-row-pad:     10px;
    --cw-contact-row-h:    56px;
    --cw-read-pad:         32px;
}

/* ===== _typography.css ===== */
/* =============================================================================
 * Typography – self-hosted Geist + base body rules.
 * ============================================================================= */

@font-face {
    font-family: 'Geist';
    src: url('../fonts/GeistVF.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Geist Mono';
    src: url('../fonts/GeistMonoVF.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

body,
html,
.ui-widget,
.ui-dialog,
.popupmenu,
.toolbar,
.header,
.footer,
#layout,
#layout-content,
.formcontent,
.propform,
.listing,
.messagelist,
.contactlist,
.folderlist {
    font-family: var(--cw-sans) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

pre, code, .raw-message, tt, .monospace, .message-part pre {
    font-family: var(--cw-mono) !important;
}

body {
    background-color: var(--cw-bg);
    color: var(--cw-ink);
    font-feature-settings: 'ss01', 'cv11';
}

/* ===== _theme.css ===== */
/* =============================================================================
 * Theme + density switching.
 *
 * Theme is selected by `data-cw-theme` on <html>:
 *   "light"  – always light
 *   "dark"   – always dark
 *   "auto" / absent – follow the OS via prefers-color-scheme
 *
 * The dark palette is declared ONCE as `--cw-d-*` on :root and then aliased
 * onto the live `--cw-*` tokens by the two activating selectors below, so the
 * palette never has to be maintained in two places.
 *
 * Density is selected by `data-cw-density` on <html>: "comfortable" (default)
 * or "compact".
 *
 * Both attributes are written before first paint by cloudweb_branding's
 * inline head script, so there is no flash of the wrong theme.
 * ============================================================================= */

:root {
    --cw-d-primary:       #7B93FF;
    --cw-d-primary-deep:  #3355FF;
    --cw-d-primary-hover: #4A69FF;
    --cw-d-primary-50:    #1A2138;
    --cw-d-primary-100:   #2A3557;
    --cw-d-accent-2:      #9AAEFF;
    --cw-d-on-tint:       #A8BCFF;
    --cw-d-on-accent:     #0B0E14;

    --cw-d-success:        #9FE04A;
    --cw-d-success-soft:   #1E2A12;
    --cw-d-success-ink:    #C4EE86;
    --cw-d-success-border: #3A5220;
    --cw-d-on-success:     #0B0E14;
    --cw-d-danger:         #F87171;
    --cw-d-danger-soft:    #2C1618;
    --cw-d-danger-ink:     #FCA5A5;
    --cw-d-danger-border:  #4E2226;
    --cw-d-warning:        #FBBF24;
    --cw-d-warning-soft:   #2C2110;
    --cw-d-warning-ink:    #FCD34D;
    --cw-d-warning-border: #4E3A12;

    --cw-d-bg:          #0B0E14;
    --cw-d-bg-soft:     #12161F;
    --cw-d-card:        #151A24;
    --cw-d-ink:         #E8ECF3;
    --cw-d-ink-2:       #C3CBD8;
    --cw-d-muted:       #8B95A7;
    --cw-d-muted-2:     #69748A;
    --cw-d-border:      #262E3D;
    --cw-d-border-soft: #1D2431;

    --cw-d-code-bg:  #05070B;
    --cw-d-code-ink: #D7DEEA;

    --cw-d-ring:        0 0 0 4px rgba(123, 147, 255, 0.26);
    --cw-d-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.36), 0 1px 3px rgba(0, 0, 0, 0.28);
    --cw-d-shadow:      0 6px 14px -6px rgba(0, 0, 0, 0.55), 0 12px 28px -12px rgba(0, 0, 0, 0.60);
    --cw-d-shadow-lg:   0 18px 40px -12px rgba(0, 0, 0, 0.66), 0 30px 60px -20px rgba(0, 0, 0, 0.55);
    --cw-d-shadow-up:   0 -4px 12px -8px rgba(0, 0, 0, 0.55);
    --cw-d-shadow-rail: 0 -4px 18px -8px rgba(0, 0, 0, 0.60);

    --cw-d-btn-shadow:        0 1px 2px rgba(0, 0, 0, 0.45);
    --cw-d-btn-shadow-hover:  0 6px 14px -4px rgba(51, 85, 255, 0.45);
    --cw-d-btn-inset:         inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --cw-d-btn-inset-hover:   inset 0 1px 0 rgba(255, 255, 255, 0.16);

    --cw-d-btn-glow:        rgba(0, 0, 0, 0.45);
    --cw-d-btn-glow-hover:  rgba(51, 85, 255, 0.45);
    --cw-d-hilite:          rgba(255, 255, 255, 0.12);
    --cw-d-hilite-strong:   rgba(255, 255, 255, 0.16);

    --cw-d-overlay:            rgba(3, 5, 9, 0.66);
    --cw-d-scroll-thumb:       rgba(232, 236, 243, 0.16);
    --cw-d-scroll-thumb-hover: rgba(232, 236, 243, 0.30);

    --cw-d-grid-line:         rgba(232, 236, 243, 0.05);
    --cw-d-glow-primary:      rgba(51, 85, 255, 0.22);
    --cw-d-glow-primary-soft: rgba(51, 85, 255, 0.16);
    --cw-d-glow-success:      rgba(128, 199, 0, 0.10);
}

/* -----------------------------------------------------------------------------
 * Dark activation. Both selectors carry the identical alias list.
 * -------------------------------------------------------------------------- */
html[data-cw-theme="dark"] {
    color-scheme: dark;

    --cw-primary:       var(--cw-d-primary);
    --cw-primary-deep:  var(--cw-d-primary-deep);
    --cw-primary-hover: var(--cw-d-primary-hover);
    --cw-primary-50:    var(--cw-d-primary-50);
    --cw-primary-100:   var(--cw-d-primary-100);
    --cw-accent-2:      var(--cw-d-accent-2);
    --cw-on-tint:       var(--cw-d-on-tint);
    --cw-on-accent:     var(--cw-d-on-accent);

    --cw-success:        var(--cw-d-success);
    --cw-success-soft:   var(--cw-d-success-soft);
    --cw-success-ink:    var(--cw-d-success-ink);
    --cw-success-border: var(--cw-d-success-border);
    --cw-on-success:     var(--cw-d-on-success);
    --cw-danger:         var(--cw-d-danger);
    --cw-danger-soft:    var(--cw-d-danger-soft);
    --cw-danger-ink:     var(--cw-d-danger-ink);
    --cw-danger-border:  var(--cw-d-danger-border);
    --cw-warning:        var(--cw-d-warning);
    --cw-warning-soft:   var(--cw-d-warning-soft);
    --cw-warning-ink:    var(--cw-d-warning-ink);
    --cw-warning-border: var(--cw-d-warning-border);

    --cw-bg:          var(--cw-d-bg);
    --cw-bg-soft:     var(--cw-d-bg-soft);
    --cw-card:        var(--cw-d-card);
    --cw-ink:         var(--cw-d-ink);
    --cw-ink-2:       var(--cw-d-ink-2);
    --cw-muted:       var(--cw-d-muted);
    --cw-muted-2:     var(--cw-d-muted-2);
    --cw-border:      var(--cw-d-border);
    --cw-border-soft: var(--cw-d-border-soft);

    --cw-code-bg:  var(--cw-d-code-bg);
    --cw-code-ink: var(--cw-d-code-ink);

    --cw-ring:        var(--cw-d-ring);
    --cw-shadow-sm:   var(--cw-d-shadow-sm);
    --cw-shadow:      var(--cw-d-shadow);
    --cw-shadow-lg:   var(--cw-d-shadow-lg);
    --cw-shadow-up:   var(--cw-d-shadow-up);
    --cw-shadow-rail: var(--cw-d-shadow-rail);

    --cw-btn-shadow:        var(--cw-d-btn-shadow);
    --cw-btn-shadow-hover:  var(--cw-d-btn-shadow-hover);
    --cw-btn-inset:         var(--cw-d-btn-inset);
    --cw-btn-inset-hover:   var(--cw-d-btn-inset-hover);

    --cw-btn-glow:        var(--cw-d-btn-glow);
    --cw-btn-glow-hover:  var(--cw-d-btn-glow-hover);
    --cw-hilite:          var(--cw-d-hilite);
    --cw-hilite-strong:   var(--cw-d-hilite-strong);

    --cw-overlay:            var(--cw-d-overlay);
    --cw-scroll-thumb:       var(--cw-d-scroll-thumb);
    --cw-scroll-thumb-hover: var(--cw-d-scroll-thumb-hover);

    --cw-grid-line:         var(--cw-d-grid-line);
    --cw-glow-primary:      var(--cw-d-glow-primary);
    --cw-glow-primary-soft: var(--cw-d-glow-primary-soft);
    --cw-glow-success:      var(--cw-d-glow-success);
}

@media (prefers-color-scheme: dark) {
    html[data-cw-theme="auto"],
    html:not([data-cw-theme]) {
        color-scheme: dark;

        --cw-primary:       var(--cw-d-primary);
        --cw-primary-deep:  var(--cw-d-primary-deep);
        --cw-primary-hover: var(--cw-d-primary-hover);
        --cw-primary-50:    var(--cw-d-primary-50);
        --cw-primary-100:   var(--cw-d-primary-100);
        --cw-accent-2:      var(--cw-d-accent-2);
        --cw-on-tint:       var(--cw-d-on-tint);
        --cw-on-accent:     var(--cw-d-on-accent);
    --cw-on-accent:     var(--cw-d-on-accent);
    --cw-on-tint:       var(--cw-d-on-tint);
    --cw-on-accent:     var(--cw-d-on-accent);

        --cw-success:        var(--cw-d-success);
        --cw-success-soft:   var(--cw-d-success-soft);
        --cw-success-ink:    var(--cw-d-success-ink);
        --cw-success-border: var(--cw-d-success-border);
        --cw-on-success:     var(--cw-d-on-success);
    --cw-on-success:     var(--cw-d-on-success);
        --cw-danger:         var(--cw-d-danger);
        --cw-danger-soft:    var(--cw-d-danger-soft);
        --cw-danger-ink:     var(--cw-d-danger-ink);
        --cw-danger-border:  var(--cw-d-danger-border);
        --cw-warning:        var(--cw-d-warning);
        --cw-warning-soft:   var(--cw-d-warning-soft);
        --cw-warning-ink:    var(--cw-d-warning-ink);
        --cw-warning-border: var(--cw-d-warning-border);

        --cw-bg:          var(--cw-d-bg);
        --cw-bg-soft:     var(--cw-d-bg-soft);
        --cw-card:        var(--cw-d-card);
        --cw-ink:         var(--cw-d-ink);
        --cw-ink-2:       var(--cw-d-ink-2);
        --cw-muted:       var(--cw-d-muted);
        --cw-muted-2:     var(--cw-d-muted-2);
        --cw-border:      var(--cw-d-border);
        --cw-border-soft: var(--cw-d-border-soft);

        --cw-code-bg:  var(--cw-d-code-bg);
        --cw-code-ink: var(--cw-d-code-ink);

        --cw-ring:        var(--cw-d-ring);
        --cw-shadow-sm:   var(--cw-d-shadow-sm);
        --cw-shadow:      var(--cw-d-shadow);
        --cw-shadow-lg:   var(--cw-d-shadow-lg);
        --cw-shadow-up:   var(--cw-d-shadow-up);
        --cw-shadow-rail: var(--cw-d-shadow-rail);

        --cw-btn-shadow:        var(--cw-d-btn-shadow);
        --cw-btn-shadow-hover:  var(--cw-d-btn-shadow-hover);
        --cw-btn-inset:         var(--cw-d-btn-inset);
        --cw-btn-inset-hover:   var(--cw-d-btn-inset-hover);

        --cw-btn-glow:        var(--cw-d-btn-glow);
        --cw-btn-glow-hover:  var(--cw-d-btn-glow-hover);
        --cw-hilite:          var(--cw-d-hilite);
        --cw-hilite-strong:   var(--cw-d-hilite-strong);

        --cw-overlay:            var(--cw-d-overlay);
        --cw-scroll-thumb:       var(--cw-d-scroll-thumb);
        --cw-scroll-thumb-hover: var(--cw-d-scroll-thumb-hover);

        --cw-grid-line:         var(--cw-d-grid-line);
        --cw-glow-primary:      var(--cw-d-glow-primary);
        --cw-glow-primary-soft: var(--cw-d-glow-primary-soft);
        --cw-glow-success:      var(--cw-d-glow-success);
    }
}

/* -----------------------------------------------------------------------------
 * Dark-only corrections.
 *
 * Everything else in the skin resolves through the tokens above and needs no
 * per-theme rule. What lands here is only what a token swap cannot express.
 * -------------------------------------------------------------------------- */

/* `.cw-dark` is mirrored onto <html> by the branding script – it resolves
 * "auto + OS is dark" and an explicit dark choice into one selector, so the
 * rules below do not have to repeat the media query. */

/* Roundcube's own "dark mode" user preference paints `body.dark-mode` with
 * elastic's palette, which is not ours. We own the theme, so neutralise it. */
body.dark-mode {
    background: var(--cw-bg) !important;
    color: var(--cw-ink) !important;
}

/* The rack half of the lockup is near-black; on a dark card it needs the
 * lightened variant or it reads as a silhouette. */
html.cw-dark body:not(.task-login) #layout-menu .popover-header #logo,
html.cw-dark body:not(.task-login) #layout-menu .popover-header img.logo,
html.cw-dark .cw-login-logo {
    content: url('../images/logo-light.svg');
}

/* Elastic paints a handful of widget internals with literal light values that
 * our token rules do not reach. */
html.cw-dark .ui-widget-content,
html.cw-dark .ui-widget-header,
html.cw-dark .ui-state-default {
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    border-color: var(--cw-border) !important;
}

/* Sender HTML assumes a white page. Keep the message body on paper in dark
 * mode rather than inverting it – inverting turns hand-authored dark text on
 * a hardcoded white table into black-on-black.
 *
 * The surface alone is not enough: the skin styles quotes, links and rules
 * inside the message body through the same tokens as the rest of the app, so
 * on a white card those would still resolve to dark-theme values (a near-black
 * blockquote, a pale blue link). Re-declaring the tokens on the container
 * flips every one of those rules back to its light value at once, with no
 * per-element dark override to keep in sync. */
html.cw-dark .message-htmlpart,
html.cw-dark #messagebody .message-htmlpart {
    --cw-ink:         #0F1419;
    --cw-ink-2:       #2B3339;
    --cw-muted:       #697079;
    --cw-muted-2:     #858E9D;
    --cw-border:      #E5E7EB;
    --cw-border-soft: #EEF0F3;
    --cw-card:        #FFFFFF;
    --cw-bg-soft:     #F3F6FA;
    --cw-primary:      #1437FF;
    --cw-primary-50:   #EEF1FF;
    --cw-primary-100:  #D9E0FF;
    --cw-on-tint:      #001dc0;

    background: var(--cw-paper) !important;
    color: var(--cw-paper-ink) !important;
    border-radius: var(--cw-radius);
    padding: 18px 20px;
}

/* Contact photos and inline mail images sit on paper too, so their own white
 * matting does not glare against the dark card. */
html.cw-dark #message-header > .header img.contactphoto,
html.cw-dark img.contactphoto {
    background: var(--cw-primary-50) !important;
}

/* Native form controls inside iframes we do not otherwise style. */
html.cw-dark input,
html.cw-dark select,
html.cw-dark textarea {
    color-scheme: dark;
}

/* -----------------------------------------------------------------------------
 * Compact density
 * -------------------------------------------------------------------------- */
html[data-cw-density="compact"] {
    --cw-msg-row-pad:      5px;
    --cw-msg-row-gap:      1px;
    --cw-msg-from-size:    0.8rem;
    --cw-msg-subject-size: 0.78rem;
    --cw-msg-date-size:    0.68rem;
    --cw-tree-row-h:       27px;
    --cw-tree-font:        0.79rem;
    --cw-list-row-pad:     6px;
    --cw-contact-row-h:    44px;
    --cw-read-pad:         22px;
}

/* -----------------------------------------------------------------------------
 * Focus visibility.
 *
 * The skin replaces elastic's focus borders on rows, tree items and toolbar
 * buttons. Without this block keyboard navigation has no visible target at
 * all. Pointer users never see it (:focus-visible, not :focus).
 * -------------------------------------------------------------------------- */
:focus-visible {
    outline: 2px solid var(--cw-primary);
    outline-offset: 2px;
    border-radius: var(--cw-radius-sm);
}

.messagelist tbody tr:focus-visible,
.contactlist tbody tr:focus-visible,
table.listing tbody tr:focus-visible {
    outline: 2px solid var(--cw-primary);
    outline-offset: -2px;
}

/* Elements that already carry a ring shadow keep it and drop the outline so
 * the two do not double up. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-control:focus-visible,
.custom-select:focus-visible {
    outline: none;
}

/* ===== _buttons.css ===== */
/* =============================================================================
 * Buttons – matches cloudweb.sk .btn--primary / .btn--secondary recipes.
 * Covers:
 *   - Links / inline anchors (color usage)
 *   - .btn-primary / .btn-secondary / cancel / link
 *   - Toolbar buttons (.toolbar a.button, .formbuttons button)
 *   - Dropdown-button caret styling
 * Login button styling lives in _login.css (scoped to body.task-login).
 * ============================================================================= */

/* ---- Link colour ---- */
a, .listing td a,
.toolbar a.button:not(.disabled):hover,
.menu a:hover,
.popupmenu li a:hover,
#taskmenu a.selected,
#taskmenu a.button.selected {
    color: var(--cw-primary);
}

/* ---- Primary button ---- */
.btn-primary,
a.btn-primary,
button.btn-primary,
.ui-dialog .ui-dialog-buttonset .ui-button.btn-primary,
.formbuttons .btn-primary,
button.mainaction:not(#rcmloginsubmit) {
    background-color: var(--cw-primary-deep) !important;
    border-color: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border-radius: var(--cw-radius);
    font-weight: 500;
    padding: 0.55rem 1rem;
    box-shadow: 0 1px 2px var(--cw-btn-glow),
                inset 0 1px 0 var(--cw-hilite);
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-primary:hover,
a.btn-primary:hover,
button.btn-primary:hover,
button.mainaction:not(#rcmloginsubmit):hover {
    background-color: var(--cw-primary-hover) !important;
    border-color: var(--cw-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -4px var(--cw-btn-glow-hover);
}

.btn-primary:active { transform: translateY(0); }

/* ---- Secondary / outline ---- */
.btn-secondary,
.btn.cancel,
.btn-link,
.ui-dialog .ui-dialog-buttonset .ui-button:not(.btn-primary) {
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius);
    padding: 0.55rem 1rem;
    font-weight: 500;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover,
.btn.cancel:hover,
.btn-link:hover {
    border-color: var(--cw-primary) !important;
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

/* ---- Danger variant ---- */
.btn-danger,
button.btn-danger {
    background-color: var(--cw-danger) !important;
    border-color: var(--cw-danger) !important;
    color: var(--cw-on-primary) !important;
    border-radius: var(--cw-radius);
    font-weight: 500;
}

.btn-danger:hover { filter: brightness(0.95); }

/* =============================================================================
 * Toolbar buttons (.toolbar a.button) – used throughout mail/contacts/settings
 *
 * Elastic renders these as narrow icon-only buttons. We give them a friendlier
 * hit area + cloudweb hover tint. The icon stays from elastic's icon font.
 * ============================================================================= */

body:not(.task-login) .toolbar a.button {
    border-radius: var(--cw-radius);
    color: var(--cw-ink-2);
    transition: background-color 0.12s ease, color 0.12s ease;
    padding: 6px 10px;
    font-weight: 500;
}

body:not(.task-login) .toolbar a.button::before {
    color: currentColor;
}

body:not(.task-login) .toolbar a.button:not(.disabled):hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

body:not(.task-login) .toolbar a.button.disabled {
    color: var(--cw-muted-2);
    opacity: 0.6;
    cursor: not-allowed;
}

body:not(.task-login) .toolbar a.button.selected,
body:not(.task-login) .toolbar a.button.active {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

/* Dropdown caret next to a split-button */
body:not(.task-login) .toolbar .dropbutton > .dropdown {
    color: var(--cw-muted);
    padding: 6px 4px;
    border-radius: var(--cw-radius);
    transition: background-color 0.12s ease, color 0.12s ease;
}

body:not(.task-login) .toolbar .dropbutton > .dropdown:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

/* Spacer */
body:not(.task-login) .toolbar .spacer {
    background: var(--cw-border-soft);
    width: 1px;
    margin: 6px 8px;
}

/* =============================================================================
 * Formbuttons row (at bottom of settings forms, compose, etc)
 * ============================================================================= */
body:not(.task-login) .formbuttons,
body:not(.task-login) .formbuttons-cancel-submit {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 18px;
    background: var(--cw-card);
    border-top: 1px solid var(--cw-border);
}

/* ===== _forms.css ===== */
/* =============================================================================
 * Form controls – inputs, selects, textareas, switches, checkboxes.
 * Scope is post-login UI; login inputs are restyled in _login.css.
 * ============================================================================= */

input:focus, textarea:focus, select:focus,
.form-control:focus, .custom-select:focus {
    border-color: var(--cw-primary) !important;
    box-shadow: var(--cw-ring) !important;
    outline: none;
}

.custom-switch .custom-control-input:checked ~ .custom-control-label::before,
input[type="checkbox"]:checked,
.pretty input:checked ~ .state label::before {
    background-color: var(--cw-primary) !important;
    border-color: var(--cw-primary) !important;
}

.form-control, .custom-select,
input[type="text"], input[type="email"],
input[type="password"], input[type="search"], textarea {
    border-radius: var(--cw-radius);
    border-color: var(--cw-border);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* ===== _layout.css ===== */
/* =============================================================================
 * App chrome – #layout shell, task rail, sidebars, per-pane headers, scrollbars.
 *
 * Elastic DOM we target (post-login):
 *   #layout
 *     #layout-menu            – left task rail (brand + task buttons)
 *       #taskmenu             – the button strip inside it
 *     #layout-sidebar         – mid-left (folder list / directory tree)
 *       .header               – pane header (title + actions)
 *       .scroller             – content
 *     #layout-list            – middle (message list / record list)
 *       .header               – toolbar
 *       #messagelist-content  – list body
 *     #layout-content         – right (preview / iframe)
 *       .header               – toolbar (mailtoolbar etc)
 *
 * Phase 2 scope: make the chrome feel like cloudweb.sk. Per-pane widgets
 * (message list rows, folder tree, toolbar dropdowns) get their own
 * passes in Phases 3 / 5 / 6.
 * ============================================================================= */

/* ---- Reset body chrome to cloudweb bg (elastic defaults to a grey) --- */
body:not(.task-login) {
    background: var(--cw-bg) !important;
    color: var(--cw-ink);
    font-feature-settings: 'ss01', 'cv11';
}

body:not(.task-login) #layout {
    background: var(--cw-bg);
    gap: 0;
}

/* =============================================================================
 * Task rail (#layout-menu / #taskmenu) – the left app rail
 *
 * Goals:
 *   - Narrow vertical column, white card, clean separation from content
 *   - Brand logo pinned to the top
 *   - Task buttons: icon + label stacked, 72px tall, generous tap target
 *   - Active state: primary-50 pill bg, primary icon + label
 *   - Hover: primary-50 with slight lift
 * ============================================================================= */

body:not(.task-login) #layout-menu {
    background: var(--cw-card) !important;
    border-right: 1px solid var(--cw-border);
    box-shadow: none !important;
    /* Elastic narrows the rail below ~1080px; our buttons are sized for 80px
     * and would hang over the pane next to it. */
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    display: flex;
    flex-direction: column;
    padding: 14px 5px 18px;
    gap: 12px;
}

/* Brand logo at the top of the rail.
 * Elastic ships a dark background on .popover-header (used as the mobile
 * drawer header) – force light here. !important is required because the
 * elastic rule is specific enough to win otherwise. */
body:not(.task-login) #layout-menu .popover-header {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 6px 0 14px !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    color: var(--cw-ink) !important;
    min-height: auto !important;
    position: static !important;
}

body:not(.task-login) #layout-menu .popover-header > * {
    background: transparent !important;
}

/* Elastic hides every anchor in the popover-header above 480px (that is how
 * it drops the drawer's close button on desktop), so the link wrapping the
 * logo needs !important to survive. */
body:not(.task-login) #layout-menu .popover-header .cw-logo-link {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: var(--cw-radius);
    transition: opacity 0.15s ease;
}

body:not(.task-login) #layout-menu .popover-header .cw-logo-link:hover { opacity: 0.75; }

/* The <img id="logo"> src is overridden to our SVG via meta.json logos map,
 * so we just size it consistently here – no background-image overlay (that
 * caused a duplicate logo layered on top of the <img>). */
body:not(.task-login) #layout-menu .popover-header #logo,
body:not(.task-login) #layout-menu .popover-header img.logo {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    display: block !important;
    object-fit: contain;
    filter: none;
}

/* Close button only visible on mobile drawer – hide on desktop rail */
body:not(.task-login) #layout-menu .popover-header .button.cancel {
    display: none;
}

/* The #taskmenu itself becomes a vertical button stack */
body:not(.task-login) #taskmenu {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    width: 100% !important;
    gap: 4px;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    box-shadow: none;
    height: auto;
    flex: 1 1 auto;
    overflow: visible;
}

body:not(.task-login) #taskmenu .action-buttons,
body:not(.task-login) #taskmenu .special-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;  /* elastic sets .special-buttons absolute */
    background: transparent !important;
    background-color: transparent !important;
    width: auto !important;
    left: auto !important;
    bottom: auto !important;
}

body:not(.task-login) #taskmenu .special-buttons {
    margin-top: auto !important;
    padding-top: 12px !important;
    border-top: 1px solid var(--cw-border-soft);
}

/* Elastic paints .action-buttons children cyan via
 * `#taskmenu .action-buttons a { color: #37beff }` – override so Compose
 * stays white on blue (matching our FAB treatment). Also wipe any stray
 * colours elastic sets on non-compose rail buttons. */
body:not(.task-login) #taskmenu .action-buttons a.compose,
body:not(.task-login) #taskmenu .action-buttons a.compose:hover,
body:not(.task-login) #taskmenu .action-buttons a.compose:focus {
    color: var(--cw-on-primary) !important;
}
body:not(.task-login) #taskmenu .action-buttons a.compose::before {
    color: var(--cw-on-primary) !important;
}

/* Elastic gives logout red via `#taskmenu a.logout { color:#ff5552!important }`
 * – we want logout subtle muted until hover, then danger. */
body:not(.task-login) #taskmenu a.logout,
body:not(.task-login) #taskmenu a.logout:focus {
    color: var(--cw-muted) !important;
}
body:not(.task-login) #taskmenu a.logout::before {
    color: inherit !important;
}

/* Task button base – icon + label stacked, square-ish pill.
 * !important throughout because elastic ships strong default rules on
 * `.menu a.button`, `.toolbar a.button` and their `.selected` variants,
 * and our skin inherits elastic's CSS via @import – we MUST win. */
body:not(.task-login) #taskmenu a {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 68px !important;
    min-width: 68px !important;
    max-width: 68px !important;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    margin: 0 auto !important;
    padding: 8px 2px !important;
    background: transparent !important;
    color: var(--cw-muted) !important;
    border: 1px solid transparent !important;
    border-radius: var(--cw-radius) !important;
    text-decoration: none !important;
    line-height: 1 !important;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    box-shadow: none !important;
    font-weight: 500 !important;
    text-shadow: none !important;
    overflow: hidden;
}

/* Elastic renders button icons via ::before pseudo-element with an icon font.
 * Size it consistently, colour via currentColor, and – critically – nuke the
 * dark background circle elastic draws around the glyph in its default menu
 * styling. Every geometry prop needs !important or one elastic selector
 * further sneaks in a padding + dark bg. */
body:not(.task-login) #taskmenu a::before {
    font-size: 1.25rem !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    color: inherit !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    line-height: 1 !important;
}

/* The inner span is the label text – keep small and legible */
body:not(.task-login) #taskmenu a .inner {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: inherit;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Hover */
body:not(.task-login) #taskmenu a:not(.compose):hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    border-color: transparent !important;
}

/* Active / selected (e.g. current task) – subtle light-blue pill.
 * MUST use !important + not(.compose) so it never applies the light
 * treatment to the compose FAB (compose can get a .selected class too
 * when action=compose). */
body:not(.task-login) #taskmenu a.selected:not(.compose),
body:not(.task-login) #taskmenu a.selected:not(.compose):hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    border-color: var(--cw-primary-100) !important;
    font-weight: 600 !important;
}

body:not(.task-login) #taskmenu a.selected:not(.compose)::before {
    color: var(--cw-primary) !important;
}

/* Compose FAB gets primary filled treatment – always deep-blue */
body:not(.task-login) #taskmenu a.compose,
body:not(.task-login) #taskmenu a.compose.selected {
    background: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border-color: transparent !important;
    box-shadow: 0 1px 2px var(--cw-btn-glow),
                inset 0 1px 0 var(--cw-hilite) !important;
}

body:not(.task-login) #taskmenu a.compose::before {
    color: var(--cw-on-primary) !important;
}

body:not(.task-login) #taskmenu a.compose:hover {
    background: var(--cw-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -4px var(--cw-btn-glow-hover),
                inset 0 1px 0 var(--cw-hilite-strong);
}

/* Logout button: keep subtle but with a gentle danger hint on hover */
body:not(.task-login) #taskmenu a.logout:hover {
    background: var(--cw-danger-soft);
    color: var(--cw-danger-ink);
}

body:not(.task-login) #taskmenu a.logout:hover::before {
    color: var(--cw-danger-ink) !important;
}

/* =============================================================================
 * Per-pane containers: #layout-sidebar / #layout-list / #layout-content
 *
 * Keep them flush (no outer gap) so the chrome looks like one continuous
 * surface. Each gets a subtle right border to delineate from its neighbour.
 * ============================================================================= */

body:not(.task-login) #layout-sidebar,
body:not(.task-login) #layout-list {
    background: var(--cw-card);
    border-right: 1px solid var(--cw-border);
    box-shadow: none;
}

body:not(.task-login) #layout-content {
    background: var(--cw-bg);
}

/* Per-pane header – consistent across sidebar/list/content */
body:not(.task-login) #layout-sidebar > .header,
body:not(.task-login) #layout-list > .header,
body:not(.task-login) #layout-content > .header {
    background: var(--cw-card);
    border-bottom: 1px solid var(--cw-border);
    padding: 10px 14px;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: none;
}

body:not(.task-login) #layout-sidebar > .header .header-title,
body:not(.task-login) #layout-list > .header .header-title,
body:not(.task-login) #layout-content > .header .header-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cw-ink);
    letter-spacing: -0.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The inner .toolbar / .toolbar.menu inside a pane header must lay out
 * horizontally. Elastic's default `.menu` class is a vertical list – we
 * override it to an inline flex row with consistent spacing. */
body:not(.task-login) #layout-sidebar > .header .toolbar,
body:not(.task-login) #layout-list > .header .toolbar,
body:not(.task-login) #layout-content > .header .toolbar,
body:not(.task-login) .header > .toolbar.menu {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 2px;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    list-style: none;
}

/* Tidy the standalone buttons dropped next to a .toolbar inside .header
 * (e.g. refresh, overflow "…") so they line up with the toolbar row. */
body:not(.task-login) .header > a.button.icon:not(.back-list-button):not(.back-sidebar-button):not(.task-menu-button):not(.toolbar-menu-button):not(.toolbar-list-button):not(.sidebar-menu) {
    flex: 0 0 auto;
    align-self: center;
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* The "back to list / sidebar / menu" mobile affordances only want to
 * show at narrow widths – elastic already handles this, we just make
 * sure they don't push other toolbar items offscreen on desktop. */
body:not(.task-login) .header > a.back-list-button,
body:not(.task-login) .header > a.back-sidebar-button,
body:not(.task-login) .header > a.task-menu-button,
body:not(.task-login) .header > a.toolbar-menu-button {
    flex: 0 0 auto;
}

/* Toolbar dropdown carets sit tight against their split-button parent */
body:not(.task-login) .header .dropbutton {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

body:not(.task-login) .formcontent,
body:not(.task-login) .box-inner,
body:not(.task-login) .contentbox {
    background: var(--cw-card);
}

/* elastic paints these white from `#layout > div > .footer`, which carries an
 * id and so outranks a plain class selector. */
body:not(.task-login) .footer,
body:not(.task-login) .pagenav,
#layout > div > .footer,
#layout > div > .pagenav {
    background: var(--cw-card);
    border-top: 1px solid var(--cw-border);
    box-shadow: none;
}

body:not(.task-login) .quota-widget { color: var(--cw-muted); }

body:not(.task-login) .quota-widget .bar {
    background-color: var(--cw-bg-soft);
    border-color: var(--cw-border);
}

body:not(.task-login) .quota-widget .value { background-color: var(--cw-primary); }
body:not(.task-login) .quota-widget .value.warning { background-color: var(--cw-danger); }

body:not(.task-login) .pagenav .rcpagejumper,
#layout > div > .pagenav input.rcpagejumper {
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border);
    color: var(--cw-ink);
    border-radius: var(--cw-radius-sm);
}

/* =============================================================================
 * Scrollbars – thin cloudweb-toned
 * ============================================================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--cw-scroll-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--cw-scroll-thumb-hover); }

* {
    scrollbar-width: thin;
    scrollbar-color: var(--cw-scroll-thumb) transparent;
}

/* Touch devices get the platform scrollbar back – a 8px custom thumb is
 * unusable with a finger and elastic already suppresses its own there. */
html.touch ::-webkit-scrollbar { width: auto; height: auto; }
html.touch * { scrollbar-width: auto; }

/* =============================================================================
 * The #layout-sidebar / #layout-list list-style containers
 * (will be populated further in Phase 3 / 5 for mail + contacts)
 * ============================================================================= */

body:not(.task-login) #layout-sidebar .listbox,
body:not(.task-login) #layout-list .listbox {
    background: transparent;
    border: 0;
}

body:not(.task-login) .scroller {
    background: transparent;
}

/* =============================================================================
 * Print
 * ============================================================================= */
@media print {
    #taskmenu, #layout-menu, .header.toolbar, .footer, #layout-sidebar {
        display: none !important;
    }
}

/* =============================================================================
 * Content frame (iframes used by message preview / settings)
 * ============================================================================= */
body:not(.task-login) iframe.contentframe,
body:not(.task-login) #messagecontframe,
body:not(.task-login) #preferences-frame,
body:not(.task-login) #contact-frame {
    background: var(--cw-card);
    border: 0;
}

/* =============================================================================
 * Pane header toolbar – icon + label buttons (Select / Threads / Options /
 * Refresh; Reply / Reply all / Forward / Delete / Mark / More).
 *
 * Elastic default renders these as tall icon-above-label blocks with inconsistent
 * padding. We flatten them to compact 44px-tall buttons with a tight icon+label
 * stack and cloudweb hover/active tints.
 * ============================================================================= */

body:not(.task-login) .header .toolbar a.button,
body:not(.task-login) .header > a.button.icon:not(.back-list-button):not(.back-sidebar-button):not(.task-menu-button):not(.toolbar-menu-button):not(.toolbar-list-button):not(.sidebar-menu) {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    min-width: 52px !important;
    height: 44px !important;
    padding: 4px 8px !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: var(--cw-radius) !important;
    color: var(--cw-muted) !important;
    text-decoration: none !important;
    line-height: 1 !important;
    font-size: 0.6875rem !important;
    font-weight: 500 !important;
    box-shadow: none !important;
    transition: background 0.12s ease, color 0.12s ease;
}

body:not(.task-login) .header .toolbar a.button::before,
body:not(.task-login) .header > a.button.icon::before {
    font-size: 1rem !important;
    line-height: 1 !important;
    color: inherit !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
}

body:not(.task-login) .header .toolbar a.button .inner,
body:not(.task-login) .header > a.button.icon .inner {
    display: inline-block !important;
    font-size: 0.6875rem !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    color: inherit !important;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

body:not(.task-login) .header .toolbar a.button:not(.disabled):hover,
body:not(.task-login) .header > a.button.icon:not(.disabled):hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

body:not(.task-login) .header .toolbar a.button.active,
body:not(.task-login) .header .toolbar a.button.selected {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

body:not(.task-login) .header .toolbar a.button.disabled,
body:not(.task-login) .header > a.button.icon.disabled {
    color: var(--cw-muted-2) !important;
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

/* Kebab-style icon-only buttons in pane headers: no visible label, compact
 * circle hit area. Includes the folder actions dropdown, the popover-header
 * close button (shown only on mobile drawer), etc. */
body:not(.task-login) .header > a.button.icon.sidebar-menu,
body:not(.task-login) #layout-menu .popover-header .button.icon.cancel {
    min-width: 36px !important;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: var(--cw-radius) !important;
    color: var(--cw-muted) !important;
    flex: 0 0 auto !important;
}

body:not(.task-login) .header > a.button.icon.sidebar-menu:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

/* Voice-only: hide the .inner label text but keep it accessible to screen
 * readers. Applied to all pure icon buttons where the glyph is the entire
 * meaning (kebab menus, back arrows, menu togglers). */
body:not(.task-login) .header > a.button.icon.sidebar-menu > .inner,
body:not(.task-login) .header > a.back-list-button > .inner,
body:not(.task-login) .header > a.back-sidebar-button > .inner,
body:not(.task-login) .header > a.task-menu-button > .inner,
body:not(.task-login) .header > a.toolbar-menu-button > .inner,
body:not(.task-login) #layout-menu .popover-header .button.icon.cancel > .inner {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    padding: 0 !important;
    margin: -1px !important;
    border: 0 !important;
}

/* Close button inside popover-header: only shows on mobile drawer. Hide on
 * desktop so the logo sits centred and clean. */
@media (min-width: 768px) {
    body:not(.task-login) #layout-menu .popover-header .button.icon.cancel {
        display: none !important;
    }
}

/* =============================================================================
 * Panel link ("Nastavenia účtu" / "Účet") – custom entry we added to the
 * task rail in templates/includes/menu.html. Gets the same visual treatment
 * as a regular rail button but with a subtle tint to distinguish it.
 * ============================================================================= */
body:not(.task-login) #taskmenu a.panel {
    color: var(--cw-ink-2) !important;
}

body:not(.task-login) #taskmenu a.panel::before {
    content: "\f013" !important; /* cog icon */
    font-family: "Icons" !important;
    font-weight: 900 !important;
    font-size: 1.25rem !important;
}

body:not(.task-login) #taskmenu a.panel:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

/* ===== _toolbar.css ===== */
/* =============================================================================
 * Toolbars – the action bars above lists (mail list, contact list, message
 * preview). Elastic ships them as `.toolbar` rows with `.button` children.
 * We skin them as flat 44px bars with chip-style buttons grouped tight.
 * Search is treated specially as a pill input that sits inline with the
 * toolbar buttons.
 * ============================================================================= */

/* Pane header – elastic's `.header` div above each pane (list, preview, etc).
 *
 * Design: icon+label stacked vertically inside every action button, all icons
 * the same size, all labels the same size. The pane header grows to 60px tall
 * to fit the stack comfortably; the inner list title sits on the left. */
#layout .header,
.header.toolbar {
    background: var(--cw-card) !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    border-top: 0 !important;
    box-shadow: none !important;
    min-height: 60px !important;
    padding: 4px 10px !important;
    display: flex !important;
    align-items: center !important;
    gap: 2px;
}

/* Toolbar row label / heading on the left */
#layout .header .header-title,
.header.toolbar .header-title {
    color: var(--cw-ink) !important;
    font-size: 0.92rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.005em;
    margin: 0 12px 0 4px;
    flex: 0 0 auto;
}

/* The <ul class="toolbar"> list inside the header – flex row, no bullets.
 *
 * This is what un-hides the toolbar elastic parked in a popupmenu. It is
 * deliberately gated at 769px: below that the header cannot fit the tiles and
 * the actions belong in the popover behind `a.toolbar-menu-button`. */
@media (min-width: 769px) {
    .header ul.toolbar,
    #layout .header ul.toolbar {
        display: inline-flex !important;
        align-items: stretch;
        list-style: none;
        margin: 0;
        padding: 0;
        gap: 0;
        flex: 1 1 auto;
        min-width: 0;
    }
}

.header ul.toolbar > li {
    display: inline-flex;
    align-items: stretch;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* =============================================================================
 *  Stacked icon + label buttons in the pane header toolbar.
 *
 *  Every action (compose, reply, reply-all, forward, delete, mark, more …) is
 *  rendered as a 56×52px tile with the icon on top and a Slovak label below.
 *  All icons share one font-size (1.05rem); all labels share one (0.68rem)
 *  so the bar reads as a grid of uniform tiles, not a ragged row.
 *
 *  Selector scope: only the pane-header toolbar. We intentionally do NOT
 *  match popupmenu entries (which are rendered as plain rows in menus) or
 *  non-header toolbars.
 * ============================================================================= */
.header .toolbar > li > a,
.header .toolbar > li > .dropbutton > a,
#layout .header .toolbar > li > a,
#layout .header .toolbar > li > .dropbutton > a,
.header > a.button.icon:not(.back-list-button):not(.back-sidebar-button):not(.task-menu-button):not(.toolbar-menu-button):not(.toolbar-list-button):not(.sidebar-menu),
#layout .header > a.button.icon:not(.back-list-button):not(.back-sidebar-button):not(.task-menu-button):not(.toolbar-menu-button):not(.toolbar-list-button):not(.sidebar-menu) {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    min-width: 56px;
    height: 52px;
    padding: 4px 6px !important;
    margin: 0 !important;
    background: transparent !important;
    color: var(--cw-ink-2) !important;
    border: 1px solid transparent !important;
    border-radius: var(--cw-radius-sm) !important;
    font-family: var(--cw-sans);
    font-size: 0.68rem !important;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    box-shadow: none !important;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* Shared icon size for every button in the pane header */
.header .toolbar > li > a:before,
.header .toolbar > li > .dropbutton > a:before,
#layout .header .toolbar > li > a:before,
#layout .header .toolbar > li > .dropbutton > a:before,
.header > a.button.icon:before,
#layout .header > a.button.icon:before {
    font-size: 1.05rem !important;
    color: var(--cw-muted) !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    float: none !important;
    background: transparent !important;
    transition: color 0.12s ease;
}

/* Restore the label (span.inner) – render it below the icon.
 * Elastic's default inside .iconized toolbars is `display:none`. Our earlier
 * override made it sr-only. Now we flip it back on for pane-header toolbars
 * specifically, matching the "icon on top, text below" requirement. */
.header .toolbar > li > a > span.inner,
.header .toolbar > li > .dropbutton > a:not(.dropdown) > span.inner,
#layout .header .toolbar > li > a > span.inner,
#layout .header .toolbar > li > .dropbutton > a:not(.dropdown) > span.inner {
    position: static !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
    font-size: 0.68rem !important;
    font-weight: 500 !important;
    line-height: 1.1 !important;
    color: inherit !important;
    white-space: nowrap;
    text-align: center;
    letter-spacing: 0;
    text-transform: none;
    /* In a narrow list pane the tile is thinner than its label; degrade to an
     * ellipsis instead of slicing the last glyph in half. */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dropbutton pair (reply-all + chevron, forward + chevron).
 * Keep as a horizontal pair: the main action tile on the left, a thin
 * chevron strip on the right. Both sit inside the same flex row. */
.header .toolbar .dropbutton,
#layout .header .toolbar .dropbutton {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 0;
    border-radius: var(--cw-radius-sm) !important;
    overflow: hidden;
}

.header .toolbar .dropbutton > a.dropdown,
#layout .header .toolbar .dropbutton > a.dropdown {
    min-width: 16px !important;
    width: 16px !important;
    padding: 4px 2px !important;
    margin: 0 !important;
    flex-direction: column !important;
}
.header .toolbar .dropbutton > a.dropdown > span.inner,
#layout .header .toolbar .dropbutton > a.dropdown > span.inner {
    /* The dropdown anchor's label is redundant with the main button's label */
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}
.header .toolbar .dropbutton > a.dropdown:before,
#layout .header .toolbar .dropbutton > a.dropdown:before {
    font-size: 0.7rem !important;
}

/* Hover (exclude disabled) */
.header .toolbar > li > a:not(.disabled):hover,
.header .toolbar > li > .dropbutton:not(.disabled) > a:not(.disabled):hover,
#layout .header .toolbar > li > a:not(.disabled):hover,
#layout .header .toolbar > li > .dropbutton:not(.disabled) > a:not(.disabled):hover,
.header > a.button.icon:not(.disabled):hover,
#layout .header > a.button.icon:not(.disabled):hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
.header .toolbar > li > a:not(.disabled):hover:before,
.header .toolbar > li > .dropbutton:not(.disabled) > a:not(.disabled):hover:before,
#layout .header .toolbar > li > a:not(.disabled):hover:before,
#layout .header .toolbar > li > .dropbutton:not(.disabled) > a:not(.disabled):hover:before {
    color: var(--cw-primary) !important;
}

/* Active / aria-expanded popover open */
.header .toolbar > li > a.active[aria-expanded="true"],
.header .toolbar > li > a.selected,
#layout .header .toolbar > li > a.active[aria-expanded="true"] {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

/* Disabled */
.header .toolbar > li > a.disabled,
.header .toolbar > li > .dropbutton.disabled > a,
.header .toolbar > li > .dropbutton > a.disabled,
#layout .header .toolbar > li > a.disabled,
#layout .header .toolbar > li > .dropbutton.disabled > a {
    opacity: 0.42 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Spacer between button groups (the `.spacer` li) – vertical divider. */
.header .toolbar > li.spacer,
#layout .header .toolbar > li.spacer {
    width: 1px !important;
    min-width: 1px;
    height: 30px;
    background: var(--cw-border);
    margin: 0 6px;
    align-self: center;
}

/* Mobile-only buttons in the iconized toolbar. Hide them on desktop so the
 * bar doesn't render Výber / Konverzácie / Možnosti chips next to the real
 * actions. */
.header .toolbar > li > a.hidden-big,
.header .toolbar > li > a.hidden-large,
#layout .header .toolbar > li > a.hidden-big,
#layout .header .toolbar > li > a.hidden-large {
    display: none !important;
}

/* The toolbar hamburger is hidden from 769px up in _layout.css, where the
 * rest of the header-visibility rules live. Below that it is the only way to
 * reach the actions, so it stays. */

/* Back button on mobile (Dozadu) – hidden on desktop via elastic's inline
 * style; keep our stacked styles consistent if ever shown. */
.header > a.button.back-list-button > span.inner {
    position: static !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    overflow: visible !important;
    font-size: 0.68rem !important;
    font-weight: 500 !important;
    color: inherit !important;
}

/* Voice-only sr-only text */
.toolbar .voice,
.header .voice {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* Search bar – flat rectangular input inline with the toolbar.
 *
 * Structure (elastic):
 *   .searchbar
 *     form
 *       &:before – leading magnifier icon (font-icon)
 *       label.voice (sr-only)
 *       input
 *     a.reset          – hidden by default, revealed by .searchbar.active
 *     a.unread         – toggle unread-only
 *     a.options        – dropdown chevron
 *     a.search         – hidden by default (submit via Enter)
 *
 * We carefully keep elastic's `display: none` on .reset + .search by NOT
 * forcing display on every `a.button` – we only set display on the buttons
 * that should be shown. */
/* Elastic parks the bar as a direct child of #layout-list, spanning the pane
 * between the header and the list. Nothing else in the chrome is a framed
 * box, so a bordered field there reads as a stray form input – it is a flush
 * row with a hairline under it instead, and only tints on focus. */
.searchbar,
#searchbar,
form.searchbar,
.searchbar.menu {
    display: flex !important;
    align-items: center !important;
    gap: 2px;
    margin: 0 !important;
    padding: 0 8px 0 0 !important;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--cw-border-soft);
    border-radius: 0 !important;
    height: 42px;
    flex: 0 0 auto;
    overflow: visible !important;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.searchbar:focus-within,
#searchbar:focus-within {
    background: var(--cw-bg-soft);
    border-bottom-color: var(--cw-primary);
}

/* Where elastic keeps it inline with the toolbar tiles it is one control among
 * several, so there it stays a field and has to be able to give way. */
.header > .searchbar,
.header > #searchbar {
    flex: 1 1 150px;
    min-width: 150px;
    max-width: 320px;
    height: 34px;
    margin: 0 4px !important;
    padding: 0 4px 0 0 !important;
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius) !important;
}

.header > .searchbar:focus-within,
.header > #searchbar:focus-within {
    background: var(--cw-card);
    border-color: var(--cw-primary);
    box-shadow: var(--cw-ring);
}

/* Form wraps the leading magnifier `:before` + input – make it a flex row so
 * both line up vertically in the center of the bar. */
.searchbar > form,
#searchbar > form {
    display: flex !important;
    align-items: center !important;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    margin: 0;
}

/* Leading search icon (elastic's `.searchbar form:before`). Align vertically. */
.searchbar > form:before,
#searchbar > form:before {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 20px !important;
    height: 100% !important;
    margin: 0 6px 0 10px !important;
    font-size: 0.9rem !important;
    line-height: 1 !important;
    color: var(--cw-muted) !important;
}

.searchbar input,
#searchbar input,
.searchbar > .searchfield {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    height: 100% !important;
    line-height: normal !important;
    padding: 0 6px !important;
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--cw-sans);
    font-size: 0.85rem;
    color: var(--cw-ink) !important;
    outline: none !important;
}

.searchbar input::placeholder {
    color: var(--cw-muted-2);
    line-height: inherit;
}

/* sr-only labels inside the searchbar */
.searchbar .voice,
.searchbar > h2.voice,
.searchbar label.voice {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

/* Trailing action buttons. Do NOT use `display: inline-flex !important` on
 * every `a.button` – that would override elastic's `display: none` on the
 * normally-hidden .reset + .search buttons. Instead, target the always-shown
 * buttons explicitly (.unread + .options), and let elastic's own
 * `.searchbar.active a.reset { display: inline }` reveal the X when a query
 * is active. */
.searchbar a.button.unread,
.searchbar a.button.options,
.searchbar.active a.button.reset {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-muted) !important;
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}
.searchbar a.button:before {
    line-height: 1 !important;
    margin: 0 !important;
    font-size: 0.88rem !important;
    width: auto !important;
    height: auto !important;
}
.searchbar a.button:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
.searchbar a.button.selected {
    color: var(--cw-on-tint) !important;
    background: var(--cw-primary-50) !important;
}

/* Pagination block on the right of toolbar */
/* The pager sits at the end of a header row. `.pagenav-list` is the same class
 * on a full-width bar in the pane column, where margin-left:auto would
 * shrink-wrap it to the right edge. */
.pagenav {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--cw-muted);
    font-size: 0.78rem;
    font-family: var(--cw-mono);
    margin-left: auto;
}

.pagenav.pagenav-list { margin-left: 0; }

.pagenav .countdisplay,
.pagenav .pagenav-text {
    color: var(--cw-muted);
    padding: 0 8px;
    font-variant-numeric: tabular-nums;
}

.pagenav a.button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0 !important;
    border-radius: var(--cw-radius-sm) !important;
}

/* Mode switch (list/threads, etc.) */
.toolbar a.button.dropdown-toggle:after,
.toolbar a.button.dropbtn:after {
    margin-left: 4px;
    color: var(--cw-muted-2);
    font-size: 0.75em;
}

/* Floating-action-button (FAB) on mobile compose – defer to mobile partial */

/* ===== _treelist.css ===== */
/* =============================================================================
 * Tree list – folder tree in mail, directory tree in contacts, section list
 * in settings. Elastic renders these as `<ul class="treelist listing">` with
 * nested `<ul>` for depth. We preserve structure but re-skin rows as compact
 * 32px pills with primary-50 active state and chip-style unread counts.
 * ============================================================================= */

/* Tree list shell – unified padding, transparent background */
ul.treelist,
ul.listing.iconized {
    padding: 6px 6px !important;
    background: transparent;
    font-family: var(--cw-sans);
}

ul.treelist li,
ul.listing.iconized li {
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative;
}

/* Row link – 32px compact pill */
ul.treelist li > a,
ul.treelist li > div > a,
ul.listing.iconized li > a {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-height: var(--cw-tree-row-h);
    line-height: 1.2;
    padding: 0 10px !important;
    margin: 1px 0;
    border-left: 0 !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-ink-2) !important;
    font-size: var(--cw-tree-font);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* Icon sizing in tree rows */
ul.treelist li > a:before,
ul.treelist li > div > a:before,
ul.listing.iconized li > a:before {
    font-size: 0.95rem !important;
    width: 1.1em !important;
    height: auto !important;
    margin-right: 2px !important;
    color: var(--cw-muted-2);
    flex: 0 0 auto;
}

/* Hover state */
ul.treelist li > a:hover,
ul.treelist li > div > a:hover,
ul.listing.iconized li > a:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
ul.treelist li > a:hover:before,
ul.listing.iconized li > a:hover:before {
    color: var(--cw-primary) !important;
}

/* Selected state – primary-50 background, ink text, primary icon */
ul.treelist li.selected > a,
ul.treelist li.selected > div > a,
/* elastic tints the row itself, which shows as a light ring around the anchor
 * that carries our own selected fill. */
ul.listing li.selected,
ul.listing.iconized li.selected {
    background: var(--cw-primary-50);
}

ul.listing.iconized li.selected > a {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    font-weight: 600;
    border-left: 0 !important;
}
ul.treelist li.selected > a:before,
ul.listing.iconized li.selected > a:before {
    color: var(--cw-primary) !important;
}

/* Focus indicator – replace elastic's left border with a soft ring */
html:not(.touch) ul.treelist li > a:focus,
html:not(.touch) ul.listing.iconized li > a:focus {
    border-left: 0 !important;
    outline: 0;
    box-shadow: var(--cw-ring);
}

/* Tree toggle chevrons – smaller, muted */
ul.treelist li div.treetoggle {
    width: 1.1em !important;
    top: 4px !important;
    left: 2px !important;
    color: var(--cw-muted-2);
}
ul.treelist li div.treetoggle:before {
    font-size: 0.7rem !important;
    color: var(--cw-muted-2);
}

/* Indent nested levels – elastic uses multiplicative padding-left */
ul.treelist ul {
    padding-left: 14px !important;
    border-top: 0 !important;
}

/* Folder unread count chip – compact pill on the right */
.folderlist li.mailbox .unreadcount,
ul.treelist li.mailbox .unreadcount {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    margin: 0 !important;
    padding: 2px 7px !important;
    min-width: 20px;
    height: 18px;
    line-height: 14px !important;
    border-radius: 999px !important;
    background: var(--cw-bg-soft) !important;
    color: var(--cw-ink-2) !important;
    font-family: var(--cw-mono);
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    text-align: center;
    border: 1px solid var(--cw-border);
}

/* Selected mailbox unread count – primary tint */
.folderlist li.mailbox.selected .unreadcount,
ul.treelist li.mailbox.selected .unreadcount {
    background: var(--cw-primary) !important;
    color: var(--cw-on-accent) !important;
    border-color: var(--cw-primary) !important;
}

/* Mailbox with unread mail – primary-colored count */
.folderlist li.mailbox.unread:not(.selected) .unreadcount {
    background: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border-color: var(--cw-primary-deep) !important;
}

/* Reserve right padding on unread rows so count doesn't overlap text */
.folderlist li.mailbox.unread > a {
    padding-right: 3em !important;
}

/* Drop target highlight */
ul.treelist li.droptarget > a,
ul.listing.iconized li.droptarget > a {
    background: var(--cw-primary-100) !important;
    color: var(--cw-on-tint) !important;
    box-shadow: inset 0 0 0 1px var(--cw-primary) !important;
}

/* Recent folder accent – subtle green hint */
.folderlist li.mailbox.recent > a {
    color: var(--cw-ink) !important;
}
.folderlist li.mailbox.recent > a > .unreadcount {
    background: var(--cw-success) !important;
    color: var(--cw-on-success) !important;
    border-color: var(--cw-success) !important;
}

/* ===== _listing.css ===== */
/* =============================================================================
 * Generic listings – settings section list, contact list, identities, filters,
 * responses. Mail-specific message list lives in _mail.css; folder/section
 * trees live in _treelist.css.
 * ============================================================================= */

/* Generic table-listing baseline */
table.listing {
    background: var(--cw-card);
    border-collapse: separate;
    border-spacing: 0;
}

table.listing tbody td {
    background: transparent !important;
    border-left: 0 !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    padding: var(--cw-list-row-pad) 12px !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.86rem;
    line-height: 1.4;
    vertical-align: middle;
}

table.listing tbody tr:hover td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

table.listing tbody tr.selected td,
table.listing tbody tr.focused.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
    font-weight: 500;
}

table.listing tbody tr.disabled td {
    color: var(--cw-muted-2) !important;
    font-style: italic;
}

/* Iconized-rows (settings sections list) – icon precedes label */
.listing.iconized tr td:before,
.listing.iconized tr td.section:before {
    color: var(--cw-muted) !important;
    margin-right: 10px !important;
    font-size: 1rem !important;
}
.listing.iconized tr.selected td:before {
    color: var(--cw-primary) !important;
}

/* Empty-list helper text */
.listing-info {
    color: var(--cw-muted) !important;
    font-weight: 500 !important;
}

/* Generic "unread count" badge (also used by responses, identities, etc) */
.unreadcount {
    background-color: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--cw-mono);
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 6px;
}

/* Contact list – soften default styling, defer rich treatment to _contacts.css */
.contactlist tbody td {
    padding: 10px 12px !important;
}
.contactlist tbody tr.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
.contactlist span.email {
    color: var(--cw-muted) !important;
    font-style: normal;
    font-family: var(--cw-mono);
    font-size: 0.78rem;
}

/* Focus indicator – elastic uses a left border, we soften to a primary tint */
html:not(.touch) .listing.focus tbody tr.focused > td:first-child,
html:not(.touch) .listing.focus:not(.withselection) tbody tr.focused > td.selection + td {
    border-left: 0 !important;
}

/* ===== _mail.css ===== */
/* =============================================================================
 * Mail task – message list rows, preview pane (sticky sender header,
 * attachment chips, body iframe shell) and the compact folder list rail.
 *
 * Elastic ships rich semantics on `.messagelist tr`:
 *   .unread       – not yet opened
 *   .flagged      – user-starred
 *   .deleted      – marked for deletion
 *   .replied / .forwarded – status icons
 *   .selected     – clicked / focused row
 *   tr.thread     – thread parent
 *
 * We keep the table semantics (so JS that walks rows still works) but make
 * each row a 56px Card-y line with a stacked sender + subject/snippet layout.
 * ============================================================================= */

/* ---- Mail layout panes ----------------------------------------------------- */

body.task-mail #layout-list,
body.task-mail #layout-content {
    background: var(--cw-bg) !important;
}

body.task-mail #layout-sidebar {
    background: var(--cw-card) !important;
    border-right: 1px solid var(--cw-border-soft) !important;
}

/* The list pane scroller – soften, no inner border */
body.task-mail #layout-list .scroller,
body.task-mail #layout-content .scroller {
    background: var(--cw-bg) !important;
    border: 0 !important;
}

/* ---- Message list rows ---------------------------------------------------- */

.messagelist {
    background: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

.messagelist tbody tr {
    background: var(--cw-card);
    transition: background-color 0.1s ease;
}

.messagelist tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--cw-border-soft) !important;
}

/* Row cell baseline – ~64px tall to fit a two-line layout (sender+date / subject) */
.messagelist tbody td {
    background: transparent !important;
    padding: var(--cw-msg-row-pad) 6px !important;
    vertical-align: middle !important;
    border-left: 0 !important;
    color: var(--cw-ink-2) !important;
    font-size: var(--cw-msg-from-size) !important;
    line-height: 1.3 !important;
}

/* Selection checkbox column */
.messagelist tbody td.selection {
    width: 36px !important;
    padding-left: 12px !important;
    padding-right: 0 !important;
}

/* Status / threads gutter */
.messagelist tbody td.threads,
.messagelist tbody td.status {
    width: 22px !important;
    padding: 0 !important;
    text-align: center;
}

/* Subject TD packs sender, date, subject, status icon, attachment + size into a
 * single cell (elastic's compact 3-pane mode). Layout intent:
 *   row 1:  [sender ........................ date]
 *   row 2:  [● subject ............................]
 * Achieved with flex-wrap + ordered children. fromto stays flex:1 (not 100%)
 * so the date can ride on the same row, pushed right by margin-left:auto.
 * subject takes its own full row via flex-basis 100%. */
.messagelist tbody td.subject {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: baseline;
    padding: var(--cw-msg-row-pad) 14px var(--cw-msg-row-pad) 10px !important;
    column-gap: 10px;
    row-gap: var(--cw-msg-row-gap);
    overflow: hidden;
    /* `html.layout-phone/.touch .messagelist tr` becomes a flex row, so the
     * subject cell needs to be shrinkable or long subjects push the row wide. */
    flex: 1 1 auto;
    min-width: 0;
}

.messagelist tbody td.subject span.fromto {
    order: 1;
    flex: 1 1 0 !important;
    min-width: 0;
    padding-left: 0 !important;
    padding-right: 0 !important;
    font-size: var(--cw-msg-from-size) !important;
    color: var(--cw-ink) !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messagelist tbody td.subject span.date {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
    font-family: var(--cw-mono) !important;
    font-size: var(--cw-msg-date-size) !important;
    color: var(--cw-muted-2) !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
    line-height: 1.35 !important;
    white-space: nowrap;
}

.messagelist tbody td.subject span.subject {
    order: 3;
    flex: 0 0 100% !important;
    min-width: 0;
    font-size: var(--cw-msg-subject-size) !important;
    color: var(--cw-muted) !important;
    line-height: 1.35 !important;
    font-weight: 400 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Subject row contains an <a> with the actual text – let it ellipsis */
.messagelist tbody td.subject span.subject > a {
    color: inherit !important;
    text-decoration: none !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

/* Size column – elastic puts it inside td.subject; we never show it */
.messagelist tbody td.subject span.size {
    display: none !important;
}

/* Hover state */
.messagelist tbody tr:hover {
    background: var(--cw-primary-50) !important;
}
.messagelist tbody tr:hover td {
    color: var(--cw-ink) !important;
}

/* Selected / focused row – primary tint. Accent bar only on the FIRST cell
 * of the row (td.selection / td.threads) so we get ONE vertical bar at the
 * leftmost edge, not one bar between every column. */
.messagelist tbody tr.selected td,
.messagelist tbody tr.focused.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
.messagelist tbody tr.selected td:first-child,
.messagelist tbody tr.focused.selected td:first-child {
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
}

.messagelist tbody tr.selected td.subject span.fromto,
.messagelist tbody tr.selected td.subject span.subject {
    color: var(--cw-on-tint) !important;
}

/* Unread row – bold sender + subject, single primary bar on leftmost cell */
.messagelist tbody tr.unread td:first-child {
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
}
.messagelist tbody tr.unread td.subject span.fromto,
.messagelist tbody tr.unread td.subject span.subject {
    font-weight: 700 !important;
    color: var(--cw-ink) !important;
}

/* Unread + selected – combine bar with primary tint */
.messagelist tbody tr.unread.selected td {
    background: var(--cw-primary-50) !important;
}
.messagelist tbody tr.unread.selected td:first-child {
    box-shadow: inset 3px 0 0 0 var(--cw-primary-deep);
}

/* Flagged row – warning dot accent */
.messagelist tbody tr.flagged td.subject span.fromto:after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--cw-warning);
    margin-left: 6px;
    vertical-align: middle;
}

/* Deleted / disabled – strikethrough muted */
.messagelist tbody tr.deleted td,
.messagelist tbody tr.deleted td.subject span.fromto,
.messagelist tbody tr.deleted td.subject span.subject {
    color: var(--cw-muted-2) !important;
    text-decoration: line-through;
}

/* Status icon column (replied / forwarded / unread dot) */
.messagelist tbody td.subject span.msgicon.status:before {
    color: var(--cw-muted-2) !important;
    font-size: 0.85rem !important;
}
.messagelist tbody td.subject span.msgicon.status.unread:before {
    color: var(--cw-primary) !important;
}
.messagelist tbody td.subject span.msgicon.status.replied:before,
.messagelist tbody td.subject span.msgicon.status.forwarded:before {
    color: var(--cw-success) !important;
}

/* Attachment paperclip + flag column */
.messagelist tbody td.flags {
    width: 28px !important;
    padding-right: 12px !important;
}
.messagelist tbody td.subject span.attachment span:before {
    color: var(--cw-muted) !important;
    font-size: 0.85rem;
}

/* Flag star – muted off, warning on */
.messagelist tbody td.flags span.flag.flagged:before,
.messagelist tbody td.flags span.flagged:before {
    color: var(--cw-warning) !important;
}
.messagelist tbody td.flags span.unflagged:before {
    color: var(--cw-border) !important;
}
.messagelist tbody tr:hover td.flags span.unflagged:before {
    color: var(--cw-muted-2) !important;
}

/* Thread expand chevron */
.messagelist tbody tr.thread td.threads div:before {
    color: var(--cw-muted) !important;
    font-size: 0.8rem !important;
}

/* Selection checkbox – modern square */
.messagelist tbody td.selection input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--cw-primary);
}

/* Empty list message */
.listing-info {
    color: var(--cw-muted) !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
}

/* List header – ths above the list (sort indicators, etc.) */
.messagelist > thead {
    display: none; /* elastic already hides */
}

#messagelist-header,
.messagelistheader {
    background: var(--cw-card) !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
}

/* Breathing room between the list pane's header (title + searchbar) and the
 * first message row. Elastic stacks the toolbar tight against the list. */
#mailboxcontainer #messagelist,
#messagelist {
    margin-top: 8px;
}

/* The scroller wraps messagelist + header; push the list down from whatever
 * chrome sits above it. */
#layout-list .scroller > .messagelist:first-child,
#layout-list .scroller > table.messagelist {
    margin-top: 6px;
}

/* ---- Message preview pane / standalone message --------------------------- */

#messagecontframe,
#messagepreview {
    background: var(--cw-card) !important;
    border: 0 !important;
}

#message-content {
    background: var(--cw-card);
    padding: var(--cw-read-pad) !important;
}

/* Sticky sender header at top of preview.
 *
 * Layout intent: the header lives inside #message-content which has 32px of
 * padding. When the user scrolls the preview pane, we want the sticky header
 * to break out of that padding so it butts right up against the pane edges –
 * no awkward 32px gap between the pane background and the sticky bar.
 * Negative margins of -32px on top/left/right extend the header flush to the
 * pane. Inner padding of 16px (top + left) keeps the subject and avatar off
 * the very edge of the card. */
#message-header {
    margin: calc(-1 * var(--cw-read-pad)) calc(-1 * var(--cw-read-pad)) 1rem !important;
    padding: 16px !important;
    border-bottom: 1px solid var(--cw-border-soft);
    position: sticky;
    top: calc(-1 * var(--cw-read-pad));
    background: var(--cw-card);
    z-index: 4;
}

#message-header > .subject {
    font-size: 1.4rem !important;
    font-weight: 700 !important;
    color: var(--cw-ink) !important;
    line-height: 1.3 !important;
    margin: 0 0 12px 0 !important;
    letter-spacing: -0.015em;
}

/* Avatar / contact photo */
#message-header > .header img.contactphoto {
    width: 44px !important;
    height: 44px !important;
    border-radius: 999px !important;
    background: var(--cw-primary-50) !important;
    object-fit: cover;
    margin: 0 14px 0 0 !important;
    flex: 0 0 44px;
    box-shadow: inset 0 0 0 1px var(--cw-border);
}

/* Header content alignment */
#message-header .header-content {
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

#message-header .header-content .header-summary {
    margin-top: 0 !important;
    color: var(--cw-muted);
    font-size: 0.84rem;
}

#message-header .header-content .header-summary > span {
    color: var(--cw-ink-2);
}

/* From / To / Cc field rows in details view */
#message-header .header-headers .header-title {
    color: var(--cw-muted) !important;
    font-weight: 500 !important;
    font-size: 0.78rem !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-right: 14px !important;
}

#message-header .header-headers td {
    padding: 4px 0;
    color: var(--cw-ink-2);
    font-size: 0.86rem;
}

/* "Show details / show all headers" links row */
#message-header .header-links {
    margin-top: 12px !important;
}
#message-header .header-links a {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    margin-right: 14px !important;
    padding: 4px 10px;
    border-radius: var(--cw-radius-sm);
    background: var(--cw-bg-soft);
    color: var(--cw-ink-2) !important;
    font-size: 0.78rem !important;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s ease;
}
#message-header .header-links a:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint) !important;
}
#message-header .header-links a:before {
    color: var(--cw-muted) !important;
    font-size: 0.85rem !important;
    height: auto !important;
    line-height: 1 !important;
}

/* Message body container */
#messagebody {
    padding-top: 14px;
    color: var(--cw-ink);
    font-family: var(--cw-sans);
    font-size: 0.95rem;
    line-height: 1.55;
}

/* Plain-text part formatting */
.message-part {
    font-family: var(--cw-mono);
    font-size: 0.875rem;
    color: var(--cw-ink-2);
    white-space: pre-wrap;
}

/* HTML part – give iframe wrapper room to breathe */
.message-htmlpart {
    color: var(--cw-ink);
}

/* Blockquotes – cloudweb subtle left-bar style */
.message-part blockquote,
.message-htmlpart blockquote {
    border-left: 3px solid var(--cw-primary-100) !important;
    border-right: 0 !important;
    background: var(--cw-bg-soft) !important;
    color: var(--cw-ink-2) !important;
    margin: 8px 0 !important;
    padding: 10px 14px !important;
    border-radius: 0 var(--cw-radius-sm) var(--cw-radius-sm) 0;
    font-style: normal;
}

/* Quoted-quotes nesting depths */
.message-part blockquote blockquote {
    border-left-color: var(--cw-border) !important;
    background: var(--cw-card) !important;
}

/* ---- Attachment chip strip ------------------------------------------------ */

#message-content .attachmentslist,
.attachmentslist {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 0 14px 0 !important;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachmentslist li {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    padding: 6px 12px !important;
    background: var(--cw-bg-soft) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: 999px !important;
    line-height: 1.2 !important;
    height: auto !important;
    max-width: 320px;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.attachmentslist li:hover {
    background: var(--cw-primary-50) !important;
    border-color: var(--cw-primary-100) !important;
}

.attachmentslist li:before {
    color: var(--cw-primary) !important;
    font-size: 1rem !important;
    height: auto !important;
    flex: 0 0 auto;
}

.attachmentslist li a.filename {
    padding: 0 !important;
    flex: 1 1 auto;
    overflow: hidden;
}
.attachmentslist li .attachment-name {
    color: var(--cw-ink) !important;
    font-size: 0.82rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}
.attachmentslist li .attachment-size {
    color: var(--cw-muted-2) !important;
    font-family: var(--cw-mono);
    font-size: 0.72rem;
    padding-left: 6px !important;
}

.attachmentslist li a.dropdown:before,
.attachmentslist li a.delete:before,
.attachmentslist li a.cancelupload:before {
    color: var(--cw-muted) !important;
    font-size: 0.85rem;
}

/* ---- Folder list specifics (mailbox tree under sidebar) ------------------ */

#mailboxlist {
    padding: 6px 6px !important;
    background: transparent;
}

/* Boxes – elastic uses divs/headers around the tree */
#folderlist-content,
#mailboxlist-container {
    background: transparent !important;
    border: 0 !important;
}

/* "More folders…" link / treelist footer */
.treelist + .treelist-footer,
.foldermore {
    padding: 8px 10px;
    color: var(--cw-muted);
    font-size: 0.78rem;
}

/* ===== _compose.css ===== */
/* =============================================================================
 * Compose pane – the message-write screen.
 *
 * Elastic structure (preserve all IDs – Roundcube JS binds to them):
 *   #layout-content > .header (toolbar: save/attach/sig/responses/spell/encrypt)
 *   #compose-content > #compose-headers (From/To/Cc/Bcc/Subject rows)
 *   #compose-content > #composebodycontainer > textarea#composebody
 *   #compose-content > .formbuttons (Send + extwin)
 *   #layout-sidebar > #compose-attachments + #compose-options
 *
 * Body editor is currently TinyMCE (will be swapped to TipTap in 4b). For now
 * we style the iframe shell + textarea fallback so the edges feel cloudweb.
 * ============================================================================= */

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

body.task-mail.action-compose #layout-content {
    background: var(--cw-bg) !important;
}

#compose-content.formcontainer {
    background: var(--cw-bg);
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* The composeFormHead object renders an open <form> tag inline; the form
 * itself is invisible so only its descendants matter. */
#compose-content > .formcontent.scroller {
    background: transparent !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    overflow: visible !important;
}

/* ---- Compose headers card ----------------------------------------------- */

#compose-headers {
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    margin: 14px 14px 10px 14px;
    padding: 14px 18px;
}

#compose-headers .compose-headers .form-group.row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 8px 0 !important;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--cw-border-soft);
    padding-bottom: 8px;
}

#compose-headers .compose-headers .form-group.row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0 !important;
}

#compose-headers .compose-headers .form-group.row.hidden {
    display: none !important;
}

/* Field label */
#compose-headers .compose-headers .form-group.row > label.col-form-label {
    flex: 0 0 auto;
    width: 80px !important;
    max-width: 80px;
    padding: 6px 0 !important;
    margin: 0;
    color: var(--cw-muted) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.5;
}

/* Right-side input column */
#compose-headers .compose-headers .form-group.row > .col-10 {
    flex: 1 1 auto;
    max-width: none;
    padding: 0;
}

/* Input group inside each row – flatten Bootstrap's borders */
#compose-headers .input-group {
    background: transparent;
    border: 0;
    border-radius: 0;
    flex-wrap: nowrap;
}

/* Recipient inputs – flat, no border, focus-ring is on the parent row */
#compose-headers .input-group input.form-control,
#compose-headers .input-group .form-control,
#compose-headers .compose-headers input.recipient-input,
#compose-headers .compose-headers .recipient-input {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius) !important;
    box-shadow: none !important;
    padding: 5px 10px !important;
    color: var(--cw-ink) !important;
    font-size: 0.92rem !important;
    line-height: 1.5;
    min-height: 38px;
}

#compose-headers .compose-headers .recipient-input:focus-within {
    border-color: var(--cw-primary) !important;
    box-shadow: var(--cw-ring) !important;
}

#compose-headers .input-group input:focus,
#compose-headers .input-group .form-control:focus {
    box-shadow: none !important;
    border-color: transparent !important;
    outline: 0;
}

/* Subject specifically – slightly larger, semibold to feel like the title */
#compose-subject {
    font-size: 1.05rem !important;
    font-weight: 600 !important;
    color: var(--cw-ink) !important;
}

/* Right-edge action icons (edit identity / add contact / add header / delete) */
#compose-headers .input-group-append a.input-group-text {
    background: transparent !important;
    border: 0 !important;
    color: var(--cw-muted) !important;
    padding: 6px 8px !important;
    font-size: 0.95rem;
    border-radius: var(--cw-radius-sm) !important;
    transition: background 0.12s ease, color 0.12s ease;
}

#compose-headers .input-group-append a.input-group-text:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

#compose-headers .input-group-append a.input-group-text.delete:hover {
    background: var(--cw-danger-soft) !important;
    color: var(--cw-danger) !important;
}

/* ---- Recipient chips (pillification) – elastic uses span.recipient ------ */

.recipient-input.form-control,
.compose-headers .form-control,
.input-group input.form-control {
    line-height: 1.6;
}

.recipient-input span.recipient,
#compose-headers span.recipient {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
    padding: 2px 10px 2px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    border: 1px solid var(--cw-primary-100);
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recipient-input span.recipient .name,
#compose-headers span.recipient .name {
    font-weight: 600;
}
.recipient-input span.recipient .email,
#compose-headers span.recipient .email {
    color: var(--cw-primary);
    font-family: var(--cw-mono);
    font-size: 0.78rem;
}

.recipient-input span.recipient.invalid,
#compose-headers span.recipient.invalid {
    background: var(--cw-danger-soft);
    color: var(--cw-danger-ink);
    border-color: var(--cw-danger-border);
}

.recipient-input span.recipient .delete,
.recipient-input span.recipient a.btn-remove,
#compose-headers span.recipient a {
    color: inherit !important;
    opacity: 0.6;
    text-decoration: none;
    padding: 0 0 0 4px;
    font-size: 0.95em;
    line-height: 1;
}
.recipient-input span.recipient a:hover {
    opacity: 1;
}

/* ---- Editor body container ---------------------------------------------- */

#composebodycontainer {
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    margin: 0 14px 14px 14px;
    padding: 0;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

#composebodycontainer textarea#composebody {
    flex: 1 1 auto;
    width: 100%;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 16px 20px !important;
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    font-family: var(--cw-sans) !important;
    font-size: 0.95rem !important;
    line-height: 1.55 !important;
    resize: none;
    min-height: 320px;
}

#composebodycontainer textarea#composebody:focus {
    outline: 0;
    box-shadow: none !important;
    border: 0 !important;
}

/* TinyMCE iframe shell – soften default chrome until TipTap replaces it */
#composebodycontainer .mce-tinymce,
#composebodycontainer .tox-tinymce {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: var(--cw-card) !important;
    flex: 1 1 auto;
    display: flex !important;
    flex-direction: column;
}

#composebodycontainer .tox-toolbar,
#composebodycontainer .tox-toolbar__primary {
    background: var(--cw-bg-soft) !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
}

#composebodycontainer .tox .tox-tbtn {
    color: var(--cw-ink-2) !important;
    border-radius: var(--cw-radius-sm) !important;
}
#composebodycontainer .tox .tox-tbtn:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
#composebodycontainer .tox .tox-tbtn--enabled {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

#composebodycontainer .tox .tox-edit-area__iframe {
    background: var(--cw-paper) !important;
}

/* ---- Form action row (Send + open-in-new-window) ----------------------- */

#compose-content > .formbuttons {
    background: var(--cw-card) !important;
    border-top: 1px solid var(--cw-border-soft) !important;
    padding: 14px 24px !important;
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 0 14px 14px 14px;
    border-radius: 0 0 var(--cw-radius-lg) var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-up);
}

/* Send button extra weight */
#compose-content .formbuttons .btn-primary.send {
    padding: 9px 22px !important;
    font-weight: 600 !important;
    font-size: 0.9rem !important;
}

/* ---- Sidebar (compose options + attachments) --------------------------- */

body.task-mail.action-compose #layout-sidebar {
    background: var(--cw-card) !important;
    border-left: 1px solid var(--cw-border-soft);
    border-right: 0 !important;
}

/* ---- Attachment drop zone ------------------------------------------------
 *
 * elastic renders this as a 0.2rem dashed box with 12rem of bottom padding and
 * a fixed grey 160px arrow bitmap dropped in by `.droptarget:after`. Replaced
 * with one card: a masked icon that takes the current colour, the two actions,
 * and the size hint last. `.hover` is what elastic toggles while a file is
 * over the pane, `.active` while a drag is in progress anywhere in the window.
 * -------------------------------------------------------------------------- */
:root {
    --cw-upload-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15.5V4'/%3E%3Cpath d='m8 8 4-4 4 4'/%3E%3Cpath d='M20 14v3.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5V14'/%3E%3C/svg%3E");
}

#compose-attachments {
    margin: 14px;
    padding: 18px 16px 14px;
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius);
    transition: background 0.15s ease, border-color 0.15s ease;
}

#compose-attachments.droptarget { padding-bottom: 14px !important; }

/* The bitmap arrow elastic appends after the content. */
#compose-attachments.droptarget:after { content: none !important; }

#compose-attachments.droptarget.active { border-color: var(--cw-primary) !important; }

#compose-attachments.droptarget.hover {
    background: var(--cw-primary-50);
    border-color: var(--cw-primary) !important;
}

#compose-attachments .upload-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 10px 0;
    padding: 0 !important;
    text-align: center;
}

#compose-attachments .upload-form:before {
    content: "";
    align-self: center;
    width: 34px;
    height: 34px;
    margin-bottom: 4px;
    background: var(--cw-muted-2);
    -webkit-mask: var(--cw-upload-icon) center / 34px 34px no-repeat;
    mask: var(--cw-upload-icon) center / 34px 34px no-repeat;
    transition: background 0.15s ease;
}

#compose-attachments.droptarget.hover .upload-form:before { background: var(--cw-primary); }

#compose-attachments .upload-form button.attach {
    order: 1;
    width: 100%;
    margin: 0 !important;
    background: var(--cw-primary-deep) !important;
    border: 1px solid transparent !important;
    color: var(--cw-on-primary) !important;
    border-radius: var(--cw-radius);
    padding: 9px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

#compose-attachments .upload-form button.attach:hover {
    background: var(--cw-primary-hover) !important;
}

#compose-attachments .upload-form button.attach.vcard {
    order: 2;
    background: var(--cw-card) !important;
    border-color: var(--cw-border) !important;
    color: var(--cw-ink-2) !important;
}

#compose-attachments .upload-form button.attach.vcard:hover {
    background: var(--cw-primary-50) !important;
    border-color: var(--cw-primary) !important;
    color: var(--cw-on-tint) !important;
}

#compose-attachments .hint {
    order: 3;
    margin: 2px 0 0 0 !important;
    color: var(--cw-muted) !important;
    font-size: 0.76rem;
    text-align: center;
}

/* Attachments list inside sidebar – stack vertical chips */
#compose-attachments #attachment-list,
#compose-attachments .attachmentslist {
    flex-direction: column;
    gap: 6px;
    margin: 0 !important;
}

#compose-attachments .attachmentslist li {
    width: 100%;
    max-width: none;
    border-radius: var(--cw-radius-sm) !important;
    background: var(--cw-bg-soft) !important;
    border: 1px solid var(--cw-border-soft) !important;
    padding: 8px 12px !important;
}

/* Compose options form-group rows */
#compose-options.formcontent {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 14px !important;
    border-radius: 0;
}

#compose-options .form-group.row {
    margin: 0 0 10px 0;
    align-items: center;
}

#compose-options label.col-form-label {
    color: var(--cw-muted) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 0 !important;
}

#compose-options select.custom-select {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    font-size: 0.84rem !important;
    color: var(--cw-ink) !important;
    padding: 4px 8px !important;
    height: 32px;
}

/* ---- Compose toolbar (#messagetoolbar) – inherits _toolbar.css mostly --- */

#messagetoolbar.toolbar {
    margin-left: 8px;
    flex: 1 1 auto;
    overflow: visible;
}

#messagetoolbar .options {
    display: none; /* sidebar is always visible on desktop */
}

#messagetoolbar a.button.send.btn-primary {
    background: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border: 0 !important;
    padding: 8px 16px !important;
    border-radius: var(--cw-radius-sm) !important;
}
#messagetoolbar a.button.send.btn-primary:hover {
    background: var(--cw-primary-hover) !important;
}

/* ---- Editor selector (HTML / Plain switch) ------------------------------ */

#editor-selector {
    margin: 8px 14px 0 14px;
    display: flex;
    gap: 4px;
    background: var(--cw-bg-soft);
    border-radius: 999px;
    padding: 2px;
    width: fit-content;
}

#editor-selector input[type="radio"] {
    display: none;
}

#editor-selector label {
    padding: 4px 12px;
    border-radius: 999px;
    color: var(--cw-muted) !important;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    margin: 0 !important;
    transition: background 0.12s ease, color 0.12s ease;
}

#editor-selector input[type="radio"]:checked + label,
#editor-selector label.selected {
    background: var(--cw-card);
    color: var(--cw-ink) !important;
    box-shadow: var(--cw-shadow-sm);
}

#editor-selector.hidden {
    display: none;
}

/* ---- Status bar (saving, autosave hint, etc) --------------------------- */

#composestatusbar {
    color: var(--cw-muted);
    font-size: 0.78rem;
    font-family: var(--cw-mono);
    padding: 0 12px;
    line-height: 44px;
}

/* =============================================================================
 * TipTap editor (Phase 4b) – replaces TinyMCE iframe with a flat
 * contenteditable surface managed by ProseMirror. The adapter mounts:
 *
 *   <div class="cw-editor cw-editor--mail">
 *     <div class="cw-editor-toolbar-slot">
 *       <div class="cw-editor-toolbar" role="toolbar">
 *         <button class="cw-editor-btn" data-cmd="bold">…</button>
 *         <span class="cw-editor-toolbar-sep"></span>
 *         …
 *       </div>
 *     </div>
 *     <div class="cw-editor-content">
 *       <div class="ProseMirror" contenteditable="true">…</div>
 *     </div>
 *   </div>
 *   <textarea id="composebody" style="display:none">…</textarea>
 * ============================================================================= */

.cw-editor {
    display: flex;
    flex-direction: column;
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    overflow: hidden;
    min-height: 320px;
    position: relative;
}

.cw-editor-toolbar-slot {
    background: linear-gradient(180deg, var(--cw-card) 0%, var(--cw-bg-soft) 100%);
    border-bottom: 1px solid var(--cw-border-soft);
    position: sticky;
    top: 0;
    z-index: 5;
}

.cw-editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px 10px;
}

.cw-editor-toolbar-sep {
    width: 1px;
    align-self: stretch;
    background: var(--cw-border-soft);
    margin: 4px 6px;
}

.cw-editor-btn {
    appearance: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--cw-ink-2);
    height: 32px;
    min-width: 32px;
    padding: 0 8px;
    border-radius: var(--cw-radius-sm);
    font: 600 0.82rem var(--cw-sans);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease, color 0.1s ease, transform 0.1s ease;
}

/* The adapter's icons are bare `<svg viewBox="0 0 24 24">` with no width or
 * height attribute, so without an explicit size they fall back to the CSS
 * default replaced-element size of 300x150. */
.cw-editor-btn svg {
    width: 18px;
    height: 18px;
    display: block;
    flex: 0 0 auto;
}

.cw-editor-btn:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

.cw-editor-btn:disabled {
    color: var(--cw-muted-2);
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.cw-editor-btn:focus-visible {
    outline: 2px solid var(--cw-primary);
    outline-offset: -2px;
}

.cw-editor-btn:active {
    transform: scale(0.96);
}

.cw-editor-btn.is-active {
    background: var(--cw-primary);
    color: var(--cw-on-accent);
    box-shadow: 0 1px 2px var(--cw-btn-glow);
}

.cw-editor-btn.is-active:hover {
    background: var(--cw-primary-deep);
}

.cw-editor-content {
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--cw-card);
    padding: 18px 22px 24px;
    min-height: 240px;
}

/* ---- ProseMirror prose styles ------------------------------------------ */

.cw-editor .ProseMirror {
    outline: none;
    font-family: var(--cw-sans);
    color: var(--cw-ink);
    font-size: 0.95rem;
    line-height: 1.6;
    min-height: 220px;
}

.cw-editor .ProseMirror:focus {
    outline: none;
}

.cw-editor .ProseMirror p {
    margin: 0 0 0.85em 0;
}

.cw-editor .ProseMirror p:last-child {
    margin-bottom: 0;
}

.cw-editor .ProseMirror h1,
.cw-editor .ProseMirror h2,
.cw-editor .ProseMirror h3 {
    color: var(--cw-ink);
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 1.2em 0 0.4em;
    line-height: 1.25;
}

.cw-editor .ProseMirror h1 { font-size: 1.55rem; }
.cw-editor .ProseMirror h2 { font-size: 1.3rem; }
.cw-editor .ProseMirror h3 { font-size: 1.1rem; }

.cw-editor .ProseMirror ul,
.cw-editor .ProseMirror ol {
    margin: 0 0 0.85em 0;
    padding-left: 1.6em;
}

.cw-editor .ProseMirror ul li,
.cw-editor .ProseMirror ol li {
    margin: 0.15em 0;
}

.cw-editor .ProseMirror blockquote {
    margin: 0.6em 0;
    padding: 0.4em 0 0.4em 14px;
    border-left: 3px solid var(--cw-primary-100);
    color: var(--cw-ink-2);
    background: var(--cw-bg-soft);
    border-radius: 0 var(--cw-radius-sm) var(--cw-radius-sm) 0;
}

.cw-editor .ProseMirror code {
    background: var(--cw-bg-soft);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-family: var(--cw-mono);
    font-size: 0.86em;
    color: var(--cw-on-tint);
}

.cw-editor .ProseMirror pre {
    background: var(--cw-code-bg);
    color: var(--cw-code-ink);
    padding: 12px 14px;
    border-radius: var(--cw-radius);
    overflow-x: auto;
    font-family: var(--cw-mono);
    font-size: 0.82rem;
    line-height: 1.5;
}

.cw-editor .ProseMirror pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.cw-editor .ProseMirror a {
    color: var(--cw-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cw-editor .ProseMirror img {
    max-width: 100%;
    height: auto;
    border-radius: var(--cw-radius-sm);
    margin: 0.5em 0;
}

.cw-editor .ProseMirror hr {
    border: 0;
    height: 1px;
    background: var(--cw-border);
    margin: 1.4em 0;
}

.cw-editor .ProseMirror table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.6em 0;
    table-layout: fixed;
}

.cw-editor .ProseMirror th,
.cw-editor .ProseMirror td {
    border: 1px solid var(--cw-border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.cw-editor .ProseMirror th {
    background: var(--cw-bg-soft);
    font-weight: 600;
    color: var(--cw-ink);
}

/* Placeholder (shown when editor is empty) */
.cw-editor .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: var(--cw-muted-2);
    float: left;
    height: 0;
    pointer-events: none;
}

/* Reply quote (signature/quoted message wrapped in <blockquote> by Roundcube) */
.cw-editor .ProseMirror #_rc_sig {
    color: var(--cw-muted);
    border-top: 1px solid var(--cw-border-soft);
    margin-top: 1.2em;
    padding-top: 0.6em;
    font-size: 0.88rem;
}

/* Mobile (≤768px): full-width edges, smaller toolbar buttons */
@media screen and (max-width: 768px) {
    .cw-editor {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }
    .cw-editor-toolbar {
        gap: 0;
        padding: 6px 6px;
    }
    .cw-editor-btn {
        height: 36px;
        min-width: 36px;
    }
    .cw-editor-content {
        padding: 14px 16px 20px;
    }
}

/* ===== _editor.css ===== */
/* =============================================================================
 * TipTap editor chrome that lives outside `.cw-editor` itself:
 * the link/image modals, the image drop zone and the image resize overlay.
 *
 * The adapter (skin/cloudweb/js/rcmail_tiptap_adapter.js) builds all of this
 * markup by hand, so the class names here are a contract with that file.
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * Shared buttons used by the modals
 * -------------------------------------------------------------------------- */
/* elastic's ui.js stamps `btn btn-secondary` onto every <button> that has no
 * `.btn`, and this skin's .btn-secondary rule paints those !important. */
.cw-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border-radius: var(--cw-radius);
    border: 1px solid transparent;
    font: 500 0.88rem var(--cw-sans);
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease,
                color 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.cw-btn--primary {
    background: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    box-shadow: var(--cw-btn-shadow), var(--cw-btn-inset);
}

.cw-btn--primary:hover {
    background: var(--cw-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--cw-btn-shadow-hover), var(--cw-btn-inset-hover);
}

.cw-btn--primary:active { transform: translateY(0); }

.cw-btn--ghost {
    background: var(--cw-card) !important;
    color: var(--cw-ink-2) !important;
    border-color: var(--cw-border) !important;
}

.cw-btn--ghost:hover {
    background: var(--cw-primary-50) !important;
    border-color: var(--cw-primary) !important;
    color: var(--cw-on-tint) !important;
}

.cw-modal-extra:hover {
    background: var(--cw-danger-soft) !important;
    border-color: var(--cw-danger-border) !important;
    color: var(--cw-danger-ink) !important;
}

/* -----------------------------------------------------------------------------
 * Modal shell
 * -------------------------------------------------------------------------- */
.cw-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--cw-overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: cw-modal-in 0.16s var(--cw-easing) both;
}

.cw-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 48px);
    background: var(--cw-card);
    color: var(--cw-ink);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-lg);
    font-family: var(--cw-sans);
    overflow: hidden;
    animation: cw-modal-rise 0.2s var(--cw-easing) both;
}

.cw-modal--image { max-width: 540px; }

@keyframes cw-modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes cw-modal-rise {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cw-modal-overlay,
    .cw-modal { animation: none !important; }
}

.cw-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--cw-border-soft);
    background: linear-gradient(180deg, var(--cw-primary-50) 0%, var(--cw-card) 100%);
}

.cw-modal-header h3 {
    flex: 1 1 auto;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--cw-ink);
}

.cw-modal-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cw-muted);
    border-radius: var(--cw-radius-sm);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cw-modal-close:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

.cw-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px 22px;
}

.cw-modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--cw-border-soft);
    background: var(--cw-bg-soft);
}

.cw-modal-spacer { flex: 1 1 auto; }

/* -----------------------------------------------------------------------------
 * Modal form controls
 * -------------------------------------------------------------------------- */
.cw-modal-label {
    display: block;
    margin: 0 0 6px;
    color: var(--cw-ink-2);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.cw-modal-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    background: var(--cw-bg-soft);
    color: var(--cw-ink);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    font: 500 0.9rem var(--cw-sans);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cw-modal-input::placeholder {
    color: var(--cw-muted-2);
    font-weight: 400;
}

.cw-modal-input:focus {
    outline: none;
    background: var(--cw-card);
    border-color: var(--cw-primary);
    box-shadow: var(--cw-ring);
}

/* -----------------------------------------------------------------------------
 * Tabs (image modal: from device / from URL)
 * -------------------------------------------------------------------------- */
.cw-modal-tabs {
    display: inline-flex;
    gap: 2px;
    margin-bottom: 18px;
    padding: 3px;
    background: var(--cw-bg-soft);
    border-radius: 999px;
}

.cw-modal-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--cw-muted);
    padding: 6px 16px;
    border-radius: 999px;
    font: 500 0.82rem var(--cw-sans);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cw-modal-tab:hover { color: var(--cw-ink-2); }

.cw-modal-tab.is-active {
    background: var(--cw-card);
    color: var(--cw-ink);
    box-shadow: var(--cw-shadow-sm);
}

.cw-modal-tabpanel[hidden] { display: none; }

/* -----------------------------------------------------------------------------
 * Image drop zone
 * -------------------------------------------------------------------------- */
.cw-imgdrop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 30px 20px;
    background: var(--cw-bg-soft);
    border: 1.5px dashed var(--cw-border);
    border-radius: var(--cw-radius-lg);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.cw-imgdrop:hover,
.cw-imgdrop:focus-visible {
    border-color: var(--cw-primary);
    background: var(--cw-primary-50);
    outline: none;
}

.cw-imgdrop.is-dragover {
    border-color: var(--cw-primary);
    border-style: solid;
    background: var(--cw-primary-50);
    box-shadow: var(--cw-ring);
}

.cw-imgdrop.has-file {
    border-color: var(--cw-success);
    background: var(--cw-success-soft);
}

.cw-imgdrop-icon {
    color: var(--cw-primary);
    opacity: 0.85;
}

.cw-imgdrop-icon svg {
    width: 34px;
    height: 34px;
    display: block;
}

.cw-imgdrop-title {
    color: var(--cw-ink);
    font-size: 0.92rem;
    font-weight: 600;
}

.cw-imgdrop-sub {
    color: var(--cw-muted);
    font-size: 0.82rem;
}

.cw-imgdrop-hint {
    margin-top: 10px;
    color: var(--cw-muted-2);
    font-size: 0.76rem;
    line-height: 1.45;
    text-align: center;
}

.cw-imgdrop-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 12px;
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius);
}

.cw-imgdrop-preview[hidden] { display: none; }

.cw-imgdrop-preview img {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    object-fit: cover;
    border-radius: var(--cw-radius-sm);
    background: var(--cw-paper);
    box-shadow: inset 0 0 0 1px var(--cw-border);
}

.cw-imgdrop-meta {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--cw-ink-2);
    font-family: var(--cw-mono);
    font-size: 0.78rem;
    line-height: 1.4;
    word-break: break-word;
}

/* -----------------------------------------------------------------------------
 * Image resize overlay
 *
 * The overlay is mounted on <body> and positioned in viewport coordinates, so
 * that `.cw-editor`'s own `overflow: hidden` (which keeps its rounded corners)
 * cannot clip the floating toolbar off the top of the editor.
 *
 * It must not swallow pointer events, or a second click on the image would
 * land on the overlay instead; only the handles and the toolbar opt back in.
 * -------------------------------------------------------------------------- */
.cw-img-resizer {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    box-shadow: 0 0 0 2px var(--cw-primary);
    border-radius: 2px;
}

.cw-img-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--cw-card);
    border: 2px solid var(--cw-primary);
    border-radius: 3px;
    pointer-events: auto;
}

.cw-img-handle--nw { top: -6px;    left: -6px;   cursor: nwse-resize; }
.cw-img-handle--ne { top: -6px;    right: -6px;  cursor: nesw-resize; }
.cw-img-handle--sw { bottom: -6px; left: -6px;   cursor: nesw-resize; }
.cw-img-handle--se { bottom: -6px; right: -6px;  cursor: nwse-resize; }

.cw-img-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    padding: 3px 8px;
    background: var(--cw-overlay);
    color: var(--cw-on-primary);
    border-radius: 999px;
    font-family: var(--cw-mono);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.cw-img-resizer:hover .cw-img-badge,
.cw-img-resizer.is-dragging .cw-img-badge { opacity: 1; }

.cw-img-toolbar {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--cw-card);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    box-shadow: var(--cw-shadow);
    pointer-events: auto;
    white-space: nowrap;
}

.cw-img-resizer.is-dragging .cw-img-toolbar { opacity: 0; }

.cw-img-toolbar button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: transparent;
    border: 0;
    border-radius: var(--cw-radius-sm);
    color: var(--cw-ink-2);
    font: 600 0.72rem var(--cw-sans);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.cw-img-toolbar button svg {
    width: 16px;
    height: 16px;
    display: block;
}

.cw-img-toolbar button:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

.cw-img-toolbar button[data-act="delete"]:hover {
    background: var(--cw-danger-soft);
    color: var(--cw-danger-ink);
}

.cw-img-toolbar-sep {
    width: 1px;
    align-self: stretch;
    margin: 3px 4px;
    background: var(--cw-border-soft);
}

/* -----------------------------------------------------------------------------
 * Image alignment, written as `data-align` by the resize toolbar. The same
 * attribute is serialised into the outgoing message, so it is also styled in
 * embed.css for the reading pane.
 * -------------------------------------------------------------------------- */
.cw-editor .ProseMirror img[data-align="left"] {
    display: block;
    margin-right: auto;
    margin-left: 0;
}

.cw-editor .ProseMirror img[data-align="center"] {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.cw-editor .ProseMirror img[data-align="right"] {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

/* Selected image reads as selected even before the overlay paints. */
.cw-editor .ProseMirror img.ProseMirror-selectednode {
    outline: 2px solid var(--cw-primary);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
 * Phone
 * -------------------------------------------------------------------------- */
@media screen and (max-width: 600px) {
    .cw-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .cw-modal {
        max-width: none;
        max-height: 92vh;
        border-radius: var(--cw-radius-xl) var(--cw-radius-xl) 0 0;
        border-bottom: 0;
    }

    .cw-modal-footer { flex-wrap: wrap; }
    .cw-modal-footer .cw-btn { flex: 1 1 auto; }
    .cw-modal-extra { order: 3; flex-basis: 100%; }

    .cw-img-toolbar { gap: 0; }
}

/* ===== _contacts.css ===== */
/* =============================================================================
 * Contacts task – list, view, edit.
 *
 * Elastic structure:
 *   #layout-sidebar > #directorylist (treelist of address books / groups)
 *   #layout-list   > #contacts-table (tbody rows)
 *   #layout-content > .formcontent > .contact-header > #contactphoto + contacthead
 *                                  > #contacttabs.tabbed > propform fieldsets
 *
 * Goals:
 *   - Contact list rows: avatar circle + name + email row, 56px tall.
 *   - Contact view: hero card with 96px avatar, big name, org/title muted,
 *     phone/email/address grouped under uppercase legend chips.
 *   - Contact edit: same chrome but with input fields swapped in.
 * ============================================================================= */

/* ---- Contact list (#contacts-table) ------------------------------------- */

#contacts-table.contactlist {
    background: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

#contacts-table.contactlist tbody tr {
    background: var(--cw-card);
    transition: background-color 0.1s ease;
}

#contacts-table.contactlist tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--cw-border-soft) !important;
}

#contacts-table.contactlist tbody td {
    padding: 12px 14px !important;
    border-left: 0 !important;
    height: var(--cw-contact-row-h);
    vertical-align: middle;
}

#contacts-table.contactlist tbody td.name {
    font-size: 0.9rem !important;
    color: var(--cw-ink) !important;
    font-weight: 500 !important;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Avatar slot before the name – use the iconized td:before as the avatar.
 * Elastic provides a fa-user / fa-users glyph; we wrap it in a circle. */
#contacts-table.contactlist tbody td.name:before,
#contacts-table.contactlist tbody td.contact:before,
#contacts-table.contactlist tbody td.contactgroup:before {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    border-radius: 999px !important;
    background: var(--cw-primary-50) !important;
    color: var(--cw-primary) !important;
    font-size: 0.95rem !important;
    margin-right: 0 !important;
    flex: 0 0 36px;
}

/* Email shown after the name in compose-recipient lists */
#contacts-table.contactlist span.email {
    color: var(--cw-muted) !important;
    font-style: normal;
    font-family: var(--cw-mono);
    font-size: 0.78rem;
    margin-left: 0;
}

/* Hover + selected */
#contacts-table.contactlist tbody tr:hover td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
#contacts-table.contactlist tbody tr.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
}

/* Read-only contact rows (e.g. LDAP) – italic muted */
#contacts-table.contactlist tbody tr.contact.readonly td {
    color: var(--cw-muted) !important;
    font-style: italic;
}

/* ---- Address-book / groups tree (sidebar) ------------------------------- */

#directorylist.treelist {
    padding: 6px 6px;
}

#directorylist li.addressbook > a:before,
#directorylist li.contactgroup > a:before {
    color: var(--cw-muted-2) !important;
    font-size: 0.95rem !important;
}

#directorylist li.addressbook.selected > a:before,
#directorylist li.contactgroup.selected > a:before {
    color: var(--cw-primary) !important;
}

/* ---- Contact view / edit pane ------------------------------------------- */

body.task-addressbook .formcontent {
    background: var(--cw-card);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    margin: 16px;
    padding: 0 !important;
    border: 1px solid var(--cw-border-soft);
    overflow: hidden;
}

/* Hero header – avatar + name/org */
.contact-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    background: linear-gradient(180deg, var(--cw-primary-50) 0%, transparent 100%);
    border-bottom: 1px solid var(--cw-border-soft);
}

#contactphoto.contact-photo,
fieldset#contactphoto.contact-photo {
    margin: 0;
    padding: 0;
    border: 0;
    flex: 0 0 auto;
}

#contactphoto img,
#contactpic,
#contactpic img,
.contact-photo img {
    width: 96px !important;
    height: 96px !important;
    border-radius: 999px !important;
    object-fit: cover;
    background: var(--cw-card) !important;
    box-shadow: 0 0 0 4px var(--cw-card), 0 0 0 5px var(--cw-border), var(--cw-shadow-sm);
    display: block;
}

#contacthead.contact-head {
    flex: 1 1 auto;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

#contacthead.contact-head .names {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: var(--cw-ink) !important;
    line-height: 1.2 !important;
    letter-spacing: -0.015em;
    margin: 0 0 4px 0 !important;
    word-break: break-word;
}

#contacthead.contact-head .source,
#contacthead.contact-head .source.row,
#contacthead.contact-head td.title {
    color: var(--cw-muted) !important;
    font-size: 0.82rem !important;
    font-weight: 500 !important;
    font-style: normal !important;
}

/* Edit-mode head – inputs are inline */
#contacthead.contact-head.propform input.form-control {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    padding: 6px 10px !important;
    font-size: 0.9rem !important;
    margin: 2px 0 !important;
}

#contacthead.contact-head.propform input.ff_firstname,
#contacthead.contact-head.propform input.ff_surname,
#contacthead.contact-head.propform input.ff_name {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

/* ---- Tabbed sections (Personal / Phone / Address / Notes) -------------- */

#contacttabs.tabbed {
    padding: 18px 28px 24px 28px;
}

#contacttabs.tabbed > .tabsbar,
#contacttabs.tabbed > ul.nav-tabs {
    margin-bottom: 16px;
}

/* Each tab content fieldset becomes a row of grouped key/value pairs */
#contacttabs fieldset.propform.grouped {
    background: transparent;
    border: 0;
    margin: 0 0 18px 0 !important;
    padding: 0 !important;
}

#contacttabs fieldset.propform > legend {
    display: inline-block;
    padding: 4px 12px !important;
    margin: 0 0 12px 0 !important;
    background: var(--cw-bg-soft);
    color: var(--cw-ink-2) !important;
    border-radius: 999px;
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Grouped row layout (label | value) */
#contacttabs fieldset.propform.grouped .row.input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px !important;
    padding: 6px 0;
    border-bottom: 1px solid var(--cw-border-soft);
}

#contacttabs fieldset.propform.grouped .row.input-group:last-child {
    border-bottom: 0;
    margin-bottom: 0 !important;
}

#contacttabs fieldset.propform.grouped .row.input-group > *:first-child {
    flex: 0 0 130px !important;
    min-width: 130px !important;
    color: var(--cw-muted) !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
}

#contacttabs fieldset.propform.grouped .row.input-group > *:nth-child(2) {
    flex: 1 1 auto;
    color: var(--cw-ink) !important;
    font-size: 0.92rem !important;
    line-height: 1.5;
    word-break: break-word;
}

/* Email / phone values – monospace family for that tabular feel */
#contacttabs .ff_email,
#contacttabs .ff_phone,
#contacttabs span.email,
#contacttabs td.email,
#contacttabs td.phone {
    font-family: var(--cw-mono) !important;
    font-size: 0.88rem !important;
}

/* Edit-mode inputs in tabs */
#contacttabs input.form-control,
#contacttabs select.form-control,
#contacttabs textarea.form-control {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    padding: 6px 10px !important;
    font-size: 0.88rem !important;
    color: var(--cw-ink) !important;
    box-shadow: none !important;
    height: auto;
}

#contacttabs input.form-control:focus,
#contacttabs select.form-control:focus,
#contacttabs textarea.form-control:focus {
    border-color: var(--cw-primary) !important;
    box-shadow: var(--cw-ring) !important;
}

/* Add field selector */
#contacttabs .addfield {
    margin-top: 16px;
}
#contacttabs .addfield select {
    width: auto !important;
    min-width: 200px;
}

/* ---- Form button row at bottom of contact pane ------------------------- */

body.task-addressbook .formbuttons {
    background: var(--cw-card) !important;
    border-top: 1px solid var(--cw-border-soft) !important;
    padding: 14px 28px !important;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 16px 16px 16px;
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
}

/* Composite (multi-value) field rows in edit mode */
#contacttabs .composite input,
#contacttabs .composite select {
    margin-bottom: 6px !important;
}

/* Row buttons (add/remove) at end of input rows */
#contacttabs .row.input-group .rowbuttons,
#contacttabs td.rowbuttons {
    flex: 0 0 auto !important;
    min-width: 0 !important;
}

#contacttabs .rowbuttons a {
    width: 28px;
    height: 28px;
    line-height: 28px;
    display: inline-block;
    text-align: center;
    border-radius: var(--cw-radius-sm);
    color: var(--cw-muted);
}

#contacttabs .rowbuttons a:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

#contacttabs .rowbuttons a.delete:hover {
    background: var(--cw-danger-soft);
    color: var(--cw-danger);
}

/* ---- Empty state for contacts list ------------------------------------- */

body.task-addressbook .listing-info {
    color: var(--cw-muted) !important;
    text-align: center;
    padding: 40px 20px;
    font-size: 0.95rem;
}

/* ===== _settings.css ===== */
/* =============================================================================
 * Settings task – preferences forms, identities editor, responses, folders.
 *
 * Elastic structure:
 *   #layout-list .listing.iconized → settings sections rail (Preferences,
 *      Identities, Responses, Folders, Filters, Vacation, Password)
 *   #layout-content > .iframe-wrapper > #preferences-frame → form iframe
 *   Inside the iframe: <form><fieldset><legend><table.propform>...
 *      ...</table></fieldset><div class="formbuttons">...</div></form>
 *
 * Goals:
 *   - Section rail = pill-style nav (already mostly handled by _treelist.css
 *     for `ul.listing.iconized`; settings uses a TABLE so add table rules).
 *   - Form panes = white cards with 14px radius, soft shadow, generous
 *     internal padding, sticky bottom action row.
 *   - Fieldsets = visual cards with a small legend chip on top.
 *   - Identity editor = wider form with a 2-column grid for email + name,
 *     stacked for textareas (signature).
 * ============================================================================= */

/* ---- Settings sections rail (table-rendered) ----------------------------- */

#sections-table.listing.iconized {
    background: transparent !important;
    border: 0 !important;
    padding: 6px 6px;
    font-family: var(--cw-sans);
}

#sections-table.listing.iconized tbody td {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}

#sections-table.listing.iconized tbody tr {
    background: transparent !important;
    transition: background-color 0.12s ease, color 0.12s ease;
}

#sections-table.listing.iconized tbody tr td.section {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    line-height: 1.2;
    padding: 0 12px !important;
    margin: 1px 0 !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.85rem !important;
    font-weight: 500;
    cursor: pointer;
}

#sections-table.listing.iconized tbody tr td.section:before {
    color: var(--cw-muted) !important;
    font-size: 0.95rem !important;
    margin-right: 4px !important;
    flex: 0 0 auto;
}

#sections-table.listing.iconized tbody tr:hover td.section {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
#sections-table.listing.iconized tbody tr:hover td.section:before {
    color: var(--cw-primary) !important;
}

#sections-table.listing.iconized tbody tr.selected td.section {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    border: 0 !important;
}
#sections-table.listing.iconized tbody tr.selected td.section:before {
    color: var(--cw-primary) !important;
}

/* ---- Form pane shell (inside iframe) ------------------------------------- */

/* The iframe body itself – ensure it picks up our background */
html.iframe body,
body.iframe {
    background: var(--cw-bg) !important;
    color: var(--cw-ink) !important;
    font-family: var(--cw-sans) !important;
}

/* The flexbox container that holds form content + sticky button row */
.formcontainer {
    background: var(--cw-bg);
    padding: 0;
}

/* Form content – give it card treatment with breathing room */
.formcontent {
    background: var(--cw-card);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    margin: 16px;
    padding: 20px 24px !important;
    border: 1px solid var(--cw-border-soft);
}

.formcontent:not(.popupmenu) {
    width: auto;
}

/* Inside iframe, no margin (use full pane width) */
html.iframe .formcontent {
    margin: 14px;
}

/* ---- Fieldsets ----------------------------------------------------------- */

fieldset {
    background: transparent;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 0 24px 0 !important;
}

fieldset:last-child {
    margin-bottom: 0 !important;
}

.formcontent fieldset:not(.tab-pane):nth-of-type(n+2),
.propform fieldset:not(.tab-pane):nth-of-type(n+2) {
    margin-top: 24px !important;
}

/* Section heading (legend) – pill chip above the rules */
fieldset > legend,
.formcontent > legend {
    display: inline-block;
    width: auto !important;
    padding: 4px 12px !important;
    margin: 0 0 14px 0 !important;
    background: var(--cw-bg-soft);
    color: var(--cw-ink) !important;
    border-radius: 999px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 0 !important;
    line-height: 1.4;
}

/* Advanced (collapsible) fieldset */
fieldset.advanced > legend {
    cursor: pointer;
    background: var(--cw-bg-soft);
    color: var(--cw-ink-2) !important;
}
fieldset.advanced > legend:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint) !important;
}
fieldset.advanced > legend:after {
    color: var(--cw-muted-2) !important;
    margin-left: 8px !important;
}

/* ---- Propform table (key-value rows) ------------------------------------- */

table.propform {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

table.propform > tbody > tr > td.title,
table.propform > tbody > tr > th.title {
    width: 200px !important;
    min-width: 160px;
    padding: 8px 16px 8px 0 !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    vertical-align: top;
    text-align: left;
}

table.propform > tbody > tr > td:not(.title):not(.rowbuttons) {
    padding: 0 !important;
    color: var(--cw-ink) !important;
    vertical-align: top;
}

table.propform label {
    color: var(--cw-ink-2) !important;
    font-weight: 500 !important;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Hint / form-text helper */
.form-text,
.formcontent .form-text {
    color: var(--cw-muted) !important;
    font-size: 0.78rem !important;
    margin-top: 4px;
    line-height: 1.4;
}

/* Row buttons (e.g. add/remove email row) */
table.propform td.rowbuttons {
    padding-left: 8px !important;
}
table.propform td.rowbuttons a {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-muted) !important;
    text-align: center;
    transition: background 0.12s ease, color 0.12s ease;
}
table.propform td.rowbuttons a:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
table.propform td.rowbuttons a.delete:hover {
    background: var(--cw-danger-soft) !important;
    color: var(--cw-danger) !important;
}

/* Composite (multi-input) groups (e.g. multi-email row) */
table.propform .composite input,
table.propform .composite select {
    margin-bottom: 6px !important;
}

/* ---- Inputs inside form panes ------------------------------------------- */

.formcontent input.form-control,
.formcontent select.form-control,
.formcontent textarea.form-control,
.formcontent .custom-select {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius) !important;
    padding: 8px 12px !important;
    /* bootstrap pins a calc() height that predates this padding, so the value
     * clipped the text; let the box grow to its own content instead. */
    height: auto !important;
    min-height: 36px;
    font-family: var(--cw-sans) !important;
    font-size: 0.86rem !important;
    line-height: 1.35 !important;
    color: var(--cw-ink) !important;
    box-shadow: none !important;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.formcontent input.form-control:focus,
.formcontent select.form-control:focus,
.formcontent textarea.form-control:focus {
    border-color: var(--cw-primary) !important;
    box-shadow: var(--cw-ring) !important;
    outline: 0;
}

/* Disabled inputs */
.formcontent input.form-control:disabled,
.formcontent select.form-control:disabled,
.formcontent textarea.form-control:disabled {
    background: var(--cw-bg-soft) !important;
    color: var(--cw-muted) !important;
    cursor: not-allowed;
}

/* ---- Sticky form action row ---------------------------------------------- */

.formcontainer .formbuttons {
    background: var(--cw-card) !important;
    border-top: 1px solid var(--cw-border-soft) !important;
    padding: 14px 24px !important;
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: var(--cw-shadow-up);
}

.formcontainer .formbuttons button {
    margin-right: 0 !important;
}

/* ---- Identity editor specifics ------------------------------------------ */

#identity-form .formcontent,
#identityform .formcontent {
    max-width: 760px;
}

/* Signature textarea – give it a sensible height + monospace font for
 * editing raw HTML/text */
textarea[name="_signature"],
textarea#rcmfd_signature,
textarea.signature {
    min-height: 180px;
    font-family: var(--cw-mono) !important;
    font-size: 0.85rem !important;
    line-height: 1.5;
}

/* Identity preview / contact photo upload box */
.identity-photo,
#contactpic {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    background: var(--cw-bg-soft);
    border-radius: var(--cw-radius);
    border: 1px dashed var(--cw-border);
}

.identity-photo img,
#contactpic img,
img.contactphoto {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    object-fit: cover;
    background: var(--cw-primary-50);
    box-shadow: inset 0 0 0 1px var(--cw-border);
}

/* ---- Identities listing (left pane in Settings → Identities) ------------ */

#identities-table.listing tbody td.mail {
    padding: 12px 16px !important;
    color: var(--cw-ink) !important;
    font-weight: 500;
}
#identities-table.listing tbody td.mail:before {
    color: var(--cw-muted) !important;
    margin-right: 10px !important;
    font-size: 1rem !important;
}
#identities-table.listing tbody tr.default td.mail:after {
    content: var(--cw-badge-default, none);
    margin-left: 10px;
    padding: 1px 8px;
    background: var(--cw-success-soft);
    color: var(--cw-success-ink);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

/* ---- Tabs on multi-section forms (e.g. preferences sub-tabs) ------------ */

.nav-tabs,
.tabsbar {
    border-bottom: 1px solid var(--cw-border) !important;
    margin-bottom: 18px;
    padding: 0;
    background: transparent;
    display: flex;
    gap: 4px;
}

.nav-tabs .nav-link,
.tabsbar a.tablink {
    border: 0 !important;
    background: transparent !important;
    color: var(--cw-muted) !important;
    font-weight: 500;
    font-size: 0.86rem;
    padding: 8px 14px !important;
    border-radius: var(--cw-radius-sm) var(--cw-radius-sm) 0 0 !important;
    border-bottom: 2px solid transparent !important;
    margin: 0 !important;
    text-decoration: none;
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.nav-tabs .nav-link:hover,
.tabsbar a.tablink:hover {
    color: var(--cw-on-tint) !important;
    background: var(--cw-primary-50) !important;
}

.nav-tabs .nav-link.active,
.tabsbar a.tablink.selected {
    color: var(--cw-on-tint) !important;
    border-bottom-color: var(--cw-primary) !important;
    background: transparent !important;
}

/* ---- Generic settings-frame back button on mobile ---------------------- */

.header .back-list-button,
.header .back-sidebar-button {
    color: var(--cw-muted) !important;
}

/* ---- Signature editor (Roundcube's own bar, not the compose editor) ----- */

.html-editor .editor-toolbar {
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border);
    border-top: 0;
    border-radius: 0 0 var(--cw-radius) var(--cw-radius);
    padding: 2px 6px;
}

.html-editor .editor-toolbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    border-radius: var(--cw-radius-sm);
    color: var(--cw-muted);
}

.html-editor .editor-toolbar a:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

/* ---- Pretty checkboxes / switches ------------------------------------- */

.custom-switch .custom-control-label::before {
    background: var(--cw-bg-soft);
    border-color: var(--cw-border);
}

.custom-switch .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--cw-primary) !important;
    border-color: var(--cw-primary) !important;
}

.custom-switch .custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: var(--cw-ring) !important;
}

/* ---- Radios in settings (e.g. mail format html/plain) ----------------- */

.custom-radio .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--cw-card) !important;
    border-color: var(--cw-primary) !important;
}
.custom-radio .custom-control-input:checked ~ .custom-control-label::after {
    background-image: radial-gradient(circle, var(--cw-primary) 40%, transparent 45%) !important;
}

/* ===== _filters.css ===== */
/* =============================================================================
 * Sieve plugin – filters, vacation, and responses-related forms.
 * Password plugin (settings → password) just re-uses _settings.css propform.
 *
 * Elastic structure for filters:
 *   #layout-list > #filtersetslistbox > #filtersetslist (top selector)
 *               > .scroller > #filterslist (rule rows, drag-reorder)
 *   #layout-content > .header (toolbar) > #filter-box (iframe → propform)
 *
 * Vacation:
 *   #vacationform.propform (status toggle, reason textarea, date pickers,
 *   from/to fields, action select)
 * ============================================================================= */

/* ---- Filterset top selector (the active sieve script chooser) ----------- */

/* elastic keeps this box at height:0 and grows it from JS when the selector is
 * expanded, so any padding or border here is a stray strip above the rules. */
#filtersetslistbox.navlist {
    background: var(--cw-bg-soft);
    padding: 0;
    max-height: 240px;
}

.pagenav-list.expanded + #filtersetslistbox.navlist {
    border-bottom: 1px solid var(--cw-border);
}

#filtersetslist.listing {
    background: transparent;
    margin: 0;
}

#filtersetslist.listing tbody td,
#filtersetslist.listing tbody td.name {
    padding: 8px 12px !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.84rem;
    font-weight: 500;
    border: 0 !important;
    border-radius: var(--cw-radius-sm) !important;
}

#filtersetslist.listing tbody td.name:before {
    color: var(--cw-muted) !important;
    margin-right: 8px !important;
    font-size: 0.9rem !important;
}

#filtersetslist.listing tbody tr {
    background: transparent;
}
#filtersetslist.listing tbody tr:hover td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
#filtersetslist.listing tbody tr.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    font-weight: 600;
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
}

#filtersetslist.listing tbody tr.disabled td.name:after {
    content: var(--cw-badge-disabled, none);
    margin-left: 8px;
    padding: 1px 8px;
    background: var(--cw-bg-soft);
    color: var(--cw-muted);
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid var(--cw-border);
}

/* Pagenav / collapse toggle above the set list */
.pagenav.pagenav-list {
    background: var(--cw-card);
    border-bottom: 1px solid var(--cw-border-soft);
    padding: 0 12px;
    height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.pagenav.pagenav-list:hover { background: var(--cw-bg-soft); }
.pagenav.pagenav-list a.expand {
    color: var(--cw-muted);
    text-decoration: none;
}
.pagenav.pagenav-list #filterset-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--cw-ink-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---- Filters list (the rules in the active set, drag-reorderable) ------ */

#filterslist.listing {
    background: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

#filterslist.listing tbody tr {
    background: var(--cw-card);
    cursor: grab;
}
#filterslist.listing tbody tr:active {
    cursor: grabbing;
}

#filterslist.listing tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--cw-border-soft) !important;
}

#filterslist.listing tbody td {
    padding: 12px 14px !important;
    color: var(--cw-ink) !important;
    font-size: 0.86rem;
    font-weight: 500;
    border-left: 0 !important;
    line-height: 1.4;
}

#filterslist.listing tbody td.name:before {
    content: "\F0DC"; /* fa-arrows-v / drag handle */
    font-family: "Icons";
    font-weight: 900;
    color: var(--cw-muted-2) !important;
    margin-right: 12px;
    opacity: 0.6;
    font-size: 0.85rem;
}

#filterslist.listing tbody tr:hover td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

#filterslist.listing tbody tr.selected td {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    box-shadow: inset 3px 0 0 0 var(--cw-primary);
    font-weight: 600;
}

/* Disabled filter rule */
#filterslist.listing tbody tr.disabled td {
    color: var(--cw-muted-2) !important;
    font-style: italic;
}

#filterslist.listing tbody tr.disabled td.name:after {
    content: var(--cw-badge-disabled, none);
    margin-left: 10px;
    padding: 1px 7px;
    background: var(--cw-bg-soft);
    color: var(--cw-muted);
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid var(--cw-border);
    vertical-align: middle;
}

/* Drag-reorder visual hints (override the inline <style> block in template) */
#filterslist tr.filtermoveup td {
    border-top: 2px solid var(--cw-primary) !important;
}
#filterslist tr.filtermovedown td {
    border-bottom: 2px solid var(--cw-primary) !important;
}

/* Drop target highlight while dragging */
#filterslist.listing tbody tr.droptarget td {
    background: var(--cw-primary-100) !important;
    color: var(--cw-on-tint) !important;
}

/* ---- Filter rule editor (#filter-form inside iframe) ------------------- */

#filter-form.propform {
    width: 100%;
}

/* The rule rows: each is `<tr><td.title>Ak</td><td.rowactions>select</td>
 * <td.rowtargets>...</td><td.rowbuttons>buttons</td></tr>`. We turn the
 * static labels (Ak/Vykon) into chip-like pills and group the operands
 * into a clean horizontal stack. */
#filter-form table.propform > tbody > tr > td.title {
    width: 80px !important;
    min-width: 80px;
    color: var(--cw-muted) !important;
    font-size: 0.74rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 10px 0 0 !important;
    vertical-align: top;
}

/* Operand select (Predmet/Od/Komu/...) – chip-like with primary tint */
#filter-form table.propform td.rowactions select.form-control,
#filter-form table.propform td.rowactions .custom-select {
    background: var(--cw-bg-soft) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-ink) !important;
    font-size: 0.85rem !important;
    padding: 6px 10px !important;
    height: auto;
    margin-bottom: 6px !important;
}

#filter-form table.propform td.rowactions select.form-control:focus {
    border-color: var(--cw-primary) !important;
    box-shadow: var(--cw-ring) !important;
    background: var(--cw-card) !important;
}

#filter-form table.propform td.rowtargets {
    padding: 0 8px !important;
}

#filter-form table.propform td.rowtargets input.form-control,
#filter-form table.propform td.rowtargets select.form-control,
#filter-form table.propform td.rowtargets .input-group {
    background: var(--cw-card) !important;
    border-radius: var(--cw-radius-sm) !important;
}

/* The "advanced" toggle inside a target cell */
#filter-form table.propform td.rowtargets > .advanced {
    margin-top: 6px;
    color: var(--cw-muted);
    font-size: 0.78rem;
}

#filter-form table.propform td.rowtargets > .advanced > label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Add/remove rule buttons */
#filter-form table.propform td.rowbuttons {
    padding: 4px 0 0 0 !important;
    white-space: nowrap;
}

#filter-form table.propform td.rowbuttons a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    line-height: 1;
    border-radius: var(--cw-radius-sm);
    color: var(--cw-muted);
    margin: 0 2px;
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border);
    transition: all 0.12s ease;
}

#filter-form table.propform td.rowbuttons a:hover {
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
    border-color: var(--cw-primary-100);
}

#filter-form table.propform td.rowbuttons a.delete:hover {
    background: var(--cw-danger-soft);
    color: var(--cw-danger);
    border-color: var(--cw-danger-border);
}

/* Rule "any/all" matcher dropdown at the top of the form */
#filter-form .input-group select#rule_any {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    border-color: var(--cw-primary-100) !important;
    font-weight: 600;
}

/* ---- Vacation (#vacationform) ------------------------------------------ */

#vacationform.propform {
    max-width: 720px;
    margin: 0 auto;
}

/* Status toggle row – elevate it to a hero card */
#vacationform.propform > tbody > tr:first-child > td.title {
    color: var(--cw-ink) !important;
    font-size: 0.95rem !important;
    text-transform: none !important;
    letter-spacing: normal;
    font-weight: 600 !important;
    padding-top: 14px !important;
}

/* Reason textarea – generous height */
#vacationform.propform textarea[name*="reason"],
#vacationform.propform textarea#vacation_reason,
#vacationform.propform textarea {
    min-height: 160px;
    font-family: var(--cw-sans);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* Date inputs side-by-side */
#vacationform.propform td.datetime {
    display: flex;
    gap: 10px;
    align-items: center;
}

#vacationform.propform td.datetime input.form-control {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
    font-family: var(--cw-mono);
    width: auto;
    min-width: 130px;
}

/* Vacation "When" select (always/range/etc) */
#vacationform.propform select#vacation_when,
#vacationform.propform select[name="vacation_when"] {
    background: var(--cw-bg-soft) !important;
    border-color: var(--cw-border) !important;
    border-radius: var(--cw-radius-sm) !important;
    font-weight: 500;
}

/* ---- Responses list (#responses-table) – elastic uses .listing.iconized */

#responses-table.listing tbody td {
    padding: 14px 16px !important;
    color: var(--cw-ink) !important;
    font-weight: 500;
    font-size: 0.88rem;
}

#responses-table.listing tbody td.name:before {
    color: var(--cw-muted) !important;
    margin-right: 12px !important;
    font-size: 1rem !important;
}

#responses-table.listing tbody tr:hover td:before,
#responses-table.listing tbody tr.selected td:before {
    color: var(--cw-primary) !important;
}

/* Response edit form – propform already styled, just ensure body is large */
#responseform textarea[name*="text"],
#responseform textarea {
    min-height: 200px;
    font-family: var(--cw-sans);
    font-size: 0.92rem;
    line-height: 1.5;
}

/* ---- Password form – nothing custom, but ensure status messages stand out */

#password-form .form-text,
.password-form .form-text {
    color: var(--cw-muted) !important;
}

#password-form input[type="password"] {
    font-family: var(--cw-mono) !important;
    letter-spacing: 0.08em;
}

/* ===== _popover.css ===== */
/* =============================================================================
 * Popovers – popupmenu (right-click, dropdown actions), context menus,
 * jQuery-UI dialogs, search dropdowns. Elastic ships these as
 * `.popupmenu` (Roundcube custom) and `.ui-dialog` (jQuery UI).
 *
 * Goals:
 *   - Floating cards: white, 14px radius, soft elevated shadow, soft border.
 *   - Menu items: 36px tall, primary-50 hover, focus ring on keyboard nav.
 *   - Dialogs: hero header with subtle gradient, sticky footer button row.
 * ============================================================================= */

/* ---- Generic floating surface ------------------------------------------- */

.popupmenu,
.dropdown-menu,
.ui-dialog,
.ui-autocomplete {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border-soft) !important;
    border-radius: var(--cw-radius-lg) !important;
    box-shadow: var(--cw-shadow-lg) !important;
    padding: 6px !important;
    color: var(--cw-ink) !important;
    font-family: var(--cw-sans);
}

/* Tiny popovers (e.g. context menus) get a slightly tighter radius */
.popupmenu.simplelist,
.popupmenu.contextmenu {
    padding: 4px !important;
    border-radius: var(--cw-radius) !important;
}

/* ---- Menu items --------------------------------------------------------- */

.popupmenu ul.menu,
.popupmenu ul.listing,
.dropdown-menu {
    margin: 0;
    padding: 0;
    list-style: none;
    background: transparent;
    border: 0;
}

.popupmenu li,
.popupmenu ul.menu li,
.dropdown-menu li {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 0 !important;
}

.popupmenu li > a,
.popupmenu ul.menu li > a,
.popupmenu ul.listing li > a,
.dropdown-menu li > a,
.dropdown-menu .dropdown-item {
    display: flex !important;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    line-height: 1.2;
    padding: 6px 12px !important;
    margin: 1px 0 !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.84rem !important;
    font-weight: 500;
    border-radius: var(--cw-radius-sm) !important;
    border-left: 0 !important;
    text-decoration: none;
    cursor: pointer;
    background: transparent;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.popupmenu li > a:before,
.popupmenu ul.menu li > a:before,
.dropdown-menu li > a:before {
    color: var(--cw-muted) !important;
    font-size: 0.95rem !important;
    width: 1em !important;
    height: auto !important;
    flex: 0 0 auto;
    margin-right: 0 !important;
    background: transparent !important;
}

/* Hover + current entry. Roundcube's `.active` marks a command as *enabled*,
 * not as the current one, so it must not be tinted. */
.popupmenu li > a:hover,
.popupmenu ul.menu li > a:hover,
.popupmenu ul.listing li > a:hover,
.popupmenu ul.listing li.selected > a,
.dropdown-menu li > a:hover,
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

.popupmenu li > a:hover:before,
.popupmenu ul.menu li > a:hover:before,
.dropdown-menu li > a:hover:before {
    color: var(--cw-primary) !important;
}

/* Disabled menu items */
.popupmenu li > a.disabled,
.popupmenu ul.menu li > a.disabled,
.dropdown-menu li > a.disabled,
.dropdown-menu .dropdown-item.disabled {
    color: var(--cw-muted-2) !important;
    cursor: not-allowed;
    opacity: 0.6;
}
.popupmenu li > a.disabled:hover {
    background: transparent !important;
}

/* Separator */
.popupmenu li.separator,
.dropdown-menu li.divider,
.dropdown-menu .dropdown-divider {
    margin: 6px 0 !important;
    padding: 0 !important;
    height: 1px;
    background: var(--cw-border-soft);
    overflow: hidden;
}

.popupmenu li.separator label,
.popupmenu ul.menu li.separator label {
    display: block;
    padding: 8px 12px 4px 12px !important;
    color: var(--cw-muted) !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: transparent;
    border: 0;
    height: auto;
}

/* ---- Specific menus (search / headers / responses / attachment) -------- */

#searchmenu,
#mailboxoptions-menu,
#listoptions-menu,
#headers-menu,
#responses-menu,
#attachmentmenu,
#listselect-menu,
#threadselect-menu,
#dragmessage-menu,
#filterset-menu,
#spell-menu,
#encryption-menu {
    min-width: 220px;
}

/* Search menu has a form with checkboxes inside */
#searchmenu .menu form {
    padding: 6px 8px;
}
#searchmenu .menu .form-check {
    margin: 6px 0;
    color: var(--cw-ink-2);
    font-size: 0.84rem;
}

/* Search submit button at bottom */
#searchmenu .menu button.btn,
#searchmenu .menu .btn-primary {
    margin-top: 6px;
    width: 100%;
}

/* ---- jQuery-UI dialogs -------------------------------------------------- */

.ui-dialog {
    padding: 0 !important;
    /* Do NOT set `overflow: hidden` on the wrapper – it clips the buttonpane
     * + resize handles against the rounded corners when jQuery UI's inline
     * `height: auto` ends up slightly shorter than the combined
     * titlebar + content + buttonpane. Round the inner surfaces instead. */
    overflow: visible !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-lg) !important;
    background: var(--cw-card) !important;
    box-shadow: var(--cw-shadow-lg) !important;
    min-width: 320px;
    max-width: min(92vw, 640px);
    height: auto !important;
}

/* A popupmenu nested inside a ui-dialog (e.g. Nastavenia zoznamu / listoptions)
 * already inherits the dialog chrome – so strip its own card styling to avoid
 * a double-bordered, double-padded, awkwardly-sized look. */
.ui-dialog .ui-dialog-content .popupmenu,
.ui-dialog .ui-dialog-content > .popupmenu {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-width: 0;
    max-width: none;
    width: 100%;
}

/* propform grids (label / control pairs) inside a dialog – tighten and align. */
.ui-dialog .propform,
.ui-dialog .ui-dialog-content .propform {
    display: block;
    width: 100%;
}
.ui-dialog .form-group.row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px 0;
}
.ui-dialog .form-group.row:last-child {
    margin-bottom: 0;
}
.ui-dialog .form-group.row > label.col-form-label {
    flex: 0 0 38%;
    max-width: 38%;
    padding: 0;
    margin: 0;
    color: var(--cw-ink-2);
    font-weight: 500;
    font-size: 0.86rem;
}
.ui-dialog .form-group.row > .col-sm-8 {
    flex: 1 1 auto;
    padding: 0;
    max-width: 62%;
}
.ui-dialog .form-group.row > .col-sm-8 > select,
.ui-dialog .form-group.row > .col-sm-8 > input {
    width: 100%;
}

.ui-dialog .ui-dialog-titlebar {
    background: linear-gradient(180deg, var(--cw-primary-50) 0%, var(--cw-card) 100%) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    padding: 14px 18px !important;
    margin: 0;
    color: var(--cw-ink) !important;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    border-radius: var(--cw-radius-lg) var(--cw-radius-lg) 0 0 !important;
}

.ui-dialog .ui-dialog-title {
    color: var(--cw-ink) !important;
    font-weight: 600 !important;
}

/* Close button (top-right X) */
.ui-dialog .ui-dialog-titlebar-close {
    background: transparent !important;
    border: 0 !important;
    color: var(--cw-muted) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: var(--cw-radius-sm) !important;
    transition: background 0.12s ease, color 0.12s ease;
    top: 50%;
    transform: translateY(-50%);
    right: 12px;
}
.ui-dialog .ui-dialog-titlebar-close:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}
.ui-dialog .ui-dialog-titlebar-close .ui-icon,
.ui-dialog .ui-dialog-titlebar-close:before {
    background: none !important;
    text-indent: 0;
}

.ui-dialog .ui-dialog-content {
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    padding: 20px 22px !important;
    border: 0 !important;
    font-size: 0.9rem;
    line-height: 1.55;
    height: auto !important;
    min-height: 0 !important;
    overflow: auto;
}

/* Button pane at the bottom of every jQuery UI dialog.
 *
 * jQuery UI measures the dialog's total size by `content height + titlebar +
 * buttonpane`, and the buttonpane's height is driven by our padding. With
 * only 12px padding, a 38-40px tall .btn gets clipped because the pane ends
 * up ~46px tall total. Bumping min-height + vertical padding and centering
 * via flex keeps buttons fully inside the pane at every zoom level. */
.ui-dialog .ui-dialog-buttonpane {
    background: var(--cw-bg-soft) !important;
    border-top: 1px solid var(--cw-border-soft) !important;
    padding: 14px 20px !important;
    margin: 0;
    min-height: 68px;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
    border-radius: 0 0 var(--cw-radius-lg) var(--cw-radius-lg);
}

.ui-dialog .ui-dialog-buttonset {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
}

.ui-dialog .ui-dialog-buttonset .ui-button,
.ui-dialog .ui-dialog-buttonset .btn {
    margin: 0 !important;
    flex: 0 0 auto;
}

/* Backdrop overlay */
.ui-widget-overlay,
#dialog-overlay {
    background: var(--cw-overlay) !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 1 !important;
}

/* ---- Autocomplete dropdown (recipient suggestions, etc.) --------------- */

.ui-autocomplete {
    max-height: 280px;
    overflow-y: auto;
    padding: 4px !important;
}

.ui-autocomplete li.ui-menu-item {
    list-style: none;
}

.ui-autocomplete li > .ui-menu-item-wrapper,
.ui-autocomplete li a {
    padding: 6px 10px !important;
    border-radius: var(--cw-radius-sm) !important;
    color: var(--cw-ink-2) !important;
    font-size: 0.84rem;
    line-height: 1.3;
    cursor: pointer;
    border: 0 !important;
    background: transparent;
    margin: 1px 0;
}

.ui-autocomplete li > .ui-menu-item-wrapper.ui-state-active,
.ui-autocomplete li > .ui-menu-item-wrapper:hover,
.ui-autocomplete li.ui-state-focus a,
.ui-autocomplete li a:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    border: 0 !important;
}

/* ---- jQuery-UI date picker --------------------------------------------- */

.ui-datepicker {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius) !important;
    box-shadow: var(--cw-shadow) !important;
    padding: 10px !important;
    font-family: var(--cw-sans);
}

.ui-datepicker .ui-datepicker-header {
    background: transparent !important;
    border: 0 !important;
    color: var(--cw-ink) !important;
    font-weight: 600;
    padding: 4px 0 !important;
}

.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next {
    background: transparent !important;
    border: 0 !important;
    color: var(--cw-muted) !important;
    cursor: pointer;
    border-radius: var(--cw-radius-sm) !important;
    width: 28px;
    height: 28px;
    top: 4px !important;
}

.ui-datepicker .ui-datepicker-prev:hover,
.ui-datepicker .ui-datepicker-next:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

.ui-datepicker table {
    margin: 6px 0 0;
    font-size: 0.82rem;
}

.ui-datepicker th {
    color: var(--cw-muted) !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    padding: 4px 0;
}

.ui-datepicker td a {
    background: transparent !important;
    border: 0 !important;
    color: var(--cw-ink-2) !important;
    text-align: center;
    padding: 6px 0 !important;
    border-radius: 999px !important;
    transition: background 0.1s ease, color 0.1s ease;
}

.ui-datepicker td a:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

.ui-datepicker td a.ui-state-active,
.ui-datepicker td.ui-datepicker-current-day a {
    background: var(--cw-primary) !important;
    color: var(--cw-on-accent) !important;
}

.ui-datepicker td.ui-datepicker-today a {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    box-shadow: inset 0 0 0 1px var(--cw-primary);
}

/* =============================================================================
 * Mobile drawers.
 *
 * At `layout-phone` / `layout-small` elastic re-uses the same `.popover`
 * element as a full-height 272px drawer pinned to the right edge, with a
 * `.popover-header` title bar and a `.popover-overlay` scrim. Both were left
 * with elastic's own colours (#005984 header, #2c363a scrim), so every menu
 * on a phone – search options, folder actions, the toolbar overflow – fell
 * out of the cloudweb palette entirely.
 * ============================================================================= */

.popover {
    z-index: 1300;
}

html.layout-phone .popover:not(.select-menu),
html.layout-small .popover:not(.select-menu) {
    background: var(--cw-card) !important;
    border: 0 !important;
    border-left: 1px solid var(--cw-border) !important;
    border-radius: 0 !important;
    box-shadow: var(--cw-shadow-lg) !important;
    padding: 0 !important;
    /* Sit above the fixed task rail rather than behind it. */
    bottom: var(--cw-rail-total) !important;
}

html.layout-phone .popover-overlay,
html.layout-small .popover-overlay {
    background: var(--cw-overlay) !important;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

html.layout-phone .popover-header,
html.layout-small .popover-header {
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    height: 56px !important;
    min-height: 56px !important;
    line-height: 56px !important;
    padding: 0 8px 0 16px !important;
    font-family: var(--cw-sans);
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}

html.layout-phone .popover-header a,
html.layout-small .popover-header a {
    color: var(--cw-muted) !important;
}

html.layout-phone .popover-header a:hover,
html.layout-small .popover-header a:hover {
    color: var(--cw-on-tint) !important;
}

html.layout-phone .popover-body,
html.layout-small .popover-body {
    background: var(--cw-card) !important;
    padding: 6px !important;
}

/* Inside a drawer the toolbar entries are plain menu rows, not the stacked
 * tiles the desktop header uses – undo the tile geometry for them. */
.popover .menu.toolbar > li > a,
.popover .menu.toolbar > li > .dropbutton > a {
    flex-direction: row !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    gap: 12px !important;
    padding: 10px 12px !important;
    font-size: 0.9rem !important;
    text-align: left !important;
}

.popover .menu.toolbar > li > a > span.inner,
.popover .menu.toolbar > li > .dropbutton > a > span.inner {
    position: static !important;
    width: auto !important;
    height: auto !important;
    clip: auto !important;
    clip-path: none !important;
    margin: 0 !important;
    overflow: visible !important;
    font-size: 0.9rem !important;
    text-align: left !important;
    white-space: nowrap;
}

.popover .menu.toolbar > li.spacer {
    width: auto !important;
    min-width: 0;
    height: 1px !important;
    margin: 6px 0 !important;
    background: var(--cw-border-soft);
}

/* A split button (reply-all + caret, forward + caret) has to collapse into a
 * single drawer row: the main action takes the row, the caret stays a narrow
 * strip on the trailing edge with its redundant label hidden again. */
.popover .menu.toolbar > li > .dropbutton {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    width: 100% !important;
    background: transparent !important;
    border-radius: var(--cw-radius-sm) !important;
    overflow: hidden;
}

.popover .menu.toolbar > li > .dropbutton > a:not(.dropdown) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.popover .menu.toolbar > li > .dropbutton > a.dropdown {
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    justify-content: center !important;
    gap: 0 !important;
    padding: 10px 0 !important;
    background: transparent !important;
    border-left: 1px solid var(--cw-border-soft);
}

.popover .menu.toolbar > li > .dropbutton > a.dropdown > span.inner {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
}

.popover .menu.toolbar > li > a.disabled,
.popover .menu.toolbar > li > .dropbutton.disabled,
.popover .menu.toolbar > li > .dropbutton.disabled > a,
.popover .menu.toolbar > li > .dropbutton > a.disabled {
    background: transparent !important;
    color: var(--cw-muted) !important;
    opacity: 0.45;
}

/* The select-menu (a native <select> replacement) is a centred sheet, not a
 * side drawer, so it keeps the card treatment. */
.select-menu {
    background: var(--cw-card) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius-lg) !important;
    box-shadow: var(--cw-shadow-lg) !important;
}

.select-menu .popover-header {
    background: var(--cw-bg-soft) !important;
    color: var(--cw-ink) !important;
    border-bottom: 1px solid var(--cw-border-soft) !important;
    border-radius: var(--cw-radius-lg) var(--cw-radius-lg) 0 0 !important;
}

/* ===== _frames.css ===== */
/* =============================================================================
 * Standalone framed pages – about, error, generic plugin iframe wrapper.
 * Elastic renders these as `<div class="frame-content">` inside layout-content.
 *
 * Goals:
 *   - About: hero card with cloudweb mail wordmark, subtle copyright,
 *     installed plugins as a clean records-table.
 *   - Error: centered warning card with primary "back to inbox" CTA.
 * ============================================================================= */

/* ---- Frame content shell ------------------------------------------------- */

.frame-content {
    background: var(--cw-bg);
    padding: 32px;
    min-height: 100%;
    overflow-y: auto;
}

.frame-content > h2.sysname,
.frame-content .sysname {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cw-ink);
    margin: 0 0 6px 0;
    letter-spacing: -0.015em;
}

.frame-content p.copyright,
.frame-content p.license {
    color: var(--cw-muted);
    font-size: 0.84rem;
    line-height: 1.5;
    margin: 0 0 4px 0;
}

.frame-content p.license a,
.frame-content p.copyright a {
    color: var(--cw-primary) !important;
    text-decoration: none;
}
.frame-content p.license a:hover,
.frame-content p.copyright a:hover {
    text-decoration: underline;
}

/* About page wrapper – treat the top sysname/copyright block as a hero card */
body.task-settings .frame-content > h2.sysname {
    padding: 24px 28px 4px 28px;
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-lg) var(--cw-radius-lg) 0 0;
    margin: 0;
}
body.task-settings .frame-content > p.copyright,
body.task-settings .frame-content > p.license {
    padding: 0 28px;
    background: var(--cw-card);
    border-left: 1px solid var(--cw-border-soft);
    border-right: 1px solid var(--cw-border-soft);
    margin: 0;
}
body.task-settings .frame-content > p.license {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--cw-border-soft);
    border-radius: 0 0 var(--cw-radius-lg) var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-sm);
    margin-bottom: 24px;
}

/* About: installed plugins block */
.frame-content .readtext {
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-lg);
    padding: 20px 24px;
    box-shadow: var(--cw-shadow-sm);
}

.frame-content .readtext h3 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cw-muted);
    margin: 0 0 14px 0;
}

.frame-content .records-table,
.frame-content #pluginlist {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    font-size: 0.86rem;
}

.frame-content .records-table th {
    text-align: left;
    color: var(--cw-muted) !important;
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--cw-border-soft);
}

.frame-content .records-table td {
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--cw-border-soft);
    color: var(--cw-ink-2);
}

.frame-content .records-table tr:last-child td {
    border-bottom: 0;
}

.frame-content .records-table tr:hover td {
    background: var(--cw-primary-50);
}

/* Plugin name in mono font */
.frame-content .records-table td:first-child,
.frame-content #pluginlist td.name {
    font-family: var(--cw-mono);
    color: var(--cw-ink) !important;
    font-weight: 500;
}

/* ---- Error page -------------------------------------------------------- */

body.task-error .frame-content,
body.errorpage .frame-content {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
}

body.task-error .frame-content > div,
body.task-error #message,
body.errorpage .frame-content > div {
    max-width: 480px;
    background: var(--cw-card);
    border: 1px solid var(--cw-border-soft);
    border-radius: var(--cw-radius-xl);
    box-shadow: var(--cw-shadow-lg);
    padding: 36px 32px;
    text-align: center;
}

body.task-error h1,
body.task-error h2,
body.errorpage h1,
body.errorpage h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--cw-ink);
    margin: 0 0 12px 0;
    letter-spacing: -0.015em;
}

body.task-error p,
body.errorpage p {
    color: var(--cw-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    margin: 0 0 20px 0;
}

body.task-error a.btn,
body.errorpage a.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--cw-primary-deep);
    color: var(--cw-on-primary);
    border-radius: var(--cw-radius);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    box-shadow: 0 1px 2px var(--cw-btn-glow);
    transition: background 0.12s ease, transform 0.1s ease;
}

body.task-error a.btn:hover,
body.errorpage a.btn:hover {
    background: var(--cw-primary-hover);
    transform: translateY(-1px);
}

/* ---- Plugin iframe generic wrapper ------------------------------------- */

.iframe-wrapper {
    background: var(--cw-bg);
    border: 0;
    overflow: hidden;
    height: 100%;
}

iframe.contentframe,
iframe#preferences-frame,
iframe#contact-frame,
iframe#filter-box,
iframe#messagecontframe {
    background: var(--cw-card) !important;
    border: 0 !important;
    width: 100%;
    height: 100%;
}

/* ===== _callout.css ===== */
/* =============================================================================
 * Toasts and transient overlays in the app (post-login).
 *
 * Elastic renders `#messagestack` as dark 320px pills in the bottom-right
 * corner, coloured with its own palette (#2c363a / #37beff / #41b849 /
 * #ffd452 / #ff5552). The login page already had a cloudweb treatment; this
 * gives the rest of the app the same one, so a "Message sent" toast in the
 * inbox looks like a "Login failed" toast on the sign-in screen.
 *
 * Login-page toasts stay in _login.css – they need `body.task-login`
 * specificity and sit top-centre rather than bottom-right.
 * ============================================================================= */

body:not(.task-login) #messagestack {
    right: 16px;
    bottom: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

body:not(.task-login) #messagestack > div {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 12px 15px !important;
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    border: 1px solid var(--cw-border) !important;
    border-radius: var(--cw-radius) !important;
    box-shadow: var(--cw-shadow) !important;
    font-family: var(--cw-sans);
    font-size: 0.87rem;
    font-weight: 500;
    line-height: 1.45;
    animation: cw-toast-in 0.22s var(--cw-easing) both;
}

body:not(.task-login) #messagestack > div > i.icon {
    flex: 0 0 auto;
    font-size: 1.05rem !important;
}

body:not(.task-login) #messagestack > div > i.icon:before {
    color: inherit !important;
}

body:not(.task-login) #messagestack > div a {
    color: var(--cw-on-tint) !important;
    text-decoration: underline;
}

body:not(.task-login) #messagestack .alert-info,
body:not(.task-login) #messagestack .alert-info.information,
body:not(.task-login) #messagestack .loading {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    border-color: var(--cw-primary-100) !important;
}

body:not(.task-login) #messagestack .alert-success {
    background: var(--cw-success-soft) !important;
    color: var(--cw-success-ink) !important;
    border-color: var(--cw-success-border) !important;
}

body:not(.task-login) #messagestack .alert-warning {
    background: var(--cw-warning-soft) !important;
    color: var(--cw-warning-ink) !important;
    border-color: var(--cw-warning-border) !important;
}

body:not(.task-login) #messagestack .alert-warning > i.icon:before {
    color: var(--cw-warning-ink) !important;
}

body:not(.task-login) #messagestack .alert-danger {
    background: var(--cw-danger-soft) !important;
    color: var(--cw-danger-ink) !important;
    border-color: var(--cw-danger-border) !important;
}

@keyframes cw-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    body:not(.task-login) #messagestack > div { animation: none; }
}

/* On phones the stack goes full width above the task rail. */
@media screen and (max-width: 768px) {
    body:not(.task-login) #messagestack {
        left: 8px;
        right: 8px;
        bottom: calc(var(--cw-rail-total) + 8px);
        width: auto;
        max-width: none;
    }

    body:not(.task-login) #messagestack > div {
        min-height: 0 !important;
        border-radius: var(--cw-radius) !important;
    }
}

/* -----------------------------------------------------------------------------
 * Drag preview shown while moving messages or contacts onto a folder. Elastic
 * paints it in its own dark grey.
 * -------------------------------------------------------------------------- */
#rcmdraglayer {
    background: var(--cw-primary-deep) !important;
    color: var(--cw-on-primary) !important;
    border-radius: var(--cw-radius) !important;
    box-shadow: var(--cw-shadow-lg) !important;
    font-family: var(--cw-sans);
    font-size: 0.84rem;
    font-weight: 500;
    padding: 10px 14px !important;
}

/* ===== _appearance.css ===== */
/* =============================================================================
 * Appearance panel – theme (system / light / dark) and list density.
 *
 * Opened from the "Vzhľad" button in the task rail. The markup is built by
 * cloudweb_branding.js; the class names here are a contract with that file.
 * ============================================================================= */

/* ---- Rail button --------------------------------------------------------- */

body:not(.task-login) #taskmenu a.appearance {
    color: var(--cw-ink-2) !important;
}

/* This button carries a real <svg>, so elastic's icon-font ::before is an empty
 * box stacked on top of it – on the phone rail that squeezed the label to 0. */
body:not(.task-login) #taskmenu a.appearance::before {
    content: none !important;
    display: none !important;
}

body:not(.task-login) #taskmenu a.appearance svg {
    width: 20px;
    height: 20px;
    display: block;
    flex: 0 0 auto;
}

body:not(.task-login) #taskmenu a.appearance:hover,
body:not(.task-login) #taskmenu a.appearance.is-open {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

/* ---- Panel --------------------------------------------------------------- */

.cw-appearance-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: transparent;
}

.cw-appearance {
    position: fixed;
    z-index: 1401;
    width: 244px;
    padding: 8px;
    background: var(--cw-card);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius-lg);
    box-shadow: var(--cw-shadow-lg);
    font-family: var(--cw-sans);
    color: var(--cw-ink);
    animation: cw-appearance-in 0.14s var(--cw-easing) both;
}

@keyframes cw-appearance-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cw-appearance { animation: none; }
}

.cw-appearance-group + .cw-appearance-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--cw-border-soft);
}

.cw-appearance-title {
    margin: 0;
    padding: 8px 10px 4px;
    color: var(--cw-muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.cw-appearance-opt {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    background: transparent !important;
    border: 0 !important;
    border-radius: var(--cw-radius-sm);
    color: var(--cw-ink-2) !important;
    font: 500 0.85rem var(--cw-sans);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.cw-appearance-opt:focus-visible {
    outline: 2px solid var(--cw-primary);
    outline-offset: -2px;
}

.cw-appearance-opt:hover {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

.cw-appearance-opt[aria-checked="true"] {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
    font-weight: 600;
}

.cw-appearance-opt .cw-appearance-label {
    flex: 1 1 auto;
    min-width: 0;
}

/* Trailing check, only on the active option. */
.cw-appearance-opt::after {
    content: "";
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    background: currentColor;
    opacity: 0;
    /* Inline check glyph – no dependency on elastic's icon font subset. */
    -webkit-mask: var(--cw-check) center / 14px 14px no-repeat;
    mask: var(--cw-check) center / 14px 14px no-repeat;
}

.cw-appearance-opt[aria-checked="true"]::after { opacity: 1; }

:root {
    --cw-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* ---- Theme glyphs -------------------------------------------------------- */

.cw-appearance-glyph {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    color: var(--cw-muted);
}

.cw-appearance-opt[aria-checked="true"] .cw-appearance-glyph { color: var(--cw-on-tint); }

/* ---- Density glyphs ------------------------------------------------------ */

.cw-appearance-rows {
    flex: 0 0 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 18px;
    height: 18px;
}

.cw-appearance-rows--compact { gap: 1.5px; }

.cw-appearance-rows i {
    display: block;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.55;
}

/* ---- Phone: the rail is at the bottom, so the panel becomes a sheet ------ */

@media screen and (max-width: 768px) {
    .cw-appearance-backdrop { background: var(--cw-overlay); }

    .cw-appearance {
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: calc(var(--cw-rail-total) + 8px) !important;
        width: auto;
        padding: 10px;
    }

    .cw-appearance-opt { padding: 11px 12px; font-size: 0.92rem; }
}

/* ===== _mobile.css ===== */
/* =============================================================================
 * Responsive layer.
 *
 * Elastic drives the layout from JS, not from media queries: `ui.js` measures
 * the window and stamps `layout-phone` (≤480), `layout-small` (481–768),
 * `layout-normal` (769–1200) or `layout-large` (>1200) onto <html>, then shows
 * exactly one pane on phone/small and toggles panes with `.hidden`
 * (`display: none !important`).
 *
 * That matters for the task rail. On `layout-phone` elastic calls j(false),
 * which adds `.hidden` to #layout-menu and only re-shows it as a right-side
 * drawer when the user taps the hamburger – and it re-hides it on every rail
 * click. Our design puts the rail at the bottom as a permanent tab bar, so we
 * have to out-specify `.hidden` and neutralise the drawer treatment. Without
 * that the bottom bar simply never appears on a phone, while #layout still
 * reserves 64px of empty space for it.
 * ============================================================================= */

/* ---- Tablet (≤1080px) – tighter chrome, but still multi-pane ------------- */

@media screen and (max-width: 1080px) {
    #compose-headers,
    #composebodycontainer,
    .cw-editor,
    #compose-content > .formbuttons {
        margin-left: 10px;
        margin-right: 10px;
    }

    .formcontent {
        margin: 10px;
    }
    body.task-addressbook .formcontent {
        margin: 10px;
    }

    #message-header > .subject {
        font-size: 1.25rem !important;
    }
}

/* =============================================================================
 * ≤768px – single pane, bottom task rail
 * ============================================================================= */

@media screen and (max-width: 768px) {

    /* ----- Task rail: permanent bottom tab bar ------------------------- */

    body:not(.task-login) #layout-menu,
    /* beats elastic's `.hidden { display: none !important }` */
    body:not(.task-login) #layout-menu.hidden,
    /* and its drawer treatment, applied when the hamburger is tapped */
    body:not(.task-login) #layout-menu.popover {
        display: flex !important;
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: none !important;
        /* `viewport-fit=cover` lets the page run under the iPhone home
         * indicator, so the rail grows by the safe-area inset or its tap
         * targets end up beneath it. */
        height: var(--cw-rail-total) !important;
        min-height: var(--cw-rail-total) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        z-index: 1200;
        flex-direction: row !important;
        transform: none !important;
        margin: 0 !important;
        background: var(--cw-card) !important;
        border: 0 !important;
        border-top: 1px solid var(--cw-border) !important;
        border-radius: 0 !important;
        box-shadow: var(--cw-shadow-rail) !important;
    }

    /* The rail is always on screen, so the hamburger that would open it as a
     * drawer is dead weight – and tapping it would drop a scrim over the app
     * for a menu that never visually changes. */
    body:not(.task-login) .header > a.task-menu-button,
    #menu-overlay {
        display: none !important;
    }

    /* Logo + drawer close button belong to the drawer presentation only. */
    body:not(.task-login) #layout-menu .popover-header {
        display: none !important;
    }

    body:not(.task-login) #taskmenu {
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        gap: 0 !important;
        height: 100% !important;
        width: 100%;
        padding: 0 6px !important;
        overflow: visible !important;
    }

    /* The two <span> wrappers exist only to group buttons for the vertical
     * desktop rail. Flattening them makes every button a direct flex item of
     * #taskmenu, so the tabs share the width evenly instead of overflowing –
     * which matters because the taskbar container can also receive buttons
     * from other plugins. */
    body:not(.task-login) #taskmenu .action-buttons,
    body:not(.task-login) #taskmenu .special-buttons {
        display: contents !important;
    }

    /* Content-sized, not equal-width: a short label like "Mail" hands its
     * spare width to a long one like "Appearance" instead of clipping it. */
    body:not(.task-login) #taskmenu a {
        flex: 0 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 90px !important;
        height: 52px !important;
        min-height: 52px !important;
        max-height: 52px !important;
        margin: 0 1px !important;
        padding: 6px 5px !important;
    }

    body:not(.task-login) #taskmenu a .inner {
        flex: 0 0 auto;
        font-size: 0.72rem;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body:not(.task-login) #taskmenu a.compose {
        border-radius: var(--cw-radius-lg) !important;
    }

    /* Push app content clear of the rail. */
    body:not(.task-login) #layout {
        padding-bottom: var(--cw-rail-total) !important;
    }

    /* Elastic's own compose FAB duplicates the rail's Compose button and
     * would land on top of it. */
    .floating-action-buttons {
        display: none !important;
    }

    /* ----- Panes -------------------------------------------------------- */

    #layout-sidebar,
    #layout-list,
    #layout-content {
        border-right: 0 !important;
        border-left: 0 !important;
        max-width: none !important;
    }

    /* Cards go edge to edge. */
    #compose-headers,
    #composebodycontainer,
    .cw-editor,
    #compose-content > .formbuttons,
    .formcontent,
    body.task-addressbook .formcontent,
    body.task-addressbook .formbuttons {
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: 0 !important;
        border-right: 0 !important;
        box-shadow: none !important;
    }

    /* ----- Pane header --------------------------------------------------
     * Below 769px the actions stay in the popover behind the hamburger, so
     * the header only carries back / title / search / hamburger.
     *
     * elastic parks those actions in a `.popupmenu` (display:none) inside the
     * header; two separate rules in this skin force header toolbars back to
     * inline-flex, and both have to be undone here or ~7 tiles fight the title
     * and the search field for 390px. */
    #layout .header ul.toolbar.popupmenu,
    .header ul.toolbar.popupmenu,
    #layout-list > .header .toolbar.popupmenu,
    #layout-content > .header .toolbar.popupmenu {
        display: none !important;
    }


    #layout .header,
    .header.toolbar {
        min-height: 52px !important;
        padding: 4px 6px !important;
        gap: 0;
        overflow: visible !important;
    }

    #layout .header .header-title,
    .header.toolbar .header-title {
        flex: 1 1 auto !important;
        min-width: 0;
        margin: 0 6px !important;
        font-size: 0.95rem !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Header buttons become icon-only squares – there is no room for the
     * stacked icon+label tiles the desktop header uses. */
    #layout .header > a.button.icon,
    .header > a.button.icon {
        min-width: 44px !important;
        width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
        flex: 0 0 auto !important;
    }

    #layout .header > a.button.icon:before,
    .header > a.button.icon:before {
        font-size: 1.15rem !important;
    }

    #layout .header > a.button.icon > .inner,
    .header > a.button.icon > .inner {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
    }

    /* ----- Lists --------------------------------------------------------
     * `html.layout-phone .messagelist tr` becomes `display: flex`, which drops
     * the table sizing the desktop rules rely on. */

    .messagelist tbody tr {
        align-items: stretch;
    }

    .messagelist tbody td.threads,
    .messagelist tbody td.status,
    /* elastic only reveals the checkbox column in select mode; forcing it
     * visible cost 36px of a 390px screen on every row. */
    .messagelist.withselection tbody td.selection {
        flex: 0 0 auto;
        display: flex !important;
        align-items: center;
        justify-content: center;
        line-height: 1 !important;
    }

    .messagelist:not(.withselection) tbody td.selection { display: none !important; }

    .messagelist tbody td {
        min-height: 62px;
        padding: 10px !important;
    }

    .messagelist tbody td.subject span.date {
        font-size: 0.68rem !important;
    }

    /* `html.layout-phone .messagelist td.flags` is absolutely positioned over
     * the right edge of the row, so the date needs to stop short of it. */
    .messagelist tbody td.subject {
        padding-right: 30px !important;
    }

    #contacts-table.contactlist tbody td {
        height: 62px;
    }

    ul.treelist li > a,
    ul.listing.iconized li > a {
        min-height: 42px;
        font-size: 0.9rem;
    }

    #sections-table.listing.iconized tbody tr td.section {
        min-height: 44px;
        font-size: 0.92rem;
    }

    .searchbar,
    #searchbar {
        min-width: 0;
        flex: 1 1 auto;
        width: auto;
    }

    /* The folder name must not push the search field down to icons-only. */
    #layout .header .header-title,
    .header.toolbar .header-title {
        max-width: 40%;
    }

    /* ----- Compose ------------------------------------------------------ */

    #compose-headers .compose-headers .form-group.row > label.col-form-label {
        width: 64px !important;
        font-size: 0.7rem !important;
    }

    /* One scrollable row beats three wrapped rows eating a third of a phone
     * screen before the user can type anything. */
    .cw-editor-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    /* `html.touch` restores the platform scrollbar everywhere, which put a
     * track under the toolbar row – this one stays hidden, it is swiped. */
    .cw-editor-toolbar::-webkit-scrollbar,
    html.touch .cw-editor-toolbar::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }

    html.touch .cw-editor-toolbar { scrollbar-width: none; }

    .cw-editor-btn,
    .cw-editor-toolbar-sep {
        flex: 0 0 auto;
    }

    #composebodycontainer,
    .cw-editor {
        min-height: 220px;
    }

    #composebodycontainer textarea#composebody,
    .cw-editor .ProseMirror {
        min-height: 180px;
    }

    /* iOS zooms any input whose font-size is under 16px on focus, which
     * silently breaks the layout for the rest of the session. */
    #composebodycontainer textarea#composebody,
    .cw-editor .ProseMirror,
    #compose-headers .input-group input.form-control,
    #compose-subject,
    .searchbar input,
    .cw-modal-input,
    .formcontent input.form-control,
    .formcontent select.form-control,
    .formcontent textarea.form-control,
    #contacttabs input.form-control {
        font-size: 16px !important;
    }

    /* ----- Reading pane -------------------------------------------------- */

    #message-header > .subject {
        font-size: 1.15rem !important;
    }
    #message-header > .header img.contactphoto {
        width: 36px !important;
        height: 36px !important;
        flex: 0 0 36px;
    }

    /* ----- Contacts ------------------------------------------------------ */

    .contact-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 18px;
    }
    #contactphoto img,
    #contactpic,
    .contact-photo img {
        width: 72px !important;
        height: 72px !important;
    }
    #contacthead.contact-head .names {
        font-size: 1.25rem !important;
    }
    #contacttabs.tabbed {
        padding: 14px 18px 18px 18px;
    }
    #contacttabs fieldset.propform.grouped .row.input-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    #contacttabs fieldset.propform.grouped .row.input-group > *:first-child {
        flex: 0 0 auto !important;
        min-width: 0 !important;
    }

    /* ----- Settings / filters -------------------------------------------- */

    #filter-form table.propform > tbody > tr > td.title {
        display: block;
        width: 100% !important;
        min-width: 0;
        padding-top: 10px !important;
    }

    #vacationform.propform td.datetime {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    #vacationform.propform td.datetime input.form-control {
        width: 100%;
    }

    table.propform > tbody > tr > td.title,
    table.propform > tbody > tr > th.title {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        padding: 0 0 4px 0 !important;
    }

    table.propform > tbody > tr > td:not(.title):not(.rowbuttons) {
        display: block;
        width: 100%;
    }

    .formcontainer .formbuttons {
        padding: 12px 16px !important;
        /* Above the task rail, not underneath it. */
        bottom: 0;
    }

    /* ----- Dialogs -------------------------------------------------------- */

    .ui-dialog {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        left: 12px !important;
        right: 12px !important;
        max-height: calc(100vh - var(--cw-rail-total) - 24px) !important;
    }
    .ui-dialog .ui-dialog-titlebar {
        padding: 12px 16px !important;
    }
    .ui-dialog .ui-dialog-content {
        padding: 16px 18px !important;
    }
}

/* =============================================================================
 * ≤480px – elastic's `layout-phone`
 * ============================================================================= */

@media screen and (max-width: 480px) {

    body:not(.task-login) #taskmenu a {
        max-width: 76px !important;
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        padding: 6px 3px !important;
        gap: 2px !important;
    }
    body:not(.task-login) #taskmenu a .inner {
        font-size: 0.68rem;
        letter-spacing: -0.01em;
    }
    body:not(.task-login) #taskmenu a::before {
        font-size: 1.1rem !important;
    }

    :root { --cw-rail-h: 58px; }

    #compose-headers .compose-headers .form-group.row > label.col-form-label {
        width: 48px !important;
        font-size: 0.66rem !important;
    }

    #contacts-table.contactlist span.email {
        display: none;
    }

    #filter-form table.propform td.rowbuttons a {
        width: 28px;
        height: 28px;
    }
}

/* ---- Use 100dvh on iOS Safari to avoid keyboard viewport jumps ---------- */

@supports (height: 100dvh) {
    @media screen and (max-width: 768px) {
        html,
        body:not(.task-login) {
            height: 100dvh;
        }
        body:not(.task-login) #layout {
            height: 100dvh;
        }
    }
}

/* ---- Touch-only tweaks (Roundcube adds html.touch) ---------------------- */

html.touch ul.treelist li > a,
html.touch ul.listing.iconized li > a {
    min-height: 44px;
    font-size: 0.92rem;
}

html.touch .messagelist tbody td {
    min-height: 64px;
    font-size: 0.92rem !important;
}

/* `html.touch .messagelist tr` is `display: flex` at every width, including
 * on a touch laptop, so the subject cell needs to stay shrinkable there too. */
html.touch .messagelist tbody td.subject {
    flex: 1 1 auto;
    min-width: 0;
}

html.touch .messagelist tbody td.flags {
    align-self: flex-start;
}

html.touch .toolbar .button,
html.touch .header .button:not(.cancel) {
    min-width: 44px;
    height: 44px;
}

html.touch .popupmenu li > a,
html.touch .dropdown-menu li > a,
html.touch .popover .listing li a {
    min-height: 44px;
    font-size: 0.9rem;
}

/* =============================================================================
 * Message navigation bar (Previous / Reply / Next) – elastic only shows it
 * below 769px. Its buttons are laid out in a row, so the label wrapped under
 * the icon and the 44px button clipped it.
 * ============================================================================= */
@media screen and (max-width: 768px) {
    .content-frame-navigation {
        height: 56px !important;
        padding: 0 4px !important;
        background: var(--cw-card) !important;
        border-top: 1px solid var(--cw-border) !important;
        box-shadow: none !important;
    }

    /* Elastic drops the message-nav arrows on pages that have nothing to page
     * through (compose, settings sections) – our display rule must not undo it. */
    .content-frame-navigation.hide-nav-buttons a.prev,
    .content-frame-navigation.hide-nav-buttons a.next {
        display: none !important;
    }

    /* Compose already has Send in the footer bar; the form's own submit row
     * would be a second one two thumb-widths away. */
    #compose-content > .formbuttons {
        display: none !important;
    }

    .content-frame-navigation a.button {
        display: inline-flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px;
        height: 100% !important;
        min-width: 0 !important;
        padding: 0 10px !important;
        color: var(--cw-muted) !important;
        white-space: nowrap;
    }

    .content-frame-navigation a.button > .inner {
        display: inline !important;
        font-size: 0.8rem;
        line-height: 1;
    }

    .content-frame-navigation a.button.disabled {
        opacity: 0.45;
        pointer-events: none;
    }

    .content-frame-navigation a.button:not(.disabled):active {
        color: var(--cw-on-tint) !important;
    }
}

/* =============================================================================
 * Touch devices have no pointer to move away, so a tapped row keeps its
 * :hover paint until something else is tapped – a folder you visited once
 * reads as selected forever. Gated on elastic's own `html.touch` rather than
 * `(hover: none)`, which desktop Chrome reports false for even while elastic
 * has decided the device is touch. Selection and the active press stay.
 * ============================================================================= */
html.touch ul.listing li:not(.selected) > a:hover,
html.touch ul.listing.iconized li:not(.selected) > a:hover,
html.touch ul.treelist li:not(.selected) > a:hover {
    background: transparent !important;
    color: var(--cw-ink-2) !important;
}

html.touch ul.listing li:not(.selected) > a:hover:before,
html.touch ul.listing.iconized li:not(.selected) > a:hover:before,
html.touch ul.treelist li:not(.selected) > a:hover:before {
    color: var(--cw-muted) !important;
}

html.touch .messagelist tbody tr:not(.selected):hover td { background: transparent !important; }

html.touch body:not(.task-login) #taskmenu a:not(.selected):hover {
    background: transparent !important;
}

html.touch .popupmenu li > a:not(.active):hover,
html.touch .popover .listing li > a:not(.selected):hover {
    background: transparent !important;
}

/* The press itself still has to be felt. */
html.touch ul.listing li > a:active,
html.touch ul.listing.iconized li > a:active,
html.touch ul.treelist li > a:active,
html.touch .messagelist tbody tr:active td,
html.touch .popupmenu li > a:active,
html.touch .popover .listing li > a:active {
    background: var(--cw-primary-50) !important;
}

/* ===== _login.css ===== */
/* =============================================================================
 * LOGIN PAGE – mirrors cloudweb.sk hero aesthetic
 * (radial-gradient + 48px grid on light #F9FBFC bg, white card,
 * gradient-text heading, domain-form input pattern, primary-deep button)
 * ============================================================================= */

html, body.task-login {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

body.task-login {
    background: var(--cw-bg) !important;
    font-family: var(--cw-sans);
    color: var(--cw-ink);
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* Hero radial glow (blue + faint green) – same recipe as .hero::before */
body.task-login::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, var(--cw-glow-primary), transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 30%, var(--cw-glow-success), transparent 70%),
        radial-gradient(ellipse 70% 50% at 0% 80%, var(--cw-glow-primary-soft), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* 48px grid texture with radial mask – same recipe as .hero::after */
body.task-login::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--cw-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--cw-grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 30%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

/* Override elastic's #layout for full-screen flex centering */
body.task-login #layout {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh;
    padding: 1.5rem;
    margin: 0 !important;
    background: transparent !important;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

body.task-login #layout-content.cw-login-shell {
    width: 100%;
    max-width: 1040px;
    text-align: left !important;
    display: block !important;
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0;
    overflow: visible;
    animation: cw-fade-up 0.7s var(--cw-easing) both;
}

/* Override elastic's absolutely-positioned #login-form */
body.task-login #login-form.cw-login-form-wrapper {
    margin: 0 !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: none !important;
    position: static !important;
}

/* --- Hide elastic's leaking UI on the login page ------------------------- */
body.task-login h1.voice,
body.task-login .voice {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

body.task-login .input-group-prepend,
body.task-login .input-group-append,
body.task-login .input-group-text {
    display: none !important;
}
body.task-login .input-group { display: block !important; }

body.task-login .content-frame-navigation,
body.task-login .footer.menu.toolbar,
body.task-login #rcmloginsubmit-clone,
body.task-login .footer.menu { display: none !important; }

body.task-login #layout-content > #logo,
body.task-login #layout-content > .logo,
body.task-login > #layout > #logo { display: none !important; }

body.task-login #login-footer { display: none !important; }

body.task-login form > p > br { display: none; }

@keyframes cw-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Card ---------------------------------------------------------------- */
.cw-login-card {
    background: var(--cw-card);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius-xl);
    box-shadow: var(--cw-shadow-lg);
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    min-height: 560px;
}

@media (min-width: 900px) {
    .cw-login-card { grid-template-columns: 1.05fr 0.95fr; }
}

/* --- Form column --------------------------------------------------------- */
.cw-login-form-col {
    padding: 2.75rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--cw-card);
}

@media (min-width: 900px) {
    .cw-login-form-col { padding: 3.25rem 3.25rem 2.25rem; }
}

/* --- Brand lockup (mirrors nav .logo on cloudweb.sk) --------------------- */
.cw-login-brand,
.cw-login-brand:hover,
.cw-login-brand:focus {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--cw-ink);
    line-height: 1;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.cw-login-brand:hover { opacity: 0.75; }
.cw-login-brand:hover em, .cw-login-brand:focus em { color: var(--cw-primary); }

.cw-login-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    display: block;
}

.cw-login-wordmark { display: inline-flex; align-items: baseline; gap: 6px; }
.cw-login-wordmark em { font-style: normal; color: var(--cw-primary); }
.cw-login-wordmark .cw-login-product {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--cw-muted);
    letter-spacing: -0.01em;
    padding-left: 8px;
    margin-left: 2px;
    border-left: 1px solid var(--cw-border);
}

/* --- Heading (mirrors .page-hero h1) ------------------------------------- */
.cw-login-heading {
    font-size: clamp(1.75rem, 3vw, 2.1rem);
    font-weight: 600;
    color: var(--cw-ink);
    margin: 0.5rem 0 0;
    letter-spacing: -0.03em;
    line-height: 1.08;
    animation: cw-fade-up 0.7s var(--cw-easing) both;
    animation-delay: 0.05s;
}

.cw-login-heading em {
    font-style: normal;
    background: linear-gradient(135deg, var(--cw-primary) 20%, var(--cw-accent-2) 80%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cw-login-subheading {
    font-size: 0.95rem;
    color: var(--cw-muted);
    margin: 0;
    line-height: 1.55;
    max-width: 32ch;
    animation: cw-fade-up 0.7s var(--cw-easing) both;
    animation-delay: 0.1s;
}

/* --- Form (Roundcube renders it as a table – we restyle aggressively) ---- */
.cw-login-form-wrapper {
    margin-top: 0.25rem;
    animation: cw-fade-up 0.7s var(--cw-easing) both;
    animation-delay: 0.15s;
}

.cw-login-form-wrapper form { margin: 0; }

.cw-login-form-wrapper table,
.cw-login-form-wrapper tbody,
.cw-login-form-wrapper tr,
.cw-login-form-wrapper td {
    display: block;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
}

.cw-login-form-wrapper tr { margin-bottom: 0.95rem; }

/* Hide host pulldown row (single-host deployment) */
.cw-login-form-wrapper tr:has(input[type="hidden"]) { display: none; }
.cw-login-form-wrapper tr:has(select#rcmloginhost) { display: none; }

.cw-login-form-wrapper td.title { margin-bottom: 0.4rem; }

.cw-login-form-wrapper td.title label {
    display: block;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--cw-ink-2);
    margin: 0;
    letter-spacing: 0.005em;
}

/* Input – mirrors .domain-form aesthetic (bg-soft resting, card on focus) */
.cw-login-form-wrapper td.input input,
.cw-login-form-wrapper td.input select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 0.95rem;
    font-size: 0.95rem;
    font-family: var(--cw-sans);
    font-weight: 500;
    color: var(--cw-ink);
    background: var(--cw-bg-soft);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.cw-login-form-wrapper td.input input:hover { border-color: var(--cw-muted-2); }

.cw-login-form-wrapper td.input input:focus,
.cw-login-form-wrapper td.input select:focus {
    border-color: var(--cw-primary);
    box-shadow: var(--cw-ring);
    background: var(--cw-card);
    outline: none;
}

.cw-login-form-wrapper td.input input::placeholder {
    color: var(--cw-muted-2);
    font-weight: 400;
}

/* --- Submit button (mirrors .btn--primary / .domain-form submit) --------- */
.cw-login-form-wrapper p.formbuttons { margin: 1.3rem 0 0; }

.cw-login-form-wrapper button#rcmloginsubmit,
.cw-login-form-wrapper button.mainaction {
    width: 100%;
    padding: 0.85rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--cw-sans);
    color: var(--cw-on-primary);
    background: var(--cw-primary-deep);
    border: 1px solid transparent;
    border-radius: var(--cw-radius);
    cursor: pointer;
    letter-spacing: 0.005em;
    transition: background 0.15s ease, transform 0.15s var(--cw-easing), box-shadow 0.25s ease;
    box-shadow: 0 1px 2px var(--cw-btn-glow), inset 0 1px 0 var(--cw-hilite);
}

.cw-login-form-wrapper button#rcmloginsubmit:hover,
.cw-login-form-wrapper button.mainaction:hover {
    background: var(--cw-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -6px var(--cw-btn-glow-strong), inset 0 1px 0 var(--cw-hilite-strong);
}

.cw-login-form-wrapper button#rcmloginsubmit:active,
.cw-login-form-wrapper button.mainaction:active {
    transform: translateY(0);
    filter: brightness(0.97);
}

/* --- Passkey button (poste_passkey_login plugin) ------------------------- */
.cw-login-form-wrapper #passkey-login-btn {
    width: 100%;
    padding: 0.7rem 1.1rem;
    margin-top: 0.6rem;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--cw-sans);
    color: var(--cw-ink-2);
    background: var(--cw-card);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cw-login-form-wrapper #passkey-login-btn:hover {
    border-color: var(--cw-primary);
    background: var(--cw-primary-50);
    color: var(--cw-on-tint);
}

.cw-login-form-wrapper #passkey-login-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.75;
}

.cw-login-form-wrapper p:has(#passkey-login-btn) {
    margin: 0;
    text-align: center;
}
.cw-login-form-wrapper p:has(#passkey-login-btn) br { display: none; }

/* --- Footer link row ----------------------------------------------------- */
.cw-login-footer {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--cw-muted);
    animation: cw-fade-up 0.7s var(--cw-easing) both;
    animation-delay: 0.25s;
}

.cw-login-footer a {
    color: var(--cw-muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.cw-login-footer a:hover { color: var(--cw-on-tint); }

.cw-login-footer .cw-sep { color: var(--cw-muted-2); opacity: 0.7; }

/* --- Theme picker (the login screen has no task rail) -------------------- */
.cw-login-theme {
    display: inline-flex;
    margin-left: auto;
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    overflow: hidden;
}

/* elastic's ui.js stamps `btn btn-secondary` onto every classless <button>,
 * and this skin's own .btn-secondary rule paints those !important. */
.cw-login-theme button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    border-left: 1px solid var(--cw-border) !important;
    border-radius: 0;
    color: var(--cw-muted-2) !important;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cw-login-theme button:first-child { border-left: 0 !important; }

.cw-login-theme button:hover {
    background: var(--cw-bg-soft) !important;
    color: var(--cw-ink-2) !important;
}

.cw-login-theme button[aria-checked="true"] {
    background: var(--cw-primary-50) !important;
    color: var(--cw-on-tint) !important;
}

.cw-login-theme svg { width: 15px; height: 15px; }

/* --- Right column: illustration ------------------------------------------ */
.cw-login-illustration-col {
    display: none;
    position: relative;
    background:
        radial-gradient(ellipse 80% 60% at 50% 10%, var(--cw-glow-primary), transparent 65%),
        radial-gradient(ellipse 60% 40% at 100% 90%, var(--cw-glow-success), transparent 70%),
        linear-gradient(180deg, var(--cw-bg) 0%, var(--cw-bg-soft) 100%);
    padding: 3rem 2.5rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    overflow: hidden;
    border-left: 1px solid var(--cw-border-soft);
}

@media (min-width: 900px) {
    .cw-login-illustration-col { display: flex; }
}

/* 48px grid texture with radial mask on the illustration column */
.cw-login-illustration-col::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--cw-grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--cw-grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 30%, transparent 80%);
}

.cw-illu {
    width: 100%;
    max-width: 380px;
    height: auto;
    position: relative;
    z-index: 1;
    animation: cw-float 6s ease-in-out infinite;
}

@keyframes cw-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.cw-illu-caption {
    text-align: center;
    max-width: 320px;
    position: relative;
    z-index: 1;
    animation: cw-fade-up 0.8s var(--cw-easing) both;
    animation-delay: 0.3s;
}

.cw-illu-caption h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--cw-ink);
    margin: 0 0 0.4rem;
    letter-spacing: -0.015em;
}

.cw-illu-caption p {
    font-size: 0.88rem;
    color: var(--cw-muted);
    margin: 0;
    line-height: 1.55;
}

/* --- Roundcube toast stack on the login page ----------------------------- */
/* Roundcube JS calls rcmail.display_message("Login failed.","warning",0),
 * which injects a child div into #messagestack. Elastic's default positions
 * it bottom-right, 320px, dark pill – easy to miss on our light layout.
 * Override for login: top-center, wide, on-brand danger/warning styling.
 */
body.task-login #messagestack {
    position: fixed !important;
    top: 1.25rem !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 2rem);
    max-width: 480px;
    height: auto !important;
    max-height: none !important;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

body.task-login #messagestack > div {
    pointer-events: auto;
    padding: 0.85rem 1.1rem !important;
    border-radius: var(--cw-radius) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.45 !important;
    background: var(--cw-card) !important;
    color: var(--cw-ink) !important;
    border: 1px solid var(--cw-border) !important;
    box-shadow: var(--cw-shadow) !important;
    animation: cw-fade-up 0.35s var(--cw-easing) both;
}

body.task-login #messagestack > div.error,
body.task-login #messagestack > div.loginerror {
    background: var(--cw-danger-soft) !important;
    color: var(--cw-danger-ink) !important;
    border-color: var(--cw-danger-border) !important;
}

body.task-login #messagestack > div.warning {
    background: var(--cw-warning-soft) !important;
    color: var(--cw-warning-ink) !important;
    border-color: var(--cw-warning-border) !important;
}

body.task-login #messagestack > div.confirmation,
body.task-login #messagestack > div.notice {
    background: var(--cw-success-soft) !important;
    color: var(--cw-success-ink) !important;
    border-color: var(--cw-success-border) !important;
}

/* Legacy #message container (some Roundcube paths still use it) */
body.task-login #message {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: 480px;
    width: calc(100% - 2rem);
}
body.task-login #message > div {
    padding: 0.85rem 1.1rem;
    border-radius: var(--cw-radius);
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--cw-card);
    color: var(--cw-ink);
    border: 1px solid var(--cw-border);
    box-shadow: var(--cw-shadow);
}
body.task-login #message > div.error {
    background: var(--cw-danger-soft);
    color: var(--cw-danger-ink);
    border-color: var(--cw-danger-border);
}
body.task-login #message > div.warning {
    background: var(--cw-warning-soft);
    color: var(--cw-warning-ink);
    border-color: var(--cw-warning-border);
}

/* --- Responsive: tighten on mobile --------------------------------------- */
@media (max-width: 600px) {
    body.task-login #layout { padding: 0; align-items: stretch; }
    .cw-login-card {
        border-radius: 0;
        border: 0;
        min-height: 100vh;
        box-shadow: none;
    }
    .cw-login-form-col {
        padding: 2rem 1.5rem 1.5rem;
        justify-content: flex-start;
    }
    .cw-login-heading { font-size: 1.55rem; }
}

/* --- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .cw-login-shell,
    .cw-login-heading,
    .cw-login-subheading,
    .cw-login-form-wrapper,
    .cw-login-footer,
    .cw-illu,
    .cw-illu-caption {
        animation: none !important;
    }
}
