/* ============================================================
   ui.css — shared design tokens + base rules for every inbox page
   (index.php, calendar.php, documents.php, admin.php, link.php).
   Load FIRST so page/component CSS can build on it.

   Design pass 02/10/2026 (docs: inbox-design-2026-10-02/REPORT.md).
   Phase 1 = tokens, legacy aliases, focus ring, contrast floor,
   accent selected state, z-index ladder. Phase 2 appends the
   components (buttons, menus, modals, toasts, badges) to the
   empty sections at the bottom — keep the section order.

   Dark mode: the pages toggle a `.dark` class on <html> (theme
   boot script, key `feather_theme`), so dark tokens live under
   `.dark`, never a prefers-color-scheme media query.
   ============================================================ */

/* ================= 1. Tokens ================= */
:root {
  /* surfaces — raised = lighter in dark */
  --bg: #f8fafc; --surface: #fff; --surface-2: #f1f5f9; --surface-3: #e2e8f0;
  --border: #e2e8f0; --border-strong: #cbd5e1;

  /* text — --text-muted (#64748b) is the lightest TEXT colour on light
     backgrounds (WCAG AA); --text-faint is for icons/borders/decoration */
  --text: #0f172a; --text-2: #334155; --text-muted: #64748b; --text-faint: #94a3b8;

  /* one accent blue (blue-600 / blue-500 in dark) */
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: rgba(37,99,235,.08); --accent-ring: rgba(37,99,235,.28); --on-accent: #fff;
  /* logo artwork only (app icon, splash, OS theme-color) — never UI chrome */
  --brand-logo: #1976d2;

  /* status */
  --danger: #dc2626; --danger-soft: #fef2f2; --warn: #d97706; --warn-soft: #fffbeb; --success: #16a34a; --success-soft: #f0fdf4;
  --unread: #f59e0b; --nr-waiting: #8b5cf6;

  /* type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; --font-brand: "Urbanist", var(--font-ui);
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 22px;

  /* shape + elevation */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-full: 9999px;
  --ctl-sm: 32px; --ctl-md: 38px; --ctl-lg: 44px;
  --ring: 0 0 0 3px var(--accent-ring);
  --shadow-1: 0 4px 12px -2px rgba(15,23,42,.12), 0 1px 3px rgba(15,23,42,.08);
  --shadow-2: 0 12px 32px -8px rgba(15,23,42,.22), 0 2px 6px rgba(15,23,42,.08);
  --shadow-3: 0 24px 64px -12px rgba(15,23,42,.32);
  --scrim: rgba(15,23,42,.45);

  /* z-index ladder: toasts sit BELOW menus and modals */
  --z-toast: 50; --z-menu: 60; --z-modal: 70; --z-modal-top: 80;
}
.dark {
  --bg: #0f172a; --surface: #111a2e; --surface-2: #1e293b; --surface-3: #334155;
  --border: #1e293b; --border-strong: #334155;
  --text: #e2e8f0; --text-2: #cbd5e1; --text-muted: #94a3b8; --text-faint: #64748b;
  --accent: #3b82f6; --accent-hover: #60a5fa; --accent-soft: rgba(59,130,246,.15); --accent-ring: rgba(59,130,246,.35);
  --danger-soft: rgba(220,38,38,.15); --warn-soft: rgba(217,119,6,.15); --success-soft: rgba(22,163,74,.15);
  --shadow-1: 0 4px 12px -2px rgba(0,0,0,.5); --shadow-2: 0 12px 32px -8px rgba(0,0,0,.6); --shadow-3: 0 24px 64px -12px rgba(0,0,0,.7);
  --scrim: rgba(2,6,23,.65);
}

/* ================= 2. Legacy aliases =================
   Older surfaces each grew their own namespace. They now point at
   the tokens so each surface can be migrated one at a time.
   :root-level namespaces are aliased here; component-scoped ones
   (--cc-* on .cdmcall, --rm-* on #replyModal, --ah-* on
   #aiHelperModal, --nr-* / --mc-* in index.php) reference the
   tokens where they are declared. */
:root {
  --brand: var(--brand-logo);

  /* calendar / documents / AI chat (were duplicated in calendar.css + ai-chat.css) */
  --cal-bg: var(--surface);
  --cal-bg-subtle: var(--bg);
  --cal-bg-hover: var(--surface-2);
  --cal-border: var(--border);
  --cal-border-light: var(--surface-2);
  --cal-text: var(--text);
  --cal-text-muted: var(--text-muted);
  --cal-text-faint: var(--text-muted);   /* was #94a3b8 text on white (A1) */
  --cal-accent: var(--accent);
  --cal-accent-soft: var(--accent-soft);
  --cal-accent-ring: var(--accent-ring);
  --cal-radius: .75rem;
  --cal-radius-sm: .5rem;

  /* team chat dock (chat-dm.css) */
  --cdm-accent: var(--accent);
  --cdm-accent-2: var(--accent-hover);
  --cdm-grad: linear-gradient(145deg, #3b82f6, var(--accent));
  --cdm-online: #22c55e;
  --cdm-surface: var(--surface);
  --cdm-surface-2: var(--surface-2);
  --cdm-border: var(--border);
  --cdm-text: var(--text);
  --cdm-muted: var(--text-muted);
  --cdm-shadow: 0 18px 48px -12px rgba(15, 23, 42, .30), 0 4px 12px -6px rgba(15, 23, 42, .18);
  --cdm-radius: var(--r-lg);
}
.dark {
  --cal-bg-subtle: var(--bg);
  --cal-border-light: var(--border);
  --cal-text-faint: var(--text-faint);
  --cdm-grad: linear-gradient(145deg, #3b82f6, #2563eb);
  --cdm-muted: var(--text-muted);
  --cdm-border: #1f2c3f;
  --cdm-shadow: 0 18px 48px -12px rgba(0, 0, 0, .6), 0 4px 12px -6px rgba(0, 0, 0, .5);
}

/* ================= 3. Base: focus ring =================
   One accent ring, keyboard focus only (:focus-visible). :where()
   keeps specificity at 0 so components with their own focus style
   still win. Outline (not box-shadow) so it never fights a
   component's own shadow; it follows border-radius. The resting
   outline is a TRANSPARENT ring rather than none: many controls have
   `transition: all`, and animating from `none` (currentColor) flashed
   a thick black ring on every focus. */
@media not (forced-colors: active) {   /* forced-colors would paint the resting ring */
  :where(a, button, summary, [role="button"], [role="tab"], [role="menuitem"], [tabindex]) { outline: 3px solid transparent; outline-offset: 1px; }
  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) { outline: 3px solid transparent; outline-offset: 0; }
}
:where(a, button, summary, [role="button"], [role="tab"], [role="menuitem"], [tabindex]):focus-visible { outline-color: var(--accent-ring); }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus-visible {
  outline-color: var(--accent-ring); border-color: var(--accent);
}
:where(input[type="checkbox"], input[type="radio"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ================= 4. Base: contrast floor + mobile inputs =================
   Placeholders were #94a3b8 on white (~2.6:1, A1). */
html :is(input, textarea)::placeholder { color: var(--text-muted); opacity: 1; }
html.dark :is(input, textarea)::placeholder { color: var(--text-faint); }
/* iOS zooms the page when a focused field is under 16px — keep text
   fields at 16px on touch phones so pinch-zoom can stay enabled. */
@media (max-width: 767px) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea, [contenteditable="true"] { font-size: max(16px, 1em); }
}

/* ================= 5. Segmented control / selected state =================
   One toggle group: .segmented > button[aria-pressed] | .is-active, or
   > label > input[type=radio] (selected via :has(:checked), no JS).
   Selected = accent-soft fill + accent text (was near-black in Calendar/
   Documents, invisible in dark). .seg / .seg-view (Calendar Month|Agenda,
   Documents grid|list) are the legacy names — same rules.
   .segmented-sm = 28px (search scope "This folder | All folders"). */
.segmented, .seg, .seg-view {
  display: inline-flex; align-items: stretch; gap: 2px; padding: 2px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden; vertical-align: middle;
}
.segmented > button, .segmented > label, .seg > button, .seg-view > button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: calc(var(--ctl-sm) - 6px); padding: 0 .7rem; margin: 0;
  border: 0; border-radius: calc(var(--r-md) - 3px); background: transparent;
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; line-height: 1.2;
  cursor: pointer; white-space: nowrap; transition: background-color .15s, color .15s;
}
.segmented > button:hover, .segmented > label:hover, .seg > button:hover, .seg-view > button:hover { background: var(--surface-2); color: var(--text); }
.segmented > label { position: relative; }
.segmented > label > input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented > label:has(input:focus-visible) { outline: 3px solid var(--accent-ring); outline-offset: -1px; }
.segmented [aria-pressed="true"], .segmented .is-active, .segmented > label:has(input:checked),
.seg [aria-pressed="true"], .seg .is-active, .seg-view [aria-pressed="true"], .seg-view .is-active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.segmented-block { display: flex; }
.segmented-block > button, .segmented-block > label { flex: 1 1 0; }
.segmented-sm > button, .segmented-sm > label { min-height: 24px; padding: 0 .6rem; font-size: var(--fs-xs); }

/* One selected-card style for option cards (Settings → business card design). */
.option-card, .theme-card { position: relative; display: block; cursor: pointer; border: 1px solid var(--border); border-radius: var(--r-md); padding: .75rem .9rem; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.option-card:hover, .theme-card:hover { background: var(--surface-2); }
.option-card.is-selected, .option-card:has(input:checked), .theme-card.is-selected, .theme-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ================= 6. Buttons (Phase 2) =================
   One button: .btn [+ variant] [+ size] [+ .btn-icon].
     variants  (default = secondary) .btn-primary · .btn-secondary · .btn-ghost · .btn-danger
     sizes     .btn-sm 32 · (md 38, default) · .btn-lg 44 — the --ctl-* tokens
     icon-only .btn-icon (square; combine with a size)
   Legacy names kept as aliases so markup migrates gradually:
     .user-btn = primary · .btn-outline = secondary · .icon-btn = icon lg ·
     .btn-xs (26px) · .btn-success / .btn-warn (status actions).
   Tailwind utilities on the element (px-*, text-*) still win — the CDN
   injects them after this file. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--ctl-md); padding: .375rem .9rem;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: transparent; color: inherit; font-size: var(--fs-md);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; }
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn i { pointer-events: none; }

.btn-secondary, .btn-outline { background: var(--surface); }
.btn-secondary:hover, .btn-outline:hover { background: var(--surface-2); }

.btn-primary, .user-btn { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover, .user-btn:hover { background: var(--accent-hover); }
.dark .btn-primary:hover, .dark .user-btn:hover { background: #2563eb; }   /* dark --accent-hover is lighter — keep white text readable */

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); border-color: transparent; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warn { background: var(--surface); border-color: #f59e0b; color: #b45309; }
.btn-warn:hover { background: var(--warn-soft); border-color: var(--warn); color: #92400e; }
.dark .btn-warn { background: var(--warn-soft); border-color: rgba(245,158,11,.5); color: #fcd34d; }
.dark .btn-warn:hover { border-color: rgba(245,158,11,.7); color: #fed7aa; }
/* destructive secondary ("Delete draft") */
.btn.text-red-600, .btn.btn-danger-text { color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn.text-red-600:hover, .btn.btn-danger-text:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { min-height: var(--ctl-sm); padding: .25rem .7rem; font-size: var(--fs-sm); gap: .4rem; }
.btn-lg { min-height: var(--ctl-lg); padding: .5rem 1.1rem; }
.btn-xs { min-height: 26px; padding: .2rem .5rem; font-size: var(--fs-xs); gap: .3rem; border-radius: var(--r-sm); }
.btn-icon, .icon-btn { padding: 0; width: var(--ctl-md); min-width: var(--ctl-md); flex-shrink: 0; }
.btn-icon.btn-sm { width: var(--ctl-sm); min-width: var(--ctl-sm); }
.btn-icon.btn-lg, .icon-btn { width: var(--ctl-lg); min-width: var(--ctl-lg); min-height: var(--ctl-lg); }

/* Ghost icon buttons in small bars (minimised compose, chat box header) —
   legacy names for .btn.btn-ghost.btn-icon.btn-sm. */
.cmin-btn, .cdm-box-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: var(--ctl-sm); height: var(--ctl-sm); padding: 0; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-muted); font-size: .9rem; cursor: pointer;
  transition: background-color .12s, color .12s;
}
.cmin-btn:hover, .cdm-box-btn:hover { background: var(--surface-2); color: var(--text); }

/* Vertical tab nav (Settings, Calendar settings): .side-tab [.is-active].
   Mobile turns these into a bottom-bordered tab row (page CSS). */
.side-tab, .settings-nav-btn, .cal-settings-nav-btn {
  display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 36px; padding: .45rem 1rem;
  border: 0; border-radius: 0; background: none; color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: 500; text-align: left; cursor: pointer;
  transition: background-color .12s, color .12s;
}
.side-tab:hover, .settings-nav-btn:hover, .cal-settings-nav-btn:hover { background: var(--surface-2); color: var(--text); }
.side-tab.is-active, .settings-nav-btn.is-active, .cal-settings-nav-btn.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
:is(.side-tab, .settings-nav-btn, .cal-settings-nav-btn) > i { width: 16px; text-align: center; font-size: .85rem; }

/* Action buttons inside a coloured toast / banner (white on accent). */
.btn-on-accent, #toastContainer .toast .btn {
  min-height: 30px; padding: .25rem .75rem; border: 1px solid rgba(255,255,255,.35); border-radius: var(--r-sm);
  background: rgba(255,255,255,.12); color: #fff; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
}
.btn-on-accent:hover, #toastContainer .toast .btn:hover { background: rgba(255,255,255,.24); }
#toastContainer .toast .t-msg .btn { margin: .4rem .4rem 0 0; }   /* actions written into the message html (push prompt) */

/* ================= 7. Menus (Phase 2) =================
   One menu: .menu > .menu-item | .menu-sep, danger = .menu-item.is-danger.
   14px text, 36px rows (44px on touch), --r-md, --shadow-1, --z-menu.
   Older containers share the look (their own rules only position/animate
   them): .dropdown-menu (user menu), .mv-overflow-menu (··· in the message
   view), .dropup-menu (mobile drop-ups), .editor-ctx-menu (compose right-
   click; spellcheck injects into it). .ctx-item / .ctx-sep / .ctx-danger and
   .menu-item.text-red-600 are the legacy item names.
   .menu-float = a fixed-position context menu (window.UIKit.menu). */
:root { --danger-fg: var(--danger); --menu-bg: var(--surface); --menu-hover: var(--surface-2); --menu-sep: var(--border); }
.dark { --danger-fg: #f87171; --menu-bg: var(--surface-2); --menu-hover: var(--surface-3); --menu-sep: var(--border-strong); }

.menu, .dropdown-menu, .mv-overflow-menu, .dropup-menu, .editor-ctx-menu {
  min-width: 200px; padding: 4px;
  background: var(--menu-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-1);
  font-size: var(--fs-md); text-align: left;
}
.dark :is(.menu, .dropdown-menu, .mv-overflow-menu, .dropup-menu, .editor-ctx-menu) { border-color: var(--border-strong); }
.menu-item, .ctx-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 36px; padding: 6px 12px; margin: 0;
  border: 0; border-radius: var(--r-sm); background: none; color: inherit;
  font: inherit; font-size: var(--fs-md); line-height: 1.3; text-align: left; text-decoration: none;
  cursor: pointer; transition: background-color .1s;
}
.menu-item:hover, .ctx-item:hover, .menu-item:focus-visible, .ctx-item:focus-visible, .menu-item.is-focus { background: var(--menu-hover); outline: none; }
.menu-item > i:first-child, .ctx-item > i:first-child { width: 16px; flex-shrink: 0; text-align: center; color: var(--text-muted); }
.menu-item:hover > i:first-child, .ctx-item:hover > i:first-child { color: var(--text); }
.menu-item.is-danger, .ctx-item.ctx-danger, .menu-item.text-red-600,
.menu-item.is-danger > i:first-child, .ctx-item.ctx-danger > i:first-child, .menu-item.text-red-600 > i:first-child { color: var(--danger-fg); }
.menu-item.is-danger:hover, .ctx-item.ctx-danger:hover, .menu-item.text-red-600:hover { background: var(--danger-soft); }
.menu-item:disabled, .menu-item.is-disabled, .ctx-item.disabled { opacity: .4; cursor: default; pointer-events: none; }
.menu-sep, .ctx-sep { height: 1px; margin: 4px 0; background: var(--menu-sep); }
hr.menu-sep { border: 0; }
.menu-label { padding: 6px 12px 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.menu-kbd, .ctx-kbd { margin-left: auto; padding-left: 12px; font-size: var(--fs-xs); color: var(--text-muted); }
.menu-item.is-checked::after { content: "\2713"; margin-left: auto; color: var(--accent); font-weight: 700; }
@media (pointer: coarse) { .menu-item, .ctx-item { min-height: 44px; } }

/* Floating (context) menus sit above modals: the compose editor menu opens
   inside the compose modal, row/folder menus over the page. */
.menu-float, .editor-ctx-menu {
  position: fixed; z-index: var(--z-popover);
  opacity: 0; transform: scale(.97) translateY(-4px); transform-origin: top left; pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.menu-float.open, .editor-ctx-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu-float { max-height: calc(100vh - 16px); overflow-y: auto; outline: none; }
.editor-ctx-menu .ctx-ai > i:first-child { color: var(--accent); }   /* compose right-click: AI Assist */

/* ================= 8. Modals + scrim (Phase 2) =================
   One modal: .modal-root > .modal-backdrop + .modal-wrap > .modal-panel.
   One dark scrim (--scrim) on every page (Documents had a light frosted
   one, Inbox a white wash in light mode). Add .modal-confirm for the
   "Unsent message" look — icon tile + title, body, footer buttons — with
   tone .is-danger / .is-warning / .is-success (default accent).
   window.confirmDialog() (js/ui-kit.src.js) builds one on demand.
   z ladder: modal 70 < stacked modals (-2/-3/-4) < confirm 78 < toasts
   lifted over a modal (80) < floating menus 90. */
:root { --z-modal-2: 72; --z-modal-3: 74; --z-modal-4: 76; --z-confirm: 78; --z-popover: 90; }

.modal-root { position: fixed; inset: 0; z-index: var(--z-modal); transition: display .2s allow-discrete; }
.modal-root.hidden { display: none; }
.modal-root.modal-stack-2 { z-index: var(--z-modal-2); }
.modal-root.modal-confirm { z-index: var(--z-confirm); }
.modal-backdrop {
  position: absolute; inset: 0; background: var(--scrim);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 1; transition: opacity .2s ease;
}
.modal-root.hidden .modal-backdrop { opacity: 0; }
@starting-style { .modal-root:not(.hidden) .modal-backdrop { opacity: 0; } }
.modal-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 1rem; overflow-y: auto;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px)); padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px)); padding-right: calc(1rem + env(safe-area-inset-right, 0px)); }
.modal-wrap::before, .modal-wrap::after { content: ''; flex: 1 1 0%; min-height: 0; }   /* centre, but scroll from the top when taller than the screen */
.modal-panel {
  position: relative; width: 100%; max-width: 28rem;
  background: var(--tw-bg, var(--surface)); color: inherit;
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden;
  opacity: 1; transform: none; transition: opacity .2s ease, transform .2s ease;
}
.modal-root.hidden .modal-panel { opacity: 0; transform: scale(.97) translateY(6px); }
@starting-style { .modal-root:not(.hidden) .modal-panel { opacity: 0; transform: scale(.97) translateY(6px); } }
.modal-panel.modal-panel-sm { max-width: 24rem; }

/* --- .modal-confirm: the canonical small dialog --- */
.modal-confirm { --mc-tint: var(--accent); --mc-tint-soft: var(--accent-soft); --mc-tile: linear-gradient(135deg, #3b82f6, #2563eb 50%, #1d4ed8); }
.modal-confirm.is-danger  { --mc-tint: var(--danger);  --mc-tint-soft: var(--danger-soft);  --mc-tile: linear-gradient(135deg, #ef4444, #dc2626 50%, #b91c1c); }
.modal-confirm.is-warning { --mc-tint: var(--warn);    --mc-tint-soft: var(--warn-soft);    --mc-tile: linear-gradient(135deg, #fbbf24, #f59e0b 50%, #d97706); }
.modal-confirm.is-success { --mc-tint: var(--success); --mc-tint-soft: var(--success-soft); --mc-tile: linear-gradient(135deg, #22c55e, #16a34a 50%, #15803d); }
.modal-confirm .modal-panel { border: 0 !important; box-shadow: var(--shadow-3), 0 0 0 1px var(--border-strong) !important; }
.modal-confirm .modal-panel::before {   /* 3px tone bar along the top */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 2; pointer-events: none;
  background: var(--mc-tile); opacity: .9;
}
/* header row: icon tile + title (+ optional close ✕) */
.modal-confirm .modal-panel > .border-b, .modal-head { padding: .85rem 1.1rem !important; border-bottom: 1px solid var(--border) !important; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.modal-confirm .modal-panel > .border-b > .font-semibold, .modal-title {
  display: flex !important; align-items: center; gap: .6rem; min-width: 0;
  font-size: var(--fs-md) !important; font-weight: 700 !important; letter-spacing: -.01em; color: var(--text) !important;
}
.modal-confirm .modal-panel > .border-b > .font-semibold > i:first-child, .modal-icon-tile {
  display: inline-flex !important; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px !important; height: 30px !important; border-radius: 9px;
  font-size: .82rem; color: #fff !important; background: var(--mc-tile, var(--accent)) !important;
  box-shadow: 0 6px 14px -4px color-mix(in srgb, var(--mc-tint, var(--accent)) 45%, transparent), inset 0 0 0 1px rgba(255,255,255,.18);
}
.modal-confirm .modal-panel > .border-b .btn-ghost, .modal-close {
  width: 32px !important; min-width: 32px; height: 32px !important; min-height: 32px; padding: 0 !important;
  border-radius: var(--r-sm) !important; border: none !important; background: transparent !important; color: var(--text-muted) !important;
}
.modal-confirm .modal-panel > .border-b .btn-ghost:hover, .modal-close:hover { background: var(--surface-2) !important; color: var(--text) !important; }
/* body */
.modal-confirm .modal-panel > .p-3, .modal-confirm .modal-panel > .p-4, .modal-confirm #csdBody, .modal-body-text {
  padding: 1.1rem !important; font-size: var(--fs-md) !important; line-height: 1.55 !important; color: var(--text-2);
}
/* form fields inside small dialogs (prompt, send-later, snooze…) */
.modal-confirm :is(.input, input[type="text"], input[type="email"], input[type="number"], input[type="datetime-local"], input[type="date"], input[type="time"], textarea) {
  border: 1px solid var(--border-strong) !important; border-radius: var(--r-md) !important;
  padding: .6rem .85rem !important; font-size: var(--fs-md) !important; background: var(--surface) !important; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.modal-confirm :is(.input, input, textarea):focus { outline: none !important; border-color: var(--mc-tint) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--mc-tint) 25%, transparent) !important; }
.modal-confirm .label { font-size: var(--fs-2xs) !important; letter-spacing: .04em; text-transform: uppercase; font-weight: 700 !important; color: var(--text-muted) !important; }
/* info call-out inside the body follows the tone */
.modal-confirm :is(.border-red-200\/70, .border-blue-200\/70, .border-amber-200\/70) { border-color: color-mix(in srgb, var(--mc-tint) 30%, transparent) !important; }
.modal-confirm :is(.bg-red-50, .bg-blue-50, .bg-amber-50) { background: var(--mc-tint-soft) !important; }
.dark .modal-confirm :is(.dark\:border-red-900\/40, .dark\:border-blue-900\/40, .dark\:border-amber-900\/40) { border-color: color-mix(in srgb, var(--mc-tint) 35%, transparent) !important; }
.dark .modal-confirm :is(.dark\:bg-red-900\/20, .dark\:bg-blue-900\/20, .dark\:bg-amber-900\/20) { background: var(--mc-tint-soft) !important; }
.modal-callout { margin-top: .6rem; padding: .5rem .75rem; border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--mc-tint) 30%, transparent); background: var(--mc-tint-soft); color: var(--text); font-weight: 600; word-break: break-word; }
.modal-note { margin-top: .75rem; font-size: var(--fs-xs); color: var(--text-muted); }
/* footer: buttons right-aligned (a leading destructive one may sit left) */
.modal-confirm .modal-panel > .border-t, .modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
  padding: .8rem 1.1rem !important; border-top: 1px solid var(--border) !important; background: var(--bg);
}
.dark .modal-confirm .modal-panel > .border-t, .dark .modal-foot { background: rgba(15,23,42,.5); }
.modal-foot .modal-foot-start { margin-right: auto; }
/* "Unsent message" has three buttons — a little wider than max-w-sm so
   they share one row; on phones tighter buttons, no icons, never wrap. */
#confirmSaveDraft .modal-panel { max-width: 27rem; }
@media (max-width: 480px) {
  #confirmSaveDraft .modal-panel > .border-t { flex-wrap: nowrap; gap: .4rem; padding: .8rem .75rem !important; }
  #confirmSaveDraft .modal-panel > .border-t > .btn { flex: 1 1 0; }
  #confirmSaveDraft .modal-panel > .border-t > div { flex: 2 1 0; gap: .4rem; }
  #confirmSaveDraft .modal-panel > .border-t > div > .btn { flex: 1 1 0; }
  #confirmSaveDraft .modal-panel > .border-t .btn { min-width: 0; padding-inline: .25rem; font-size: var(--fs-sm); white-space: nowrap; }
  #confirmSaveDraft .modal-panel > .border-t .btn i { display: none; }
}

/* --- action sheet (folder long-press on mobile): a .modal-confirm whose body is a menu,
   so it matches the Mark all read / Empty / Delete confirm that follows it --- */
.modal-sheet .modal-sheet-body { padding: 6px; }
.modal-sheet .modal-sheet-body .menu-item { border-radius: var(--r-sm); }

/* ================= 9. Toasts (Phase 2 — one ToastStack) =================
   One stack (#toastContainer, built by js/ui-kit.src.js) on every page:
   makeToast / showToast / showUndoToast / showActionToast / showCountdownToast
   all render .toast here; Documents' old .doc-toast routes through it.
   Toasts sit BELOW modals/sheets (z ladder) so they never cover a modal's
   footer (compose Send, Settings Done). Feedback fired while a modal or sheet
   is open still has to be seen, so the stack moves to the top edge and lifts
   over the scrim instead of hiding behind it. Send Undo stays at the bottom,
   within reach of the compose Send button. */
#toastContainer {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: var(--z-toast); pointer-events: none; width: 100%; max-width: 400px; padding: 0 12px;
}
body:has(.modal-root:not(.hidden), .sheet.open, .nr-modal.is-open, .card-modal:not(.hidden)) #toastContainer:not(:has(.toast-send-countdown)) {
  z-index: var(--z-modal-top); top: calc(12px + env(safe-area-inset-top)); bottom: auto;
}
body #toastContainer:has(.toast-send-countdown) {
  z-index: var(--z-modal-top); top: auto; bottom: calc(16px + env(safe-area-inset-bottom));
}
#toastContainer .toast {
  --toast-bg: var(--accent);
  pointer-events: auto; position: relative; display: flex; flex-direction: column; width: 100%; overflow: hidden;
  border-radius: var(--r-lg); color: #fff; border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,0)), var(--toast-bg);
  box-shadow: var(--shadow-2), 0 12px 32px -10px color-mix(in srgb, var(--toast-bg) 55%, transparent);
  font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.4;
  opacity: 0; transform: translateY(14px) scale(.97); transition: opacity .22s ease, transform .22s ease;
}
.dark #toastContainer .toast { --toast-bg: #2563eb; }   /* keep white-on-blue contrast in dark */
#toastContainer .toast.show { opacity: 1; transform: none; }
#toastContainer .toast[data-variant="success"] { --toast-bg: var(--success); }
#toastContainer .toast[data-variant="error"] { --toast-bg: var(--danger); }
#toastContainer .toast[data-variant="warn"] { --toast-bg: #b45309; }
#toastContainer .toast .t-header {
  display: flex; align-items: center; gap: .4rem; padding: .55rem 2.6rem .15rem .85rem;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: rgba(255,255,255,.72);
}
#toastContainer .toast .t-body { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .15rem .85rem .65rem; }
#toastContainer .toast .t-msg { flex: 1 1 auto; min-width: 0; font-weight: 500; }
#toastContainer .toast .t-close {
  position: absolute; top: .45rem; right: .55rem; display: grid; place-items: center;
  width: 26px; height: 26px; border: 0; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.85); font-size: 12px; transition: background-color .15s;
}
#toastContainer .toast .t-close:hover { background: rgba(255,255,255,.25); }
#toastContainer .toast .t-countdown { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: rgba(255,255,255,.5); transition-property: width; transition-timing-function: linear; }
@media (max-width: 600px) {
  #toastContainer { bottom: calc(16px + env(safe-area-inset-bottom)); padding: 0 10px; max-width: calc(100vw - 20px); }
  #toastContainer .toast .t-header { padding: .5rem 2.4rem .1rem .75rem; }
  #toastContainer .toast .t-body { padding: .1rem .75rem .6rem; }
  #toastContainer .toast .t-close { top: .4rem; right: .45rem; width: 24px; height: 24px; font-size: 11px; }
}

/* ================= 10. Badges / tags / chips (Phase 2) =================
   .badge — a count.  Neutral by default; .badge-accent (Inbox unread),
            .badge-danger; .badge-outline + .badge-warn / .badge-violet for
            to-do counts that aren't unread mail (Needs reply / Waiting).
   .tag   — a short label.  Neutral; .tag-accent / .tag-warn / .tag-violet /
            .tag-success (GLOBAL / THIS DEVICE scope, Beta, folder of a search hit).
   .chip  — a token you can act on (recipient, filter pill): pill shape,
            optional trailing .chip-x.  .chip-accent for an active filter.
   Legacy names aliased here: .folder-badge (+ .badge-muted), .nr-folder-badge*,
   .setting-pill (.global / .local), .doc-chip (+ .pending), .rcp-chip
   (recipient token = .chip), .adv-pill / .m-filter-pill (active search
   filters = .chip-accent). Their page CSS keeps only layout. */
.badge, .folder-badge, .nr-folder-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  min-width: 1.25rem; height: 1.25rem; padding: 0 .4rem; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
  font-size: var(--fs-2xs); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.badge-accent, .folder-badge:not(.badge-muted) { background: var(--accent); color: var(--on-accent); }
.badge-danger { background: var(--danger); color: #fff; }
.badge-outline, .nr-folder-badge { background: transparent; border-color: currentColor; }
.badge-warn, .nr-folder-badge-needs { color: #d97706; }
.dark .badge-warn, .dark .nr-folder-badge-needs { color: #fbbf24; }
.badge-violet, .nr-folder-badge-waiting { color: var(--nr-waiting); }
.dark .badge-violet, .dark .nr-folder-badge-waiting { color: #a78bfa; }
.nr-folder-badge-ignored { background: var(--surface-3); color: var(--text-muted); border-color: transparent; }
.badge.hidden, .folder-badge.hidden, .nr-folder-badge.hidden { display: none !important; }

.tag, .setting-pill, .doc-chip {
  display: inline-flex; align-items: center; gap: .3rem; flex-shrink: 0; vertical-align: middle;
  height: 1.125rem; padding: 0 .45rem; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-2xs); font-weight: 600; line-height: 1; letter-spacing: .02em; white-space: nowrap;
}
.tag-upper, .setting-pill { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.setting-pill { margin-left: .5rem; }
.tag-accent, .setting-pill.global, .doc-chip:not(.pending) { background: var(--accent-soft); color: var(--accent); }
.tag-warn, .setting-pill.is-beta { background: var(--warn-soft); color: #b45309; }
.dark .tag-warn, .dark .setting-pill.is-beta { color: #fcd34d; }
.tag-violet { background: rgba(139,92,246,.12); color: #7c3aed; }
.dark .tag-violet { color: #a78bfa; }
.tag-success { background: var(--success-soft); color: var(--success); }
.setting-pill.local, .doc-chip.pending { background: var(--surface-2); color: var(--text-muted); }
.tag-folder { margin-right: .375rem; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }

.chip, .rcp-chip { background: var(--surface-2); color: var(--text); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%;
  min-height: 26px; padding: 0 .65rem; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  font-size: var(--fs-sm); line-height: 1.2; white-space: nowrap;
}
.chip-accent, .adv-pill, .m-filter-pill { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.chip-accent:hover, .adv-pill:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.dark :is(.chip-accent, .adv-pill, .m-filter-pill) { color: #93c5fd; }
.chip.invalid, .chip.is-invalid { background: var(--danger-soft); color: var(--danger-fg); }
.chip .chip-x { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: -.3rem; border-radius: var(--r-full); opacity: .6; cursor: pointer; }
.chip .chip-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 15%, transparent); }
/* ================= 11. App header (Phase 2 — inc/head.php + inc/app_header.php) =================
   One header on Inbox, Calendar and Documents (X1). Raised surface
   (lighter than the page in dark). The user menu inside it keeps using
   the page's .dropdown / .menu-item / .user-btn rules (§ 7 Menus). */
.app-header {
  position: sticky; top: 0; z-index: 20; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
/* black-translucent status bar: pages draw under the status bar / Dynamic Island, so the header pads itself.
   Inbox (data-page="mail") sits inside .mail-shell, which already pads, so it is excluded. Separate left/right
   insets (they differ on the Duo). Sideways on a touch phone there is no top inset (stale iOS value on reopen). */
:root { --hdr-top: env(safe-area-inset-top, 0px); }
@media (orientation: landscape) and (hover: none) and (pointer: coarse) { :root { --hdr-top: 0px; } }
.app-header:not([data-page="mail"]) {
  box-sizing: border-box; height: calc(56px + var(--hdr-top));
  padding-top: var(--hdr-top);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.app-header[data-page="mail"] { --hdr-top: 0px; }
.app-header-inner { height: 100%; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@media (min-width: 768px) { .app-header-inner { padding: 0 16px; } }
.app-header-left  { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* iPhone Duo open landscape (html.is-duo.duo-land, js/shared-core.src.js = duo-kit): the iOS clock + wifi covers only the top corner
   (--duo-strip-w x --duo-strip-h) of the strip side, so the page runs FULL WIDTH under it (no safe-area side padding on the shell) and only
   the header's strip-side controls (account button on the right, logo on the left) are pushed clear of the corner. */
/* Duo: the page must never settle, slide or rubber-band after a navigation - no scroll animation, no overscroll bounce on the 2px-scrollable
   document, and no transitions on the shell / panes (their size is final on first paint; --app-h is published from <head>). */
html.is-duo.mail-app { scroll-behavior: auto !important; overscroll-behavior: none; overflow-anchor: none; }
html.is-duo .mail-shell, html.is-duo main.layout, html.is-duo .col-mail, html.is-duo .panel-right { transition: none !important; animation: none !important; }
html.is-duo.duo-land .mail-shell,
html.is-duo.duo-land .app-header:not([data-page="mail"]) { padding-left: 0 !important; padding-right: 0 !important; }
html.duo-strip-left .app-header-inner  { padding-left:  calc(var(--duo-strip-w) + 16px) !important; }
html.duo-strip-right .app-header-inner { padding-right: calc(var(--duo-strip-w) + 16px) !important; }
/* 2.6.132 iPhone Duo FOLDED portrait (html.duo-folded, js/duo.js = duo-kit; 466x678 screen, innerWidth 382). The right --duo-strip-w (84px) is the iOS
   clock/wifi strip. The app frame is position:fixed;left:0;right:0 while the list keeps its 382 (measured clearance = --duo-fold-gap).
   The Mail/Calendar/Folders switcher + Account button are the SAME elements moved
   (CSS only) into a vertical rail fixed in the strip, below the clock + wifi ring (top = --duo-rail-top, 170px). Mail page only; nothing else changes. */
html.duo-folded .mail-shell { position: fixed; left: 0; right: 0; top: 0; width: auto }
/* fixed = out of flow: the body would lose its height and so the 2px document scroll iOS needs (2.6.121/130); body::after (touch) adds the 2px, this gives the body the frame height + 2px back (body is h-full) */
@media (hover: none) and (pointer: coarse) { html.duo-folded.mail-app body { height: calc(var(--app-h, 100dvh) + 2px) } }
/* The list column spans the frame; its children keep clear of the strip except the independently positioned action rail. */
html.duo-folded .mail-shell .col-mail > :not(#mTabBar):not(.col-mail-resizer) { margin-right: var(--duo-fold-gap, 84px) }   /* --duo-fold-gap = MEASURED reach into the strip (js/duo.js): 84 if the frame fills 466, 0 where it stays 382 (the phone) */
html.duo-folded .app-header[data-page="mail"] .app-header-inner { padding-right: calc(var(--duo-fold-gap, 84px) + 8px) }
html.duo-folded .app-header[data-page="mail"] .app-nav {
  position: fixed; z-index: 21; right: calc((var(--duo-strip-w, 84px) - 56px) / 2); top: var(--duo-rail-top, 170px); width: 56px; height: 142px; box-sizing: border-box; margin: 0;
  flex-direction: column; align-items: stretch; justify-content: space-between; gap: 2px; padding: 3px; border-radius: calc(var(--r-md) + 3px);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
}
html.duo-folded .app-header[data-page="mail"] .app-nav .app-nav-item,
html.duo-folded[data-nav] .app-header[data-page="mail"] .app-nav .app-nav-item {
  flex: 0 0 44px; width: 100%; height: 44px; min-height: 44px; padding: 0; margin: 0; justify-content: center; border-radius: var(--r-md); border-bottom: 0;
}
html.duo-folded .app-header[data-page="mail"] .app-nav .app-nav-item i { font-size: 18px }
html.duo-folded .app-header[data-page="mail"] .app-nav .app-nav-item.is-active { background: var(--surface); box-shadow: 0 1px 2px rgba(15,23,42,.08), 0 0 0 1px var(--border); color: var(--accent) }
html.dark.duo-folded .app-header[data-page="mail"] .app-nav .app-nav-item.is-active { box-shadow: 0 1px 2px rgba(0,0,0,.3) }
html.duo-folded .app-header[data-page="mail"] #userMenu {
  position: fixed; z-index: 21; right: calc((var(--duo-strip-w, 84px) - 56px) / 2); top: calc(var(--duo-rail-top, 170px) + 142px + 10px); width: 56px; height: 44px; margin: 0; display: block;
}
html.duo-folded .app-header[data-page="mail"] #userBtn { width: 56px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: var(--r-md) }
html.duo-folded .app-header[data-page="mail"] .app-header-right .user-btn { height: 44px; min-height: 44px }
/* Keep the existing five action buttons/handlers in the same rail below Account. Fixed positioning releases the footer row for mail;
   only this lower section scrolls when space is tight, leaving app navigation and Account reachable. Use the same right anchor for all
   three sections: native iOS resolves it against the physical 466 frame while the content frame can stay at 382. */
html.duo-folded[data-mnav="bar"] { --mtab-h: 0px }
html.duo-folded[data-mnav="bar"] #mTabBar {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px;
  position: fixed; z-index: 21; right: calc((var(--duo-strip-w, 84px) - 56px) / 2);
  top: auto; bottom: max(10px, env(safe-area-inset-bottom, 0px)); width: 56px; height: auto; flex: none;
  max-height: max(44px, calc(var(--app-h, 100dvh) - var(--duo-rail-top, 170px) - 216px - env(safe-area-inset-bottom, 0px)));
  box-sizing: border-box; margin: 0; padding: 3px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: none; border: 0; border-radius: calc(var(--r-md) + 3px); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border); -webkit-backdrop-filter: none; backdrop-filter: none;
}
html.duo-folded[data-mnav="bar"] #mTabBar::-webkit-scrollbar { display: none }
html.duo-folded[data-mnav="bar"] #mTabBar .mtab { flex: 0 0 44px; width: 50px; height: 44px; min-height: 44px; border-radius: var(--r-md); font-size: 18px }
html.duo-folded[data-mnav="bar"] #mTabBar .mtab-compose { align-self: center; width: 44px; border-radius: 50% }
html.duo-folded.no-scroll #mTabBar { visibility: hidden }
/* 2.6.133 folded: the strip is handled explicitly (frame full width, content clear of it), never via env(safe-area-inset-right) - the device can report
   that inset as the strip, which narrowed the shell/bar/reader a second time. Reader: the panel keeps its content clear of the strip and its bottom
   action bar becomes a rail in the strip (same elements/handlers, CSS only): Back, Reply (blue, menu opens leftwards), more (opens leftwards). */
html.duo-folded .mail-shell { padding-left: 0; padding-right: 0 }
html.duo-folded #messageSheet.sheet { left: 0; right: 0 }
html.duo-folded #messageSheet > .panel { padding-left: 0; padding-right: var(--duo-fold-gap, 84px); padding-bottom: env(safe-area-inset-bottom, 0px) }
html.duo-folded #messageSheet #messageSheetActions {
  position: fixed; right: auto; bottom: auto; left: calc(var(--duo-frame-w, 466px) - var(--duo-strip-w, 84px) + (var(--duo-strip-w, 84px) - 56px) / 2); top: var(--duo-rail-top, 170px); width: 56px; z-index: 61;
  flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 10px; padding: 0; background: none; border: 0;
}
/* the panel (a transform = containing block for its fixed children) may stay 382 wide on the phone: the rail is placed from the LEFT against the
   measured 466 frame, and the strip beside the panel is painted in the panel colour; the list rail underneath is hidden while a sheet locks scroll */
html.duo-folded #messageSheet.open::after { content: ""; position: absolute; top: 0; bottom: 0; left: 100%; width: var(--duo-strip-w, 84px); background: #f8fafc; pointer-events: none; z-index: -1 }
html.dark.duo-folded #messageSheet.open::after { background: #0f172a }
html.duo-folded.no-scroll .app-header[data-page="mail"] .app-nav, html.duo-folded.no-scroll .app-header[data-page="mail"] #userMenu { visibility: hidden }
html.duo-folded #messageSheet #messageSheetActions .dropup { flex: 0 0 auto !important; width: 56px }
html.duo-folded #messageSheet #messageSheetActions .btn { width: 56px; height: 44px; min-height: 44px; min-width: 56px; padding: 0 !important; justify-content: center; gap: 2px; font-size: 0 !important }
html.duo-folded #messageSheet #messageSheetActions .btn i { font-size: 18px }
html.duo-folded #messageSheet #messageSheetActions #mReplyMenuBtn i.fa-chevron-up { font-size: 9px; margin: 0 }
html.duo-folded #messageSheet #messageSheetActions .dropup-menu { top: 0; bottom: auto; left: auto; right: calc(100% + 8px); min-width: 12rem; transform: translateX(6px) }
html.duo-folded #messageSheet #messageSheetActions .dropup.open .dropup-menu { transform: translateX(0) }
/* Folded compose uses the reader's physical-frame anchor (the transformed panel can remain only 382px wide).
   Existing controls stay in their original DOM locations, including Send's changing status text and both menus. */
html.duo-folded #composeSheet.sheet { left: 0; right: 0 }
html.duo-folded #composeSheet > .panel { --duo-compose-safe-bottom: max(10px, env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; padding-left: 0; padding-right: var(--duo-fold-gap, 84px); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--surface) }
html.duo-folded #composeSheet.open::after { content: ""; position: absolute; top: 0; bottom: 0; left: 100%; width: var(--duo-strip-w, 84px); background: var(--surface); pointer-events: none; z-index: -1 }
html.duo-folded #composeSheet > .panel > :first-child { flex: 0 0 auto; min-height: 44px }
html.duo-folded #composeSheet #composeSheetActions {
  position: fixed; left: calc(var(--duo-frame-w, 466px) - var(--duo-strip-w, 84px) + (var(--duo-strip-w, 84px) - 56px) / 2); right: auto;
  top: max(20px, min(var(--duo-rail-top, 170px), calc(var(--duo-compose-visible-bottom, 100dvh) - var(--duo-compose-safe-bottom) - 160px))); bottom: calc(var(--duo-compose-hidden-bottom, 0px) + var(--duo-compose-safe-bottom) + 54px); width: 56px; z-index: 61;
  flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 10px; padding: 0; border: 0; background: none;
}
html.duo-folded #composeSheet #composeSheetActions .dropup { flex: 0 0 auto !important; width: 56px; margin-top: auto }
html.duo-folded #composeSheet #composeBack { width: 56px; height: 44px; min-height: 44px; padding: 0; justify-content: center }
html.duo-folded #composeSheet #cSendMenuBtn { display: flex; flex-direction: column; gap: 2px; width: 56px; min-height: 52px; padding: 4px 0 !important; font-size: 11px !important; line-height: 1.2; justify-content: center }
html.duo-folded #composeSheet #cSendMenuBtn > i { font-size: 18px }
html.duo-folded #composeSheet #cSendMenuBtn > .fa-chevron-up { display: none }
html.duo-folded #composeSheet .cFields div:has(> #cActionAttach) { position: fixed; left: calc(var(--duo-frame-w, 466px) - var(--duo-strip-w, 84px) + (var(--duo-strip-w, 84px) - 56px) / 2); top: auto; bottom: calc(var(--duo-compose-hidden-bottom, 0px) + var(--duo-compose-safe-bottom)); width: 56px; height: 44px; z-index: 61 }
html.duo-folded #composeSheet #cActionAttach { width: 56px; height: 44px; min-height: 44px; padding: 0; justify-content: center; font-size: 18px }
html.duo-folded #composeSheet #cSendMenu,
html.duo-folded #composeSheet #cAttachMenu { top: auto; bottom: 0; left: auto; right: calc(100% + 14px); min-width: 0; width: 240px; max-width: calc(var(--duo-frame-w, 466px) - var(--duo-strip-w, 84px) - 24px); transform: translateX(6px) }
html.duo-folded #composeSheet .dropup.open #cSendMenu,
html.duo-folded #composeSheet #cAttachMenu.is-open { transform: translateX(0) }
html.duo-folded #composeSheet :is(#cSendMenu, #cAttachMenu) .menu-item { min-height: 44px }
html.duo-folded #composeSheet .sheet-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; overflow-y: auto }
html.duo-folded #composeSheet .sheet-body > *, html.duo-folded #composeSheet .cFields > * { margin-top: 0; margin-bottom: 0 }
html.duo-folded #composeSheet .cFields { display: flex; flex-direction: column; gap: 4px }
html.duo-folded #composeSheet :is(.rcp-card, .rcp-subject-card) { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none }
html.duo-folded #composeSheet .rcp-row { min-height: 44px; padding: 0 4px; align-items: center }
html.duo-folded #composeSheet .rcp-typing { min-height: 44px; font-size: 16px }
html.duo-folded #composeSheet .rcp-add-row { gap: 0; padding-top: 0 }
html.duo-folded #composeSheet :is(.rcp-add-btn, .rcp-collapse-btn) { min-width: 44px; min-height: 44px }
html.duo-folded #composeSheet .rcp-subject-card { flex: 1; min-height: 44px; padding: 0 4px }
html.duo-folded #composeSheet #cSubject { min-height: 44px; font-size: 16px; font-weight: 500 }
html.duo-folded #composeSheet #cEditorWrap { flex: 1 0 160px; min-height: 160px; display: flex; flex-direction: column }
html.duo-folded #composeSheet #cEditor[contenteditable] { flex: 1 0 auto; height: auto; min-height: 160px; max-height: none; padding: 8px 4px; border: 0; border-radius: 0; background: transparent; font-size: 16px; line-height: 1.55; overflow-y: auto; transition: none }
html.duo-folded #composeSheet #cEditor[contenteditable]:focus { background: transparent; box-shadow: none; outline: none }
/* Existing New-compose extras keep signature/thread choices out of the writing area. */
html.duo-folded #composeSheet .cl-mobile-extras { flex: 0 1 auto; min-height: 44px; max-height: 40%; overflow-y: auto; padding: 0 4px }
html.duo-folded #composeSheet :is(.cl-chip, .cl-quote-more, .cl-tidy-btn) { min-height: 44px }
html.duo-folded #composeSheet .cl-note { gap: 4px }
html.duo-folded #composeSheet .cl-quote { padding: 10px; border-radius: var(--r-md) }
html.duo-folded #composeSheet .cl-quote-head { flex-wrap: wrap; gap: 6px }
html.duo-folded #composeSheet .cl-quote-more { margin-left: auto }
/* User menu matches the 32px logo tile's height (.btn would make it 38) */
.app-header-right .user-btn { box-sizing: border-box; height: var(--ctl-sm); min-height: var(--ctl-sm); padding-top: 0; padding-bottom: 0; }

.app-brand {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  user-select: none; color: var(--text); text-decoration: none;
  transition: opacity .15s;
}
.app-brand:hover { opacity: .8; }
/* the wordmark is the only place Urbanist is used (V3) */
.app-wordmark {
  font-family: var(--font-brand); font-weight: 800; font-size: 1.3rem;
  letter-spacing: .08em; line-height: 1; color: var(--text);
}
.header-icon-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
}
.header-icon-wrap i { font-size: 15px; color: #fff; }
.dark .header-icon-wrap { background: linear-gradient(160deg, #2563eb, #3b82f6); box-shadow: 0 2px 8px rgba(37,99,235,.4); }

/* Mail | Calendar | Documents — the active tab is the page title */
.app-nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.app-nav-item {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
  border-radius: var(--r-md); color: var(--text-muted); text-decoration: none;
  font-size: var(--fs-md); font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.app-nav-item i { font-size: 14px; }
.app-nav-item:hover { background: var(--surface-2); color: var(--text); }
.app-nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* ^ = "soft" (html[data-nav="soft"]). The other two looks, chosen per device
   in Settings → General (inc/head.php sets data-nav; default pill): */
/* pill — grey track, current page is a raised chip */
[data-nav="pill"] .app-nav { gap: 2px; padding: 3px; border-radius: calc(var(--r-md) + 3px); background: var(--surface-2); }
[data-nav="pill"] .app-nav-item { height: 28px; padding: 0 12px; border-radius: var(--r-md); }
[data-nav="pill"] .app-nav-item:hover { background: transparent; color: var(--text); }
[data-nav="pill"] .app-nav-item.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,.08), 0 0 0 1px var(--border); }
[data-nav="pill"] .app-nav-item.is-active i { color: var(--accent); }
.dark[data-nav="pill"] .app-nav { background: var(--bg); box-shadow: inset 0 0 0 1px var(--border); }
.dark[data-nav="pill"] .app-nav-item.is-active { background: var(--surface-2); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
/* underline — full-height tabs, blue bar on the header's bottom edge */
[data-nav="underline"] .app-header-left { align-self: stretch; }
[data-nav="underline"] .app-nav { align-self: stretch; gap: 4px; }
[data-nav="underline"] .app-nav-item { height: auto; align-self: stretch; margin-bottom: -1px; padding: 0 12px; border-radius: 0; border-bottom: 2px solid transparent; }
[data-nav="underline"] .app-nav-item:hover { background: transparent; color: var(--text); border-bottom-color: var(--border-strong); }
[data-nav="underline"] .app-nav-item.is-active { background: transparent; color: var(--text); border-bottom-color: var(--accent); }
[data-nav="underline"] .app-nav-item.is-active i { color: var(--accent); }
/* position (html[data-nav-pos]; default centre; left = next to the logo).
   right = pushed across to sit beside Ask AI. centre = true middle of the
   header, wide screens only (below 1024px it would hit the logo/buttons,
   so it falls back to left). */
[data-nav-pos="right"] .app-header-left { flex: 1 1 auto; }
[data-nav-pos="right"] .app-nav { margin-left: auto; }
@media (min-width: 1024px) {
  [data-nav-pos="center"] .app-header-inner { position: relative; }
  [data-nav-pos="center"] .app-nav { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
  [data-nav-pos="center"][data-nav="underline"] .app-nav { top: 0; bottom: 0; transform: translateX(-50%); }
}
/* iPhone Duo open landscape is 951px wide (< 1024), but its header has the room: honour the centre setting there too. The strip padding sits on
   .app-header-inner's content box, while the nav is centred on its padding box, so it stays in the true middle of the header. */
html.is-duo.duo-land[data-nav-pos="center"] .app-header-inner { position: relative; }
html.is-duo.duo-land[data-nav-pos="center"] .app-nav { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
html.is-duo.duo-land[data-nav-pos="center"][data-nav="underline"] .app-nav { top: 0; bottom: 0; transform: translateX(-50%); }
/* phones: icons only, except the current page keeps its label */
@media (max-width: 639px) {
  .app-header-left { gap: 8px; }
  .app-nav-item { padding: 0 9px; }
  .app-nav-item:not(.is-active) .app-nav-label { display: none; }
  /* Mail: the folder button is the title, so the tabs are icons only and the
     folder name gives way (ellipsis) before the tabs do */
  .app-nav { flex-shrink: 0; margin-left: auto; }   /* phones: always right, beside the user button */
  .app-header-left { flex: 1 1 auto; }
  .app-header[data-page="mail"] .app-nav-label { display: none; }
  .app-header[data-page="mail"] .app-nav-item,
  [data-nav] .app-header[data-page="mail"] .app-nav-item { padding: 0 8px; }
  .app-header[data-page="mail"] .m-header-folder { max-width: none; }
  /* Out of office: no separate pill — the user button turns amber with the
     plane icon, and the user menu's first row carries the detail */
  .app-header #oooHeaderPill.active { display: none; }
  .app-header .user-btn.ooo-on, .dark .app-header .user-btn.ooo-on { background: #f59e0b; }
  .app-header .user-btn.ooo-on i.user-btn-ico { display: none; }
  .app-header .user-btn.ooo-on i.user-btn-ooo-ico { display: inline-block; }
}
/* beats Font Awesome's own .fa-regular { display } */
.user-btn i.user-btn-ooo-ico { display: none; }
.ooo-menu-item.hidden { display: none; }
@media (min-width: 640px) { .ooo-menu-item { display: none; } }
.ooo-menu-item, .ooo-menu-item > i:first-child { color: #b45309; }
.dark .ooo-menu-item, .dark .ooo-menu-item > i:first-child { color: #fbbf24; }
.ooo-menu-detail { font-size: var(--fs-xs); color: var(--text-muted); }
.ooo-menu-detail:empty { display: none; }

/* account row at the top of the user menu */
.app-menu-account {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.app-menu-account .fa-id-badge, .app-menu-account-icon { color: var(--accent); }
.dark .tns-brandmark { --tns-ink:#fff;--tns-halo:var(--halo-dark,rgba(255,255,255,.14))!important;--tns-track:rgba(0,156,255,.28); }

/* Inbox mobile header: current folder name + count (L1) */
.m-header-folder { display: inline-flex; align-items: center; gap: .4rem; min-width: 0; max-width: 58vw; color: var(--text); }
.m-header-folder.hidden { display: none; }
.m-header-name { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m-header-count.hidden { display: none; }
.m-header-folder .m-header-count { margin-right: 0; flex-shrink: 0; }
.m-header-chev { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* Calendar + Documents page column: same width rule on both (X1) */
.app-page { width: 100%; max-width: 1400px; margin: 0 auto; }

/* ================= 12. Dark surfaces (Phase 2B, V2) =================
   Slate only, three levels, raised = lighter than the page:
     page --bg #0f172a · panels/cards/header/modals --surface #111a2e ·
     raised inside a panel --surface-2 #1e293b (--surface-3 for hover).
   Markup across Inbox/Calendar/Documents uses Tailwind
   `dark:bg-slate-950` (#020617) for panels and cards, which sat DARKER
   than the slate-900 page (cards read as holes). Remap that one utility
   here instead of rewriting ~70 class lists; html.dark beats Tailwind's
   :is(.dark .x) specificity. New markup: use bg-[var(--surface)]. */
html.dark .dark\:bg-slate-950 { background-color: var(--surface); }

/* ================= 13. Type (Phase 2B, V3) =================
   One UI font (system stack) everywhere; Urbanist (--font-brand) only
   for the wordmark. Sizes come from the 7-step scale
   --fs-2xs…--fs-2xl = 11/12/13/14/16/18/22. */
:root { --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700; --lh-tight: 1.25; --lh-normal: 1.5; }
html, body { font-family: var(--font-ui); }

/* Sidebar items — real folders, Assistant folders and the
   Calendar/Documents links share one size: 14 on desktop, 16 in the
   mobile folders sheet (touch). */
#foldersList button[data-folder], #nrSidebarTop .nr-folder-btn, .sidebar-link { font-size: var(--fs-md); }
#foldersListMobile button[data-folder], #nrSidebarTopMobile .nr-folder-btn, #foldersSheet .sidebar-link { font-size: var(--fs-lg); }

/* Settings cards: title 14 semibold + 13 muted description (was three
   styles on the General tab alone). */
.set-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--text-2); margin-bottom: 4px; }
.dark .set-title { color: var(--text); }
.set-desc { font-size: var(--fs-sm); line-height: 1.45; color: var(--text-muted); }

/* ================= Date field (UIKit.dateField, js/ui-kit.src.js) =================
   House replacement for a bare <input type="date">: a styled button showing the
   formatted date + a popover month grid. The native input stays in the DOM
   (hidden) as the value holder, so existing form logic keeps working. */
.hdate { position: relative; display: flex; align-items: center; gap: 4px; margin-top: 2px; min-width: 0 }
.hdate-native { position: absolute !important; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; overflow: hidden; clip-path: inset(50%) }
.hdate-btn {
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: var(--ctl-sm); padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md); text-align: left; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.hdate-btn:hover { border-color: var(--text-faint) }
.hdate-btn:focus-visible, .hdate-btn[aria-expanded="true"] { outline: none; border-color: var(--accent); box-shadow: var(--ring) }
.hdate-btn.is-empty .hdate-text { color: var(--text-muted) }
.hdate-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.hdate-ico { color: var(--text-muted); flex-shrink: 0 }
.hdate-x {
  flex: 0 0 auto; width: var(--ctl-sm); height: var(--ctl-sm); display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r-md); background: none; color: var(--text-muted); cursor: pointer;
}
.hdate-x[hidden] { display: none }
.hdate-x:hover { background: var(--surface-2); color: var(--text) }
.hdate-x:focus-visible { outline: none; box-shadow: var(--ring) }
.hdate-pop {
  position: fixed; z-index: var(--z-popover); width: 288px; max-width: calc(100vw - 16px); padding: 10px;
  background: var(--menu-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); font-size: var(--fs-md);
}
.dark .hdate-pop { border-color: var(--border-strong) }
.hdate-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px }
.hdate-title { font-weight: 600; font-size: var(--fs-md) }
.hdate-nav {
  width: var(--ctl-sm); height: var(--ctl-sm); display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r-md); background: none; color: var(--text-2); cursor: pointer;
}
.hdate-nav:hover { background: var(--menu-hover) }
.hdate-nav:focus-visible, .hdate-link:focus-visible { outline: none; box-shadow: var(--ring) }
.hdate-dow, .hdate-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px }
.hdate-dow span { text-align: center; font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); padding: 4px 0 }
.hdate-day {
  height: 34px; border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--text);
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.hdate-day:hover { background: var(--menu-hover) }
.hdate-day.is-out { color: var(--text-faint) }
.hdate-day.is-today { border-color: var(--accent); color: var(--accent); font-weight: 600 }
.hdate-day.is-sel, .hdate-day.is-sel:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600 }
.hdate-day:focus-visible { outline: none; box-shadow: var(--ring) }
.hdate-foot { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--menu-sep) }
.hdate-link { border: 0; background: none; color: var(--accent); font: inherit; font-size: var(--fs-sm); font-weight: 600; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer }
.hdate-link:hover { background: var(--menu-hover) }
@media (pointer: coarse) { .hdate-day { height: 40px } .hdate-btn { min-height: var(--ctl-md) } }

/* 2.6.128: while --app-h is being synced nothing in the shell may animate to the new size (Duo open portrait bar). */
html.no-anim #mMailHeader, html.no-anim #mSearchOverlay, html.no-anim #mTabBar, html.no-anim #fabGroup,
html.no-anim .mail-shell, html.no-anim main.layout, html.no-anim .col-mail, html.no-anim .panel-right { transition: none !important; animation: none !important; }

/* 2.6.129: Duo open landscape, clock strip on the RIGHT: the island covers the top --duo-strip-h of the right-hand --duo-strip-w, so the
   reader header's actions (Reply + the three-dot menu) sit directly under it instead of behind it. */
html.is-duo.duo-land.duo-strip-right #mvActions { margin-top: max(0px, calc(var(--duo-strip-h, 100px) - 64px)); }
/* Other top-right controls in the strip-right state: modals sit left of the strip (compose minimise/close, etc.), and the Documents toolbar
   button drops below the island. */
html.is-duo.duo-land.duo-strip-right .modal-wrap { padding-right: calc(var(--duo-strip-w) + 8px); }
html.is-duo.duo-land.duo-strip-right #docUploadBtn { margin-top: max(0px, calc(var(--duo-strip-h, 100px) - 76px)); }
