/* =========================================================================
   MLS app chrome - shared by every app (mail, contacts, spaces, wiki, chat,
   kanban, files, core, learn, landing). Loaded by templates/app_base.html.

   Structure (borrowed from Proton): the chrome - top bar + sidebar - sits on
   a tinted canvas; the work happens on one raised "sheet". Identity:
   classification is the organising visual - stamped monospace markings in
   the level's own colours, level-coloured edges on rows and attachments.

   Three independent axes on <body>, from the user's settings:
     data-mail-theme    clean (default) | graphite | paper | midnight | terminal
     data-mail-density  compact | normal (default) | spacious
     data-mail-page     mailbox (fixed-height app) | page
   Site chrome (demo bars, classification banners, the red lock chip) reads
   from fixed colours or the content's own level colour, so it stays correct
   in every theme. App stylesheets (mail.css, wiki.css, ...) add only their
   own content styles on top.
   ========================================================================= */

:root {
    --m-accent: #2850D8;
    --m-accent-hover: #1E40B4;
    --m-accent-weak: #E9EEFC;
    --m-accent-fg: #FFFFFF;
    --m-canvas: #ECEFF4;
    --m-surface: #FFFFFF;
    --m-surface-2: #F5F7FA;
    --m-hover: #F2F5F9;
    --m-select: #E3EAFC;
    --m-chrome-hover: rgba(19, 28, 46, 0.07);
    --m-border: #E1E5EC;
    --m-border-soft: #EDF0F4;
    --m-border-strong: #C9D0DB;
    --m-text: #131C2E;
    --m-text-2: #39445A;
    --m-muted: #5B6779;
    --m-avatar-bg: #E6EBF3;
    --m-avatar-fg: #34405A;
    --m-danger: #C8322A;
    --m-danger-bg: #FDECEB;
    --m-warn: #8A4B00;
    --m-warn-bg: #FFF6E5;
    --m-warn-border: #F2B544;
    --m-success: #1C7A4B;
    --m-success-bg: #E5F6EC;
    --m-star: #E9A400;
    --m-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 24px -8px rgba(16, 24, 40, 0.10);
    --m-ring: 0 0 0 3px rgba(40, 80, 216, 0.22);

    --m-font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --m-font-head: var(--m-font);
    --m-font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --m-radius: 10px;
    --m-radius-sm: 7px;
    --m-radius-lg: 14px;

    /* site chrome heights (templates/_demo_bar.html + bottom demo banner) */
    --m-chrome-top: 22px;
    --m-chrome-bottom: 19px;
}

/* ---- Graphite: dark, cyan accent ------------------------------------- */
[data-mail-theme="graphite"] {
    --m-accent: #3CC8DB; --m-accent-hover: #67D7E6; --m-accent-weak: #15323B; --m-accent-fg: #06181C;
    --m-canvas: #0D141B; --m-surface: #151F29; --m-surface-2: #1A2531; --m-hover: #1B2834; --m-select: #183A45;
    --m-chrome-hover: rgba(255, 255, 255, 0.07);
    --m-border: #263441; --m-border-soft: #1F2B37; --m-border-strong: #34475A;
    --m-text: #E6EDF3; --m-text-2: #C3CED8; --m-muted: #8D9EAE;
    --m-avatar-bg: #22313F; --m-avatar-fg: #C3D2DE;
    --m-danger: #FF7A66; --m-danger-bg: #351813;
    --m-warn: #E6AA5C; --m-warn-bg: #2C2214; --m-warn-border: #6B5220;
    --m-success: #4BD08B; --m-success-bg: #10241A;
    --m-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px -10px rgba(0, 0, 0, 0.55);
    --m-ring: 0 0 0 3px rgba(60, 200, 219, 0.28);
}

/* ---- Paper: warm light, serif headings ------------------------------- */
[data-mail-theme="paper"] {
    --m-accent: #9A3B2E; --m-accent-hover: #7E2E23; --m-accent-weak: #F3E4DE; --m-accent-fg: #FFFFFF;
    --m-canvas: #EFE9DE; --m-surface: #FFFDF8; --m-surface-2: #F7F2E8; --m-hover: #F7F1E6; --m-select: #F1E0D8;
    --m-chrome-hover: rgba(60, 40, 20, 0.07);
    --m-border: #E4DBCB; --m-border-soft: #EEE7DA; --m-border-strong: #D2C5AE;
    --m-text: #2C2823; --m-text-2: #4A433A; --m-muted: #786E5F;
    --m-avatar-bg: #EDE3D2; --m-avatar-fg: #5A4E3E;
    --m-danger: #A5342A; --m-danger-bg: #F6E3E0;
    --m-warn: #84540D; --m-warn-bg: #F6ECD8; --m-warn-border: #C9A24A;
    --m-success: #3F7D4F; --m-success-bg: #E4EFE0;
    --m-ring: 0 0 0 3px rgba(154, 59, 46, 0.2);
    --m-font-head: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --m-radius: 6px; --m-radius-sm: 4px; --m-radius-lg: 8px;
}

/* ---- Midnight: deep navy, periwinkle accent -------------------------- */
[data-mail-theme="midnight"] {
    --m-accent: #8B9BFF; --m-accent-hover: #A9B5FF; --m-accent-weak: #1F2650; --m-accent-fg: #0B0E1F;
    --m-canvas: #0A0D1A; --m-surface: #12162B; --m-surface-2: #171C36; --m-hover: #181E3A; --m-select: #232C5E;
    --m-chrome-hover: rgba(255, 255, 255, 0.07);
    --m-border: #252C4D; --m-border-soft: #1D2342; --m-border-strong: #333B66;
    --m-text: #E7E9F6; --m-text-2: #C7CBE4; --m-muted: #9297BC;
    --m-avatar-bg: #232A4F; --m-avatar-fg: #C9CEF0;
    --m-danger: #FF7A93; --m-danger-bg: #2E1422;
    --m-warn: #E0AA55; --m-warn-bg: #2A2213; --m-warn-border: #5F4A1F;
    --m-success: #59D0A8; --m-success-bg: #11241F;
    --m-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 10px 30px -10px rgba(0, 0, 0, 0.6);
    --m-ring: 0 0 0 3px rgba(139, 155, 255, 0.3);
    --m-radius: 12px; --m-radius-sm: 8px; --m-radius-lg: 16px;
}

/* ---- Terminal: monospace, square, amber on near-black ---------------- */
[data-mail-theme="terminal"] {
    --m-accent: #E8B64C; --m-accent-hover: #F2C76A; --m-accent-weak: #2A2211; --m-accent-fg: #0A0A0A;
    --m-canvas: #080808; --m-surface: #111111; --m-surface-2: #161616; --m-hover: #1A1A1A; --m-select: #2A2211;
    --m-chrome-hover: rgba(232, 182, 76, 0.1);
    --m-border: #2A2A2A; --m-border-soft: #1E1E1E; --m-border-strong: #3A3A3A;
    --m-text: #D9D6CB; --m-text-2: #BDB9AC; --m-muted: #8C887B;
    --m-avatar-bg: #1E1E1E; --m-avatar-fg: #E8B64C;
    --m-danger: #FF6B61; --m-danger-bg: #2A1210;
    --m-warn: #D7A24A; --m-warn-bg: #241D0F; --m-warn-border: #4A3C1C;
    --m-success: #7FD06A; --m-success-bg: #14210F;
    --m-shadow: none;
    --m-ring: 0 0 0 2px var(--m-accent);
    --m-font: var(--m-font-mono); --m-font-head: var(--m-font-mono);
    --m-radius: 0; --m-radius-sm: 0; --m-radius-lg: 0;
}
[data-mail-theme="terminal"] .m-brand-name::before { content: "$ "; color: var(--m-accent); }

/* =========================================================================
   Density - HOW MUCH room. Per user (MailProfile.density), independent of
   theme and layout.
     compact   one line per message, no avatars, tight chrome
     normal    two lines (sender / subject), avatars
     spacious  adds a two-line preview, bigger type and targets
   ========================================================================= */
body {
    --m-cols: minmax(110px, 180px) minmax(0, 1fr) auto 104px 52px;   /* compact one-line columns */
    --m-sidebar-w: 236px; --m-topbar-h: 60px; --m-nav-h: 36px;
    --m-row-py: 10px; --m-row-fs: 14px; --m-avatar: 32px; --m-list-w: 420px;
    --m-body-fs: 15px; --m-body-lh: 1.62; --m-pad: 24px;
}
body[data-mail-density="compact"] {
    --m-sidebar-w: 208px; --m-topbar-h: 50px; --m-nav-h: 30px;
    --m-row-py: 6px; --m-row-fs: 13px; --m-avatar: 0px; --m-list-w: 440px;
    --m-body-fs: 14px; --m-body-lh: 1.5; --m-pad: 16px;
}
body[data-mail-density="spacious"] {
    --m-sidebar-w: 260px; --m-topbar-h: 68px; --m-nav-h: 42px;
    --m-row-py: 14px; --m-row-fs: 15px; --m-avatar: 40px; --m-list-w: 480px;
    --m-body-fs: 16px; --m-body-lh: 1.75; --m-pad: 32px;
}

/* =========================================================================
   Base
   ========================================================================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--m-font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--m-canvas);
    color: var(--m-text);
    padding-top: var(--m-chrome-top);
    padding-bottom: var(--m-chrome-bottom);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--m-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--m-font-head); letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-inline { display: inline-flex; margin: 0; }
.m-muted { color: var(--m-muted); }

.m-ico {
    width: 18px; height: 18px; flex-shrink: 0;
    fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.m-ico-sm { width: 14px; height: 14px; }

/* ---- Demo / classification banners (site chrome - not themed) ---- */
.demo-banner {
    position: fixed; left: 0; right: 0;
    background-color: #00CED1; color: #000;
    text-align: center; font-weight: 700; font-size: 10px;
    line-height: 1.3; padding: 3px 0; z-index: 9999; letter-spacing: 1.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.demo-banner-top { top: 0; }
.demo-banner-bottom { bottom: 0; }
.classification-banner {
    position: sticky; z-index: 100; text-align: center; font-weight: 700;
    font-family: var(--m-font-mono); font-size: 12.5px;
    letter-spacing: 0.14em; padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}
/* "DEMO" watermark flanking the marking - this is training data, not real. */
.classification-banner::before,
.classification-banner::after { content: "DEMO"; opacity: 0.55; letter-spacing: 3px; }
.classification-banner::before { margin-right: 1.75em; }
.classification-banner::after  { margin-left: 1.75em; }
.classification-banner-top { top: var(--m-chrome-top); }
.classification-banner-bottom { bottom: var(--m-chrome-bottom); border-bottom: none; border-top: 1px solid rgba(0, 0, 0, 0.18); }

/* =========================================================================
   Buttons
   ========================================================================= */
.m-btn, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 14px; border-radius: var(--m-radius-sm);
    border: 1px solid var(--m-border-strong); background: var(--m-surface); color: var(--m-text);
    font-size: 14px; font-weight: 600; font-family: var(--m-font); line-height: 1;
    cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.m-btn:hover, .btn:hover { background: var(--m-hover); text-decoration: none; }
.m-btn:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--m-ring); }
.m-btn .m-ico { width: 16px; height: 16px; }
.m-btn-primary, .btn-primary { background: var(--m-accent); border-color: var(--m-accent); color: var(--m-accent-fg); }
.m-btn-primary:hover, .btn-primary:hover { background: var(--m-accent-hover); border-color: var(--m-accent-hover); }
.btn-secondary { background: var(--m-surface); }
.btn-danger { color: var(--m-danger); border-color: color-mix(in srgb, var(--m-danger) 45%, var(--m-border)); }
.btn-danger:hover { background: var(--m-danger-bg); }
.m-btn-ghost { border-color: transparent; background: transparent; }
.m-btn-ghost:hover { background: var(--m-hover); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }

.m-iconbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--m-radius-sm);
    border: none; background: transparent; color: var(--m-muted); cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}
.m-iconbtn:hover { background: var(--m-hover); color: var(--m-text); text-decoration: none; }
.m-iconbtn.on { color: var(--m-accent); }
.m-iconbtn-danger:hover { background: var(--m-danger-bg); color: var(--m-danger); }

/* =========================================================================
   App frame: top bar + sidebar on the canvas, content on a sheet
   ========================================================================= */
.m-app { display: flex; flex-direction: column; min-height: calc(100vh - var(--m-chrome-top) - var(--m-chrome-bottom)); }
body[data-mail-page="mailbox"] .m-app { height: calc(100vh - var(--m-chrome-top) - var(--m-chrome-bottom)); }

.m-topbar {
    display: flex; align-items: center; gap: 16px;
    height: var(--m-topbar-h); padding: 0 16px 0 0; flex-shrink: 0;
}
.m-brand {
    display: flex; align-items: center; gap: 10px;
    width: var(--m-sidebar-w); padding-left: 20px; flex-shrink: 0;
    color: var(--m-text); font-family: var(--m-font-head); font-size: 17px; font-weight: 700;
}
.m-brand:hover { text-decoration: none; }
.m-brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--m-text); color: var(--m-canvas);
}
.m-brand-mark .m-ico { width: 18px; height: 18px; stroke-width: 2; }
.m-brand-name { letter-spacing: -0.01em; }

.m-search {
    position: relative; flex: 1; max-width: 680px; margin: 0;
}
.m-search .m-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--m-muted); pointer-events: none; }
.m-search input {
    width: 100%; height: 40px; padding: 0 14px 0 40px;
    border: 1px solid transparent; border-radius: var(--m-radius);
    background: var(--m-surface); color: var(--m-text); font-size: 14px;
    box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
}
.m-search input::placeholder { color: var(--m-muted); }
.m-search input:focus { outline: none; border-color: var(--m-accent); box-shadow: var(--m-ring); }
body[data-mail-density="compact"] .m-search input { height: 34px; font-size: 13px; }

.m-topnav { margin-left: auto; display: flex; align-items: center; gap: 2px; font-size: 14px; }
.m-topnav > a:not(.m-iconbtn) { color: var(--m-text-2); padding: 6px 10px; border-radius: var(--m-radius-sm); }
.m-topnav > a:not(.m-iconbtn):hover { background: var(--m-chrome-hover); text-decoration: none; }
.m-topbar .m-iconbtn:hover { background: var(--m-chrome-hover); }
.m-me { display: inline-flex; align-items: center; gap: 10px; margin: 0 6px 0 10px; }
.m-me-text { display: flex; flex-direction: column; line-height: 1.2; }
.m-me-text strong { font-size: 13px; font-weight: 600; }
.m-me-text small { font-size: 12px; color: var(--m-muted); }
.m-user { color: var(--m-muted); padding: 0 8px; }
@media (max-width: 1180px) { .m-me-text { display: none; } }

.m-body { display: flex; flex: 1; min-height: 0; }
.m-sidebar {
    width: var(--m-sidebar-w); flex-shrink: 0;
    padding: 4px 12px 20px; overflow-y: auto;
}
.m-content {
    flex: 1; min-width: 0; min-height: 0;
    display: flex; flex-direction: column;
    padding: 20px;
}
.m-app .m-content { padding: 0 16px 16px 0; }

/* compose button + folder nav */
.m-compose-btn {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    height: 44px; margin: 4px 0 18px; border-radius: var(--m-radius);
    background: var(--m-accent); color: var(--m-accent-fg);
    font-size: 15px; font-weight: 650;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transition: background-color .12s ease;
}
.m-compose-btn:hover { background: var(--m-accent-hover); text-decoration: none; }
.m-compose-btn .m-ico { stroke-width: 2.1; }
body[data-mail-density="compact"] .m-compose-btn { height: 36px; font-size: 14px; margin-bottom: 12px; }
body[data-mail-density="spacious"] .m-compose-btn { height: 50px; font-size: 16px; margin-bottom: 24px; }

.m-nav { margin-bottom: 18px; }
.m-nav ul { list-style: none; margin: 0; padding: 0; }
.m-nav li a {
    display: flex; align-items: center; gap: 12px;
    height: var(--m-nav-h); padding: 0 12px; border-radius: var(--m-radius-sm);
    color: var(--m-text-2); font-size: 14px; font-weight: 500;
}
.m-nav li a .m-ico { color: var(--m-muted); }
.m-nav li a:hover { background: var(--m-chrome-hover); text-decoration: none; }
.m-nav li a.active { background: var(--m-surface); color: var(--m-text); font-weight: 650; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.m-nav li a.active .m-ico { color: var(--m-accent); }
.m-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-nav-count { font-size: 12px; font-weight: 700; color: var(--m-accent); font-variant-numeric: tabular-nums; }
.m-nav-heading {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 0 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--m-muted);
}
.m-nav-heading a { font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.m-nav-empty { padding: 4px 12px; font-size: 13px; color: var(--m-muted); }
.m-tag-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; margin: 0 4px; }
body[data-mail-density="compact"] .m-nav { margin-bottom: 12px; }
body[data-mail-density="compact"] .m-nav li a { font-size: 13px; gap: 10px; }
body[data-mail-density="compact"] .m-nav li a .m-ico { width: 16px; height: 16px; }
body[data-mail-density="spacious"] .m-nav li a { font-size: 15px; }

/* the sheet */
.m-sheet {
    background: var(--m-surface); border: 1px solid var(--m-border);
    border-radius: var(--m-radius-lg); box-shadow: var(--m-shadow);
    min-width: 0;
}
.m-sheet-pad { padding: var(--m-pad); }
body[data-mail-page="mailbox"] .m-sheet { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
/* a padded page (e.g. search results) swapped into the fixed-height mailbox frame scrolls */
body[data-mail-page="mailbox"] .m-sheet-pad { display: block; overflow-y: auto; }

/* flash messages */
.m-messages { margin: 0 0 10px; display: grid; gap: 6px; }
.m-message { padding: 10px 14px; border-radius: var(--m-radius); font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.m-message-success { background: var(--m-success-bg); color: var(--m-success); border-color: color-mix(in srgb, var(--m-success) 25%, transparent); }
.m-message-error { background: var(--m-danger-bg); color: var(--m-danger); border-color: color-mix(in srgb, var(--m-danger) 25%, transparent); }
.m-message-info, .m-message-warning { background: var(--m-warn-bg); color: var(--m-warn); }

/* generic page header (tags / rules / search) */
.m-page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.m-page-header h1 { font-size: 22px; margin: 0; }

.m-listhead {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px 10px;
}
.m-listhead h1 { display: flex; align-items: center; gap: 8px; font-size: 21px; font-weight: 700; margin: 0; }
.m-listhead-count {
    font-family: var(--m-font); font-size: 13px; font-weight: 600; color: var(--m-muted);
    background: var(--m-surface-2); border: 1px solid var(--m-border); border-radius: 999px; padding: 1px 9px;
    font-variant-numeric: tabular-nums;
}
.m-listhead-tools { display: flex; align-items: center; gap: 8px; }
body[data-mail-density="compact"] .m-listhead { padding: 8px 14px 6px; }
body[data-mail-density="compact"] .m-listhead h1 { font-size: 17px; }
body[data-mail-density="spacious"] .m-listhead { padding: 20px 28px 14px; }
body[data-mail-density="spacious"] .m-listhead h1 { font-size: 24px; }

/* segmented control */
.m-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--m-radius-sm); background: var(--m-surface-2); border: 1px solid var(--m-border); }
.m-seg a { padding: 4px 11px; border-radius: calc(var(--m-radius-sm) - 2px); font-size: 13px; font-weight: 600; color: var(--m-muted); }
.m-seg a:hover { color: var(--m-text); text-decoration: none; }
.m-seg a.on { background: var(--m-surface); color: var(--m-text); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.10); }

/* select dressed as a menu button */
.m-menu {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 8px 0 10px; border-radius: var(--m-radius-sm);
    border: 1px solid var(--m-border); background: var(--m-surface); color: var(--m-text-2); cursor: pointer;
}
.m-menu:hover { border-color: var(--m-border-strong); }
.m-menu:focus-within { border-color: var(--m-accent); box-shadow: var(--m-ring); }
.m-menu .m-ico { width: 16px; height: 16px; color: var(--m-muted); }
.m-menu select {
    appearance: none; -webkit-appearance: none; border: none; background: transparent;
    font-size: 13px; font-weight: 600; color: var(--m-text-2); cursor: pointer;
    padding: 0 18px 0 0; outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6779' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right center; background-size: 14px;
}
.m-menu select option { color: #131C2E; background: #fff; }
.m-menu-sm { height: 28px; }


/* =========================================================================
   Classification marks - stamped monospace in the level's own colours
   ========================================================================= */
.m-mark {
    display: inline-flex; align-items: center; gap: 5px; max-width: 220px;
    padding: 3px 7px; border-radius: 4px;
    background: var(--lvl, #6c757d); color: var(--lvl-fg, #fff);
    font-family: var(--m-font-mono); font-size: 10.5px; font-weight: 700; line-height: 1.2;
    letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.m-mark > span { overflow: hidden; text-overflow: ellipsis; }
.m-mark .mb-full { display: none; }
body:not([data-mail-density="compact"]) .m-row .m-mark .mb-short { display: none; }
body:not([data-mail-density="compact"]) .m-row .m-mark .mb-full { display: inline; }
/* beside a reading pane the list is narrow: level code only (full marking on hover / in the pane) */
.m-split.has-preview.pane-right .m-row .m-mark .mb-short,
.m-list-col.narrow .m-row .m-mark .mb-short { display: inline !important; }
.m-split.has-preview.pane-right .m-row .m-mark .mb-full,
.m-list-col.narrow .m-row .m-mark .mb-full { display: none !important; }
.m-row .m-mark { justify-self: end; }
.m-mark-lg { font-size: 12px; padding: 5px 10px; max-width: none; }
.m-mark-lg .m-ico { width: 13px; height: 13px; stroke-width: 2.2; }
/* legacy badge class (wiki-shared partials) */
.m-marking-badge {
    display: inline-block; font-family: var(--m-font-mono); font-weight: 700; font-size: 10.5px; letter-spacing: 0.05em;
    padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}

.m-tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5;
    background: color-mix(in srgb, var(--tag, #6B778C) 15%, var(--m-surface));
    color: color-mix(in srgb, var(--tag, #6B778C) 70%, var(--m-text));
    border: 1px solid color-mix(in srgb, var(--tag, #6B778C) 35%, transparent);
}
.m-tag-chip-btn { cursor: pointer; font-family: var(--m-font); }
.m-tag-chip-btn:hover { border-color: var(--tag); }

.m-empty { padding: 56px 24px; text-align: center; color: var(--m-text-2); }
.m-empty .m-ico { width: 40px; height: 40px; stroke-width: 1.2; color: var(--m-border-strong); }
.m-empty p { margin: 6px 0 0; }
.m-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 4px; font-size: 13px; }
.m-pager-links { display: inline-flex; align-items: center; gap: 8px; }

/* ---- recipient clearance chips (compose + headers) ---- */
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; align-items: center; }
.m-chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
    padding: 2px 9px; border-radius: 999px; background: var(--m-surface-2);
    border: 1px solid var(--m-border); color: var(--m-text-2);
}
.m-chip.blocked { background: var(--m-danger-bg); border-color: var(--m-danger); color: var(--m-danger); font-weight: 650; }
.m-chip.external { background: var(--m-warn-bg); border-color: var(--m-warn-border); color: var(--m-warn); }
.m-chip svg { flex-shrink: 0; }
.m-chip-kind { color: var(--m-muted); text-transform: uppercase; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; min-width: 30px; }
[data-mail-theme="terminal"] .m-chip { border-radius: 0; }


/* =========================================================================
   Classification picker - a marking builder
   ========================================================================= */
.classify-picker {
    border: 1px solid var(--m-border); border-radius: var(--m-radius);
    background: var(--m-surface); overflow: hidden;
}
.classify-stamp {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    padding: 9px 14px; background: #6c757d; color: #fff;
    transition: background-color .18s ease, color .18s ease;
}
.classify-stamp .m-ico { width: 14px; height: 14px; stroke-width: 2.2; }
.classify-preview {
    font-family: var(--m-font-mono); font-size: 13px; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase; text-align: center; overflow-wrap: anywhere;
}
.classify-row {
    display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 12px;
    padding: 10px 16px; border-top: 1px solid var(--m-border-soft);
}
.classify-stamp + .classify-row { border-top: none; }
.classify-heading { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--m-muted); }

.classify-seg { display: inline-flex; flex-wrap: wrap; justify-self: start; border: 1px solid var(--m-border-strong); border-radius: var(--m-radius-sm); overflow: hidden; }
.classify-option { position: relative; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; color: var(--m-text-2); }
.classify-option input { position: absolute; opacity: 0; pointer-events: none; }
.classify-level {
    padding: 7px 14px; font-family: var(--m-font-mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0.05em;
    border-left: 1px solid var(--m-border-strong); background: var(--m-surface);
    transition: background-color .12s ease, color .12s ease;
}
.classify-level:first-child { border-left: none; }
.classify-level:hover { background: var(--m-hover); }
.classify-level:has(input:checked) { background: var(--c); color: var(--fg); }
.classify-level:has(input:checked) .classify-dot { display: none; }
.classify-option:has(input:focus-visible) { outline: 2px solid var(--m-accent); outline-offset: -2px; z-index: 1; }
.classify-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.co-name { display: none; }

/* disclosure rows */
.classify-more { display: block; padding: 0; }
.classify-more > summary {
    display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; align-items: center; gap: 12px;
    padding: 10px 16px; cursor: pointer; list-style: none;
}
.classify-more > summary::-webkit-details-marker { display: none; }
.classify-more > summary:hover { background: var(--m-hover); }
.classify-summary { font-size: 13px; color: var(--m-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classify-summary.has { color: var(--m-text); font-family: var(--m-font-mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0.03em; }
.classify-chev { width: 16px; height: 16px; color: var(--m-muted); transition: transform .15s ease; }
.classify-more[open] .classify-chev { transform: rotate(180deg); }
.classify-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 16px 14px calc(16px + 128px + 12px); }
.classify-pill {
    padding: 4px 10px; border: 1px solid var(--m-border); border-radius: 999px; background: var(--m-surface);
    font-family: var(--m-font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
}
.classify-pill:hover { border-color: var(--m-border-strong); background: var(--m-hover); }
.classify-pill:has(input:checked) { background: var(--m-accent-weak); border-color: var(--m-accent); color: var(--m-text); }
.classify-pill:has(input:checked)::after {
    content: ""; width: 10px; height: 6px; margin-left: 1px;
    border-left: 2px solid var(--m-accent); border-bottom: 2px solid var(--m-accent);
    transform: rotate(-45deg) translateY(-2px);
}
.classify-help {
    margin: 0; padding: 9px 16px; font-size: 12.5px; color: var(--m-muted);
    background: var(--m-surface-2); border-top: 1px solid var(--m-border-soft);
}
body[data-mail-density="compact"] .classify-row, body[data-mail-density="compact"] .classify-more > summary { padding-top: 6px; padding-bottom: 6px; }
body[data-mail-density="compact"] .classify-level { padding: 5px 11px; }
body[data-mail-density="spacious"] .classify-row, body[data-mail-density="spacious"] .classify-more > summary { padding-top: 14px; padding-bottom: 14px; }
body[data-mail-density="spacious"] .classify-level { padding: 9px 18px; font-size: 13.5px; }
@media (max-width: 720px) {
    .classify-row { grid-template-columns: 1fr auto; }
    .classify-more > summary { grid-template-columns: auto minmax(0, 1fr) auto; }
    .classify-more-note, .classify-search { margin-left: 16px; }
    .classify-row > .classify-heading { grid-column: 1 / -1; }
    .classify-pills { padding-left: 16px; }
}

/* search inside a big group (10,000 SAP programs) */
.classify-search { position: relative; margin: 0 16px 14px calc(16px + 128px + 12px); }
.classify-search > .m-ico { position: absolute; left: 10px; top: 10px; width: 15px; height: 15px; color: var(--m-muted); }
.classify-search-input {
    width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--m-border-strong);
    border-radius: var(--m-radius-sm); background: var(--m-surface); font-size: 13.5px; color: var(--m-text);
}
.classify-search-input:focus { outline: none; border-color: var(--m-accent); box-shadow: var(--m-ring); }
.classify-results { display: flex; flex-direction: column; margin-top: 4px; max-height: 260px; overflow-y: auto; border-radius: var(--m-radius-sm); }
.classify-results:empty { display: none; }
.classify-results:not(:empty) { border: 1px solid var(--m-border); background: var(--m-surface); padding: 4px; }
.classify-result {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: none; background: none;
    border-radius: 6px; cursor: pointer; text-align: left; color: var(--m-text); font-size: 13px;
}
.classify-result:hover, .classify-result:focus-visible { background: var(--m-hover); outline: none; }
.classify-result .co-code { font-family: var(--m-font-mono); font-size: 12px; font-weight: 700; }
.classify-result-name { color: var(--m-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classify-result.held { opacity: .55; }
.classify-result-held { font-size: 11px; font-weight: 700; color: var(--m-success); text-transform: uppercase; letter-spacing: .06em; }
.classify-noresult { padding: 7px 8px; font-size: 12.5px; color: var(--m-muted); }
.classify-pills:empty { display: none; }
/* host forms style bare labels (core.css .form-group label {display:block}) - keep pills pills */
.classify-picker label.classify-option { display: inline-flex; margin: 0; font-weight: inherit; }
.classify-picker .classify-pill:has(input:checked)::after { display: inline-block; flex-shrink: 0; }
.classify-more-note { margin: -4px 16px 10px calc(16px + 128px + 12px); font-size: 12.5px; color: var(--m-muted); }
.classify-rule { margin: 0; padding: 8px 16px; font-size: 13px; color: var(--m-text-2); background: var(--m-warn-bg); border-top: 1px solid var(--m-border-soft); }
.classify-picker-admin .classify-more:first-child { border-top: none; }
@media (max-width: 720px) { .classify-search { margin-left: 16px; } }

/* =========================================================================
   Settings
   ========================================================================= */
.m-settings { width: 100%; max-width: 1020px; margin: 0 auto; overflow: hidden; }
.m-settings-head { padding: var(--m-pad) calc(var(--m-pad) + 8px) 18px; }
.m-settings-head h1 { margin: 0 0 4px; font-size: 22px; }
.m-settings-head p { margin: 0; font-size: 13.5px; }
.m-set {
    display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px;
    padding: 22px calc(var(--m-pad) + 8px); border-top: 1px solid var(--m-border);
}
.m-set-label h2 { font-size: 15px; margin: 0 0 4px; }
.m-set-label p { font-size: 13px; color: var(--m-muted); margin: 0; }
.m-set-fields .m-form-row:first-child { margin-top: 0; }
.m-settings-foot {
    position: sticky; bottom: 0; display: flex; justify-content: flex-end;
    padding: 14px calc(var(--m-pad) + 8px); border-top: 1px solid var(--m-border); background: var(--m-surface-2);
}
@media (max-width: 860px) { .m-set { grid-template-columns: 1fr; gap: 12px; } }

.m-opt-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.m-opt {
    position: relative; display: flex; flex-direction: column; gap: 6px; width: 136px;
    padding: 9px; border: 1px solid var(--m-border); border-radius: var(--m-radius);
    background: var(--m-surface); cursor: pointer; color: var(--m-text-2);
}
.m-opt:hover { border-color: var(--m-border-strong); }
.m-opt input { position: absolute; opacity: 0; pointer-events: none; }
.m-opt:has(input:checked) { border-color: var(--m-accent); box-shadow: var(--m-ring); color: var(--m-text); }
.m-opt:has(input:focus-visible) { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-opt-name { font-size: 13px; font-weight: 650; }
.m-opt-note { font-size: 12px; color: var(--m-muted); margin-top: -4px; }
.m-wire { display: flex; gap: 4px; height: 56px; padding: 5px; border: 1px solid var(--m-border); border-radius: var(--m-radius-sm); background: var(--m-surface-2); overflow: hidden; }
.m-wire.col { flex-direction: column; }
.m-wire .b { background: var(--m-accent-weak); border-radius: 3px; }
.m-wire .lines { display: flex; flex-direction: column; gap: 4px; padding: 2px; }
.m-wire .lines i { display: block; height: 4px; flex-shrink: 0; background: var(--m-border-strong); border-radius: 2px; }
.m-wire .lines.cozy i { height: 9px; }
.m-den-compact .lines { gap: 3px; }
.m-den-compact .lines i { height: 3px; }
.m-den-normal .lines { gap: 5px; }
.m-den-normal .lines i { height: 5px; }
.m-den-spacious .lines { gap: 8px; }
.m-den-spacious .lines i { height: 7px; }
.m-theme-swatch { display: flex; height: 56px; border-radius: var(--m-radius-sm); overflow: hidden; border: 1px solid var(--m-border); }
.m-theme-swatch i { flex: 1; }
.m-theme-swatch i:nth-child(3) { flex: 0 0 26%; }
.m-theme-clean    i:nth-child(1){background:#ECEFF4} .m-theme-clean    i:nth-child(2){background:#fff}    .m-theme-clean    i:nth-child(3){background:#2850D8}
.m-theme-graphite i:nth-child(1){background:#0D141B} .m-theme-graphite i:nth-child(2){background:#151F29} .m-theme-graphite i:nth-child(3){background:#3CC8DB}
.m-theme-paper    i:nth-child(1){background:#EFE9DE} .m-theme-paper    i:nth-child(2){background:#FFFDF8} .m-theme-paper    i:nth-child(3){background:#9A3B2E}
.m-theme-midnight i:nth-child(1){background:#0A0D1A} .m-theme-midnight i:nth-child(2){background:#12162B} .m-theme-midnight i:nth-child(3){background:#8B9BFF}
.m-theme-terminal i:nth-child(1){background:#080808} .m-theme-terminal i:nth-child(2){background:#111111} .m-theme-terminal i:nth-child(3){background:#E8B64C}

/* =========================================================================
   Forms, tables, notes (tags, rules, contacts)
   ========================================================================= */
.m-form-row { margin: 16px 0; }
.m-form-row > label, .m-form-label { display: block; font-size: 13px; font-weight: 600; color: var(--m-text-2); margin-bottom: 6px; }
.m-form-row input[type=text], .m-form-row input[type=email], .m-form-row input:not([type]),
.m-form-row textarea, .m-form-row select {
    width: 100%; max-width: 520px; padding: 8px 11px; border: 1px solid var(--m-border-strong);
    border-radius: var(--m-radius-sm); font-size: 14px; background: var(--m-surface); color: var(--m-text);
}
.m-form-row input:focus, .m-form-row textarea:focus, .m-form-row select:focus { outline: none; border-color: var(--m-accent); box-shadow: var(--m-ring); }
.m-form-row input[type=color] { width: 56px; height: 36px; padding: 2px; border: 1px solid var(--m-border-strong); border-radius: var(--m-radius-sm); background: var(--m-surface); }
.m-form-actions { margin-top: 20px; display: flex; gap: 8px; }

.m-card { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius-lg); padding: var(--m-pad); }
.m-sheet .m-card { border: none; padding: 0; border-radius: 0; }
.m-sheet .m-card > .m-msg-subject { margin-bottom: 8px; }

.m-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius); overflow: hidden; }
.m-table th, .m-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--m-border-soft); vertical-align: middle; }
.m-table th { color: var(--m-muted); text-transform: uppercase; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; background: var(--m-surface-2); }
.m-table tr:last-child td { border-bottom: none; }
.m-table tbody tr:hover td { background: var(--m-hover); }
.m-table td form { display: inline; margin-left: 6px; }
.m-note { background: var(--m-warn-bg); border: 1px solid var(--m-warn-border); color: var(--m-warn); border-radius: var(--m-radius); padding: 10px 14px; font-size: 13.5px; margin: 12px 0; }

/* contacts: "my contacts" | "directory" */
.c-split { display: grid; gap: 22px; align-items: start; margin-top: 14px; }
@media (min-width: 900px) { .c-split { grid-template-columns: 1fr 1fr; } }
.c-col h2 { font-size: 15px; margin: 0 0 2px; }
.c-col > .m-muted { font-size: 12.5px; margin: 0 0 8px; }
.c-col .m-filter-bar { margin: 0 0 8px; display: block; }
.c-col .m-filter-bar input, .c-col .m-filter-bar input:last-child, .c-col .m-filter-bar input:focus { width: 100%; height: 36px; font-family: var(--m-font); font-size: 14px; }
.c-dir-in { color: var(--m-success); font-size: 12.5px; font-weight: 600; }

/* avatars (rows, account menu, reading view) */
.m-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--m-avatar, 32px); height: var(--m-avatar, 32px); border-radius: 9px;
    background: var(--m-avatar-bg); color: var(--m-avatar-fg);
    font-size: calc(var(--m-avatar, 32px) * 0.42); font-weight: 700; line-height: 1;
    font-family: var(--m-font); user-select: none;
}
.m-avatar-me { --m-avatar: 30px; background: var(--m-text); color: var(--m-canvas); }
.m-avatar-lg { --m-avatar: 42px; border-radius: 11px; }

/* compact filter inputs (mail filter bar, contacts / directory search) */
.m-filter-bar { display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto; flex-wrap: wrap; }
.m-filter-bar > .m-ico { width: 16px; height: 16px; color: var(--m-muted); margin-right: 2px; }
.m-filter-bar input {
    height: 30px; width: 112px; padding: 0 10px;
    border: 1px solid var(--m-border); border-radius: var(--m-radius-sm);
    background: var(--m-surface-2); font-size: 13px; color: var(--m-text);
    transition: border-color .12s ease, background-color .12s ease, width .15s ease;
}
.m-filter-bar input:last-child { width: 136px; font-family: var(--m-font-mono); font-size: 12px; }
.m-filter-bar input::placeholder { color: var(--m-muted); font-family: var(--m-font); font-size: 13px; }
.m-filter-bar input:focus { outline: none; border-color: var(--m-accent); background: var(--m-surface); box-shadow: var(--m-ring); width: 160px; }
.m-filter-bar input:not(:placeholder-shown) { background: var(--m-accent-weak); border-color: color-mix(in srgb, var(--m-accent) 40%, var(--m-border)); }


/* =========================================================================
   Top bar: home (always far left), app switcher, account menu
   ========================================================================= */
.m-home {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-left: 12px; border-radius: var(--m-radius-sm);
    color: var(--m-text-2); flex-shrink: 0;
}
.m-home:hover { background: var(--m-chrome-hover); color: var(--m-text); text-decoration: none; }
.m-home .m-ico { width: 20px; height: 20px; }
.m-topbar .m-brand { width: calc(var(--m-sidebar-w) - 50px); padding-left: 4px; }

.m-apps { display: flex; align-items: center; gap: 2px; }
.m-apps a { position: relative; }
.m-apps a.on { color: var(--m-accent); background: var(--m-surface); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.m-topnav-sep { width: 1px; height: 22px; background: var(--m-border-strong); margin: 0 8px; opacity: .6; }

.m-usermenu { position: relative; }
.m-usermenu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 4px 4px; border-radius: var(--m-radius); user-select: none;
}
.m-usermenu > summary::-webkit-details-marker { display: none; }
.m-usermenu > summary:hover, .m-usermenu[open] > summary { background: var(--m-chrome-hover); }
.m-usermenu > summary:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }
.m-usermenu .m-chev { width: 14px; height: 14px; color: var(--m-muted); transition: transform .15s ease; }
.m-usermenu[open] .m-chev { transform: rotate(180deg); }
.m-usermenu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 248px;
    background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius);
    box-shadow: 0 16px 40px -12px rgba(16, 24, 40, 0.35); padding: 6px;
}
.m-usermenu-head { padding: 10px 10px 10px; border-bottom: 1px solid var(--m-border-soft); margin-bottom: 6px; }
.m-usermenu-head strong { display: block; font-size: 14px; }
.m-usermenu-head small { display: block; font-size: 12.5px; color: var(--m-muted); }
.m-usermenu-head .m-mark { margin-top: 8px; max-width: 100%; }
.m-usermenu-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: none; background: none; border-radius: var(--m-radius-sm);
    font-size: 14px; color: var(--m-text); text-align: left; cursor: pointer;
}
.m-usermenu-item:hover { background: var(--m-hover); text-decoration: none; }
.m-usermenu-item .m-ico { color: var(--m-muted); width: 17px; height: 17px; }
.m-usermenu-panel form { margin: 0; }
.m-usermenu-sep { height: 1px; background: var(--m-border-soft); margin: 6px 0; }

/* sidebar section headings / generic nav (apps without folders) */
.m-side-title { padding: 0 12px 10px; font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--m-muted); }

/* =========================================================================
   Landing page + pre-sign-in "gate" pages
   ========================================================================= */
.home { max-width: 1040px; width: 100%; margin: 0 auto; padding: 8px 0 24px; }
.home-head h1 { font-size: 28px; margin: 4px 0 6px; }
.home-head p { margin: 0 0 20px; max-width: 46rem; font-size: 15px; }
.home-ico {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: 10px; background: var(--m-accent-weak); color: var(--m-accent);
}
.home-start, .home-card {
    display: flex; gap: 14px; color: var(--m-text); background: var(--m-surface);
    border: 1px solid var(--m-border); border-radius: var(--m-radius-lg); box-shadow: var(--m-shadow);
    padding: 18px 20px; transition: border-color .12s ease, transform .12s ease;
}
.home-start:hover, .home-card:hover { border-color: var(--m-accent); text-decoration: none; transform: translateY(-1px); }
.home-start { align-items: center; margin-bottom: 16px; border-color: color-mix(in srgb, var(--m-success) 45%, var(--m-border)); }
.home-start .home-ico { background: var(--m-success-bg); color: var(--m-success); }
.home-start > span:last-child, .home-card { flex-direction: column; }
.home-start > span:last-child { display: flex; gap: 2px; }
.home-start strong, .home-card strong { font-size: 16px; }
.home-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--m-success); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.home-card { gap: 8px; }
.home-card .m-muted { font-size: 13.5px; }
.m-search-spacer { flex: 1; }

.gate-body { min-height: 100vh; }
.gate { min-height: calc(100vh - var(--m-chrome-top) - var(--m-chrome-bottom)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px 16px; }
.gate-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.gate-sheet { width: 100%; max-width: 760px; padding: 34px 36px; text-align: center; }
.gate-narrow { max-width: 440px; }
.gate-sheet h1 { font-size: 22px; margin: 0 0 6px; }
.gate-sub { color: var(--m-muted); font-size: 14.5px; line-height: 1.5; margin: 0 auto 22px; max-width: 34rem; }
.gate-lock { width: 54px; height: 54px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 14px; background: var(--m-accent-weak); color: var(--m-accent); }
.gate-lock .m-ico { width: 26px; height: 26px; }
.gate-go { width: 100%; height: 48px; font-size: 16px; }
.gate-pin { display: block; width: 100%; margin-bottom: 12px; padding: 12px; border-radius: var(--m-radius); border: 1px solid var(--m-border-strong); background: var(--m-surface); font-size: 22px; letter-spacing: .5em; text-align: center; }
.gate-pin:focus { outline: none; border-color: var(--m-accent); box-shadow: var(--m-ring); }
.gate-err { margin-bottom: 16px; text-align: left; }
.gate-foot { margin: 20px 0 0; font-size: 12.5px; color: var(--m-muted); }
.gate-personas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; text-align: left; }
.gate-personas form { margin: 0; }
.gate-persona {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; cursor: pointer;
    background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius); text-align: left;
}
.gate-persona:hover { border-color: var(--m-accent); background: var(--m-hover); }
.gate-persona-name { display: block; font-weight: 700; font-size: 15px; text-transform: capitalize; }
.gate-persona-clr { display: block; font-family: var(--m-font-mono); font-size: 11.5px; color: var(--m-muted); margin-top: 2px; word-break: break-word; }

/* =========================================================================
   Legacy app variables -> shared tokens. wiki.css / spaces.css / core.css
   were written against their own palettes; pointing those variables at the
   shared tokens makes every app follow the user's theme.
   ========================================================================= */
body {
    --wiki-blue: var(--m-accent); --wiki-blue-light: var(--m-accent-weak);
    --wiki-bg: var(--m-canvas); --wiki-sidebar-bg: var(--m-canvas);
    --wiki-border: var(--m-border); --wiki-text: var(--m-text); --wiki-muted: var(--m-muted);
    --wiki-danger: var(--m-danger); --wiki-success: var(--m-success);
    --mls-accent: var(--m-accent); --mls-accent-light: var(--m-accent-weak);
    --mls-bg: var(--m-canvas); --mls-sidebar-bg: var(--m-canvas);
    --mls-border: var(--m-border); --mls-text: var(--m-text); --mls-muted: var(--m-muted);
    --mls-danger: var(--m-danger); --mls-success: var(--m-success); --mls-warning: var(--m-warn);
}

/* =========================================================================
   Narrow screens: icon-only sidebar, then no sidebar
   ========================================================================= */
@media (max-width: 900px) {
    body { --m-sidebar-w: 68px; }
    .m-brand-name, .m-compose-btn span, .m-nav-label, .m-nav-heading, .m-nav-empty { display: none; }
    .m-brand { padding-left: 19px; }
    .m-compose-btn { width: 44px; margin-left: auto; margin-right: auto; }
    .m-nav li a { justify-content: center; padding: 0; position: relative; }
    .m-nav-count { position: absolute; top: 3px; right: 6px; font-size: 10px; }
    .m-filter-bar { margin-left: 0; }
}
@media (max-width: 720px) {
    /* the site demo bar wraps to two lines here (templates/_demo_bar.html) */
    :root { --m-chrome-top: 46px; }
    .m-listhead { flex-wrap: wrap; }
    .m-listhead-tools { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    .m-sidebar { display: none; }
    .m-brand { width: auto; padding-left: 14px; }
    .m-app .m-content { padding: 0 8px 8px; }
    .m-apps { display: none; }
    .m-topbar .m-brand { width: auto; }
    body { --m-pad: 16px; }
}

