/* Mailense tenant workspace — 2026 design system (v6.0).
 *
 * Zero build, zero framework. One stylesheet of modern native CSS, served
 * straight out of the Go binary's embedded filesystem.
 *
 * The visual language is 星曜靛紫 ("Sovereign Indigo"): one light scheme,
 * platinum alabaster neutrals (OKLCH hue 268), a floating porcelain work area,
 * precision hairlines, tabular numerals everywhere and exactly one sovereign
 * indigo primary action per view.
 *
 * Conventions:
 *   - Layers keep the cascade predictable: tokens < base < layout < components.
 *   - Every colour/radius/shadow is a token; components never use a literal.
 *   - Motion is opt-out via prefers-reduced-motion.
 */

@layer reset, tokens, base, layout, components, utilities;

/* ================================================================ tokens == */
@layer tokens {
  :root {
    /* 星曜靛紫 · Sovereign Indigo -- the one light scheme.
       Neutrals are platinum alabaster (OKLCH hue 268, whisper-low chroma):
       architectural, crisp, zero green or yellow cast. --canvas is also the
       first-frame colour in index.html, offline.html, the ops pages and the
       manifest: change them together. */
    --canvas: #f5f6fa;          /* the shell's base: sidebar and the gutter round the work area */
    --surface: #ffffff;         /* the work area, cards, fields */
    --surface-2: #eef0f6;       /* quiet fills, card feet, the inbox collab strip */
    --surface-3: #e3e6f0;       /* hover fills, progress tracks, selected rows */
    --surface-4: #d4d8e6;       /* pressed fills, skeletons */
    --overlay: #ffffff;         /* menus, dialogs: the surface, lifted by a shadow */

    /* Precision titanium hairlines (hue 268). --line-strong is every secondary
       button's and card's standing edge; --line-input clears 3:1 (WCAG 1.4.11)
       because it is a field's only edge. */
    --line: oklch(0.24 0.018 268 / 0.125);
    --line-strong: oklch(0.24 0.018 268 / 0.25);
    --line-input: oklch(0.30 0.016 268 / 0.52);
    --scrim: oklch(0.14 0.020 268 / 0.34);

    /* Obsidian graphite ink. Re-measure with docs/design/check-contrast.py
       before changing a value: the tightest pair is --ink-3 on --surface-4. */
    --ink: #0c0d14;
    --ink-2: #343748;
    --ink-3: #51556a;

    /* Sovereign indigo: links, focus, the selected icon and row marker,
       progress. The primary action is a deeper royal indigo (below). */
    --accent: #463cd4;
    --accent-strong: #3229a8;
    --accent-soft: #ecebfe;
    /* Derived from --accent (never a fixed colour), so an agency brand
       (js/brand.js overrides the six accent/primary tokens) recolours the
       focus halo and edges with it. */
    --accent-ring: color-mix(in oklab, var(--accent) 24%, transparent);
    --accent-edge: color-mix(in oklab, var(--accent) 18%, transparent);

    /* Semantic colours: crisp jewel tones, each cleanly separated in hue from
       sovereign indigo (268). Emerald is reserved strictly for ok/verified;
       AI/automation uses orchid plum (312). Every pair clears 5.1:1. */
    --ok: #116a3f;
    --ok-soft: #e2f5ea;
    --warn: #8f4e05;
    --warn-soft: #fcf0d6;
    --bad: #b5242d;
    --bad-soft: #fde6e8;
    --info: #1654b5;
    --info-soft: #e5effe;
    --violet: #8624a8;
    --violet-soft: #f5e8fc;
    /* Semantic hairlines: a badge or alert's 1px edge in its own hue. */
    --ok-edge: color-mix(in oklab, var(--ok) 18%, transparent);
    --warn-edge: color-mix(in oklab, var(--warn) 18%, transparent);
    --bad-edge: color-mix(in oklab, var(--bad) 18%, transparent);
    --info-edge: color-mix(in oklab, var(--info) 18%, transparent);
    --violet-edge: color-mix(in oklab, var(--violet) 18%, transparent);

    /* Midnight obsidian for solid ink blocks (the floating bulk bar, toasts);
       deep sovereign indigo for the one primary action per view and brand mark.
       An agency brand replaces --primary with its own colour. */
    --solid: #0e1018;
    --solid-hover: #1d2030;
    --solid-ink: #ffffff;
    --primary: #382fb5;
    --primary-hover: #2a2292;
    --primary-ink: #ffffff;
    --raised: #ffffff;

    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 10px;
    --r-xl: 12px;
    --r-full: 999px;

    /* Elevation in cool obsidian graphite (hue 268): crisp contact + ambient. */
    --shadow-1:
      0 1px 1px oklch(0.18 0.016 268 / 0.045),
      0 1px 2px oklch(0.18 0.016 268 / 0.05);
    --shadow-2:
      0 0 0 1px oklch(0.18 0.016 268 / 0.04),
      0 4px 12px -2px oklch(0.18 0.016 268 / 0.085),
      0 12px 28px -6px oklch(0.18 0.016 268 / 0.075);
    --shadow-3:
      0 0 0 1px oklch(0.18 0.016 268 / 0.06),
      0 14px 34px -4px oklch(0.18 0.016 268 / 0.15),
      0 32px 64px -16px oklch(0.18 0.016 268 / 0.17);
    /* A field's resting inset, and the primary's glass top cut + contact shadow. */
    --shadow-inset: inset 0 1px 1px oklch(0.18 0.016 268 / 0.045);
    --shadow-primary:
      inset 0 1px 0 oklch(1 0 0 / 0.22),
      0 1px 2px oklch(0.18 0.04 268 / 0.34),
      0 3px 8px -2px oklch(0.28 0.08 268 / 0.22);

    /* Latin letters and figures from the bundled Geist Sans / Geist Mono (the
       @font-face rules after this layer, served from app/fonts); CJK falls
       through to the native multi-weight system stack. Nothing is fetched from
       another origin. */
    --sans: "Mailense Sans", -apple-system, BlinkMacSystemFont, "PingFang SC",
            "Hiragino Sans GB", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC",
            "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --mono: "Mailense Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
            "Liberation Mono", monospace;

    --sidebar-w: 236px;
    /* Motion: one exponential ease-out. --dur for hover, press and selection;
       --dur-pop for popovers, menus, dialogs and drawers coming in. */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur: 0.12s;
    --dur-pop: 0.18s;

    color-scheme: light;
  }
}

/* ================================================================= fonts == */
/* The Latin faces (docs/ui-ux-guidelines.md §3.1): Geist Sans and Geist Mono,
   variable weight, Latin subset (Fontsource 5.3.0 builds, SIL OFL 1.1; the
   licences sit next to the files in app/fonts). The relative URL resolves under
   the versioned /app/v/<hash>/ path, so the files are cached as immutable.
   unicode-range keeps CJK on the native system stack: a Chinese sentence only
   takes its Latin letters, figures and punctuation from these faces. */
@font-face {
  font-family: "Mailense Sans";
  src: url("fonts/geist-latin-var.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Mailense Mono";
  src: url("fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ================================================================= reset == */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
  ul, ol { margin: 0; padding: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
  img, svg { display: block; }
  button { background: none; border: 0; padding: 0; }
  dialog { padding: 0; border: 0; }
  /* `hidden` must win over any component's own display (a .card is a grid, a
     .row is a flex box). Important in the first layer beats every later one,
     so no component needs its own [hidden] rule. Same as the ops console. */
  [hidden] { display: none !important; }
}

/* ================================================================== base == */
@layer base {
  body {
    font-family: var(--sans);
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-optical-sizing: auto;
    font-variant-numeric: tabular-nums;
  }

  /* CJK headings stay open (-0.01em) so Han characters never crowd; Latin
     headings tighten cleanly under :lang(en) (guidelines §3.3). */
  h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; text-wrap: balance; }
  h1:lang(en) { letter-spacing: -0.025em; }
  h2:lang(en) { letter-spacing: -0.02em; }
  h3:lang(en) { letter-spacing: -0.015em; }
  h1 { font-size: 22px; }
  h2 { font-size: 16px; }
  h3 { font-size: 14px; }
  h4 { font-size: 13px; }

  a { color: var(--accent); text-decoration: none; transition: color var(--dur) var(--ease); }
  a:hover {
    color: var(--accent-strong);
    text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
    text-decoration-color: color-mix(in oklab, var(--accent) 42%, transparent);
  }
  code, pre, kbd { font-family: var(--mono); font-size: 0.86em; }
kbd {
    display: inline-flex; align-items: center; justify-content: center; min-width: 18px;
    padding: 1px 5px; border-radius: var(--r-xs); border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink-2); font-size: 11px;
    box-shadow: inset 0 -1px 0 var(--line-strong);
  }
  ::selection { background: var(--accent-soft); color: var(--accent-strong); }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-xs);
  }

  .skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--surface); color: var(--ink);
    padding: 10px 16px; border-radius: 0 0 var(--r-sm) 0;
    box-shadow: var(--shadow-2);
  }
  .skip-link:focus { left: 0; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* ================================================================= layout == */
@layer layout {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    /* mobile-ios: dvh needs iOS 15.4+; the vh line is the fallback (a phone's
       browser chrome makes it slightly taller, which only overshoots below
       the fold, never clips the shell). */
    height: 100vh;
    height: 100dvh;
    padding: 0;
    gap: 0;
    background: var(--canvas);
  }
  /* Inset shell (desktop): the sidebar sits on the warm canvas with no divider,
     and the work area is a porcelain sheet with an 8px gutter, a hairline and
     one contact shadow. Below 960px the sidebar is a drawer and the work area
     goes edge to edge again. */
  @media (min-width: 961px) {
    .shell { padding: 8px 8px 8px 0; }
    .shell > .sidebar { padding-top: 10px; padding-bottom: 4px; }
    .shell > .main {
      border: 1px solid var(--line); border-radius: var(--r-xl);
      box-shadow: var(--shadow-1);
    }
  }

  /* ---------------------------------------------------------- sidebar -- */
.sidebar {
    display: flex; flex-direction: column; gap: 8px;
    min-height: 0; padding: 16px 10px 10px 12px;
    background: var(--canvas);
  }
  .side-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 6px 2px; min-width: 0;
  }
.side-brand .mark {
    width: 28px; height: 28px; border-radius: var(--r-md); flex: none;
    display: grid; place-items: center;
    /* The brand anchor: deep sovereign indigo of the primary action, crisp
       white prism-envelope glyph, top glass-cut. Follows --primary under white-label. */
    color: var(--primary-ink); background: var(--primary);
    box-shadow: var(--shadow-primary);
  }
  .side-brand .brand-name {
    font-weight: 650; letter-spacing: -0.02em; font-size: 16px;
    min-width: 0;
  }
  .side-brand .brand-meta { font-size: 11px; color: var(--ink-3); }

  /* Tenant card: the workspace's identity, and the way to its settings. */
.side-tenant {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 5px 8px;
    border: 1px solid transparent; border-radius: var(--r-md);
    background: transparent; color: var(--ink);
    text-decoration: none;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .side-tenant:hover { background: var(--surface-3); text-decoration: none; }
  .side-tenant[aria-current="page"] {
    background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1);
  }
  .side-tenant > svg { flex: none; color: var(--ink-3); }
.side-tenant-mark {
    width: 24px; height: 24px; border-radius: var(--r-sm); flex: none;
    display: grid; place-items: center;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-strong); box-shadow: var(--shadow-1);
    font-size: 12px; font-weight: 600;
  }
  .side-tenant-main { display: grid; gap: 1px; min-width: 0; }
  .side-tenant-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
  .side-tenant-meta { font-size: 12px; color: var(--ink-3); }

  /* Workspace switcher (§54): the button sits over the card's right edge. */
  .side-switch { position: relative; }
  .side-switch .side-tenant { padding-right: 42px; }
  /* A rounded button inset inside the card: a full-height fill would paint
     over the card's right border and read as a missing corner. */
  .side-switch-btn {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 28px; height: 28px;
    display: grid; place-items: center; border: 0; background: transparent;
    color: var(--ink-3); cursor: pointer; border-radius: var(--r-md);
  }
  .side-switch-btn:hover, .side-switch-btn[aria-expanded="true"] { color: var(--ink); background: var(--surface-3); }
  .side-switch .side-switch-menu { top: calc(100% + 4px); bottom: auto; max-height: 60vh; overflow: auto; }
  .side-switch-item { align-items: center; }
  .side-switch-item[disabled] { opacity: 0.5; cursor: not-allowed; }
  .side-switch-item[aria-current="true"] { background: var(--surface-3); color: var(--ink); }
  .side-switch-item > .side-tenant-mark { width: 24px; height: 24px; font-size: 11px; }

  /* The command trigger reads as a quiet input, not a button. */
.side-search {
    display: flex; align-items: center; gap: 8px; width: 100%;
    margin: 0; padding: 0 6px 0 10px; min-height: 32px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); box-shadow: var(--shadow-1);
    color: var(--ink-3); font-size: 13px; cursor: pointer;
    transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .side-search:hover { border-color: var(--line-strong); color: var(--ink-2); }
  .side-search .grow { flex: 1; text-align: left; }
  .side-search kbd { background: var(--surface-2); border-color: var(--line); box-shadow: none; }

  .side-nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; flex: 1;
              /* 3px horizontal breathing room keeps active-item contact shadow
                 from being clipped by the scroll container's overflow box. */
              padding: 2px 3px 20px; margin: 0 -3px;
              scrollbar-width: none;
              /* The scrollbar is hidden, so a soft fade at the bottom says there is more. */
              mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent); }
  .side-nav::-webkit-scrollbar { display: none; }

  .side-section {
    padding: 10px 10px 3px; font-size: 12px; font-weight: 500;
    letter-spacing: 0.02em; color: var(--ink-3);
  }
  .side-section:first-child { padding-top: 2px; }
  /* The space of a heading, for a group that has none (main.js sidebar). */
  .side-gap { height: 14px; }

.side-link {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    padding: 0 8px; min-height: 32px; border-radius: var(--r-md);
    color: var(--ink-2); font-size: 13px; font-weight: 450;
    text-decoration: none; white-space: nowrap;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .side-link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.side-link[aria-current="page"] {
    background: var(--surface); color: var(--ink); font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  }
  .side-link svg { flex: none; width: 16px; height: 16px; color: var(--ink-3); transition: color var(--dur) var(--ease); }
  .side-link:hover svg { color: var(--ink-2); }
  /* The current page: porcelain float, obsidian label, and its icon carries
     the one sovereign indigo accent in the sidebar. */
  .side-link[aria-current="page"] svg { color: var(--accent); }

  .side-badge {
    flex: none; padding: 1px 7px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--ink-2);
    font-size: 11px; font-weight: 600; line-height: 16px;
    font-variant-numeric: tabular-nums;
  }
  /* Unread inbox badge gets subtle sovereign tint so new replies register immediately. */
  .side-link[href="#/inbox"] .side-badge {
    background: var(--accent-soft); color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px var(--accent-edge);
  }
  .side-badge[hidden] { display: none; }

  .side-foot { margin-top: auto; padding-top: 2px; display: grid; gap: 4px; }
  /* Monthly sending: one line and a hairline bar, not a card. */
  .side-usage { display: grid; gap: 5px; padding: 8px 6px 4px; }
  .side-usage-head {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 12px; color: var(--ink-2);
  }
  .side-usage-head .grow { flex: 1; min-width: 0; }
  .side-usage-value { font-size: 12px; font-weight: 600; color: var(--ink); }
  .side-usage-value.is-bad { color: var(--bad); }
  .side-usage-bar { height: 4px; }
  .side-usage-note { font-size: 12px; line-height: 1.5; color: var(--ink-3); }
  .side-usage-note.is-bad { color: var(--bad); }
  /* The account row opens a small menu upwards (language, settings,
     sign out). */
  .side-account { position: relative; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }
  .side-user {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    padding: 6px; border-radius: var(--r-md); cursor: pointer; color: var(--ink-3);
    transition: background var(--dur) var(--ease);
  }
  .side-user:hover, .side-user[aria-expanded="true"] { background: var(--surface-3); color: var(--ink-2); }
  .side-user .avatar { width: 28px; height: 28px; font-size: 11px; }
  .side-user-main { display: grid; min-width: 0; }
  .side-user-name { font-size: 13px; font-weight: 550; color: var(--ink); }
  .side-user-warn { font-size: 11px; color: var(--warn); }
  .side-menu {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 20;
    display: grid; gap: 2px; padding: 6px;
    background: var(--overlay); border: 1px solid var(--line-strong);
    border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  }
  .side-menu[hidden] { display: none; }
  .side-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
  .side-menu-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 4px 6px; font-size: 12px; color: var(--ink-2);
  }
  .side-menu-item {
    display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: var(--r-sm);
    font-size: 13px; color: var(--ink-2); cursor: pointer; text-decoration: none; text-align: left; width: 100%;
  }
  .side-menu-item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
  .side-menu-item svg { color: var(--ink-3); }

  /* The workspace: flush, full-bleed white beside the hairline-edged sidebar. */
  .main {
    /* Positioned so absolutely placed descendants (every .sr-only label)
       belong to this scroll box. Without it they hang off the viewport, the
       document grows to their height and a second scrollbar appears beside
       this one -- the 套餐与账单 comparison table did exactly that. */
    position: relative;
    display: flex; flex-direction: column; min-width: 0; min-height: 0;
    background: var(--surface);
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;
    /* The scrollbar's room is kept even on a page too short to scroll, so a
       short page and a long one centre the page column on the same x: going
       from 安全与合规 to 套餐与账单 no longer nudges everything 5px. */
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
  .main::-webkit-scrollbar { width: 10px; }
  .main::-webkit-scrollbar-thumb {
    background: var(--line-strong); border-radius: var(--r-full);
    border: 3px solid var(--surface); background-clip: padding-box;
  }

  .view { display: flex; flex-direction: column; min-height: 100%; }

  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 24px var(--page-pad) 18px;
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.2) blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .grow { flex: 1; min-width: 0; }
  .topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.012em; }
  .topbar h1:lang(en) { letter-spacing: -0.025em; }
  .topbar p { margin-top: 3px; }
  .topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

  /* Full-width workspace: lists, tables, dashboards, CRM, settings, the inbox
     and the journey canvas all fill the work area flush beside the sidebar
     (32px inset on desktop, 16px below 960px), keeping topbar, subbar, banners
     and content aligned on the same rail without a wide-monitor void next to
     the sidebar. Only focused single-column forms (.content-narrow, 820px)
     centre themselves, with their page header and subbar matching the column. */
  .main { --page-narrow-w: 820px; --page-pad: 32px; }
  .content {
    padding: 24px var(--page-pad) 56px;
    display: grid; gap: 20px; align-content: start;
    width: 100%;
  }
  .content-narrow { max-width: var(--page-narrow-w); margin-inline: auto; }
  /* The inbox gives its height to the three panes: a shorter page header and
     a 16px top padding (desktop; the phone header has its own rules). */
  @media (min-width: 961px) {
    :has(> .content.inbox-content) > .topbar { padding-top: 16px; padding-bottom: 12px; }
    .content.inbox-content { padding-top: 16px; }
  }
  @media (min-width: 961px) {
    :not(.settings-panel):has(> .content-narrow) > :is(.topbar, .subbar) {
      padding-inline: max(var(--page-pad), calc((100% - var(--page-narrow-w)) / 2 + var(--page-pad)));
    }
  }

  .crumb {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--ink-3); margin-bottom: 6px;
  }
  .crumb a { color: var(--ink-3); }
  .crumb a:hover { color: var(--ink); text-decoration: none; }
  .crumb svg { opacity: 0.55; }

  .menu-btn { display: none; }
  .scrim { display: none; }

  @media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; padding: 0; }
    .main { height: 100vh; height: 100dvh; }
    /* mobile-shell: the drawer. A closed drawer casts no shadow (its 48px blur
       leaked a grey band down the left edge of every page), and it is hidden,
       not just moved off-screen, so it is neither a tab stop nor something a
       screen reader reads. Both come back with the drawer, so the slide out
       fades rather than snaps. */
    .sidebar {
      position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 84vw);
      background: var(--surface); border-right: 1px solid var(--line);
      border-radius: 0 var(--r-xl) var(--r-xl) 0;
      box-shadow: none; visibility: hidden;
      transform: translateX(-101%);
      transition: transform 0.24s var(--ease), box-shadow 0.24s var(--ease),
                  visibility 0s linear 0.24s;
      padding-top: max(16px, env(safe-area-inset-top));
      padding-right: 14px;
      padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
      /* mobile-ios: landscape turns the notch to the left edge, which is where
         the drawer's navigation labels start. */
      padding-left: calc(14px + env(safe-area-inset-left, 0px));
      overscroll-behavior: contain;
    }
    .shell[data-nav="open"] .sidebar {
      transform: none; visibility: visible; box-shadow: var(--shadow-3);
      transition: transform 0.24s var(--ease), box-shadow 0.24s var(--ease), visibility 0s;
    }
    /* mobile-shell: the page behind an open drawer does not scroll. */
    .shell[data-nav="open"] .main { overflow: hidden; }
    body.nav-open { overflow: hidden; }
    .shell[data-nav="open"] .scrim {
      display: block; position: fixed; inset: 0; z-index: 40;
      background: var(--scrim);
      backdrop-filter: blur(2px);
      border: 0;
    }
    .side-brand { padding-right: 0; }
    .side-search {
      min-height: 42px; padding: 0 12px; border-radius: var(--r-lg);
      background: var(--surface-2); border-color: var(--line); box-shadow: none;
      font-size: 14px;
    }
    /* No desktop macOS shortcut keycap inside the touch drawer. */
    .side-search kbd { display: none; }
    .side-nav { gap: 2px; }
    .side-section { padding: 12px 12px 4px; }
    .side-link {
      min-height: 42px; padding: 0 12px; gap: 10px;
      border-radius: var(--r-lg); font-size: 14px;
    }
    .side-link[aria-current="page"] {
      background: var(--accent-soft); color: var(--accent-strong); font-weight: 600;
      box-shadow: inset 0 0 0 1px var(--accent-edge);
    }
    .side-tenant {
      min-height: 50px; padding: 6px 10px; border-radius: var(--r-lg);
      background: var(--surface-2); border-color: var(--line);
    }
    .menu-btn { display: inline-flex; }
    .topbar { padding: 14px 16px; }
    .main { --page-pad: 16px; }
    .content { padding: 16px 16px 48px; gap: 16px; }
  }
  @media (pointer: coarse) {
    .side-search kbd { display: none; }
  }

  /* mobile-shell: the phone tab bar (guidelines 8.10). Four places plus 更多,
     which opens the same drawer as the header's menu button. It is in the DOM
     at every width; above 640px the sidebar is the navigation and it is out of
     the layout, and --tabbar-lift stays 0 so nothing else moves. */
  @media (max-width: 640px) {
    body { --tabbar-lift: 0px; }
    body.has-tabbar { --tabbar-lift: 58px; }
    /* The page ends above the bar instead of running under it, so a sticky
       action row (.cn-actions), the inbox composer and every last row stay
       reachable. A page without the bar (the journey canvas) keeps the full
       height, home indicator included. */
    body.has-tabbar .main {
      height: calc(100vh - var(--tabbar-lift) - env(safe-area-inset-bottom, 0px));
      height: calc(100dvh - var(--tabbar-lift) - env(safe-area-inset-bottom, 0px));
    }
    .tabbar {
      position: fixed; inset: auto 0 0 0; z-index: 20;
      display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
      height: calc(var(--tabbar-lift) + env(safe-area-inset-bottom, 0px));
      padding: 4px env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
      background: color-mix(in oklab, var(--surface) 90%, transparent);
      backdrop-filter: saturate(1.6) blur(16px);
      border-top: 1px solid var(--line);
    }
    .tabbar-item {
      position: relative;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 2px; min-width: 0; min-height: 48px; padding: 2px;
      border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink-3);
      font-size: 12px; font-weight: 450; line-height: 1.15;
      text-decoration: none; cursor: pointer;
      transition: color var(--dur) var(--ease);
      -webkit-tap-highlight-color: transparent;
    }
    .tabbar-item:active .tabbar-icon { transform: scale(0.92); }
    .tabbar-item[aria-current="page"] { color: var(--accent-strong); font-weight: 600; }
    .tabbar-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
    .tabbar-icon {
      position: relative; display: grid; place-items: center;
      width: 48px; height: 28px; border-radius: var(--r-full);
      transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
    }
    .tabbar-item[aria-current="page"] .tabbar-icon {
      background: var(--accent-soft); color: var(--accent);
      box-shadow: inset 0 0 0 1px var(--accent-edge);
    }
    .tabbar-label { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .tabbar-badge {
      position: absolute; top: -1px; right: 4px; min-width: 16px; height: 16px;
      padding: 0 4px; border-radius: var(--r-full);
      background: var(--primary); color: var(--primary-ink);
      font-size: 11px; font-weight: 600; line-height: 16px; text-align: center;
      font-variant-numeric: tabular-nums;
      box-shadow: 0 0 0 2px var(--surface);
    }
  }
  @media (min-width: 641px) { .tabbar { display: none; } }
}

/* ============================================================= components == */
@layer components {
  /* ---------------------------------------------------------- buttons -- */
.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink);
    --btn-line: var(--line-strong);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 6px 12px; min-height: 32px;
    font-size: 13px; font-weight: 550; line-height: 1;
    color: var(--btn-fg); background: var(--btn-bg);
    border: 1px solid var(--btn-line); border-radius: var(--r-sm);
    cursor: pointer; white-space: nowrap; text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
                color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                transform var(--dur) var(--ease);
  }
.btn:hover:not(:disabled) {
    background: color-mix(in oklab, var(--btn-bg) 96%, var(--ink));
    border-color: color-mix(in oklab, var(--line-strong) 70%, var(--ink));
    text-decoration: none;
  }
  .btn:active:not(:disabled) { background: var(--surface-3); transform: scale(0.985); }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  /* A disabled primary keeps readable text instead of white on faded ink. */
  .btn-primary:disabled {
    opacity: 1; background: var(--surface-2); color: var(--ink-3);
    border-color: var(--line); box-shadow: none;
  }
  .btn svg { flex: none; }

  /* The one solid button on a screen. */
.btn-primary {
    --btn-bg: var(--primary); --btn-fg: var(--primary-ink); --btn-line: transparent;
    box-shadow: var(--shadow-primary);
  }
  .btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: transparent; }
  .btn-primary:active:not(:disabled) { background: var(--primary-hover); }

  .btn-ghost { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--ink-2); box-shadow: none; }
  .btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; color: var(--ink); }
  .btn-ghost:active:not(:disabled) { background: var(--surface-4); }
  /* The journey sheet's 删除步骤 is a ghost button with a red hover: restate it
     after the ghost hover above, or the neutral fill would win. */
  .jf-sheet-danger:hover:not(:disabled) { background: var(--bad-soft); }
  /* A "⋯" trigger is a framed icon button, never a faint glyph: porcelain
     face, the --line-strong edge, --ink-2 dots (icon("dots") draws them solid),
     a contact shadow; open, it reads as pressed. .btn-more is the hook; the
     existing triggers are listed by their own classes. */
  .btn:is(.btn-more, .inbox-head-more, .inbox-read-more, .cell-more, .ee-more) {
    --btn-bg: var(--surface); --btn-line: var(--line-strong); --btn-fg: var(--ink-2);
    box-shadow: var(--shadow-1);
  }
  .btn:is(.btn-more, .inbox-head-more, .inbox-read-more, .cell-more, .ee-more):hover:not(:disabled) {
    background: var(--surface-2); border-color: var(--line-input); color: var(--ink);
  }
  .btn:is(.btn-more, .inbox-head-more, .inbox-read-more, .cell-more, .ee-more)[aria-expanded="true"] {
    background: var(--surface-3); border-color: var(--line-input); color: var(--ink); box-shadow: none;
  }

.btn-danger {
    --btn-fg: var(--bad); --btn-line: color-mix(in oklab, var(--bad) 22%, transparent);
    --btn-bg: color-mix(in oklab, var(--bad-soft) 62%, var(--surface));
  }
  .btn-danger:hover:not(:disabled) {
    background: var(--bad-soft); border-color: color-mix(in oklab, var(--bad) 36%, transparent);
  }
  /* Banner buttons are tinted outlines (verify, announce) or plain links
     (plan banner): they keep their own hover edge, not the neutral one above. */
  .announce .btn:hover:not(:disabled) {
    background: color-mix(in oklab, currentColor 10%, transparent);
    border-color: color-mix(in oklab, currentColor 36%, transparent);
  }
  .verify-banner .btn:hover:not(:disabled) { border-color: color-mix(in oklab, var(--warn) 40%, transparent); }
  .plan-banner .btn:not(.btn-icon):hover:not(:disabled) { border-color: transparent; }

  .btn-sm { padding: 4px 9px; min-height: 26px; font-size: 12px; gap: 5px; }
  .btn-block { width: 100%; }
  .btn-icon { padding: 0; width: 30px; min-height: 30px; }
  .btn-sm.btn-icon { width: 26px; min-height: 26px; }

  /* ----------------------------------------------------------- fields -- */
  .field { display: grid; gap: 6px; }
  .field > label { font-size: 12px; font-weight: 550; color: var(--ink-2); }
  .field .hint { font-size: 12px; color: var(--ink-3); text-wrap: pretty; }
  .field .hint code { color: var(--ink-2); }

  /* A field's edge is the only thing that says "type here", so it clears
     3:1 (WCAG 1.4.11) with --line-input; dividers stay on the quieter lines. */
.input, .select, .textarea {
    width: 100%; padding: 7px 11px; min-height: 34px;
    font-size: 13px; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-input); border-radius: var(--r-md);
    box-shadow: var(--shadow-inset);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur-pop) var(--ease);
  }
  .input:hover:not(:disabled):not(:focus):not([aria-invalid="true"]),
  .select:hover:not(:disabled):not(:focus):not([aria-invalid="true"]),
  .textarea:hover:not(:disabled):not(:focus):not([aria-invalid="true"]) {
    border-color: color-mix(in oklab, var(--line-input) 72%, var(--ink));
  }
  .textarea { min-height: 108px; resize: vertical; line-height: 1.55; padding: 9px 10px; }
  .select { appearance: none; padding-right: 30px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                      linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
  .input::placeholder, .textarea::placeholder { color: var(--ink-3); }
  .input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
  }
  /* Field errors (guidelines section 8.2): the control turns red and the
     message takes the hint's place under it. ui.js setFieldError() sets both. */
  .input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
  .input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad) 22%, transparent);
  }
  .field-error { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: var(--bad); }
  .field-error svg { flex: none; margin-top: 2px; }

  .input-row { display: flex; align-items: center; gap: 8px; }
  .input-row .input { flex: 1 1 auto; width: auto; min-width: 0; }
  .input-row .btn { flex: 0 0 auto; }
  /* A one-line field on a form page stops at 560px: a text box as wide as an
     820px column reads as a rail, not a place to type. Text areas and the
     editors keep the full width; so do fields inside a grid, which are
     narrower anyway. */
  :is(.content-narrow, .settings-body, .settings-panel) .field > :is(.input, .select) { max-width: 560px; }

  /* Password reveal. The toggle is an icon docked inside the field instead of
     a text button beside it: it costs no width, its label never re-flows the
     row, and eye / struck-through eye states the CURRENT state rather than
     naming the action. Sized 30x30 with a 44px-tall field, it clears the
     minimum touch target without touching the input's baseline. */
  .pw { position: relative; }
  .pw .input { padding-right: 44px; }
  .pw-toggle {
    position: absolute; right: 5px; top: 50%; translate: 0 -50%;
    width: 30px; height: 30px; display: grid; place-items: center;
    padding: 0; border: 0; border-radius: var(--r-sm); cursor: pointer;
    color: var(--ink-3); background: transparent;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .pw-toggle:hover { color: var(--ink); background: color-mix(in oklab, var(--ink) 7%, transparent); }
  .pw-toggle:active { background: color-mix(in oklab, var(--ink) 11%, transparent); }
  .pw-toggle[aria-pressed="true"] { color: var(--accent); }
  .pw-toggle svg { width: 18px; height: 18px; }

  /* Search inputs get their own quiet, borderless-at-rest treatment. */
  .search-input { position: relative; display: flex; align-items: center; min-width: 200px; }
  .search-input svg { position: absolute; left: 9px; color: var(--ink-3); pointer-events: none; }
  .search-input .input { padding-left: 30px; }

  /* ------------------------------------------------------------ cards -- */
  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .card-head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 13px 16px; border-bottom: 1px solid var(--line);
  }
  .card-head h2, .card-head h3 { margin: 0; }
  .card-head .grow { flex: 1; min-width: 0; }
  .card-body { padding: 16px; }
  .card-body + .card-body { border-top: 1px solid var(--line); }
  .card-foot {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 16px; border-top: 1px solid var(--line);
    background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg);
  }
  /* De-carded sections: a heading, a hairline, air. */
  .section { display: grid; gap: 12px; }
  .section-head {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    padding-bottom: 10px; border-bottom: 1px solid var(--line);
  }
  .section-head h2 { font-size: 14px; font-weight: 600; }
  .section-head .grow { flex: 1; }

  .grid { display: grid; gap: 14px; }
  /* min(…, 100%): a container narrower than one column (a 320px phone, a
     card's padded body) gets one full-width column instead of overflowing. */
  .grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
  .grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(168px, 100%), 1fr)); }

  /* ------------------------------------------------------------- stats -- */
  .stat { padding: 16px; display: grid; gap: 3px; }
  .stat .label {
    font-size: 12px; font-weight: 500; letter-spacing: 0.01em; color: var(--ink-3);
    display: flex; align-items: center; gap: 6px;
  }
  .stat .value {
    font-size: 24px; font-weight: 600; letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums; line-height: 1.15;
  }
  .stat .delta { font-size: 12px; color: var(--ink-3); }
  .stat .delta strong { font-weight: 550; color: var(--ink-2); }

  .bar { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
  /* In a table row a progress bar is a 4px hairline, not a block. */
  table.data .bar { height: 4px; }
  .bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent);
             transition: width 0.5s var(--ease); }
  /* The sidebar's monthly usage is the default emerald (.bar > i); .is-warn /
     .is-bad below take over at 80% and at the limit. */
  .bar.is-ok > i { background: var(--ok); }
  .bar.is-warn > i { background: var(--warn); }
  .bar.is-bad > i { background: var(--bad); }

  /* -------------------------------------------------------- usage card -- */
  /* Four caps as short rows. Fixed four columns on desktop so the bars line
     up across resources; two then one on narrow screens, never a scroller. */
  .usage-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  /* The card sits in a side column on wide screens, where four columns leave
     each value ~80px: switch on the card's own width, not the viewport's. */
  .usage-card { container-type: inline-size; }
  @container (max-width: 640px) {
    .usage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @container (max-width: 560px) {
    .usage-grid { gap: 16px 18px; }
  }
  .usage-item { min-width: 0; display: grid; gap: 7px; align-content: start; }
  .usage-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .usage-head .grow { flex: 1; min-width: 0; }
  .usage-label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
  .usage-pct { font-size: 12px; color: var(--ink-3); }
  .usage-value {
    display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
    font-size: 16px; font-weight: 600; letter-spacing: -0.015em;
    line-height: 1.3; font-variant-numeric: tabular-nums;
  }
  .usage-amount { min-width: 0; overflow-wrap: anywhere; }
  /* A row without a bar still reserves the bar's height (6px + 7px grid gap)
     so the four cards keep one baseline. */
  .usage-item.is-unlimited { padding-bottom: 13px; }
  .usage-none { font-size: 11px; padding: 1px 6px; font-weight: 550; }
  .usage-bar { margin-top: 1px; }
  .usage-note { font-size: 12px; line-height: 1.55; color: var(--ink-3); }
  .usage-note.is-bad { color: var(--bad); }
  .usage-warm { color: var(--warn); }
  .usage-hot { color: var(--bad); }
  .quota-tag.is-full { color: var(--bad); font-weight: 550; }

  @media (max-width: 480px) {
    .usage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .usage-card .card-head { flex-wrap: wrap; }
  }

  /* Segmented funnel: queued | sending | sent | failed | suppressed. */
  /* 5px, with a 2px white cut between segments (the gap shows the card); the
     unfilled remainder is its own track segment. */
  .funnel { display: flex; gap: 2px; height: 5px; border-radius: var(--r-full); overflow: hidden;
            background: transparent; }
  .funnel::after { content: ""; flex: 1 1 0; min-width: 0; background: var(--surface-3); }
  .funnel > i { display: block; height: 100%; transition: width 0.5s var(--ease); }
  .funnel .f-queued { background: color-mix(in oklab, var(--ink-3) 45%, transparent); }
  .funnel .f-sending { background: var(--info); animation: breathe 2s var(--ease) infinite; }
  .funnel .f-sent { background: var(--ok); }
  .funnel .f-failed { background: var(--bad); }
  .funnel .f-suppressed { background: color-mix(in oklab, var(--warn) 70%, transparent); }
  @keyframes breathe { 0%, 100% { opacity: 1 } 50% { opacity: 0.5 } }
  .legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--ink-2); }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend i { width: 7px; height: 7px; border-radius: calc(var(--r-xs) / 2); display: inline-block; }
  .legend b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

  /* ------------------------------------------------------------ tables -- */
  .table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
  table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; padding: 8px 14px; font-size: 12px; font-weight: 550;
    letter-spacing: 0.01em; color: var(--ink-3); white-space: nowrap;
    background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 1;
  }
  table.data td {
    padding: 10px 14px; border-bottom: 1px solid var(--line);
    vertical-align: middle; height: 42px;
  }
  table.data tbody tr { transition: background var(--dur) var(--ease); }
  table.data tbody tr:hover { background: var(--surface-2); }
  table.data tbody tr:last-child td { border-bottom: 0; }
  table.data tbody tr[data-clickable] { cursor: pointer; }
  table.data a { color: inherit; font-weight: 500; }
  table.data a:hover { color: var(--accent); text-decoration: none; }
  .num { font-variant-numeric: tabular-nums; text-align: right; }
  /* A numeric column's header lines up with its numbers (`table.data th` sets
     left alignment with more specificity than `.num` alone). */
  table.data th.num { text-align: right; }
  .cell-mono { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

  /* ------------------------------------------------------------ badges -- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 7px 2px 6px; border-radius: var(--r-sm);
    font-size: 11px; font-weight: 550; letter-spacing: 0.01em; white-space: nowrap;
    border: 1px solid transparent;
  }
.badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex: none;
  }
  .badge-plain::before { display: none; }
  .b-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-edge); }
  .b-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-edge); }
  .b-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-edge); }
  /* A badge that is also a shortcut (mailbox list: "no display name"). */
  button.badge { font-family: inherit; cursor: pointer; }
  .b-info { background: var(--info-soft); color: var(--info); border-color: var(--info-edge); }
  .b-violet { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-edge); }
  .b-neutral { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }
  /* Status as a coloured dot and plain text: for the second state on a row,
     so a row carries one pill (the stage) and not two competing ones. */
  .status-dot, .status-dot[class*="b-"] {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap;
    color: var(--ink-2); background: none; border: 0; padding: 0;
  }
  .status-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex: none; }
  .status-dot.b-ok::before { background: var(--ok); }
  .status-dot.b-warn::before { background: var(--warn); }
  .status-dot.b-bad::before { background: var(--bad); }
  .status-dot.b-info::before { background: var(--info); }
  .status-dot.b-violet::before { background: var(--violet); }
  .b-live::before { animation: breathe 2s var(--ease) infinite; box-shadow: 0 0 0 2px color-mix(in oklab, currentColor 22%, transparent); }

  /* ------------------------------------------------------- empty / skel -- */
  .empty {
    padding: 56px 24px; text-align: center;
    display: grid; gap: 10px; justify-items: center;
  }
  .empty .icon {
    width: 40px; height: 40px; display: grid; place-items: center;
    border-radius: var(--r-lg); background: var(--surface-2); color: var(--ink-3);
    border: 1px solid var(--line); box-shadow: var(--shadow-1);
  }
  .empty h3 { font-size: 14px; font-weight: 600; }
  .empty p { color: var(--ink-3); max-width: 44ch; font-size: 13px; line-height: 1.6; text-wrap: pretty; }

  .skel {
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    border-radius: var(--r-xs); height: 11px;
    animation: shimmer 1.6s linear infinite;
  }
  /* Cache-first (stale-while-revalidate) render: the real content lands in the
     same frame from the request cache, so the skeleton is hidden rather than
     flashing grey. The router drops the attribute the moment a GET has to wait
     for the network. */
  .view[data-warm="1"] .skel { visibility: hidden; }
  @keyframes shimmer { to { background-position: -200% 0 } }

  .spinner {
    width: 14px; height: 14px; border-radius: 50%; flex: none;
    border: 1.8px solid color-mix(in oklab, currentColor 22%, transparent);
    border-top-color: currentColor; animation: spin 0.7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg) } }

  /* ------------------------------------------------------------ toasts -- */
  .toasts {
    position: fixed; inset: auto auto 20px 50%; transform: translateX(-50%);
    z-index: 80; display: grid; gap: 8px;
    width: min(400px, calc(100vw - 32px));
    margin: 0; padding: 0; border: 0; background: transparent;
    overflow: visible;
    pointer-events: none;
  }
  .toast {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 10px 12px; border-radius: var(--r-md);
    background: var(--overlay); border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-3); font-size: 13px;
    color: var(--ink); pointer-events: auto;
    animation: toast-in var(--dur-pop) var(--ease);
  }
  .toast.bad { border-color: color-mix(in oklab, var(--bad) 28%, var(--line-strong)); }
  .toast .grow { flex: 1; min-width: 0; }
  .toast .btn { box-shadow: none; }
  .toast-action { color: var(--accent); font-weight: 550; margin-top: -2px; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(6px) scale(0.99) } }
  /* Exits take 0.18s; ui.js removes the node on animationend (leave()). */
  .toast[data-closing] { animation: toast-out 0.18s var(--ease) forwards; }
  @keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.99) } }

  /* ------------------------------------------------- dialogs & drawers -- */
  dialog.modal {
    border-radius: var(--r-lg); background: transparent;
    max-width: min(520px, calc(100vw - 32px)); width: 100%; color: var(--ink);
    overflow: visible;
    animation: modal-in var(--dur-pop) var(--ease);
  }
  dialog.modal::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(2px);
    animation: fade-in 0.2s var(--ease);
  }
  dialog.modal[data-closing] { animation: modal-out 0.18s var(--ease) forwards; }
  dialog.modal[data-closing]::backdrop { animation: fade-out 0.18s var(--ease) forwards; }
  @keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.99) } }
  @keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(0.99) } }
  @keyframes fade-out { to { opacity: 0 } }
  dialog.modal .card { box-shadow: var(--shadow-3); border-color: var(--line-strong); border-radius: var(--r-xl); }
  /* A dialog taller than the window (the role editor, a member's access scope
     on a workspace with many mailboxes) scrolls its body while the head and
     the actions stay in view -- the layout the phone sheet below already uses.
     Without it the card overflowed the fixed dialog and its buttons could not
     be reached. */
  dialog.modal[open] { display: flex; flex-direction: column; }
  dialog.modal > .card {
    display: flex; flex-direction: column; min-height: 0;
    max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  }
  dialog.modal > .card > .card-head { flex: none; }
  dialog.modal > .card > .card-body:not(.modal-actions) {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  }
  dialog.modal > .card > .modal-actions { flex: none; }
  dialog.modal .card-head {
    position: sticky; top: 0; background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

  /* Slide-over drawer: the native <dialog> element, pinned right. */
  dialog.drawer {
    margin: 0 0 0 auto; width: min(var(--drawer-w, 520px), 100vw);
    max-width: 100vw; height: 100vh; max-height: 100vh;
    height: 100dvh; max-height: 100dvh;
    background: var(--surface); color: var(--ink);
    border-left: 1px solid var(--line-strong);
    box-shadow: var(--shadow-3); overflow: visible;
    animation: drawer-in 0.24s var(--ease);
  }
  dialog.drawer[open] { display: flex; flex-direction: column; }
  dialog.drawer::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(2px);
    animation: fade-in 0.2s var(--ease);
  }
  dialog.drawer[data-closing] { animation: drawer-out 0.18s var(--ease) forwards; }
  dialog.drawer[data-closing]::backdrop { animation: fade-out 0.18s var(--ease) forwards; }
  @keyframes drawer-in { from { transform: translateX(24px); opacity: 0.6 } }
  @keyframes drawer-out { to { transform: translateX(24px); opacity: 0 } }
  @keyframes fade-in { from { opacity: 0 } }

  .drawer-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
    flex: none;
  }
  .drawer-head .grow { flex: 1; min-width: 0; }
  .drawer-head h2 { font-size: 16px; }
  .drawer-head p { margin-top: 3px; font-size: 12px; color: var(--ink-3); }
  .drawer-body { padding: 20px; overflow-y: auto; flex: 1; display: grid; gap: 16px; align-content: start; }
  .drawer-foot {
    display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
    padding: 14px 20px; border-top: 1px solid var(--line);
    background: var(--surface-2); flex: none;
  }

  /* ------------------------------------------------------ command bar -- */
  dialog.cmdk {
    width: min(580px, calc(100vw - 32px)); max-width: 580px;
    margin: 12vh auto auto; border-radius: var(--r-xl);
    background: var(--overlay); color: var(--ink);
    box-shadow: var(--shadow-3); border: 1px solid var(--line-strong);
    padding: 0; overflow: hidden;
    animation: cmdk-in var(--dur-pop) var(--ease);
  }
  dialog.cmdk::backdrop {
    background: var(--scrim);
    backdrop-filter: blur(3px);
  }
  @keyframes cmdk-in { from { opacity: 0; transform: translateY(-6px) scale(0.99) } }
  .cmdk-search {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 15px; border-bottom: 1px solid var(--line);
    transition: border-color var(--dur) var(--ease);
  }
  .cmdk-search:focus-within { border-bottom-color: var(--accent); }
  .cmdk-search svg { color: var(--ink-3); flex: none; }
  .cmdk-search input {
    flex: 1; border: 0; outline: none; background: transparent;
    font-size: 14px; min-width: 0;
  }
  .cmdk-list { max-height: min(60vh, 480px); overflow-y: auto; padding: 6px; }
  .cmdk-group {
    padding: 9px 10px 5px; font-size: 11px; font-weight: 550;
    letter-spacing: 0.05em; color: var(--ink-3);
  }
  .cmdk-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 7px 10px; border-radius: var(--r-sm); cursor: pointer;
    font-size: 13px; color: var(--ink-2); text-align: left;
  }
  .cmdk-item svg { color: var(--ink-3); flex: none; }
  .cmdk-item .hint { margin-left: auto; font-size: 11px; color: var(--ink-3); }
  .cmdk-item[data-active="true"] { background: var(--surface-3); color: var(--ink); }
  .cmdk-item[data-active="true"] svg { color: var(--accent); }
  .cmdk-empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }
  .cmdk-foot {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 8px 14px; border-top: 1px solid var(--line);
    background: var(--surface-2); font-size: 11px; color: var(--ink-3);
  }
  .cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }

  /* ------------------------------------------------------------ avatar -- */
  .avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
    background: var(--surface-4); color: var(--ink-2);
    border: 1px solid var(--line);
  }
  /* Deterministic low-saturation tones (v6.1), derived strictly from tokens
     with zero green cast: indigo, orchid plum, platinum slate, ocean sapphire, champagne bronze. */
  .avatar[data-tone="0"] { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-edge); }
  .avatar[data-tone="1"] { background: var(--violet-soft); color: var(--violet); border-color: var(--violet-edge); }
  .avatar[data-tone="2"] { background: var(--surface-3); color: var(--ink-2); border-color: var(--line-strong); }
  .avatar[data-tone="3"] { background: var(--info-soft); color: var(--info); border-color: var(--info-edge); }
  .avatar[data-tone="4"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-edge); }


  /* Language: a compact select in the sidebar, a two-way switch signed out. */
  .side-lang {
    min-height: 26px; width: auto; max-width: 140px; padding: 2px 26px 2px 8px;
    font-size: 12px; background-color: var(--surface-2); box-shadow: none;
    background-position: calc(100% - 13px) 10px, calc(100% - 8px) 10px;
  }
  .lang-switch {
    display: inline-flex; align-items: center; gap: 1px; padding: 2px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface-2);
  }
  .lang-switch button {
    min-height: 28px; padding: 0 10px; border-radius: var(--r-xs);
    font-size: 12px; color: var(--ink-3); cursor: pointer;
  }
  .lang-switch button:hover { color: var(--ink); }
  .lang-switch button[aria-pressed="true"] {
    background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1);
  }
  .auth-top-end { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

  /* --------------------------------------------------------- segmented -- */
  /* One row while it fits; when its options are wider than the space it has
     (six statuses, or English labels, on a phone) they wrap inside the frame
     instead of widening the page (guidelines 4.5). */
  .segmented {
    display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 2px; gap: 2px;
    /* A grid parent (.content, .stack) would otherwise stretch the control
       into a full-width grey bar. */
    justify-self: start;
    background: var(--surface-3); border-radius: var(--r-sm);
    border: 1px solid var(--line);
  }
  .segmented button {
    padding: 4px 10px; min-height: 24px; border-radius: var(--r-xs);
    font-size: 12px; font-weight: 500; color: var(--ink-2); cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .segmented button:hover { color: var(--ink); }
  .segmented button[aria-pressed="true"] {
    background: var(--raised); color: var(--ink); font-weight: 550;
    box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  }

  /* ---------------------------------------------------------- copy code -- */
  .copy-btn {
    display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
    border-radius: var(--r-sm); color: var(--ink-3); cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .copy-btn:hover { background: var(--surface-4); color: var(--ink); }
  .copy-btn.is-done { color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok-edge); }

  /* --------------------------------------------------------------- tabs -- */
  .tabs {
    display: flex; gap: 2px; border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
  }
  .tab {
    position: relative; padding: 9px 12px; background: none; cursor: pointer;
    font-size: 13px; font-weight: 500; color: var(--ink-3);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .tab:hover { color: var(--ink); }
  .tab[aria-selected="true"] { color: var(--ink); font-weight: 550; border-bottom-color: var(--ink); }

  /* Section tabs: the row the shell adds to a page header when the screen is
     one tab of a sidebar entry (客户 / 公海 / 标签 …). It is the last row of the
     sticky header, so its underline sits on the header's own bottom border. */
  .topbar .section-tabs {
    order: 99; flex-basis: 100%;
    margin: 2px 0 -18px; border-bottom: none;
  }
  .topbar .section-tabs .tab { text-decoration: none; }
  @media (max-width: 960px) {
    .topbar .section-tabs { margin-bottom: -14px; }
  }

  /* Wizard steps: a numbered dot and a label per step, joined by a line. Done
     steps show a check, the current one is filled. */
  .steps {
    list-style: none; margin: 0; padding: 0;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 13px; color: var(--ink-3);
  }
  .steps li { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
  .steps li + li::before {
    content: ""; width: 24px; height: 1px; background: var(--line-strong);
  }
  .step-dot {
    flex: none; width: 20px; height: 20px; border-radius: var(--r-full);
    display: inline-grid; place-items: center;
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-3);
  }
  .steps li[aria-current="step"] { color: var(--ink); font-weight: 550; }
  .steps li[aria-current="step"] .step-dot { background: var(--ink); border-color: var(--ink); color: var(--surface); }
  .steps li.is-done { color: var(--ink-2); }
  .steps li.is-done .step-dot { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
  @media (max-width: 640px) {
    .steps li + li::before { width: 10px; }
  }

  /* ------------------------------------------------------- verify banner -- */
  .verify-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 32px;
    background: var(--warn-soft);
    color: var(--warn);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
  }
  .verify-banner .icon { display: grid; place-items: center; flex: none; }
  .verify-banner .grow { flex: 1; min-width: 200px; }
  .verify-banner strong { font-weight: 600; }
  .verify-banner .small { color: inherit; opacity: 0.8; }
  .verify-banner .btn {
    background: transparent; color: var(--warn);
    border-color: color-mix(in oklab, var(--warn) 28%, transparent);
    box-shadow: none;
  }
  .verify-banner .btn:hover:not(:disabled) { background: color-mix(in oklab, var(--warn-soft) 60%, var(--surface)); }
  @media (max-width: 960px) { .verify-banner { padding-left: 16px; padding-right: 16px; } }

  /* ----------------------------------- operator announcements (announcements-banner.js) -- */
  .announce {
    display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    padding: 10px 32px;
    background: var(--info-soft);
    color: var(--info);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
  }
  .announce.is-warn {
    background: var(--warn-soft);
    color: var(--warn);
  }
  .announce .icon { display: grid; place-items: center; flex: none; padding-top: 2px; }
  .announce .grow { flex: 1; min-width: 200px; }
  .announce strong { font-weight: 600; }
  .announce-body { white-space: pre-line; overflow-wrap: anywhere; opacity: 0.9; margin-top: 2px; }
  .announce-body a { color: inherit; text-decoration: underline; }
  .announce .btn {
    background: transparent; color: inherit;
    border-color: color-mix(in oklab, currentColor 28%, transparent);
    box-shadow: none;
  }
  @media (max-width: 960px) { .announce { padding-left: 16px; padding-right: 16px; } }

  /* ------------------------------------------------------- plan banner -- */
  /* One slim line above the page: a trial running out (info) or a lapsed plan
     (warn). Quieter than the verify banner, which asks for something. */
  .plan-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 8px 32px;
    background: var(--warn-soft); color: var(--warn);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
  }
  .plan-banner .btn:not(.btn-icon) {
    background: transparent; border-color: transparent; box-shadow: none;
    color: inherit; font-weight: 600;
  }
  .plan-banner .btn:not(.btn-icon):hover:not(:disabled) { background: transparent; text-decoration: underline; }
  .plan-banner .icon { display: grid; place-items: center; flex: none; }
  .plan-banner .grow { flex: 1; min-width: 160px; }
  .plan-banner.is-info, .plan-banner.is-warn { background: var(--warn-soft); color: var(--warn); }
  /* A to-do for the person (pending approvals), not a time-limited notice: blue. */
  .plan-banner.is-accent { background: var(--accent-soft); color: var(--accent-strong); }
  /* A workspace scheduled for deletion: sending is off until the owner cancels. */
  .plan-banner.is-bad {
    background: var(--bad-soft); color: var(--bad);
  }
  @media (max-width: 960px) { .plan-banner { padding-left: 16px; padding-right: 16px; } }

  /* ------------------------------------------------- banner stack -- */
  /* One account banner in full; the others fold behind a quiet one-line toggle
     (js/banner-stack.js, guidelines 8.12). The toggle is a ghost button: it is
     not the screen's primary action. */
  .banner-more-row {
    display: flex; align-items: center; padding: 2px 28px;
    border-bottom: 1px solid var(--line); background: var(--surface-2);
  }
  .banner-more { color: var(--ink-2); max-width: 100%; }
  .banner-more[aria-expanded="true"] svg { transform: rotate(180deg); }
  @media (max-width: 960px) { .banner-more-row { padding-left: 16px; padding-right: 16px; } }

  /* A control the plan does not include: the disabled button plus a way out. */
  .plan-locked { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .plan-lock {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--ink-3);
  }
  a.plan-lock { color: var(--accent); font-weight: 500; }
  a.plan-lock:hover { text-decoration: underline; }

  /* ------------------------------------------------------ plan & billing -- */
  .bill-plan-name { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
  .bill-features { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
  .bill-features li { display: inline-flex; align-items: center; gap: 6px; }
  .bill-features li.is-off { color: var(--ink-3); }
  .bill-yes { display: inline-grid; place-items: center; color: var(--ok); }
  .bill-no { color: var(--ink-3); }
  .bill-bad { color: var(--bad); font-weight: 550; }
  .bill-usage { gap: 18px 28px; }
  .bill-use { display: grid; gap: 6px; align-content: start; font-size: 13px; }
  .bill-table th, .bill-table td { white-space: nowrap; }
  .bill-table th[scope="row"] { text-align: left; font-weight: 500; color: var(--ink-2); }
  .bill-table .bill-current { background: var(--accent-soft); }
  .bill-here { margin-left: 6px; }
  .bill-pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }

  /* --------------------------------------------------------- auth pages -- */
  /* Signed-out screen: the form is a quiet column, the workspace is the
     picture. The right-hand window is decorative (aria-hidden in auth.js) and
     built from tokens only, so it needs no separate
     artwork. */
  .auth-page {
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
    position: relative;
    /* Warm porcelain with an engineering dot grid: 22px hairline dots, no light. */
    background:
      radial-gradient(var(--line-strong) 1px, transparent 1px) 0 0 / 22px 22px,
      var(--canvas);
  }
  .auth-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; padding: 26px 48px 18px;
  }
  .mark-tile {
    width: 34px; height: 34px; border-radius: var(--r-lg); flex: none;
    display: grid; place-items: center;
    /* The login page's brand mark: same sovereign indigo anchor as the sidebar. */
    background: var(--primary); color: var(--primary-ink);
    box-shadow: var(--shadow-primary);
  }
  .auth-brand { display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 650; letter-spacing: -0.005em; }
  .auth-brand > span:last-child { display: grid; line-height: 1.25; }
  .auth-brand-meta { font-size: 11px; font-weight: 400; color: var(--ink-3); letter-spacing: 0.02em; }
  .auth-top-link { margin: 0; font-size: 12px; color: var(--ink-3); }
  .auth-top-link a { color: var(--ink); font-weight: 550; }
  .auth-top-link a:hover { color: var(--accent); text-decoration: none; }

  .auth-body {
    flex: 1; display: grid; min-height: 0;
    grid-template-columns: minmax(360px, 0.82fr) minmax(0, 1.18fr);
    align-items: center; gap: 40px; padding: 0 48px 44px;
  }
  .auth-main { display: grid; place-items: center; width: 100%; min-width: 0; padding: 10px 0 24px; }

  .auth-form { width: min(356px, 100%); display: grid; gap: 16px; }
  .auth-head { display: grid; gap: 8px; margin-bottom: 6px; }
  .auth-kicker {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--accent-strong);
  }
  .auth-kicker::before {
    content: ""; width: 14px; height: 2px; border-radius: var(--r-full);
    background: var(--accent);
  }
  .auth-form h2 { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
  .auth-form h2:lang(en) { letter-spacing: -0.03em; }
  .auth-lede { font-size: 13px; color: var(--ink-3); line-height: 1.7; text-wrap: pretty; }

  /* The signed-out form is the customer's first contact with the product, so
     its controls are a size up from the dense workspace tables. */
  .auth-form .field > label { font-size: 12px; font-weight: 600; }
  .auth-form .field .input { height: 44px; font-size: 14px; padding: 0 12px; border-radius: var(--r-md); }
  .auth-form .field .hint { font-size: 12px; }

  .auth-form .btn-block { height: 44px; font-size: 14px; border-radius: var(--r-md); }
  .auth-submit { margin-top: 4px; }
  .auth-submit svg { transition: transform var(--dur) var(--ease); }
  .auth-submit:hover:not(:disabled) svg { transform: translateX(2px); }
  .auth-submit.is-busy { cursor: progress; }
  .auth-submit.is-busy svg { display: none; }
  .auth-submit.is-busy::after {
    content: ""; width: 13px; height: 13px; border-radius: 50%;
    border: 1.6px solid color-mix(in oklab, var(--solid-ink) 28%, transparent);
    border-top-color: var(--solid-ink);
    animation: spin 0.7s linear infinite;
  }

  .auth-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .auth-quiet { font-size: 12px; color: var(--ink-3); }
  .auth-legal { text-align: center; font-size: 12px; color: var(--ink-3); padding: 0 24px 22px; }
  .auth-legal a { color: inherit; }
  .auth-legal a:hover { color: var(--ink-2); }
  a.auth-quiet:hover { color: var(--ink-2); }
  .auth-switch { text-align: center; font-size: 12px; color: var(--ink-3); }
  /* Sign in with Google / Microsoft: a rule with "or" in it, then one full-width
     button per provider. They are links, so they get the button look only. */
  .auth-sso { display: grid; gap: 8px; }
  .auth-sso-sep {
    display: flex; align-items: center; gap: 10px; margin: 2px 0;
    font-size: 12px; color: var(--ink-3);
  }
  .auth-sso-sep::before, .auth-sso-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .auth-sso-btn { text-decoration: none; }
  .auth-turnstile { min-height: 65px; }
  .auth-alert {
    padding: 9px 11px; border-radius: var(--r-sm); font-size: 12px;
    background: var(--bad-soft); color: var(--bad);
    border: 1px solid color-mix(in oklab, var(--bad) 22%, transparent);
  }

  /* ------------------------------------------------------- auth showcase -- */
  .auth-hero {
    position: relative; display: grid; place-items: center; min-width: 0; padding: 30px 26px 34px;
    /* The floating chips need room beside the window: they follow the hero's
       own width, not a viewport breakpoint of their own. */
    container-type: inline-size;
  }
  /* The glow behind the product window is retired (no coloured light on the
     login page); the element stays for the markup, drawn as nothing. */
  .auth-glow { display: none; }
  .auth-stage { position: relative; width: min(680px, 100%); }
  .auth-window {
    position: relative; width: 100%; overflow: hidden;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
  }
  .aw-bar {
    display: flex; align-items: center; gap: 6px; padding: 10px 14px;
    border-bottom: 1px solid var(--line); background: var(--surface-2);
  }
  .aw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-4); }
  .aw-addr {
    margin-left: 10px; flex: 1; min-width: 0; height: 20px;
    display: flex; align-items: center; padding: 0 8px;
    border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--surface);
    font-family: var(--mono); font-size: 9px; color: var(--ink-3);
  }
  .aw-body { display: grid; grid-template-columns: 132px minmax(0, 1fr); }
  .aw-side { padding: 12px 8px; border-right: 1px solid var(--line); background: var(--canvas); }
  .aw-nav {
    display: flex; align-items: center; gap: 7px; height: 26px; padding: 0 8px;
    border-radius: var(--r-sm); font-size: 11px; color: var(--ink-2);
  }
  .aw-nav b { width: 9px; height: 9px; border-radius: calc(var(--r-xs) / 2); background: var(--surface-4); }
  .aw-nav.is-on {
    background: var(--surface); color: var(--ink); font-weight: 600;
    box-shadow: 0 0 0 1px var(--line);
  }
  .aw-nav.is-on b { background: var(--accent); }
  .aw-grp {
    padding: 12px 8px 4px; font-size: 9px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--ink-3);
  }
  .aw-content { padding: 16px 18px 18px; display: grid; gap: 12px; min-width: 0; }
  .aw-title h3 { font-size: 13px; font-weight: 600; }
  .aw-title p { margin-top: 3px; font-size: 9.5px; color: var(--ink-3); }
  .aw-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .aw-tile {
    display: grid; gap: 4px; min-width: 0; padding: 9px 10px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-md);
  }
  .aw-tile .l { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
  .aw-tile .v { font-family: var(--mono); font-size: 14px; font-weight: 550; letter-spacing: -0.01em; }
  .aw-tile .d { font-size: 8.5px; color: var(--ok); }
  .aw-tile .d.quiet { color: var(--ink-3); }
  .aw-chart { padding: 10px 10px 4px; border: 1px solid var(--line); border-radius: var(--r-md); }
  .aw-chart-head { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--ink-3); }
  .aw-chart svg { display: block; width: 100%; height: 58px; margin-top: 6px; }
  /* Soft vertical wash fading into the white surface. */
  .aw-stop-a { stop-color: var(--accent); stop-opacity: 0.16; }
  .aw-stop-b { stop-color: var(--accent); stop-opacity: 0.01; }
  .aw-dot-live { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
  .aw-dot-halo { fill: none; stroke: var(--accent); stroke-opacity: 0.4; animation: breathe 2s var(--ease) infinite; }
  .aw-area { fill: url(#aw-fill); }
  .aw-line {
    fill: none; stroke: var(--accent); stroke-width: 1.6;
    stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke;
  }
  .aw-rows { display: grid; gap: 5px; }
  .aw-r {
    display: grid; grid-template-columns: minmax(0, 1fr) 60px 52px; gap: 8px;
    align-items: center; padding: 5px 0; border-top: 1px solid var(--line);
    font-size: 9.5px; color: var(--ink-2);
  }
  .aw-r .t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .aw-r .n { font-family: var(--mono); text-align: right; color: var(--ink-3); }
  .aw-r .p { justify-self: end; font-size: 8px; font-weight: 600; padding: 2px 6px; border-radius: var(--r-full); }
  .aw-r .p.is-ok { background: var(--ok-soft); color: var(--ok); }
  .aw-r .p.is-draft { background: var(--warn-soft); color: var(--warn); }

  .auth-chip {
    position: absolute; z-index: 2; display: flex; align-items: center; gap: 9px;
    padding: 9px 13px 9px 11px; background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
    font-size: 11px; color: var(--ink-2);
  }
  .auth-chip b { font-family: var(--mono); font-size: 13px; color: var(--ink); letter-spacing: -0.01em; }
  .auth-chip .k { display: block; font-size: 9px; letter-spacing: 0.04em; color: var(--ink-3); }
  .auth-chip-ico {
    width: 26px; height: 26px; border-radius: var(--r-md); display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
  }
  .auth-chip-ico.is-ok { background: var(--ok-soft); color: var(--ok); }
  .auth-chip-a { top: -44px; left: 6px; }
  .auth-chip-b { bottom: -44px; right: 6px; }

  /* 616px is the hero's width at the 1180px viewport the chips used to hide at. */
  @container (max-width: 616px) { .auth-chip { display: none; } }
  @media (max-width: 960px) {
    .auth-body { grid-template-columns: 1fr; align-items: start; justify-items: center; padding: 0 24px 40px; }
    .auth-hero { display: none; }
    .auth-top { padding: 20px 24px 8px; }
    .auth-main { padding: max(6vh, 24px) 0 32px; }
  }
  @media (max-width: 480px) {
    .auth-top { padding: 18px 12px 6px; }
    .auth-body { padding: 0 8px 32px; }
    .auth-form h2 { font-size: 24px; }
    .auth-turnstile { width: 100%; max-width: 100%; overflow: hidden; display: flex; justify-content: center; }
  }

  /* -------------------------------------------------------------- inbox -- */
  /* Three panes: folders | message list | reader. At 960px and below the panes become
     one-at-a-time screens, switched by the data-pane attribute on .inbox. */
  .inbox-content { padding-bottom: 24px; }
  /* No mailbox yet: the empty state stands on the canvas itself, no card frame,
     centred in the space the three panes would take. */
  .card.inbox-empty {
    display: grid; place-items: center;
    min-height: min(520px, calc(100dvh - 240px));
    border: 0; background: transparent;
  }
  /* The workbench: folders on the warm canvas, list and reader pure white,
     warm hairlines between the panes and no shadow on the frame. */
  /* Folders 196px; the list 300–360px (it widens with the window, 360px from
     about 1385px up, no breakpoint of its own); the reader takes the rest.
     Positioned: the selection capsule is centred on the whole workbench. */
  .inbox {
    position: relative;
    display: grid; grid-template-columns: 196px clamp(300px, 26vw, 360px) minmax(0, 1fr);
    border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
    min-height: 620px; overflow: hidden;
  }
  .inbox > * { min-width: 0; }
  .inbox-folders {
    padding: 12px 10px; display: grid; gap: 14px; align-content: start;
    border-right: 1px solid var(--line); background: var(--canvas);
  }
  .inbox-folders .field > label { font-size: 12px; color: var(--ink-3); }
  .folder-link {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    padding: 6px 8px; min-height: 30px; border: 0; border-radius: var(--r-sm);
    background: none; color: var(--ink-2); font-size: 13px; cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .folder-link:hover { background: var(--surface-3); color: var(--ink); }
  .folder-link[aria-current="true"] {
    background: var(--surface); color: var(--ink); font-weight: 550;
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  }
  .folder-link svg { flex: none; color: var(--ink-3); transition: color var(--dur) var(--ease); }
  .folder-link[aria-current="true"] svg { color: var(--accent); }
  .folder-link .grow { flex: 1; min-width: 0; }
  .folder-link .count {
    background: var(--solid); color: var(--solid-ink); border-radius: var(--r-full);
    padding: 0 6px; font-size: 11px; line-height: 16px; font-variant-numeric: tabular-nums;
  }
  .folder-link .count.quiet { background: var(--surface-4); color: var(--ink-2); }
  .inbox-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--surface); }
  .inbox-list-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--line);
  }
  .inbox-list-head .grow { flex: 1; min-width: 0; }
  /* Search sits between the head and the rows and is never re-mounted, so the
     caret survives the 300 ms debounce (see views/inbox.js). */
  .inbox-search { display: grid; gap: 7px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
  .inbox-search-bar { display: flex; align-items: center; gap: 7px; }
  .inbox-search-bar > svg { flex: none; color: var(--ink-3); }
  .inbox-search-input {
    flex: 1; min-width: 0; width: auto; min-height: 30px; padding: 5px 8px; font-size: 13px;
  }
  .inbox-search-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
  .inbox-filter {
    display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 1px 8px;
    border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surface);
    color: var(--ink-2); font-size: 11px; cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .inbox-filter:hover { background: var(--surface-2); color: var(--ink); }
  .inbox-filter[aria-pressed="true"] {
    background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 36%, transparent);
    color: var(--accent-strong); font-weight: 550;
  }
  .inbox-search-meta { display: flex; align-items: center; gap: 8px; color: var(--ink-3); }
  .inbox-search-meta:empty { display: none; }
  .inbox-search-meta .grow { flex: 1; min-width: 0; }
  .inbox-list-body { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
  .inbox-rows { overflow-y: auto; flex: 1; max-height: 720px; }
  /* Room under the last row for the floating selection capsule. */
  .inbox-list-body:has(.inbox-bulk.is-active) .inbox-rows { padding-bottom: 116px; }
  .msg-row {
    display: flex; gap: 9px; width: 100%; text-align: left; padding: 10px 12px 11px;
    border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink);
    cursor: pointer; position: relative;
    transition: background var(--dur) var(--ease);
  }
  /* Hover is a faint wash; the open row is a sovereign indigo tint with a
     2.5px accent bar on its left edge. */
  .msg-row:hover { background: color-mix(in oklab, var(--surface-2) 60%, var(--surface)); }
  .msg-row[aria-current="true"] { background: color-mix(in oklab, var(--accent-soft) 58%, var(--surface)); }
  .msg-row[aria-current="true"]::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0;
    width: 2.5px; border-radius: 0 2px 2px 0; background: var(--accent);
  }
  .msg-row .avatar { width: 26px; height: 26px; margin-top: 1px; font-size: 11px; }
  /* No row is ever wider than the list. The grid track is minmax(0, 1fr):
     with the default auto track, line 1's chips set a min-content width wider
     than the pane, and the list grew a horizontal scrollbar. */
  .inbox-rows { overflow-x: hidden; }
  .msg-row-wrap, .msg-row { min-width: 0; }
  .msg-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; flex: 1; }
  /* Line 1: the sender (truncates) and the time (never cut). Line 3: the
     preview (truncates first) and the chips -- customer, campaign, intent,
     team state, the mailbox of a merged row -- each whole up to 115px. */
  .msg-top { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow: hidden; }
  .msg-foot { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
  .msg-foot > .msg-preview { flex: 1 1 auto; min-width: 0; }
  .msg-foot > :not(.msg-preview) {
    flex: none; max-width: 115px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .msg-from { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); }
  .msg-time { flex: none; font-size: 11px; color: var(--ink-3); }
  .msg-subject { font-size: 13px; color: var(--ink-2); }
  .msg-preview { display: block; }
  /* A draft row carries a delete control beside it (a button inside a button
     is not valid markup), so the row itself gives it room. */
  .msg-row-wrap { position: relative; }
  .msg-row-wrap .msg-row { padding-right: 36px; }
  .msg-row-del {
    position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-3); cursor: pointer;
  }
  .msg-row-del:hover { background: var(--surface-3); color: var(--bad); }
  /* Ticking and starring: both sit beside the row's own button. */
  .msg-row-wrap.has-check .msg-row { padding-left: 34px; padding-right: 38px; }
  .msg-row-wrap.has-check .msg-row[data-unread]::after { left: 26px; }
  .msg-row-wrap[data-selected] .msg-row { background: var(--surface-3); }
  .msg-check {
    position: absolute; left: 8px; top: 12px; z-index: 1; display: inline-flex;
    align-items: center; justify-content: center; width: 20px; height: 24px; cursor: pointer;
  }
  .msg-star {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-3); cursor: pointer; flex: none;
  }
  .msg-star:hover { background: var(--surface-3); color: var(--ink-2); }
  .msg-star[aria-pressed="true"] { color: var(--warn); }
  .msg-star[aria-pressed="true"] svg { fill: currentColor; }
  .msg-row-star { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); }
  /* The star and delete controls rest quiet and come up on hover or focus (or
     when starred). Only where there is a real hover: on a touch tablet nothing
     would ever bring them back to full strength. */
  /* Desktop-only Superhuman-style hover quick-action pill (mark read/unread,
     trash) sitting beside the star control. Hidden on phones/touch where
     selection mode and swipe/reader controls own row actions. */
  .msg-row-quick { display: none; }
  @media (min-width: 641px) and (hover: hover) {
    .msg-row-quick {
      position: absolute; right: 36px; top: 50%; transform: translateY(-50%);
      z-index: 2; display: inline-flex; align-items: center; gap: 2px;
      padding: 2px; border-radius: var(--r-sm);
      background: var(--surface); border: 1px solid var(--line-strong);
      box-shadow: var(--shadow-1);
      opacity: 0; pointer-events: none;
      transition: opacity var(--dur) var(--ease);
    }
    .msg-row-wrap:hover .msg-row-quick,
    .msg-row-wrap:focus-within .msg-row-quick {
      opacity: 1; pointer-events: auto;
    }
    .msg-row-qbtn {
      display: inline-grid; place-items: center; width: 24px; height: 24px;
      border-radius: var(--r-xs); color: var(--ink-2); cursor: pointer;
      transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
    }
    .msg-row-qbtn:hover { background: var(--surface-3); color: var(--ink); }
    .msg-row-qbtn[data-tone="bad"]:hover { background: var(--bad-soft); color: var(--bad); }
    .msg-row-star,
    .msg-row-del {
      opacity: 0.32;
      transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
    }
    .msg-row-wrap:hover .msg-row-star,
    .msg-row-wrap:focus-within .msg-row-star,
    .msg-row-star[aria-pressed="true"],
    .msg-row-wrap:hover .msg-row-del,
    .msg-row-wrap:focus-within .msg-row-del {
      opacity: 1;
    }
  }
  .inbox-bulk {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  }
  .inbox-bulk-all { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); }
  .inbox-bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
  .inbox-bulk-move { width: auto; font-size: 12px; padding-top: 3px; padding-bottom: 3px; }
  .inbox-bulk-note { flex-basis: 100%; margin: 0; }
  /* What lives behind "⋯" stays in the bar, hidden; inbox-bulk.js proxyMenu
     lists it. The ⋯ and ✕ come last, after the collaboration buttons. */
  .inbox-bulk .is-overflow { display: none; }
  .inbox-bulk-end { order: 1; display: flex; align-items: center; gap: 2px; }
  /* The strip is a fixed 33px on desktop, and while it floats as the capsule
     the list keeps those 33px at its top: ticking the first row does not make
     the rows jump. */
  @media (min-width: 641px) {
    .inbox-bulk:not(.is-active) { min-height: 33px; }
    .inbox-list-body:has(.inbox-bulk.is-active) { padding-top: 33px; }
  }
  /* With rows ticked the strip becomes a floating obsidian capsule (Superhuman
     / Linear): one line, centred at the foot of the whole three-pane
     workbench, not squeezed into the 300px list. Same buttons and handlers;
     the rare ones are behind "⋯". */
  .inbox-bulk.is-active {
    gap: 4px 10px; padding: 6px 8px;
    border: 1px solid color-mix(in oklab, var(--solid-ink) 8%, transparent); border-radius: var(--r-lg);
    background: var(--solid); color: var(--solid-ink); box-shadow: var(--shadow-3);
  }
  @media (min-width: 641px) {
    .inbox-list-body:has(.inbox-bulk.is-active) { position: static; }
    .inbox-bulk.is-active {
      position: absolute; z-index: 3; left: 50%; bottom: 20px; transform: translateX(-50%);
      width: max-content; max-width: calc(100% - 32px);
      flex-wrap: nowrap; white-space: nowrap;
      overflow-x: auto; scrollbar-width: none;
    }
    .inbox-bulk.is-active::-webkit-scrollbar { display: none; }
    .inbox-bulk.is-active .inbox-bulk-actions,
    .inbox-bulk.is-active .collab-bulk { flex-wrap: nowrap; }
    .inbox-bulk-end { padding-left: 6px; border-left: 1px solid color-mix(in oklab, var(--solid-ink) 14%, transparent); }
  }
  .inbox-bulk.is-active .inbox-bulk-all { padding-left: 6px; color: var(--solid-ink); }
  .inbox-bulk.is-active .inbox-bulk-actions { justify-content: center; gap: 2px; }
  /* The selects in the capsule (移动到 / 稍后处理 / 指派给) are dark controls:
     a 12% white field with a 18% white edge and a white chevron, never a
     white box on the obsidian. Their list is the themed popup (ui-select.js). */
  .inbox-bulk.is-active .select {
    width: auto; min-height: 28px; padding: 3px 26px 3px 10px; font-size: 12px;
    color: var(--solid-ink); box-shadow: none;
    background-color: color-mix(in oklab, var(--solid-ink) 12%, transparent);
    border-color: color-mix(in oklab, var(--solid-ink) 18%, transparent);
    background-image: linear-gradient(45deg, transparent 50%, color-mix(in oklab, var(--solid-ink) 72%, transparent) 50%),
                      linear-gradient(135deg, color-mix(in oklab, var(--solid-ink) 72%, transparent) 50%, transparent 50%);
    background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px;
  }
  .inbox-bulk.is-active .select:hover:not(:disabled) { border-color: color-mix(in oklab, var(--solid-ink) 32%, transparent); }
  .inbox-bulk.is-active .select:focus { border-color: var(--solid-ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--solid-ink) 18%, transparent); }
  .inbox-bulk.is-active .select:disabled { opacity: 0.5; }
  .inbox-bulk.is-active .hint { color: color-mix(in oklab, var(--solid-ink) 62%, transparent); text-align: center; }
  .inbox-bulk.is-active .btn {
    --btn-bg: transparent; --btn-line: transparent; --btn-fg: color-mix(in oklab, var(--solid-ink) 86%, transparent);
    background: transparent; border-color: transparent; color: color-mix(in oklab, var(--solid-ink) 86%, transparent); box-shadow: none;
  }
  .inbox-bulk.is-active .btn:hover:not(:disabled) { background: color-mix(in oklab, var(--solid-ink) 14%, transparent); color: var(--solid-ink); }
  .inbox-bulk.is-active .btn:active:not(:disabled) { background: color-mix(in oklab, var(--solid-ink) 20%, transparent); }
  .inbox-bulk.is-active :focus-visible { outline: 2px solid color-mix(in oklab, var(--solid-ink) 92%, transparent); outline-offset: 1px; }
  .inbox-bulk.is-active .collab-bulk { margin-left: 0; }
  /* The print preview: the sandboxed frame is sized to its message, and a white
     sheet is what comes out of the printer in either theme. */
  /* The 计划发送 list. */
  .sched-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .sched-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .sched-subject { font-size: 13px; font-weight: 600; color: var(--ink); }
  .sched-when { color: var(--ink-2); }
  .sched-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .sched-row[data-status="failed"] { background: var(--bad-soft); }
  .print-frame { width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
  .msg-row[data-unread] .msg-from,
  .msg-row[data-unread] .msg-subject { font-weight: 600; color: var(--ink); }
  /* The reader head (inbox.js headActions): 回复 (the one primary), 回复全部
     when there are others to reach, 转发, and 标为未读 / 星标 as icons; the
     rest stays in the row hidden and "⋯" opens it as a menu. */
  .inbox-head-actions > .is-overflow { display: none; }
  .inbox-head-actions > .btn { min-height: 30px; }
  .inbox-head-actions > .btn-icon,
  .inbox-head-actions > .btn[data-inbox-action="unread"],
  .inbox-head-actions > .msg-star { width: 30px; height: 30px; min-height: 30px; padding: 0; }
  /* The everyday icon actions (标为未读, 星标) carry a light frame, so they read
     as buttons on the white page and not as loose marks. */
  .inbox-head-actions > .btn[data-inbox-action="unread"],
  .inbox-head-actions > .msg-star {
    --btn-bg: var(--surface); --btn-line: var(--line-strong); --btn-fg: var(--ink-2);
    background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2);
  }
  .inbox-head-actions > .btn[data-inbox-action="unread"]:hover:not(:disabled),
  .inbox-head-actions > .msg-star:hover {
    background: var(--surface); border-color: var(--line-input); color: var(--ink);
  }
  .inbox-head-actions > .msg-star[aria-pressed="true"] { color: var(--warn); }
  .inbox-head-actions > [data-inbox-action="unread"] .btn-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .inbox-head-more { margin-left: auto; }
  /* The menu "⋯" opens (inbox-bulk.js proxyMenu), on the reader and the capsule. */
  .inbox-menu {
    position: fixed; inset: auto; margin: 0; z-index: 1000;
    display: grid; gap: 1px; min-width: 200px; max-width: 320px; padding: 4px;
    color: var(--ink); background: var(--overlay);
    border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
    overflow-y: auto; animation: modal-in var(--dur-pop) var(--ease);
  }
  .inbox-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 10px;
    border: 0; border-radius: var(--r-sm); background: none; color: var(--ink);
    font-size: 13px; text-align: left; cursor: pointer;
  }
  .inbox-menu-item svg { flex: none; color: var(--ink-2); }
  .inbox-menu-item:hover, .inbox-menu-item:focus-visible { background: var(--surface-3); color: var(--ink); outline: none; }
  .inbox-menu-item[data-tone="bad"], .inbox-menu-item[data-tone="bad"] svg { color: var(--bad); }
  .inbox-menu-item[data-tone="bad"]:hover, .inbox-menu-item[data-tone="bad"]:focus-visible { background: var(--bad-soft); }
  .inbox-menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
  .inbox-menu-item-label { flex: 1 1 auto; min-width: 0; }
  .msg-row[data-unread]::after {
    content: ""; position: absolute; left: 5px; top: 15px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  }
  /* A folded conversation row: the count sits beside the participants, quiet
     enough not to compete with the subject. */
  .thread-count {
    flex: none; background: var(--surface-4); color: var(--ink-2);
    border-radius: var(--r-full); padding: 0 6px; font-size: 11px;
    line-height: 16px; font-variant-numeric: tabular-nums;
  }
  .msg-row[data-unread] .thread-count {
    background: var(--accent-soft); color: var(--accent-strong);
  }
  /* The campaign a reply answers. It is a quiet second label, not a badge that
     competes with the sender: the row already carries the subject and preview. */
  .campaign-tag {
    flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; padding: 0 6px; border-radius: var(--r-full);
    border: 1px solid var(--accent-edge);
    background: var(--accent-soft); color: var(--accent-strong);
    font-size: 11px; line-height: 16px;
  }
  /* Which mailbox a row of the merged inbox (全部收件箱) belongs to: neutral,
     so it never competes with the campaign or customer chips. */
  .mailbox-chip {
    flex: none; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; padding: 0 6px; border-radius: var(--r-full);
    border: 1px solid var(--line);
    background: var(--surface-3); color: var(--ink-2);
    font-size: 11px; line-height: 16px;
  }
  a.campaign-tag { text-decoration: none; }
  a.campaign-tag:hover, a.campaign-tag:focus-visible { text-decoration: underline; }
  .campaign-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
  /* Who the other party is in the CRM: green for a customer, amber for a lead.
     Beside the sender, like the campaign tag, and equally quiet. In the list it
     is a span inside the row button; in the reader it is a real button. */
  .crm-chip {
    flex: none; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; padding: 0 6px; border-radius: var(--r-full);
    border: 1px solid var(--ok-edge); font: inherit; font-size: 11px; line-height: 16px; cursor: pointer;
    background: var(--ok-soft); color: var(--ok);
  }
  .crm-chip[data-kind="lead"] { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-edge); }
  button.crm-chip:hover, button.crm-chip:focus-visible { text-decoration: underline; }
  .crm-file { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .crm-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
  /* Reading a conversation: newest open, every earlier message one clickable
     line, so the whole exchange is visible without a wall of quoted text. */
  .thread {
    display: flex; flex-direction: column; gap: 10px; padding: 12px 20px 18px;
    overflow-y: auto; min-height: 0;
  }
  .thread-msg {
    display: flex; gap: 9px; width: 100%; text-align: left; padding: 9px 10px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--ink); cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .thread-msg:not(.open):hover { background: var(--surface); border-color: var(--line-strong); }
  .thread-msg .avatar { width: 24px; height: 24px; font-size: 11px; }
  .thread-msg-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
  .thread-msg-main .row { gap: 8px; align-items: baseline; }
  .thread-msg[data-unread] strong { color: var(--ink); font-weight: 600; }
  .thread-msg.open {
    display: block; padding: 0; border: 0; border-radius: 0;
    background: none; cursor: auto;
  }
  .thread-msg-head { display: flex; gap: 9px; width: 100%; padding: 2px 0 9px; }
  .thread-body { border-top: 1px solid var(--line); padding-top: 10px; }
  .inbox-pager { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
  .inbox-pager .grow { flex: 1; }
  .inbox-read { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
  .inbox-read-head {
    padding: 16px 20px 13px; border-bottom: 1px solid var(--line);
    /* The reader scrolls as one column once a reply box is docked below the
       conversation; the subject, back button and actions must stay reachable
       rather than scrolling away above it. */
    position: sticky; top: 0; z-index: 3; background: var(--surface);
  }
  /* A single message's sender, recipients and attachments: below the pinned
     head, scrolling with the body. */
  .inbox-read-lead { padding: 12px 20px 0; }
  /* Editorial subject & reading typography (v6.2): email reading and writing
     step up one rung above workspace chrome for long-form comfort. */
  .msg-title { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.012em; overflow-wrap: anywhere; }
  .msg-title:lang(en) { letter-spacing: -0.02em; }
  .mail-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .image-bar {
    display: flex; align-items: center; gap: 10px; padding: 7px 20px;
    background: var(--warn-soft); color: var(--warn); font-size: 12px;
  }
  .image-bar .grow { flex: 1; }
  /* The frame is as tall as its document (bodyView measures it), and the
     reader or the thread around it scrolls. It must not flex: with a 0% basis
     in a column of auto height it would ignore that height and fall back to an
     iframe's default 150px, cutting the mail off. */
  .mail-frame { width: 100%; flex: none; border: 0; background: #fff; }
  .mail-text {
    margin: 0; padding: 18px 20px; white-space: pre-wrap; overflow-wrap: anywhere;
    font-family: var(--sans); font-size: 14px; line-height: 1.7;
  }
  .compose { padding: 12px 20px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
  .compose .grow { flex: 1; }
  /* Autosave state: quiet while it is fine, loud when the draft could not be
     written (which is the one state the writer has to notice). */
  .compose-status { color: var(--ink-3); white-space: nowrap; }
  /* Recipient autocomplete: a listbox anchored under its field. */
  .suggest-host { position: relative; }
  .suggest {
    position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: -2px;
    max-height: 260px; overflow-y: auto; padding: 4px;
    background: var(--overlay); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  }
  .suggest[hidden] { display: none; }
  .suggest-item {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; min-height: 28px;
  }
  .suggest-item[aria-selected="true"], .suggest-item:hover { background: var(--accent-soft); }
  .suggest-main { display: flex; gap: 8px; min-width: 0; flex-wrap: wrap; overflow-wrap: anywhere; }
  .suggest-source { flex: none; white-space: nowrap; }
  .compose-status[data-state="failed"] { color: var(--bad); font-weight: 600; }
  .inbox-back { display: none; justify-self: start; }
  .inbox-read > .empty { margin: auto; }

  @media (max-width: 960px) {
    .inbox { grid-template-columns: 1fr; }
    .inbox-folders { border-right: 0; border-bottom: 1px solid var(--line); }
    .inbox[data-pane="list"] .inbox-read { display: none; }
    .inbox[data-pane="read"] .inbox-list, .inbox[data-pane="read"] .inbox-folders { display: none; }
    .inbox-list { border-right: 0; }
    .inbox-back { display: inline-flex; }
    /* One column: the search box owns the full row, so the leading icon (the
       only decoration that costs width) steps aside. */
    .inbox-search { padding: 10px 12px; }
    .inbox-search-bar > svg { display: none; }
    .inbox-search-input { min-height: 34px; font-size: 13px; }
    .inbox-search-flags { gap: 6px; }
  }

  /* --------------------------------------------- composer & attachments -- */
  .attach-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .attach-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink-2);
    font-size: 12px; text-decoration: none;
  }
  a.attach-chip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-3); }
  .attach-chip .truncate { max-width: 22ch; }
  .attach-remove {
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 0 0 0 2px;
  }
  .attach-remove:hover { color: var(--bad); }

  /* ------------------------------------------------------- rich editor -- */
  .editor {
    border: 1px solid var(--line-input); border-radius: var(--r-md);
    background: var(--surface); overflow: hidden;
  }
  .editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
  .editor-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 1px;
    padding: 5px 6px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  }
  .editor-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
  .editor-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border: 1px solid transparent;
    border-radius: var(--r-xs); background: transparent; color: var(--ink-3); cursor: pointer;
  }
  .editor-btn:hover { background: var(--surface-3); color: var(--ink); }
  .editor-btn.is-on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
  /* .select in the markup themes the arrow (guidelines 8.10); the control keeps
     its compact toolbar size instead of the 100%-wide field form. */
  .editor-select {
    width: auto; height: 26px; min-height: 26px; border: 1px solid var(--line); border-radius: var(--r-xs);
    background-color: var(--surface); color: var(--ink-2); font-size: 12px;
    padding: 0 20px 0 6px; box-shadow: none;
    background-position: calc(100% - 11px) 50%, calc(100% - 7px) 50%;
  }
  .editor-menu { position: relative; }
  .editor-menu > summary { list-style: none; }
  .editor-menu > summary::-webkit-details-marker { display: none; }
  .editor-menu-body {
    position: absolute; z-index: 20; top: 30px; left: 0; display: flex; gap: 4px;
    padding: 6px; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--overlay); box-shadow: var(--shadow-2);
  }
  .editor-swatch {
    width: 18px; height: 18px; border: 1px solid var(--line-strong);
    border-radius: var(--r-xs); cursor: pointer; padding: 0;
  }
  .editor-body {
    min-height: 240px; max-height: 60vh; overflow-y: auto; padding: 14px 16px;
    font-size: 14px; line-height: 1.7; color: var(--ink); outline: none;
    word-wrap: break-word;
  }
  .editor-body:empty::before,
  .editor-body[data-placeholder]:not(:focus):not(:has(*))::before {
    content: attr(data-placeholder); color: var(--ink-3);
  }
  .editor-body img { max-width: 100%; height: auto; }
  .editor-body blockquote {
    margin: 8px 0; padding-left: 12px; border-left: 2px solid var(--line-strong); color: var(--ink-2);
  }
  .editor-body a { color: var(--accent); }
  .editor-body h1 { font-size: 1.4em; }
  .editor-body h2 { font-size: 1.2em; }
  .editor-body h3 { font-size: 1.05em; }
  .editor-source {
    min-height: 240px; border: 0; border-radius: 0;
    font-family: var(--mono); font-size: 12px; padding: 14px 16px;
  }
  .editor-chips {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 7px 10px; border-top: 1px solid var(--line); background: var(--surface-2);
  }
  .editor-chips[hidden] { display: none; }
  .editor-cid { color: var(--ink-3); font-size: 12px; }
  .chip-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 7px; border-radius: var(--r-full);
    border: 1px solid var(--line); background: var(--surface);
    color: var(--ink-2); font-family: var(--mono); font-size: 11px; cursor: pointer;
  }
  .chip-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* ------------------------------------------------------------ dns rows -- */
  .dns-row {
    display: grid; grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 8px; align-items: center;
    padding: 7px 8px 7px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface-2); font-size: 12px;
  }
  .dns-row .kind {
    font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--ink-3);
  }
  .dns-row .val {
    font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--ink-2);
    user-select: all;
  }
  .dns-row .host { color: var(--ink); font-weight: 500; }
  .dns-row .copy-btn { margin-left: auto; }
  @media (max-width: 640px) {
    .dns-row { grid-template-columns: 1fr auto; }
    .dns-row .kind { grid-column: 1 / -1; }
  }

  /* ------------------------------------------------------- alert banner -- */
  .alert {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 13px 16px; border-radius: var(--r-md);
    border: 1px solid var(--line); background: var(--surface-2);
    font-size: 13px;
  }
  .alert .icon { flex: none; display: grid; place-items: center; margin-top: 1px; }
  .alert .grow { flex: 1; min-width: 0; display: grid; gap: 4px; }
  .alert h3 { font-size: 13px; }
  .alert p { color: var(--ink-2); }
  .alert-danger {
    background: var(--bad-soft);
    border-color: color-mix(in oklab, var(--bad) 22%, transparent);
    color: var(--bad);
  }
  .alert-danger p { color: color-mix(in oklab, var(--bad) 78%, var(--ink)); }
  .alert-warn {
    background: var(--warn-soft);
    border-color: color-mix(in oklab, var(--warn) 22%, transparent);
    color: var(--warn);
  }
  .alert-warn p { color: color-mix(in oklab, var(--warn) 78%, var(--ink)); }
  .alert-info { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 18%, transparent); }
  .alert-info .icon { color: var(--accent); }
  .alert .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
}

/* ============================================================== utilities == */
@layer utilities {
  .muted { color: var(--ink-2); }
  .dim { color: var(--ink-3); }
  .small { font-size: 12px; line-height: 1.5; }
  .mono { font-family: var(--mono); font-variant-ligatures: none; }
  .tnum { font-variant-numeric: tabular-nums; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grow { flex: 1; min-width: 0; }
  .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .row-tight { gap: 4px; }
  .stack { display: grid; gap: 14px; }
  .stack-sm { display: grid; gap: 6px; }
  .spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  /* Where a .row puts its items: pushed to the end, centred, or apart. */
  .row-end { justify-content: flex-end; }
  .row-center { justify-content: center; }
  .row-between { justify-content: space-between; }
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  /* Emphasis and state for a run of text, so a view does not reach for an
     inline style: the label weight, and the three semantic text colours. */
  .strong { font-weight: 550; }
  .text-ok { color: var(--ok); }
  .text-warn { color: var(--warn); }
  .text-bad { color: var(--bad); }
}

/* ========================================================= shell details == */
@layer layout {
  .side-user .brand-meta { font-size: 11px; color: var(--ink-3); }
}
@layer components {
  .topbar-actions { display: flex; align-items: center; gap: 6px; }
  .drawer-foot:empty { display: none; }
}

/* The menu button is a .btn, so its display must be re-asserted *after* the
   component layer's .btn rules rather than in the layout layer. */
@layer components {
  .topbar .menu-btn, .side-brand .side-close { display: none; }
  @media (max-width: 960px) {
    .topbar .menu-btn { display: inline-flex; }
    .side-brand .side-close {
      display: inline-flex; margin-left: auto;
      width: 36px; min-height: 36px; padding: 0;
      border-radius: var(--r-md); color: var(--ink-3);
    }
  }
}

/* ==================================================== phase 2: data views == */
@layer components {
  /* Sticky toolbar that sits directly under a static page header. Keeping the
     header itself static lets the filter row own `top: 0` without magic offsets. */
  .topbar.is-static { position: static; }
  .subbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px var(--page-pad);
    background: color-mix(in oklab, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.2) blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .subbar .grow { flex: 1 1 220px; min-width: 0; }
  .subbar .search-input { min-width: 220px; }
  @media (max-width: 960px) { .subbar { padding: 10px 16px; } }

  /* ---------------------------------------------------- grouped DNS rows -- */
  /* Records stack label-over-value when the group itself is narrow (a phone,
     or a narrow column), so the group is the query container. */
  .dns-group { display: grid; gap: 8px; container-type: inline-size; }
  .dns-item {
    display: grid; gap: 7px;
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2);
    transition: border-color var(--dur) var(--ease);
  }
  .dns-item:hover { border-color: var(--line-strong); }
  .dns-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  /* The record type is a small mono tag: flat, hairline, no shadow. */
  .dns-type {
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: 0.04em; color: var(--ink-2);
    padding: 1px 6px; border-radius: var(--r-xs);
    background: var(--surface); border: 1px solid var(--line-strong);
  }
  .dns-purpose { font-size: 12px; color: var(--ink-2); }
  .dns-line {
    display: grid; grid-template-columns: 62px minmax(0, 1fr) auto;
    align-items: center; gap: 8px;
  }
  .dns-label { font-size: 11px; color: var(--ink-3); }
  .dns-value {
    display: flex; align-items: center; gap: 6px; min-width: 0;
    padding: 4px 4px 4px 9px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface);
    font-family: var(--mono); font-size: 12px; color: var(--ink);
    overflow-wrap: anywhere;
  }
  /* One click selects the whole value; the copy button stays beside it. */
  .dns-value .text { flex: 1; min-width: 0; user-select: all; }
  .dns-note {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 11px; color: var(--warn); line-height: 1.5;
  }
  .dns-note .dot { width: 5px; height: 5px; margin-top: 6px; border-radius: 50%;
                   background: currentColor; flex: none; }
  .dns-note.is-muted { color: var(--ink-3); }
  @container (max-width: 600px) {
    .dns-line { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 6px; }
    .dns-line .dns-label { grid-column: 1 / -1; margin-top: 2px; }
  }

  /* ---------------------------------------------------------- CSV import -- */
  .dropzone {
    display: grid; gap: 4px; justify-items: center; text-align: center;
    padding: 22px 16px; cursor: pointer;
    border: 1px dashed var(--line-strong); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--ink-2);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .dropzone:hover, .dropzone[data-drag="true"] {
    border-color: var(--accent); background: var(--accent-soft); color: var(--ink);
  }
  .dropzone .icon {
    width: 34px; height: 34px; display: grid; place-items: center;
    border-radius: var(--r-md); border: 1px solid var(--line);
    background: var(--surface); color: var(--ink-3); margin-bottom: 4px;
  }
  .dropzone strong { font-size: 13px; font-weight: 550; }
  .dropzone span { font-size: 11px; color: var(--ink-3); }
  .dropzone input[type="file"] { display: none; }

  .import-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .import-stat {
    padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface-2); display: grid; gap: 5px;
  }
  .import-stat .label { font-size: 11px; color: var(--ink-3); }
  .import-stat b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
  .import-stat .bar { height: 3px; background: var(--surface-4); }
  .import-stat .bar > i { background: var(--ink-3); }
  .import-stat.is-ok b { color: var(--ok); } .import-stat.is-ok .bar > i { background: var(--ok); }
  .import-stat.is-info b { color: var(--info); } .import-stat.is-info .bar > i { background: var(--info); }
  .import-stat.is-warn b { color: var(--warn); } .import-stat.is-warn .bar > i { background: var(--warn); }
  .import-stat.is-bad b { color: var(--bad); } .import-stat.is-bad .bar > i { background: var(--bad); }
  @media (max-width: 480px) { .import-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

  /* ------------------------------------------------- mail client settings -- */
  .conn-card {
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2); overflow: hidden;
  }
  .conn-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 12px; background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: 12px; font-weight: 600; color: var(--ink);
  }
  .conn-head span { display: inline-flex; align-items: center; gap: 6px; }
  .conn-head svg { color: var(--ink-3); }
  .conn-row {
    display: grid; grid-template-columns: 92px minmax(0, 1fr) auto;
    align-items: center; gap: 8px; padding: 6px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
  }
  .conn-row:last-child { border-bottom: 0; }
  .conn-row .label { color: var(--ink-3); font-size: 11px; }
  .conn-row .value { font-family: var(--mono); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
  .conn-row .value b { color: var(--ink); font-weight: 600; }

  /* -------------------------------------------------------- code block -- */
  .snippet {
    position: relative; padding: 9px 34px 9px 11px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface-2);
    font-family: var(--mono); font-size: 12px; color: var(--ink-2);
    overflow-x: auto; white-space: pre;
  }
  .snippet .copy-btn { position: absolute; right: 4px; top: 4px; }
}

/* Grid and flex children must be allowed to shrink below their min-content
   width, otherwise a wide table can widen the whole page on a phone instead of
   scrolling inside its own .table-wrap. */
@layer layout {
  .content > *, .stack > *, .grid > *, .view > * { min-width: 0; }
  .card, .table-wrap, .subbar { min-width: 0; max-width: 100%; }
  .table-wrap { overflow-x: auto; }
}

/* On a phone, a card header's actions and badges drop below its title instead
   of squeezing the description into a narrow column. */
@layer components {
  @media (max-width: 640px) {
    .card-head .grow { flex-basis: 100%; }
    .card-head { gap: 8px; }
  }
}

/* ================================================= phase 3: detail views == */
@layer components {
  /* North-star metrics, divided by hairlines rather than boxed into cards.
     Five tiles on the campaign detail: recipients, sent, delivered, open rate,
     bounce rate. */
  .metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  /* Five tiles need about 720px; below that the strip's card (the query
     container) folds them into two columns, wherever the card sits. */
  .metric-card { container-type: inline-size; }
  .metric-strip .stat { padding: 16px 18px; border-left: 1px solid var(--line); }
  .metric-strip .stat:first-child { border-left: 0; }
  .metric-strip .stat .value { font-size: 28px; letter-spacing: -0.03em; }
  .metric-strip .stat .value.is-bad { color: var(--bad); }
  @container (max-width: 720px) {
    .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-strip .stat:nth-child(odd) { border-left: 0; }
    .metric-strip .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  }

  /* Circuit-breaker diagnosis: louder than a generic alert, still calm. */
  .breaker {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 15px 17px;
    border: 1px solid color-mix(in oklab, var(--bad) 26%, transparent);
    border-radius: var(--r-lg);
    background: color-mix(in oklab, var(--bad-soft) 78%, var(--surface));
  }
  .breaker > .icon { color: var(--bad); flex: none; margin-top: 1px; }
  .breaker > .grow { min-width: 0; display: grid; gap: 8px; }
  .breaker h3 { font-size: 14px; color: var(--bad); }
  .breaker p { font-size: 12px; color: color-mix(in oklab, var(--bad) 72%, var(--ink)); }
  .breaker-compare { display: flex; gap: 8px; flex-wrap: wrap; }
  .breaker-metric {
    display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
    padding: 7px 11px; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid color-mix(in oklab, var(--bad) 16%, var(--line));
  }
  .breaker-metric .label { font-size: 11px; color: var(--ink-3); }
  .breaker-metric b { font-size: 18px; font-weight: 600; color: var(--bad);
                      font-variant-numeric: tabular-nums; }
  .breaker-metric .over { font-size: 11px; color: color-mix(in oklab, var(--bad) 65%, var(--ink-3)); }

  /* Template workbench: composer left, simulated inbox right. It lives in a
     drawer as wide as the viewport allows, so the 960px breakpoint is also the
     component's own width. */
  .editor-split {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr);
    gap: 20px; align-items: start;
  }
  .editor-split > *, .drawer-body, .drawer-body > * { min-width: 0; }
  .editor-split .editor-body { min-height: 300px; max-height: 52vh; }
  .preview-pane { position: sticky; top: 0; }
  .preview-shell {
    display: flex; flex-direction: column; overflow: hidden;
    height: min(70vh, 620px);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-1);
  }
  .preview-head {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 13px; border-bottom: 1px solid var(--line);
    background: var(--surface-2); font-size: 12px; color: var(--ink-2);
  }
  .preview-head svg { color: var(--ink-3); }
  .preview-head .grow { flex: 1; }
  .preview-meta { display: flex; align-items: center; gap: 9px; padding: 11px 15px 0; }
  .preview-meta .avatar { width: 26px; height: 26px; font-size: 11px; }
  .preview-from { font-size: 12px; font-weight: 600; }
  .preview-subject {
    padding: 8px 15px 12px; font-size: 16px; font-weight: 600;
    letter-spacing: -0.01em; border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  .preview-frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; }
  .text-fallback { border-top: 1px solid var(--line); padding-top: 4px; }
  .text-fallback summary { cursor: pointer; font-size: 12px; color: var(--ink-2); padding: 6px 0; }
  .text-fallback textarea { margin-top: 6px; }
  @media (max-width: 960px) {
    .editor-split { grid-template-columns: 1fr; }
    .preview-pane { position: static; }
    .preview-shell { height: 380px; }
  }

  /* Inbox: a desktop client fills the workspace; only the frame scrolls. */
  @media (min-width: 961px) {
    .inbox {
      /* The page header (compact on the inbox, below), the content padding,
         the inset shell's 16px gutter and 2px hairlines: 148px in all. */
      height: calc(100vh - 148px); height: calc(100dvh - 148px);
      min-height: 520px;
    }
    .inbox-list { min-height: 0; overflow: hidden; }
    .inbox-read { min-height: 0; }
    .inbox-rows { max-height: none; }
    /* A single message scrolls as one column under the pinned head (a
       conversation scrolls inside its .thread and never overflows). Squeezing
       the frame into what the head left over gave a long recipient list or
       attachment row a reader 50px tall, and a plain-text body ran past the
       bottom of the pane with no way to reach it. */
    .inbox-read { overflow-y: auto; }
    .inbox-read:has(> .mail-body, > .mail-text) > * { flex-shrink: 0; }
    .inbox-folders { overflow-y: auto; }
  }
  .inbox-read:has(.compose) { overflow-y: auto; }
  /* An inline reply joins the reader's normal flow: the whole conversation
     keeps its height and the pane scrolls, instead of squeezing the thread
     into the strip above a tall editor. */
  .inbox-read:has(.compose.is-inline) { overflow-y: auto; }
  .inbox-read:has(.compose.is-inline) .thread { flex: none; overflow: visible; }
}

/* ================================================ phase 4: direction A ==== */
@layer components {
  /* Overview: the greeting owns a date line. */
  .today-label { font-size: 13px; color: var(--ink-3); margin-bottom: 2px; }

  .legend i.is-click { background: color-mix(in oklab, var(--accent) 38%, var(--surface)); }

  .overview-event-list { display: grid; position: relative; }
  .event-row {
    position: relative; display: flex; align-items: center; gap: 10px;
    padding: 10px 6px 10px 4px; border-top: 1px solid var(--line); border-radius: var(--r-xs);
    font-size: 13px; transition: background var(--dur) var(--ease);
  }
  .event-row:first-child { border-top: 0; }
  .event-row:hover { background: color-mix(in oklab, var(--surface-2) 68%, transparent); }
  .event-dot { position: relative; z-index: 1; width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px var(--surface); }
  /* The timeline: a hairline joins each event's dot to the next one. */
  .event-row:not(:last-child)::before {
    content: ""; position: absolute; left: 7.5px; top: 22px; bottom: -10px;
    width: 1px; background: var(--line);
  }
  .event-who { flex: 1; min-width: 0; color: var(--ink-2); }
  .event-type { color: var(--ink-2); white-space: nowrap; }
  .event-when { font-size: 12px; white-space: nowrap; min-width: 48px; text-align: right; }
}

@layer components {
  /* Campaigns: a filter bar over a list/detail split. The panel is the same
     information the full detail page owns, reduced to the decision at hand. */
  .campaign-toolbar {
    display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
  }
  .campaign-search { margin-left: auto; min-width: 240px; flex: 0 1 300px; }
  @media (max-width: 640px) {
    .campaign-search { margin-left: 0; flex-basis: 100%; min-width: 0; }
  }

  .campaigns-split {
    display: grid; gap: 14px; align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  }
  @media (max-width: 1080px) {
    .campaigns-split { grid-template-columns: 1fr; }
    .campaign-panel { position: static; }
  }

  .campaign-list { overflow: hidden; }
  .campaign-list table.data { min-width: 620px; }
  .campaign-list td.campaign-progress { width: 150px; }
  .campaign-link {
    display: inline-block; max-width: 100%;
    padding: 0; border: 0; background: none; cursor: pointer;
    color: var(--ink); font: inherit; font-weight: 600; text-align: left;
    overflow-wrap: anywhere;
  }
  .campaign-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
  .campaign-list tr.is-selected { background: var(--surface-2); }
  .campaign-list tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
  /* mobile-header: the phone card layout paints every selected row with the
     accent tint it reserves for checkbox selection. A campaign row is selected
     to open the panel below, which desktop draws with --surface-2, so the card
     keeps that quieter fill and only the accent bar marks it. */
  @media (max-width: 640px) {
    .campaign-list table.data:not([data-mobile="scroll"]) tbody tr.is-selected {
      background: var(--surface-2);
    }
    /* mobile-campaigns: the phone card's name is a link to the full-screen
       detail; `table.data a` would make it a 500-weight link, this keeps the
       card heading at the weight the button it replaced had. */
    .campaign-list .campaign-link { font-weight: 600; }
  }

  .campaigns-split:has(> .campaign-panel[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .campaign-panel[hidden] { display: none; }
  .campaign-panel {
    position: sticky; top: 16px;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); box-shadow: var(--shadow-1);
  }
  .campaign-panel-inner { display: grid; gap: 16px; padding: 18px; }
  .campaign-panel .empty { padding: 40px 18px; }
  .panel-title { font-size: 18px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
  .panel-subhead { font-size: 13px; font-weight: 600; color: var(--ink-2); }
  .panel-dl {
    display: grid; grid-template-columns: 64px minmax(0, 1fr);
    gap: 7px 12px; margin: 0; font-size: 13px;
  }
  .panel-dl dt { color: var(--ink-3); }
  .panel-dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

  .panel-funnel { display: grid; gap: 9px; }
  .panel-funnel-row {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) 62px;
    align-items: center; gap: 10px; font-size: 13px;
  }
  .panel-funnel-label { color: var(--ink-2); }
  .panel-funnel-bar {
    height: 18px; border-radius: var(--r-xs); background: var(--surface-3); overflow: hidden;
  }
  .panel-funnel-bar i { display: block; height: 100%; border-radius: inherit; }
  .panel-funnel-value { text-align: right; font-weight: 600; color: var(--ink); }
  .campaign-panel .breaker { padding: 12px 14px; }
  /* mobile-campaigns: the detail is a full screen on a phone. Its way back is
     the breadcrumb, which mobile-headers (the ≤ 640px header block) turns into
     the title row's back link -- one entry, not the two there used to be. A
     wide screen keeps the detail beside the list and the "返回列表" button it
     always had. */
  @media (max-width: 640px) {
    .campaign-back-list { display: none; }
  }
}

@layer components {
  /* Inbox, direction A: the folder column reads as a mailbox card + a list of
     folders; the reader docks the reply box under the conversation. */
  .inbox-mailbox {
    display: grid; gap: 3px; width: 100%; padding: 9px 11px; text-align: left;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface); box-shadow: var(--shadow-1);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .inbox-mailbox:hover { border-color: var(--line-strong); }
  .inbox-mailbox:focus-within,
  .scope-trigger:focus-visible,
  .scope-trigger[aria-expanded="true"] {
    outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
  }
  .scope-trigger { cursor: pointer; }
  .scope-trigger-top {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
  }
  .scope-trigger-caret { display: inline-flex; color: var(--ink-3); transition: transform var(--dur) var(--ease); }
  .scope-trigger[aria-expanded="true"] .scope-trigger-caret { transform: rotate(180deg); color: var(--accent); }
  .scope-trigger-row {
    display: flex; align-items: center; gap: 6px; min-width: 0;
  }
  .scope-trigger-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
  .scope-trigger-sub { font-size: 12px; color: var(--ink-3); }
  .inbox-mailbox-label { font-size: 12px; color: var(--ink-3); line-height: 1.2; }
  .inbox-folders-back { margin-bottom: 2px; }
  .inbox-folders-btn { display: none; }
  .inbox-filter-sep { width: 1px; height: 16px; background: var(--line); margin: 0 2px; }

  /* Mobile / tablet list-header scope button: tap the title directly to switch
     between All Inboxes, any domain, or any mailbox with unread indicators. */
  .inbox-scope-btn {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0;
    padding: 4px 8px; margin-left: -8px; border: 0; border-radius: var(--r-md);
    background: transparent; color: var(--ink);
    font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
    transition: background var(--dur) var(--ease);
  }
  .inbox-scope-btn:hover { background: var(--surface-2); }
  .inbox-scope-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .inbox-scope-caret { display: inline-flex; flex: none; color: var(--ink-3); transition: transform var(--dur) var(--ease); }
  .inbox-scope-btn[aria-expanded="true"] .inbox-scope-caret { transform: rotate(180deg); color: var(--accent); }
  .inbox-scope-dot {
    flex: none; width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
  }
  @media (min-width: 961px) {
    .inbox-scope-dot { display: none; }
  }

  /* Flagship Scope Switcher (desktop popover + mobile bottom sheet). */
  .scope-pop {
    position: fixed; inset: auto; margin: 0; padding: 0;
    display: flex; flex-direction: column;
    width: min(336px, calc(100vw - 24px));
    max-height: min(500px, calc(100vh - 32px));
    background: var(--overlay); color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--r-xl);
    box-shadow: var(--shadow-3); overflow: hidden;
  }
  .scope-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .scope-head {
    flex: none; display: grid; gap: 8px; padding: 10px 10px 8px;
    border-bottom: 1px solid var(--line); background: var(--surface);
  }
  .scope-search {
    display: flex; align-items: center; gap: 8px; padding: 0 10px; min-height: 34px;
    border: 1px solid var(--line-input); border-radius: var(--r-md);
    background: var(--surface); color: var(--ink-3);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .scope-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); color: var(--accent); }
  .scope-search-input {
    flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
    font-size: 13px; padding: 4px 0; outline: 0;
  }
  .scope-filters {
    display: inline-flex; gap: 4px; padding: 2px; border-radius: var(--r-md);
    background: var(--surface-2); border: 1px solid var(--line); width: 100%;
  }
  .scope-filter {
    flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 28px; padding: 0 8px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .scope-filter:hover { color: var(--ink); }
  .scope-filter.is-active {
    background: var(--surface); color: var(--ink); font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  }
  .scope-list {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 6px; display: grid; gap: 2px; align-content: start;
  }
  .scope-sec {
    padding: 8px 8px 3px; font-size: 12px; font-weight: 550;
    color: var(--ink-3); letter-spacing: 0.02em;
  }
  .scope-group { display: grid; gap: 1px; margin-bottom: 4px; }
  .scope-children {
    display: grid; gap: 1px; margin-left: 16px; padding-left: 8px;
    border-left: 1px solid var(--line);
  }
  .scope-item {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px;
    padding: 6px 8px; border: 0; border-radius: var(--r-md);
    background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 450;
    text-align: left; cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .scope-item:hover { background: var(--surface-2); color: var(--ink); }
  .scope-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .scope-item.is-selected {
    background: var(--accent-soft); color: var(--accent-strong); font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--accent-edge);
  }
  .scope-item.has-unread .scope-item-label { color: var(--ink); font-weight: 600; }
  .scope-item.is-selected .scope-item-label { color: var(--accent-strong); }
  .scope-item.is-all { min-height: 46px; padding: 7px 8px; margin-bottom: 2px; }
  .scope-all-ico {
    flex: none; width: 30px; height: 30px; border-radius: var(--r-md);
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-edge);
  }
  .scope-item-ico { flex: none; display: inline-flex; color: var(--ink-3); }
  .scope-item.has-unread .scope-item-ico,
  .scope-item.is-selected .scope-item-ico { color: var(--accent); }
  .scope-item-stack { display: grid; gap: 1px; min-width: 0; }
  .scope-item-label { flex: 1; min-width: 0; }
  .scope-item-sub { font-size: 12px; color: var(--ink-3); font-weight: 400; }
  .scope-item-meta {
    flex: none; font-size: 12px; color: var(--ink-3); font-weight: 450;
    padding: 0 5px; border-radius: var(--r-full); background: var(--surface-2);
  }
  .scope-item.is-selected .scope-item-meta {
    background: color-mix(in oklab, var(--accent) 12%, var(--surface)); color: var(--accent-strong);
  }
  .scope-dot {
    flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  }
  .scope-badge {
    flex: none; min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--r-full);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent-strong);
    box-shadow: inset 0 0 0 1px var(--accent-edge);
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  }
  .scope-badge.is-solid {
    background: var(--primary); color: var(--primary-ink); box-shadow: none;
  }
  .scope-check { flex: none; display: inline-flex; color: var(--accent); }
  .scope-empty {
    padding: 24px 12px; text-align: center; font-size: 13px; color: var(--ink-3);
  }
  .ui-sheet .scope-head { padding: 4px 0 10px; background: transparent; }
  .ui-sheet .scope-list { padding: 6px 0 4px; }
  @media (max-width: 640px) {
    .inbox-scope-btn { min-height: 40px; font-size: 16px; }
    .scope-search { min-height: 42px; border-radius: var(--r-lg); }
    .scope-search-input { font-size: 16px; }
    .scope-filters { border-radius: var(--r-lg); padding: 3px; }
    .scope-filter { min-height: 36px; border-radius: var(--r-md); font-size: 13px; }
    .scope-item { min-height: 44px; padding: 8px 10px; border-radius: var(--r-lg); font-size: 14px; }
    .scope-item.is-all { min-height: 54px; }
    .scope-badge { font-size: 12px; height: 20px; min-width: 22px; }
  }

  /* The reply box: part of the reader, not a separate screen. */
  .thread-reply {
    flex: none; padding: 14px 20px 18px;
    border-top: 1px solid var(--line); background: var(--surface-2);
  }
  .inbox-read .thread { flex: 1; }
  /* A single message renders its body first and then a notes-only timeline.
     That timeline must not split the pane with the body (it is empty most of
     the time): it takes its content height, capped so notes never crush the
     mail frame, and vanishes when there are no notes. */
  .inbox-read .mail-body ~ .thread,
  .inbox-read .mail-text ~ .thread { flex: 0 1 auto; max-height: 40%; }
  .inbox-read .mail-body ~ .thread:empty,
  .inbox-read .mail-text ~ .thread:empty { display: none; }
  .compose.is-inline {
    padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-lg);
    background: var(--surface); overflow: hidden;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .compose.is-inline:focus-within {
    border-color: color-mix(in oklab, var(--accent) 55%, var(--line));
    box-shadow: 0 0 0 3px var(--accent-ring);
  }
  .compose.is-inline > .row { padding: 10px 14px 0; }
  .compose.is-inline > .small { padding: 2px 14px 0; }
  .compose.is-inline > .field { padding: 4px 14px 0; }
  .compose.is-inline .editor { border: 0; border-radius: 0; }
  .compose.is-inline .editor:focus-within { box-shadow: none; }
  .compose.is-inline .editor-body { min-height: 88px; max-height: 18vh; }
  .compose.is-inline > .hint { padding: 0 14px; }
  .compose.is-inline > .row:last-child {
    padding: 10px 14px; border-top: 1px solid var(--line);
    background: var(--surface-2); justify-content: flex-end;
  }

  @media (max-width: 960px) {
    .inbox[data-pane="list"] .inbox-folders { display: none; }
    .inbox[data-pane="folders"] .inbox-list,
    .inbox[data-pane="folders"] .inbox-read { display: none; }
    .inbox[data-pane="folders"] .inbox-folders { display: grid; }
    .inbox-folders-btn { display: inline-flex; }
    .inbox-folders-back { display: inline-flex; }
    .inbox-mailbox { margin-bottom: 4px; }
    .thread-reply { padding: 12px; }
  }
}

@layer components {
  /* Audience: lists are the filter, so they sit above the table as cards. */
  .audience-lists {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
  @media (max-width: 480px) {
    .audience-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  .list-card-wrap { position: relative; min-width: 0; }
  .list-card {
    display: grid; gap: 3px; width: 100%; min-height: 96px;
    padding: 13px 15px; text-align: left; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); color: var(--ink);
    /* A clickable block, not a content card: it rests on --shadow-1 (§5.2). */
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .list-card:hover { border-color: var(--line-strong); }
  /* The selected list: a 1.5px accent edge (1px border + 0.5px ring, so the
     card does not grow) and a soft lift on the surface, no tinted fill. */
  .list-card.is-active {
    border-color: var(--accent); background: var(--surface);
    box-shadow: 0 0 0 0.5px var(--accent), var(--shadow-2);
  }
  .list-card-name { font-size: 13px; font-weight: 600; }
  .list-card-count { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
  .list-card-sub { font-size: 12px; color: var(--ink-3); }
  .list-card.is-new {
    border-style: dashed; border-color: var(--line-strong);
    background: transparent; color: var(--ink-2); align-content: center;
  }
  .list-card.is-new:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
  /* Edit and delete sit together in the top-right corner. The card keeps the
     name clear of them: one button reserves 40px, two reserve 72px. */
  .list-card-actions {
    position: absolute; top: 6px; right: 6px;
    display: flex; gap: 2px;
  }
  .list-card-act {
    display: grid; place-items: center; width: 30px; height: 30px;
    border-radius: var(--r-sm); background: transparent; color: var(--ink-3);
    cursor: pointer;
  }
  .list-card-act:hover { background: var(--surface-3); color: var(--ink); }
  .list-card-act.is-danger:hover { background: var(--bad-soft); color: var(--bad); }
  .list-card-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .list-card-wrap.has-actions .list-card-name { padding-right: 34px; }
  .list-card-wrap.has-two .list-card-name { padding-right: 66px; }
  .list-card-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
  /* A list's sending domains are a quiet stone tag, not a blue badge. */
  .list-card-chips .badge-plain.b-info { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
  /* 发信前检查: a pale warm strip with a hairline edge, not a coloured block. */
  .audience-hygiene { padding: 10px 14px; }
  .audience-hygiene.alert-warn { background: color-mix(in oklab, var(--warn-soft) 45%, var(--surface)); border-color: var(--warn-edge); }
  .audience-hygiene.alert-info { background: color-mix(in oklab, var(--surface-2) 70%, var(--surface)); border-color: var(--line); }
  .audience-hygiene.alert-info .icon { color: var(--ink-3); }

  .audience-toolbar { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
  .audience-search { flex: 1 1 260px; max-width: 380px; min-width: 0; }
  .audience-engagement { width: auto; max-width: 170px; }
  @media (max-width: 480px) { .audience-search { flex-basis: 100%; max-width: none; } }

  .bulk-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2);
  }
  .bulk-target { width: auto; max-width: 200px; min-height: 30px; }

  .audience-card { overflow: hidden; }
  /* The 导入 button opens two ways in: a CSV or another platform's export.
     The popover box is the themed listbox (ui-pop.js), so only the rows and
     the two-line label need rules of their own. */
  .import-menu { min-width: 260px; }
  .ui-listbox-pop .import-menu-item {
    align-items: flex-start; width: 100%; padding: 8px 10px;
    text-align: left; white-space: normal;
  }
  .ui-listbox-pop .import-menu-item:hover { background: var(--surface-3); }
  .import-menu-item svg { flex: none; margin-top: 1px; color: var(--ink-3); }
  .import-menu-text { display: grid; gap: 2px; min-width: 0; }
  .import-menu-title { font-weight: 550; color: var(--ink); }
  .import-menu-note { font-size: 12px; line-height: 1.45; color: var(--ink-3); }
  .audience-table { min-width: 880px; }
  .audience-table th.cell-check, .audience-table td.cell-check {
    width: 40px; padding-left: 16px; padding-right: 4px;
  }
  .audience-table .cell-check input {
    width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
  }
  .audience-table tr.is-selected { background: var(--surface-2); }
  /* Group-address and catch-all rows (views/mail-groups.js): the address and
     its status line keep at least 220px, so on a phone the buttons wrap onto
     their own line instead of squeezing the text into a narrow column. */
  .addr-row-main { flex: 1 1 220px; min-width: 0; }
  /* Contacts list column widths (views/audience.js, class contacts-table).
     Desktop only: a fixed layout keeps the 联系人 column to its share, so
     name and email truncate (full value on hover) instead of an auto column
     eating the row. Fixed-width columns hold their content; numbers and dates
     stay on one line; 标签 takes what is left and wraps. Phones keep the
     card layout from the utilities block, which these rules never reach. */
  @media (min-width: 641px) {
    .contacts-table { min-width: 1040px; table-layout: fixed; }
    .contacts-table th:nth-child(2) { width: 22%; }
    .contacts-table th:nth-child(3) { width: 96px; }
    .contacts-table th:nth-child(4) { width: 110px; }
    .contacts-table th:nth-child(5) { width: 72px; }
    .contacts-table th:nth-child(6) { width: 10%; }
    .contacts-table th:nth-child(8) { width: 100px; }
    .contacts-table th:nth-child(9) { width: 92px; }
    .contacts-table th:nth-child(10) { width: 100px; }
    .contacts-table td:nth-child(3) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .contacts-table td:nth-child(8),
    .contacts-table td:nth-child(9) { white-space: nowrap; }
    .contacts-table .contact-name .link-btn {
      display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
  }
  .contact-name { font-weight: 600; }
  .audience-engagement[hidden] { display: none; }
  /* Rows-per-page picker in the contacts footer, sized to sit beside .btn-sm. */
  .audience-page-size {
    width: auto; min-height: 26px; padding: 2px 26px 2px 9px; font-size: 12px;
    background-position: calc(100% - 13px) 10px, calc(100% - 8px) 10px;
  }
  .contact-email { font-size: 12px; color: var(--ink-3); }
  /* The pre-send address check under a contact (views/audience.js). */
  .contact-check { margin-top: 3px; font-size: 12px; }
  .audience-check-counts { flex-wrap: wrap; gap: 6px 16px; }
  .audience-foot { flex-wrap: wrap; }
}

/* mobile-filters: the 筛选 button, its bottom sheet and the chips that show
   what is selected (js/ui-filter-sheet.js). The controls inside the sheet are
   the page's own <select> nodes; no second copy of the filter state. */
@layer components {
  .filter-controls { display: contents; }
  .filter-btn { display: none; gap: 6px; }
  .filter-btn.is-active { border-color: var(--accent); color: var(--accent); }
  .filter-badge {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px;
    padding: 0 5px; border-radius: var(--r-full);
    background: var(--primary); color: var(--primary-ink);
    font-size: 11px; font-weight: 600; line-height: 1;
  }
  .filter-sheet { display: flex; flex-direction: column; gap: 12px; }
  .filter-sheet-rows { display: grid; gap: 12px; }
  .filter-sheet-row { display: grid; gap: 6px; min-width: 0; }
  .filter-sheet-label { font-size: 12px; font-weight: 550; color: var(--ink-2); }
  .filter-sheet .select { width: 100%; }
  .filter-sheet-foot {
    display: flex; gap: 8px; padding-top: 12px;
    border-top: 1px solid var(--line); background: var(--overlay);
  }
  .filter-sheet-foot .btn { flex: 1 1 0; justify-content: center; }
  /* One row of removable chips above the list; it scrolls sideways rather than
     wrapping, so a stack of filters still costs one line. The host is only a
     row on a phone (see the utilities block below). */
  .audience-chips { display: none; }
  .filter-chips {
    display: flex; align-items: center; gap: 6px;
    overflow-x: auto; overscroll-behavior-x: contain;
    padding: 2px 0; scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip {
    display: inline-flex; align-items: center; gap: 4px; flex: none;
    min-height: 30px; padding: 0 4px 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--r-full);
    background: var(--surface); color: var(--ink-2);
    font-size: 12px; cursor: pointer;
  }
  .filter-chip:hover { border-color: var(--accent); color: var(--ink); }
  .filter-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .filter-chip svg { flex: none; color: var(--ink-3); }
  .filter-chip-clear {
    flex: none; min-height: 30px; padding: 0 8px; border-radius: var(--r-full);
    font-size: 12px; font-weight: 550; color: var(--ink-2); cursor: pointer;
  }
  .filter-chip-clear:hover { color: var(--accent); }
  .filter-chip-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
}

@layer utilities {
  /* mobile-filters: on a phone the contacts toolbar is one search row and one
     control row (status tabs scroll sideways, 筛选 sits at the end); the five
     selects are in the sheet. The list cards become one scrolling strip. */
  @media (max-width: 640px) {
    .audience-toolbar { gap: 8px; }
    .audience-search { flex: 1 1 100%; max-width: none; }
    .audience-toolbar .segmented {
      flex: 1 1 0; min-width: 0; max-width: none;
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      scrollbar-width: none;
    }
    .audience-toolbar .segmented::-webkit-scrollbar { display: none; }
    .audience-toolbar .segmented button { flex: none; }
    .filter-btn { display: inline-flex; flex: none; }
    .filter-controls { display: none; }
    .audience-chips { display: block; }
    .audience-lists {
      display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain;
      scroll-snap-type: x mandatory; padding-bottom: 2px; scrollbar-width: none;
    }
    .audience-lists::-webkit-scrollbar { display: none; }
    .audience-lists > * { flex: 0 0 158px; min-width: 0; scroll-snap-align: start; }
    .audience-lists .list-card { min-height: 0; padding: 10px 12px 11px; }
    .audience-lists .list-card-count { font-size: 18px; }
    /* The edit/delete buttons move under the text so the name gets the full
       card width; the card reserves that bottom strip for them. */
    .audience-lists .list-card-wrap.has-actions .list-card { padding-bottom: 42px; }
    .audience-lists .list-card-actions { top: auto; right: 6px; bottom: 6px; }
    .audience-lists .list-card-wrap.has-actions .list-card-name,
    .audience-lists .list-card-wrap.has-two .list-card-name { padding-right: 0; }
    .audience-lists .list-card-sub { white-space: nowrap; }
    .audience-lists .list-card-chips { flex-wrap: nowrap; overflow: hidden; }
    .audience-lists .list-card.is-new .list-card-sub { display: none; }
    .filter-chip, .filter-chip-clear { min-height: 32px; }
    .filter-sheet .select { width: 100%; max-width: none; min-height: 44px; font-size: 16px; }
    .filter-sheet-foot .btn { min-height: 44px; }
    /* The footer stays put; only the rows scroll (guidelines 8.10). */
    .ui-sheet-body:has(> .filter-sheet) { display: flex; flex-direction: column; overflow: hidden; }
    .ui-sheet-body:has(> .filter-sheet) > .filter-sheet { flex: 1 1 auto; min-height: 0; }
    .ui-sheet-body:has(> .filter-sheet) .filter-sheet-rows {
      flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    }
  }
}

@layer utilities {
  /* On a phone the first header row is menu button, title and bell; the
     actions (gathered by ui-topbar.js) and the section tabs each take a full
     row below it. The title keeps at least 60% of the row so anything else a
     view puts in its header wraps instead of squeezing the title into two
     characters per line. This lives in utilities because the generic .grow
     rule (flex: 1) is there, and a higher layer beats specificity. */
  @media (max-width: 640px) {
    .topbar { row-gap: 4px; }
    .topbar .grow { flex: 1 1 55%; min-width: 0; }
    /* mobile-header: with a single action the title may give up the 60% floor
       and share the row; with two or more the action row keeps its own line. */
    .topbar:has(> .topbar-actions > .btn:only-child) .grow { min-width: 0; }
  }
}

/* mobile-touch: phone tap targets. 40px is the phone floor for anything that
   is pressed (guidelines 8.10); the one solid action and the toggles a label
   owns get 44px. These live in utilities, not in the Phone pass block below:
   `.btn`, `.btn-sm` and `.tab` are components-layer rules, and a later layer
   wins whatever the specificity, so a component-layer min-height would lose. */
@layer utilities {
  /* Phone flagship controls (v6.4): generous 10px/8px radii paired with 40–44px
     touch targets so buttons, inputs and segmented bars read as native mobile
     controls rather than stretched desktop rectangles. */
  @media (max-width: 640px) {
    .btn {
      min-height: 40px; padding: 0 14px; border-radius: var(--r-lg);
      font-size: 14px; font-weight: 550;
    }
    .btn:active:not(:disabled) { transform: scale(0.975); }
    .btn-sm { min-height: 40px; padding: 0 12px; border-radius: var(--r-md); font-size: 13px; }
    .btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: var(--r-md); }
    .btn-sm.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: var(--r-md); }
    .jf-sheet-foot .btn { min-height: 44px; }
    .plan-banner .btn { min-height: 44px; }
    .plan-banner .btn-icon, .plan-banner .btn-sm.btn-icon { width: 44px; min-height: 44px; }
    /* Header single action sits as a sleek pill beside the title; multi-action
       strips scroll cleanly as compact rounded buttons instead of stretched slabs. */
    .topbar > .topbar-actions:has(> .btn:only-child) > .btn:not(.btn-icon) {
      min-height: 40px; padding: 0 14px; border-radius: var(--r-full);
      font-size: 13px; font-weight: 600; gap: 5px;
    }
    .topbar > .topbar-actions > :not(:only-child):not(.btn-icon) {
      flex: none; min-height: 40px; padding: 0 12px; border-radius: var(--r-md);
      font-size: 13px; justify-content: center;
    }
    .topbar > .topbar-actions > .btn-icon { flex: none; width: 40px; min-height: 40px; border-radius: var(--r-md); }
    .input, .select { min-height: 42px; padding: 8px 12px; border-radius: var(--r-lg); }
    /* ...without undoing the room a .search-input keeps for its icon. */
    .search-input .input { padding-left: 32px; }
    .select { padding-right: 32px; background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; }
    .textarea { border-radius: var(--r-lg); padding: 10px 12px; }
    .folder-link { min-height: 40px; border-radius: var(--r-md); }
    /* Compact selects in the inbox toolbar are 26–28px on the desktop. */
    .inbox-mailbox-select, .inbox-view-select, .compose-option-select { min-height: 40px; }
    .inbox-filter { min-height: 36px; padding: 4px 10px; border-radius: var(--r-full); font-size: 12px; }
    .segmented { border-radius: var(--r-lg); padding: 3px; }
    .segmented button { min-height: 40px; padding: 0 12px; border-radius: var(--r-md); font-size: 13px; }
    .tab { min-height: 40px; }
    .list-card-actions { top: 4px; right: 4px; gap: 8px; }
    .list-card-act { width: 40px; height: 40px; border-radius: var(--r-md); }
    .list-card-wrap.has-actions .list-card-name { padding-right: 46px; }
    .list-card-wrap.has-two .list-card-name { padding-right: 94px; }
  }
  /* mobile-touch: the coarse-pointer tier. Primary actions outside the compact
     header pill grow to 44px for effortless thumb hits. */
  @media (max-width: 640px) and (pointer: coarse) {
    .btn-primary, .btn-primary.btn-sm { min-height: 44px; }
    /* The older suggestion popover; the touch one (openSheet) has its own 44px. */
    .suggest-item { min-height: 44px; }
    .topbar > .topbar-actions:has(> :only-child) > .btn:not(.btn-icon) {
      min-height: 40px; padding: 0 14px; font-size: 13px; gap: 5px;
    }
    .topbar > .topbar-actions > :not(:only-child).btn-primary { min-height: 40px; }
  }
}

/* mobile-touch: the phone floor for reading text (guidelines 3.2, 手机下限).
   Anything a person actually reads on a phone is at least 12px; the 10.5/11px
   tiers stay for badges, counters and key hints, which are scanned, not read.
   Utilities layer so these win over the component rule they are lifting. */
@layer utilities {
  @media (max-width: 640px) {
    .small,
    .field .hint,
    .field-error,
    .stat .label,
    .stat .delta,
    .legend,
    .usage-label,
    .usage-pct,
    .usage-note,
    .list-card-sub,
    .contact-email,
    .contact-check,
    .import-menu-note,
    .client-hint,
    .import-stat .label,
    .conn-row .label,
    .breaker-metric .label,
    .dns-label,
    .dns-row,
    .dns-row .kind,
    .dns-value,
    .dns-note,
    .event-when,
    .inbox-folders .field > label,
    .inbox-mailbox-label,
    .msg-time,
    .dropzone span,
    .jf-dangling,
    .cell-mono,
    .dns-row .val,
    .conn-row .value,
    .auth-quiet,
    .auth-legal,
    .inbox-search-meta,
    /* mobile-spec: the rest of the 10.5/11/11.5px tier that a phone still shows
       as words, not as badges: the drawer (the menu button opens it), the login
       form, and small chrome on a handful of screens. Desktop keeps its sizes;
       only the phone floor (3.2 手机下限) is raised here. */
    .crumb,
    .side-brand .brand-meta,
    .side-tenant-meta,
    .side-section,
    .side-usage-note,
    .side-usage-head,
    .side-user-warn,
    .side-user .brand-meta,
    .plan-lock,
    .ov-trend-foot,
    .ui-optgroup,
    .ui-cal-wd,
    .text-fallback summary,
    .image-bar,
    .preview-head,
    .conn-head,
    .conn-row,
    .attach-chip,
    .chip-btn,
    .snippet,
    .collab-chip,
    .import-csv,
    .cn-variant-head span,
    .ee-row-label,
    .auth-kicker,
    .auth-sso-sep,
    .auth-brand-meta,
    .auth-form .field > label,
    .auth-form .field .hint,
    .cmdk-group,
    .cmdk-item .hint,
    .breaker-metric .over,
    .deal-card-top,
    table.data th { font-size: 12px; }
    /* These carry a sentence, not a label: one more step up the scale. */
    .btn-sm,
    .code-block-head,
    .tx-fields dt,
    .msg-preview,
    /* mobile-spec: a segmented control's label is read, and the desktop rule is
       in the 说明 tier (11.5px); 12.5px is the tier for one-line controls. */
    .segmented button { font-size: 13px; }
    /* The column name on a table card ("列名 · 值"). */
    table.data:not([data-mobile="scroll"]) td[data-label]::before { font-size: 12px; }
    /* code/pre/kbd are 0.86em (3.3). Nested in an 11.5px hint that computed to
       9.89px, below the 10.5px floor; the phone uses max() so the ratio still
       applies to larger text but never drops under 12px. */
    code, pre, kbd { font-size: max(12px, 0.86em); }
  }
}

@layer components {
  /* i18n: F1 -- English filter labels are longer; keep each chip on one line. */
  .segmented button { white-space: nowrap; }
  /* i18n: F2 -- English labels are longer than the Chinese source. Keep the
     inbox list-head count and the filter pills on one line rather than wrapping
     a whole word mid-pill; the title beside the count still truncates. */
  .inbox-head-count { white-space: nowrap; }
  .inbox-filter { white-space: nowrap; }
  /* i18n: F3. English labels run longer than their Chinese originals: the
     engagement filter needs room for "Active in the last 30 days", and the
     audience table headers should not break mid-label. Scoped to English so
     the Chinese layout is untouched. */
  html[lang="en"] .audience-engagement { max-width: 230px; }
  html[lang="en"] .audience-table th { white-space: nowrap; }
  /* i18n: F5 -- English labels are longer than the Chinese ones. The showcase's
     fake sidebar and status pills have fixed track widths, so they clip rather
     than reflow; keep each label on one line the way the mock intends. */
  .aw-nav { white-space: nowrap; }
  .aw-r .p { white-space: nowrap; }

  /* Phone: a card header's title block takes the whole first line, so its badges
     and actions wrap below instead of squeezing the title into a narrow column. */
  @media (max-width: 640px) {
    .card-head > .grow { flex: 1 1 100%; }
  }

  /* mobile-polish: the rule above is right for a head with several actions or
     badges, but a head that holds only its title and one close (or one compact)
     button spent a whole extra row on the ×: in a bottom sheet that is ~50px of a
     phone screen. When the last thing after the title is a single icon or small
     button, the two share one line again. */
  @media (max-width: 640px) {
    .card-head:has(> .grow + .btn-icon:last-child),
    .card-head:has(> .grow + .btn-sm:last-child) { flex-wrap: nowrap; }
    .card-head:has(> .grow + .btn-icon:last-child) > .grow,
    .card-head:has(> .grow + .btn-sm:last-child) > .grow { flex: 1 1 0; min-width: 0; }
  }
}

/* ============================= overview, 澄空 (white work area, hairlines) ==== */
@layer components {
  .ov-topbar { padding-top: 22px; padding-bottom: 20px; }
  .ov-hello {
    font-size: 28px; font-weight: 600; line-height: 1.2;
    letter-spacing: -0.015em; margin-top: 2px;
  }
  .ov-hello:lang(en) { letter-spacing: -0.025em; }
  .ov-topbar .today-label { font-size: 12px; font-weight: 500; letter-spacing: 0.015em; color: var(--ink-3); }

  /* Telemetry band: four figures side by side on the porcelain, no frame and no
     fill; a hairline above and below, hairlines between the cells. */
  .ov-metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    padding: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  }
  /* No radius: the cells are divided by a left hairline, which a radius would bend. */
  .ov-metric {
    min-width: 0; padding: 16px 24px; border-left: 1px solid var(--line);
    transition: background var(--dur) var(--ease);
  }
  .ov-metric:hover { background: color-mix(in oklab, var(--surface-2) 64%, transparent); }
  .ov-metric:first-child { padding-left: 0; border-left: 0; }
  .ov-label { font-size: 12px; font-weight: 500; color: var(--ink-3); }
  .ov-metric-value {
    font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15;
    font-variant-numeric: tabular-nums; margin: 6px 0 4px; color: var(--ink);
  }
  .ov-metric-value.is-warn { color: var(--warn); }
  .ov-metric-value.is-bad { color: var(--bad); }
  .ov-metric-note { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
  /* Narrow work area (a phone, or a tablet): 2 x 2 with hairlines between
     the cells. */
  @media (max-width: 960px) {
    .ov-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ov-metric, .ov-metric:first-child { padding: 14px 12px; border-left: 0; }
    .ov-metric:nth-child(odd) { padding-left: 0; padding-right: 12px; }
    .ov-metric:nth-child(even) { padding-left: 12px; padding-right: 0; border-left: 1px solid var(--line); }
    .ov-metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  }

  /* Two columns: the trend and what was sent on the left, how the workspace
     stands on the right. One column below 1080px. */
  .ov-grid {
    display: grid; gap: 28px 40px; align-items: start;
    grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr);
  }
  @media (max-width: 1080px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }
  .ov-col { display: grid; gap: 28px; min-width: 0; align-content: start; }

  /* An unframed section: heading, a text link on the right, then content. */
  .ov-sec { min-width: 0; }
  .ov-sec-head {
    display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px;
    padding-bottom: 8px; border-bottom: 1px solid var(--line);
  }
  .ov-sec-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
  .ov-sec-head .grow { flex: 1 1 auto; min-width: 0; }
  .ov-more {
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
    font-size: 13px; font-weight: 550; color: var(--accent);
  }
  .ov-more svg { transition: transform var(--dur) var(--ease); }
  .ov-more:hover svg { transform: translateX(2px); }

  .ov-trend { position: relative; height: 164px; margin-top: 4px; }
  .ov-trend-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
  .ov-grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
  /* No sending in the window: a 1px dashed floor and a quiet line of text in
     the middle, instead of a solid line along the bottom. */
  .ov-baseline { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
  .ov-trend-empty {
    position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
    font-size: 13px; color: var(--ink-3); pointer-events: none;
  }
  /* Soft vertical wash fading into the porcelain surface. */
  .ov-stop-a { stop-color: var(--accent); stop-opacity: 0.16; }
  .ov-stop-b { stop-color: var(--accent); stop-opacity: 0.01; }
  .ov-area { fill: url(#ov-area-grad); }
  .ov-line {
    fill: none; stroke: var(--accent); stroke-width: 2;
    stroke-linejoin: round; stroke-linecap: round;
  }
  .ov-line-click {
    fill: none; stroke: var(--info); stroke-width: 1.5;
    stroke-dasharray: 3 4; stroke-linecap: round;
  }
  .ov-trend-hits { position: absolute; inset: 0; display: flex; }
  .ov-trend-hits span { position: relative; flex: 1; cursor: crosshair; }
  .ov-trend-hits span:hover { background: color-mix(in oklab, var(--ink) 4%, transparent); }
  .ov-trend-hits span:hover::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px;
    background: var(--line-strong); pointer-events: none;
  }
  .ov-trend-readout { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; }
  .ov-trend-readout:empty { display: none; }
  .ov-trend-foot {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
    font-size: 12px; color: var(--ink-3);
    border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px;
  }
  .ov-trend-foot .grow { flex: 1; }
  .legend i.is-sent { background: var(--accent); }
  .ov-trend-foot .legend i.is-click { background: var(--info); }

  /* Recent campaigns: table on a desktop, list rows on a phone. */
  .ov-camp-table { border-radius: 0; }
  .ov-camp-list { display: none; list-style: none; margin: 0; padding: 0; }
  .ov-camp-list li { border-top: 1px solid var(--line); }
  .ov-camp-list li:first-child { border-top: 0; }
  .ov-camp-row {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 0;
    color: inherit; text-decoration: none;
  }
  .ov-camp-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
  .ov-camp-main > * { display: block; }
  .ov-sec .status-dot { font-size: 13px; }
  .ov-sec .status-dot::before { width: 7px; height: 7px; }
  .ov-sec .status-dot.b-ok { color: var(--ok); }
  .ov-sec .status-dot.b-warn { color: var(--warn); }
  .ov-sec .status-dot.b-bad { color: var(--bad); }
  .ov-sec .status-dot.b-info { color: var(--info); }
  @media (max-width: 640px) {
    .ov-camp-table { display: none; }
    .ov-camp-list { display: block; }
  }

  .ov-health-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
  .ov-health-domain {
    padding: 2px 8px; border-radius: var(--r-xs); background: var(--surface-2);
    border: 1px solid var(--line); font-size: 12px; color: var(--ink); font-weight: 550;
    word-break: break-all;
  }
  .ov-health-list { list-style: none; margin: 0; padding: 0; display: grid; }
  .ov-health-list li {
    display: flex; justify-content: space-between; gap: 12px; align-items: center;
    padding: 10px 6px; border-top: 1px solid var(--line); border-radius: var(--r-xs); font-size: 13px;
    transition: background var(--dur) var(--ease);
  }
  .ov-health-list li:first-child { border-top: 0; }
  .ov-health-list li:hover { background: color-mix(in oklab, var(--surface-2) 70%, transparent); }
  .ov-health-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; text-align: right; }
  .ov-health-state.is-ok { color: var(--ok); }
  .ov-health-state.is-warn { color: var(--warn); }
  .ov-health-note { margin-top: 8px; line-height: 1.5; }
  .ov-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }
  .ov-link {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 12px;
    font-size: 13px; font-weight: 550; color: var(--accent);
  }

  .ov-attn-list { list-style: none; margin: 0; padding: 0; display: grid; }
  .ov-attn {
    position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 12px 10px; border-top: 1px solid var(--line); border-radius: var(--r-sm);
    transition: background var(--dur) var(--ease);
  }
  .ov-attn:first-child { border-top: 0; }
  .ov-attn:hover { background: var(--surface-2); }
  .ov-attn.is-bad .ov-dot { color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: breathe 2s var(--ease) infinite; }
  .ov-attn.is-warn .ov-dot { color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
  .ov-attn.is-info .ov-dot { color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .ov-attn .grow { flex: 1 1 240px; min-width: 0; }
  .ov-attn-title { font-weight: 550; font-size: 14px; }

  /* The usage grid lives in a side column: hairline-separated, no inner box. */
  .ov-sec .usage-grid { gap: 16px; }
}

/* ============================================== transactional email (2026-11) */
@layer components {
  /* The three setup steps: a numbered dot that turns into a check. */
  .tx-steps { display: grid; gap: 0; padding-top: 4px; padding-bottom: 4px; }
  .tx-step {
    display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    padding: 12px 0; border-bottom: 1px solid var(--line);
  }
  .tx-step:last-child { border-bottom: 0; }
  .tx-step h3 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
  .tx-step p { max-width: 72ch; margin: 0; }
  .tx-step > .btn { flex: none; margin-top: 2px; }
  .tx-step-num {
    flex: none; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 600; color: var(--ink-2);
    background: var(--surface-2); border: 1px solid var(--line);
  }
  .tx-step.is-done .tx-step-num { color: var(--ok); background: var(--ok-soft); border-color: transparent; }

  /* Code samples: a quiet header with the language and a copy button. */
  .code-block {
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2); overflow: hidden;
  }
  .code-block-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line);
    background: var(--surface); font-size: 12px; font-weight: 600; color: var(--ink-2);
  }
  .code-block pre {
    margin: 0; padding: 12px 14px; overflow-x: auto;
    font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--ink);
    font-variant-ligatures: none; tab-size: 2;
  }

  /* Field reference: name on the left, explanation on the right. */
  .tx-fields {
    display: grid; grid-template-columns: minmax(96px, max-content) 1fr;
    gap: 6px 14px; margin: 0;
  }
  .tx-fields dt { font-size: 12px; color: var(--ink); padding-top: 1px; overflow-wrap: anywhere; }
  .tx-fields dd { margin: 0; line-height: 1.55; }
  @media (max-width: 480px) { .tx-fields { grid-template-columns: 1fr; } .tx-fields dd { margin-bottom: 6px; } }

  table.data tr.is-muted td { color: var(--ink-3); }
}

/* ================================================= mailboxes by domain (2026-11) */
/* views/mailboxes.js groups the list under one header row per domain. The
   header is a <tr> so the table keeps one column grid; its single <th> spans
   every column. */
@layer components {
  .mb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
  .mb-toolbar .search-input { flex: 1 1 220px; max-width: 360px; }
  .mb-toolbar .select { width: auto; min-width: 180px; }
  table.data tr.mb-group > th {
    position: static; padding: 6px 14px; background: var(--surface-2);
    border-bottom: 1px solid var(--line); color: var(--ink); font-size: 13px;
  }
  table.data tr.mb-group:hover { background: transparent; }
  table.data tr.mb-group > th > .row { justify-content: space-between; }
  .mb-group-toggle {
    display: inline-flex; align-items: center; gap: 8px; min-height: 32px;
    padding: 0 6px 0 2px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: inherit; font: inherit; cursor: pointer;
  }
  .mb-group-toggle:hover { background: var(--surface-3); }
  .mb-group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  .mb-group-toggle svg { flex: none; color: var(--ink-3); transition: transform var(--dur) var(--ease); }
  .mb-group-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
  table.data tr.mb-empty:hover { background: transparent; }
  table.data tr.mb-empty td { text-align: center; padding: 20px 14px; }
  /* The overflow actions stay in the cell (proxyMenu clicks them) but a
     desktop only shows "⋯"; on a phone ui-row-menu.js does the folding. */
  @media (min-width: 641px) {
    .btn.mb-overflow { display: none; }
  }
}

/* ================================================= domain reputation (2026-11) */
@layer components {
  /* views/reputation.js. The first view moved off inline styles (guidelines
     section 14, #9): everything static is a class here, and the only inline
     values left in the script are the chart's bar heights. */
  .rep-skel { height: 220px; }
  .rep-skel.is-detail { height: 320px; }
  .rep-note { max-width: 90ch; }
  .rep-basis { min-width: 170px; max-width: 280px; }

  /* The detail drawer: a verdict card, then titled sections. */
  .rep-detail { display: grid; gap: 20px; }
  .rep-section { display: grid; gap: 10px; }
  .rep-verdict { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .rep-steps { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
  .rep-signal-src { margin-top: 4px; }
  .rep-record { word-break: break-all; }
  .rep-source { font-weight: 500; }
  .rep-source.is-unknown { font-weight: 600; color: var(--warn); }

  /* What the receiving servers said, quoted under the bounce table. */
  .rep-quotes { display: grid; gap: 8px; margin-top: 12px; }
  .rep-quote { border-left: 3px solid var(--line); padding-left: 10px; }
  .rep-quote .mono { word-break: break-word; }

  /* Daily DMARC volume: one column per day, failed stacked on passed. */
  .rep-chart-block { display: grid; gap: 4px; }
  .rep-chart { display: flex; align-items: flex-end; gap: 2px; height: 72px; }
  .rep-chart-day { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
  .rep-chart-fail { background: color-mix(in oklab, var(--bad) 75%, transparent); }
  .rep-chart-pass { background: var(--ok); }
}

/* ============================== view styles moved out of scripts (2026-11) == */
/* Guidelines section 13 and section 14 #9: a view's static styles are classes
   here, one sub-section per view script, and the only `style: {…}` left in a
   script carries a value known at run time (a progress width, a chart
   coordinate, a tag's colour). */
@layer components {
  /* ------------------------------------------------- shared by the views -- */
  /* A skeleton standing in for a whole block while it loads. The suffix is the
     block's height in px, picked to match what replaces it. */
  .skel-h48 { height: 48px; }
  .skel-h80 { height: 80px; }
  .skel-h120 { height: 120px; }
  .skel-h160 { height: 160px; }
  .skel-h220 { height: 220px; }
  .skel-h260 { height: 260px; }
  .skel-h320 { height: 320px; }
  /* webhooks.js: the empty endpoint list (intro, empty note, signature help),
     so a first visit's skeleton is exactly as tall as what replaces it. */
  .skel-webhooks { height: 138px; }
  /* A select as wide as its longest option instead of the whole row. */
  .select-auto { width: auto; }
  /* A card that clips its rows to its own rounded corners. */
  .card-clip { overflow: hidden; }
  /* A control that is not offered yet (a "load more" with nothing more). */
  .btn[hidden] { display: none; }
  /* The row's key value in a mono cell (a domain, an address): full ink. */
  .cell-ink { color: var(--ink); }
  /* An icon turned upside down, e.g. the down chevron reused as "move up". */
  .icon-flip { display: inline-flex; transform: rotate(180deg); }
  /* A grid whose cells keep their own height (a hint that wraps under one
     input must not stretch its neighbours). */
  .grid-start { align-items: start; }
  /* ui.js: the toast's leading icon takes the toast's tone, and the textarea
     behind the legacy copy path stays off screen. */
  .toast-icon { color: var(--accent); }
  .toast.ok .toast-icon { color: var(--accent); }
  .toast.bad .toast-icon { color: var(--bad); }
  .copy-sink { position: fixed; top: -1000px; opacity: 0; }

  /* ------------------------------------- views/deliverability.js (dlv-) -- */
  .dlv-note { max-width: 80ch; }
  .stat .dlv-overall { display: flex; align-items: center; gap: 10px; }
  .dlv-metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .dlv-metrics .stat { transition: border-color var(--dur) var(--ease); }
  .dlv-metrics .stat:hover { border-color: var(--line-strong); }
  .dlv-domain {
    display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-xs);
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--ink); font-size: 13px; font-weight: 600;
  }
  /* Compliance checklist: a status pill of fixed width, then title and hint. */
  .dlv-checks { padding-top: 0; }
  .dlv-check {
    display: flex; align-items: flex-start; gap: 12px; padding: 11px 8px; border-top: 1px solid var(--line);
    border-radius: var(--r-sm); transition: background var(--dur) var(--ease);
  }
  .dlv-check:hover { background: var(--surface-2); }
  .dlv-check > .badge { flex: none; min-width: 58px; justify-content: center; }
  .dlv-check-body { min-width: 0; }
  .dlv-check-title { font-size: 13px; font-weight: 550; }
  .dlv-check-hint { margin-top: 2px; max-width: 76ch; }
  /* Daily trend and warm-up schedule charts (SVG, scaled to the card). */
  .dlv-trend { display: grid; gap: 12px; }
  .dlv-chart { display: block; max-width: 100%; height: auto; border-radius: var(--r-md); padding: 4px 0; }
  .dlv-bar { cursor: pointer; transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease); }
  .dlv-bar:hover { filter: brightness(0.9); }
  .dlv-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
  .dlv-axis-label { font-family: var(--mono); font-size: 11px; fill: var(--ink-3); }
  .dlv-bar-val { font-family: var(--mono); font-size: 11px; font-weight: 550; fill: var(--ink-2); }
  .dlv-line-label { font-size: 11px; font-weight: 550; }
  .dlv-chart-empty { padding: 24px 0; }
  /* Warm-up plan card. */
  .dlv-warmup-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .dlv-warmup-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; }
  .dlv-warmup-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

  /* ---------------------------------------------- views/health.js (hlt-) -- */
  /* The three protection stages as one ladder: a numbered column each, narrowest
     and fastest first. Three across on a wide screen, stacked below 960px. */
  .hlt-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hlt-stage { padding: 16px; display: grid; gap: 8px; align-content: start; min-width: 0; }
  .hlt-stage + .hlt-stage { border-left: 1px solid var(--line); }
  .hlt-stage-head { display: flex; align-items: center; gap: 8px; }
  .hlt-stage-head h3 { font-size: 14px; margin: 0; }
  .hlt-step { flex: none; width: 20px; height: 20px; border-radius: var(--r-full); display: grid;
    place-items: center; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent-strong); }
  .hlt-stage-do { color: var(--ink-2); }
  .hlt-stage-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; }
  .hlt-stage-facts dt { color: var(--ink-3); }
  .hlt-stage-facts dd { margin: 0; color: var(--ink-2); }
  .hlt-detail { gap: 24px; }
  @media (max-width: 960px) {
    .hlt-stages { grid-template-columns: minmax(0, 1fr); }
    .hlt-stage + .hlt-stage { border-left: 0; border-top: 1px solid var(--line); }
  }

  /* ------------------------------------------------------ views/content.js -- */
  .content-search { max-width: 280px; }
  .content-col-name { min-width: 160px; }
  .content-col-subject { max-width: 320px; }
  .content-col-body { max-width: 360px; }
  .content-col-file { max-width: 260px; }
  /* Template and snippet editors: the plain-text alternative is a smaller box. */
  .tpl-plain { min-height: 90px; font-size: 12px; }
  .tpl-plain.is-short { min-height: 80px; }
  .preview-who { display: grid; gap: 0; }
  .preview-note { margin-top: 8px; }
  /* File library: a square thumbnail (or a file glyph), the upload target. */
  .lib-note { padding: 0 16px; }
  .lib-category { max-width: 150px; }
  .lib-thumb {
    width: 44px; height: 44px; flex: none; object-fit: cover;
    border-radius: var(--r-xs); background: var(--surface-3); border: 1px solid var(--line);
  }
  div.lib-thumb { display: grid; place-items: center; color: var(--ink-3); }
  .lib-drop { margin: 16px; padding: 16px; border-width: 2px; }
  .lib-drop[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

  /* ------------------------------------------ views/crm-strategy.js (st-) -- */
  /* The rest of the strategy views' classes are in the stylesheet that
     crm-strategy-common.js injects; these are the ones lifted out of inline
     styles. */
  .st-tier-table { min-width: 720px; }
  .st-runs-table { min-width: 760px; }

  /* ---------------------------------------- views/inbox.js smart views -- */
  /* The views (活动回复 …) above the folders: the same rows as a folder, with a
     hairline between the two groups. */
  .inbox-views { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  /* The folder search and a view's filters swap places with the hidden
     attribute, which the grid display above would otherwise override. */
  .inbox-search[hidden] { display: none; }
  /* A reply that was marked invalid stays in the list but steps back. */
  .msg-row[data-muted] .msg-main { opacity: 0.6; }
  /* An intent pill inside a mail row keeps to the row's micro size. */
  :is(.msg-top, .msg-foot) .reply-intent { flex: none; padding: 0 6px; font-size: 11px; line-height: 16px; }
  .inbox-view-select { width: auto; max-width: 100%; min-height: 28px; height: 28px; padding: 0 26px 0 8px; font-size: 12px; }
  /* The campaign-reply bar in the reader: what the reply was judged to want,
     and the handling actions, where the CRM filing bar sits. */
  .reply-bar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  }
  .reply-bar-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; min-width: 0; }
  /* In a narrow reader the correction menu gives way before anything clips. */
  .reply-bar .select { flex: 1 1 120px; min-width: 0; }
  /* The composer's options row: signature, tracking, reminder. */
  .compose-options { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; color: var(--ink-2); }
  .compose-option, .compose-track { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
  .compose-option > svg { flex: none; color: var(--ink-3); }
  .compose-track[hidden] { display: none; }
  .compose-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
  .compose-option-select { width: auto; max-width: 220px; min-height: 28px; height: 28px; padding: 0 26px 0 8px; font-size: 12px; }
  /* Mailbox settings drawer (views/mailboxes.js): one signature per row. */
  .mb-sig { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .mb-sig:last-child { border-bottom: 0; }
  .mb-sig .grow { flex: 1; min-width: 0; }
  .mb-sig-preview { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); overflow-wrap: anywhere; }
  .inbox-ai-option { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
  /* AI output in the inbox: a translation above the body, a conversation
     summary under the reader head, the composer's AI panel. Always text, set
     apart from the mail itself and labelled as AI output. */
  .ai-panel {
    display: grid; gap: 8px; padding: 10px 12px; margin: 0 20px 10px;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  }
  /* A porcelain toolbar, never a tinted wash: on the composer's own stone
     footing it lifts to white. Violet stays only on the small AI badge. */
  .compose .ai-panel, .thread-reply .ai-panel { background: var(--surface); }
  .ai-panel[hidden] { display: none; }
  .inbox-read-head .ai-panel, .compose .ai-panel, .thread-body .ai-panel { margin: 0; }
  .ai-text { margin: 0; max-height: 320px; overflow-y: auto; }
  .ai-text[hidden] { display: none; }
  .ai-list { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 2px; }
  .inbox-ai-option + .inbox-ai-option { margin-top: 12px; }
  /* The AI reply assistant (views/inbox-reply-assist.js): the draft under a
     campaign reply, the numbers above the list, and the settings dialog. */
  .assist-head { gap: 6px; }
  .assist-note { margin: 0; }
  .assist-text { width: 100%; min-height: 140px; resize: vertical; font: inherit; line-height: 1.5; }
  .assist-regen .input { flex: 1 1 160px; min-width: 0; }
  .assist-stats { padding: 6px 10px; gap: 10px; color: var(--ink-2); }
  .assist-stats[hidden] { display: none; }
  .assist-settings textarea { width: 100%; font: inherit; }
  /* The modal itself does not scroll, so a long form scrolls inside it and the
     Save button stays in view. */
  .assist-settings { max-height: min(62vh, 620px); overflow-y: auto; padding-right: 6px; }

  /* ----------------------------------------------------- views/overview.js -- */
  /* "Getting started": a crisp collapsible checklist. One hairline-framed strip
     (title, a 2px progress hairline, the count, the next step); the compact rows
     open under it. The server stops sending the card once the required steps are
     done or it is dismissed, and an unfilled slot takes no space at all. */
  .onboarding-slot:empty { display: none; }
  .onboarding {
    display: grid; gap: 0; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  }
  .onb-strip {
    display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap;
    padding: 8px 8px 8px 14px; font-size: 13px;
  }
  .onb-title { font-weight: 600; color: var(--ink); }
  .ov-steps-bar { width: 160px; flex: none; height: 2px; background: var(--line); }
  .onb-count { color: var(--ink-3); white-space: nowrap; }
  .onb-next { flex: 1 1 160px; min-width: 0; color: var(--ink-2); }
  .onb-go {
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
    font-weight: 550; color: var(--accent);
  }
  .onb-toggle svg { transition: transform 0.15s var(--ease); }
  .onboarding[data-expanded] .onb-toggle svg { transform: rotate(180deg); }
  .onb-panel { padding: 0 14px; border-top: 1px solid var(--line); }
  .onb-panel[hidden] { display: none; }
  .onb-list { display: grid; }
  .onb-panel-foot { display: flex; justify-content: flex-end; padding: 8px 0 10px; border-top: 1px solid var(--line); }
  .ov-step {
    padding: 8px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0;
    background: transparent; color: inherit; text-decoration: none;
  }
  .ov-step:first-child { border-top: 0; }
  .ov-step.is-done { opacity: 0.6; }
  .ov-step-mark {
    width: 18px; height: 18px; flex: none; display: grid; place-items: center;
    border-radius: 50%; background: var(--surface); color: var(--ink-3);
    border: 1px solid var(--line-strong);
  }
  .ov-step.is-done .ov-step-mark { background: var(--accent); border-color: var(--accent); color: var(--surface); }
  @media (max-width: 640px) {
    /* Title and count on one line, the bar full width, the next step and its
       link under it; the toggle sits at the end of the title line. */
    .onb-strip { gap: 6px 10px; padding: 12px 14px; }
    .onb-title { order: 1; }
    .onb-count { order: 2; flex: 1 1 auto; }
    .onb-toggle { order: 3; min-height: 44px; }
    .ov-steps-bar { order: 4; width: 100%; flex: 1 1 100%; }
    .onb-next { order: 5; flex: 1 1 0; }
    .onb-go { order: 6; min-height: 44px; }
    .onb-panel { padding: 0 14px; }
    .ov-step { min-height: 48px; }
  }
  /* Latest delivery events: the dot takes the event's semantic colour. */
  .event-dot { background: var(--ink-3); }
  .event-dot[data-type="delivered"] { background: var(--ok); }
  .event-dot[data-type="click"] { background: var(--accent); }
  .event-dot[data-type="open"], .event-dot[data-type="unsubscribe"] { background: var(--info); }
  .event-dot[data-type="bounce"], .event-dot[data-type="reject"],
  .event-dot[data-type="spam"], .event-dot[data-type="complaint"] { background: var(--bad); }
  /* First-paint skeleton, shaped like the hero card and one side card. */
  .ov-skel-hero { display: grid; gap: 14px; }
  .ov-skel-label { width: 30%; }
  .ov-skel-value { height: 36px; width: 45%; }
  .ov-skel-chart { height: 150px; }
  .ov-skel-side { padding: 0; }
  .ov-skel-side > .skel:first-child { width: 40%; }
  .ov-skel-side > .skel + .skel { height: 90px; margin-top: 12px; }

  /* ------------------------------------------------------ views/content.js -- */
  /* The template editor's preview text line and content-check results. */
  .preview-preheader { padding: 0 15px 8px; }
  .tpl-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .tpl-checks li { display: flex; gap: 8px; align-items: flex-start; }
  .tpl-checks .badge { flex: none; }

  /* ------------------------------------------------- views/campaign-new.js -- */
  /* The new-campaign page: five sections on the narrow layout. */
  .cn-page { gap: 28px; }
  /* Sub-fields shown or hidden with the hidden attribute; .field/.alert set
     their own display, which would otherwise win over the attribute. */
  .cn-page [hidden] { display: none; }
  /* local part @ domain on one line; the domain select takes what is left. */
  .cn-from { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr); align-items: center; gap: 6px; }
  .cn-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
  .cn-step { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); }
  .cn-step-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .cn-narrow { max-width: 120px; }
  /* A/B variants of a step: key, subject, template, weight, remove. */
  .cn-variants { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .cn-variant { display: grid; grid-template-columns: 28px minmax(0, 1.4fr) minmax(0, 1fr) 72px 30px; gap: 6px; align-items: center; }
  .cn-variant-head span { font-size: 11px; }
  @media (max-width: 640px) {
    .cn-variant { grid-template-columns: 28px minmax(0, 1fr) 72px 30px; }
    .cn-variant > .select, .cn-variant-head > span:nth-child(3) { grid-column: 2 / -1; }
  }
  .cn-days { display: flex; flex-wrap: wrap; gap: 6px 14px; }
  .cn-day { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
  .cn-day input, .cn-check input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
  .cn-checks { list-style: none; margin: 0; padding: 0; display: grid; }
  .cn-check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
  .cn-check:first-child { border-top: none; }
  .cn-check .badge { flex: none; margin-top: 1px; }
  .cn-actions {
    position: sticky; bottom: 0; z-index: 3;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 0; border-top: 1px solid var(--line); background: var(--surface);
  }
  /* mobile-campaigns: the note is a button now (the phone can tap it), so its
     text has to stay left-aligned the way the span's was. */
  .cn-actions .cn-why { text-align: left; }
  /* mobile-flows: the new-campaign step strip. It is hidden on wider screens,
     where all five sections are in one column anyway. */
  .cn-progress { display: none; }
  /* mobile-flows: on a phone the actions are one row: secondary "save draft"
     and the primary slot (save-and-check until the check passes, then start),
     with the note on a small line above them and the bar clear of the home
     indicator. The two full-width buttons of the desktop bar go away. */
  @media (max-width: 640px) {
    .topbar .cn-back { display: none; }
    .cn-progress {
      display: flex; align-items: baseline; gap: 8px;
      position: sticky; top: 0; z-index: 2;
      padding: 8px 0;
      border-bottom: 1px solid var(--line); background: var(--surface);
      color: var(--ink-3); font-size: 12px;
    }
    .cn-progress-count { color: var(--ink-2); font-weight: 550; white-space: nowrap; }
    .cn-progress-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .cn-actions {
      gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    }
    .cn-actions > .grow, .cn-actions .cn-check-btn { display: none; }
    .cn-actions .cn-why { order: 0; flex: 1 0 100%; line-height: 1.5; text-align: left; }
    .cn-actions .cn-why:empty { display: none; }
    /* mobile-campaigns: the note is a button on a phone and carries the reader
       to the report it names; 40px tall like every other touch target here,
       and the dotted underline is the only thing that says it can be tapped. */
    .cn-actions button.cn-why {
      display: inline-flex; align-items: center;
      min-height: 40px; padding: 4px 0; text-align: left;
      text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
    }
    /* the sticky step strip would cover the section title we scroll to */
    .cn-page .section { scroll-margin-top: 44px; }
    .cn-actions .cn-save-btn { order: 1; flex: 1 1 0; min-width: 0; }
    .cn-actions .cn-start-btn { order: 2; flex: 1 1 0; min-width: 0; }
  }

  /* ---------------------------------------------------- views/campaigns.js -- */
  .dns-row-lead { font-weight: 600; }
  .campaign-skel { height: 180px; }
  .campaign-pause-why { margin-top: 4px; }
  .breaker-note { opacity: 0.85; }
  /* Send-funnel legend: solid swatches for the funnel's segment classes. */
  .legend i.f-queued { background: var(--ink-3); }
  .legend i.f-sending { background: var(--info); }
  .legend i.f-sent { background: var(--ok); }
  .legend i.f-failed { background: var(--bad); }
  .legend i.f-suppressed { background: var(--warn); }
  /* Side panel: its loading skeleton, and the delivery funnel's bar colours. */
  .panel-skel-kicker { width: 40%; }
  .panel-skel-title { height: 22px; width: 70%; }
  .panel-skel-stats { height: 88px; }
  .panel-funnel-row.is-sent .panel-funnel-bar i { background: var(--accent); }
  .panel-funnel-row.is-delivered .panel-funnel-bar i { background: color-mix(in oklab, var(--accent) 70%, var(--surface)); }
  .panel-funnel-row.is-click .panel-funnel-bar i { background: color-mix(in oklab, var(--accent) 45%, var(--surface)); }
  .panel-funnel-row.is-bounce .panel-funnel-bar i { background: var(--bad); }

  /* ---------------------------------------------- views/crm-deals.js (deal-) -- */
  /* The board: each stage is a soft warm well (--surface-2) holding pure white
     cards on a hairline. Amounts are tabular figures; a stage's outcome is only
     a thin marker under the column head, never a tint. (These rules used to be
     injected by crm-deals.js as an unlayered <style>, guidelines 14. The global
     [hidden] rule and the phone 16px input rule cover what that sheet repeated.) */
  .deal-skel-board { height: 280px; }
  .deal-skel-admin { height: 200px; }
  .deal-card-margin { font-weight: 400; }
  .deal-stage-prob { margin-left: 6px; }
  .deal-more { margin-top: 8px; }
  .deal-currency { text-transform: uppercase; }
  .deal-main { grid-template-columns: minmax(0, 1fr); }
  .deal-base-note {
    grid-column: 1 / -1;
    padding: 8px 12px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
  }
  /* Three tiles across the whole column, so their right edge is the board's
     and the base-currency note's (phones: two-up, below). */
  .deal-summary {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  }
  .deal-summary .stat { transition: border-color var(--dur) var(--ease); }
  .deal-summary .stat:hover { border-color: var(--line-strong); }
  .deal-summary .stat .value { font-size: 18px; display: grid; gap: 2px; }
  .deal-money { display: grid; gap: 1px; font-variant-numeric: tabular-nums; }

  /* Search and filters sit 8px apart; only the board/list switch is pushed to
     the right edge (by the .grow spacer before it). The search box is a fixed 280px: its input fills it (the
     width:auto below is for the selects, it used to shrink the input to 190px
     inside a 320px box and leave a blank gap before the filters). */
  .deal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .deal-toolbar .grow { flex: 1; }   /* pushes only the board/list switch to the right edge */
  .deal-toolbar .select, .deal-toolbar .input { width: auto; min-width: 0; }
  .deal-toolbar .deal-search { flex: 0 1 280px; min-width: 0; }
  .deal-toolbar .deal-search .input { width: 100%; }
  .deal-dates { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); }
  .deal-dates[hidden] { display: none; }
  /* The chosen conditions of the filter sheet, above the board (phones only). */
  .deal-filter-chips { display: none; }

  .deal-board {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(216px, 1fr); gap: 10px;
    overflow-x: auto; align-items: start; padding-bottom: 10px;
  }
  .deal-col {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 8px;
    display: grid; gap: 8px; align-content: start;
    min-height: 160px; min-width: 0;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  /* Won and lost stages: only the hairline under the head changes hue. */
  .deal-col[data-outcome="won"] .deal-col-head { border-bottom-color: color-mix(in oklab, var(--ok) 45%, var(--line)); }
  .deal-col[data-outcome="lost"] .deal-col-head { border-bottom-color: color-mix(in oklab, var(--ink-3) 45%, var(--line)); }
  /* The drop target while a card is dragged over it: an accent hairline. */
  .deal-col[data-over="1"] {
    border-color: var(--accent);
    background: var(--surface-3);
    box-shadow: inset 0 0 0 1px var(--accent);
  }
  .deal-col-head {
    display: grid; gap: 4px; padding: 4px 4px 6px;
    border-bottom: 1px solid var(--line);
  }
  .deal-col-title { display: flex; align-items: center; gap: 6px; }
  .deal-col-title strong {
    font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink);
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .deal-col-title .dim { font-size: 12px; }
  .deal-col-sum { font-size: 12px; font-weight: 550; color: var(--ink-2); font-variant-numeric: tabular-nums; }
  /* The stage's win probability: a 3px hairline track with a flat accent fill. */
  .deal-prob {
    height: 3px; border-radius: var(--r-full);
    background: var(--surface-4); overflow: hidden; margin: 2px 0 0;
  }
  .deal-prob i {
    display: block; height: 100%; border-radius: inherit;
    background: var(--accent);
    transition: width 0.5s var(--ease);
  }

  /* A deal card: pure white on a hairline; the move button shows on hover. */
  .deal-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 10px 11px;
    display: grid; gap: 6px;
    cursor: grab; min-width: 0;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
  }
  .deal-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
  .deal-card:active { cursor: grabbing; }
  .deal-card[data-dragging="1"] {
    opacity: 0.5;
    box-shadow: var(--shadow-3);
  }
  .deal-card-top {
    display: flex; gap: 6px; align-items: center;
    font-size: 11px; color: var(--ink-3); min-height: 20px;
  }
  .deal-card-top .grow { flex: 1; }
  .deal-move {
    width: 22px; height: 22px; min-height: 22px; padding: 0;
    color: var(--ink-3);
    transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  @media (min-width: 641px) {
    .deal-move { opacity: 0.35; }
    .deal-card:hover .deal-move,
    .deal-card:focus-within .deal-move,
    .deal-move[aria-expanded="true"] { opacity: 1; }
  }
  .deal-card-title {
    all: unset; font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--ink); cursor: pointer;
    overflow-wrap: anywhere; line-height: 1.35;
    transition: color var(--dur) var(--ease);
  }
  .deal-card-title:hover { color: var(--accent); }
  .deal-card-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
  /* Touch: the move button and the title are a deal card's two targets, and
     both need at least 24px (WCAG 2.5.8); the move button is never dimmed. */
  @media (pointer: coarse) {
    .deal-move { width: 40px; height: 40px; min-height: 40px; opacity: 1; }
    .deal-card-title { display: block; padding: 4px 0; }
  }
  .deal-card-co { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .deal-card-amount {
    font-size: 14px; font-weight: 600; letter-spacing: -0.015em;
    color: var(--ink); font-variant-numeric: tabular-nums;
  }
  .deal-card-meta {
    display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center;
    padding-top: 6px; border-top: 1px solid var(--line);
    font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  }
  /* A deal with no close date or owner has an empty meta row: no stray hairline. */
  .deal-card-meta:empty { display: none; }
  .deal-overdue {
    display: inline-flex; align-items: center;
    padding: 0 6px; border-radius: var(--r-full);
    background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-edge);
    font-weight: 550;
  }
  .deal-card select { width: 100%; font-size: 12px; min-height: 26px; padding: 2px 6px; }
  .deal-col-empty {
    font-size: 12px; color: var(--ink-3); text-align: center;
    padding: 18px 8px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-md);
  }

  /* The width that keeps columns readable applies above phone width; on a
     phone the rows become cards (ui-table.js and the stylesheet). */
  @media (min-width: 641px) {
    .deal-table { min-width: 880px; }
  }
  .deal-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
  /* Stage history: a vertical hairline with a dot per change. */
  .deal-history {
    position: relative; list-style: none; margin: 0; padding: 0;
    display: grid; gap: 8px; font-size: 13px;
  }
  .deal-history li {
    position: relative; padding-left: 16px;
    display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: baseline;
  }
  .deal-history li::before {
    content: ""; position: absolute; left: 2px; top: 6px;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
  }
  .deal-history li:not(:last-child)::after {
    content: ""; position: absolute; left: 4.5px; top: 15px; bottom: -10px;
    width: 1px; background: var(--line);
  }
  .deal-pick { display: grid; gap: 6px; }
  .deal-admin-modal { width: min(780px, 94vw); max-width: 94vw; }
  .deal-admin { max-height: 66vh; overflow-y: auto; }
  .deal-pipe {
    border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 14px; display: grid; gap: 10px;
    background: var(--surface);
  }
  .deal-pipe-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .deal-pipe-head .input { flex: 1 1 180px; min-width: 0; }
  .deal-stage-row {
    display: grid; grid-template-columns: minmax(120px, 1.6fr) 76px 108px auto; gap: 6px; align-items: center;
  }
  .deal-stage-row .actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

  /* mobile-crm: the toolbar is the search box, then one row with the scope and
     view switches and the filter sheet button; the board shows one ~85vw
     column at a time, and a column scrolls its own cards so its head stays
     pinned. Two summary tiles per row, and the card meta line takes the 12px
     phone floor (3.2). */
  @media (max-width: 640px) {
    .deal-stage-row { grid-template-columns: minmax(0, 1fr) 76px 108px; }
    .deal-stage-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
    .deal-card-meta { font-size: 12px; }
    .deal-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .deal-toolbar { align-items: center; gap: 8px; }
    .deal-toolbar > .deal-search { order: -2; flex: 1 1 100%; max-width: none; }
    .deal-toolbar > .segmented { flex: none; }
    .deal-toolbar > .grow { display: none; }
    .deal-toolbar > .filter-btn { order: 1; flex: none; min-height: 40px; }
    .deal-toolbar > .deal-dates { order: 2; flex: 1 1 100%; }
    .deal-dates .input { flex: 1 1 0; min-width: 0; }
    .deal-filter-chips { display: block; }
    .deal-board {
      grid-auto-columns: 85vw; gap: 10px;
      scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    }
    .deal-col {
      scroll-snap-align: start; overflow-y: visible;
      max-height: none;
    }
    .deal-col::-webkit-scrollbar { display: none; }
    .deal-col-head { position: sticky; top: 0; z-index: 1; background: inherit; }
  }

  /* ------------------------------------------------------ views/sending.js -- */
  .sending-note { max-width: 70ch; }
  .sending-skel-detail { height: 140px; }
  .sending-domain { letter-spacing: -0.01em; }

  /* ---------------------------------------------------- views/mailboxes.js -- */
  /* Mail-client setup notes: small text with a little more leading. */
  .client-hint { font-size: 12px; line-height: 1.65; }

  /* ------------------------------------------------------------ editor.js -- */
  /* Snippet picker: a scrolling list of left-aligned, two-line options. */
  .snippet-options { max-height: 360px; overflow-y: auto; }
  .snippet-option { justify-content: flex-start; text-align: left; height: auto; padding: 10px 12px; }
  .snippet-option-body { display: grid; gap: 2px; min-width: 0; }

  /* ------------------------------------------------ views/transactional.js -- */
  .tx-note { max-width: 72ch; }
  .tx-search { max-width: 240px; }

  /* --------------------------------------------------- views/crm-drawer.js -- */
  .drawer-deal-link { max-width: 100%; justify-content: flex-start; }
  .drawer-deal-meta { padding-left: 10px; }

  /* ----------------------------------------------------- views/audience.js -- */
  .audience-skel-lists { height: 104px; }
  .import-csv { min-height: 96px; font-size: 12px; }
  /* The contact recycle bin drawer: one deleted contact per row. */
  .trash-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  }
  .trash-row-main { min-width: 0; display: grid; gap: 2px; }

  /* ------------------------------------------------------- views/tokens.js -- */
  .token-lede { margin-top: 6px; }
  .token-ok { padding: 16px; background: var(--ok-soft); border-color: transparent; }

  /* ------------------------------------------- views/crm-analytics.js (an-) -- */
  /* The legend strokes are drawn with border-top in currentColor, so a series
     sets the colour. */
  .an-card-head { justify-content: space-between; }
  .an-usage { margin-top: 16px; }
  .an-legend i.is-sent { color: var(--accent); }
  .an-legend i.is-reply { color: var(--ok); }
  .an-legend i.is-new { color: var(--info); }

  /* -------------------------------------------------------- views/inbox.js -- */
  .inbox-skel-row { height: 56px; margin: 10px; }
  .inbox-skel-read { height: 160px; margin: 16px; }

  /* ----------------------------------------------------- views/settings.js -- */
  .settings-field { max-width: 56ch; }
  .settings-note { max-width: 48ch; }
  /* 设置 › 团队: the member list and the one-time invitation link. */
  .settings-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
  .settings-invite-url { overflow-wrap: anywhere; font-size: 12px; }
  /* 设置 › 工作区 › 角色与权限: the fixed presets and the permission grid. */
  .settings-preset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; display: grid; gap: 4px; }
  .role-groups { display: grid; gap: 12px; }
  .role-group { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px 10px; margin: 0; }
  .role-group > legend { padding: 0 6px; font-size: 13px; font-weight: 550; }
  .role-perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 8px 16px; }
  .role-perm { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
  .role-perm-text { display: grid; gap: 2px; }

  /* 设置: a partition page is a header row, a rail, then the section's cards.
     The wrapped sub-screens (billing, booking, stores, compliance, brand) put
     the same three parts in this grid through .settings-panel's display:
     contents, so their own topbar becomes the header and no second page header
     is drawn. See views/settings-shell.js. */
  .settings-layout {
    flex: 1;
    /* Full-width workspace grid shared by every section: switching 个人 ->
       套餐与账单 keeps the header, the rail and the cards' edges in the exact
       same place. The body fills the rest of the work area, so the header's
       buttons end where the cards end on every section; forms stay readable
       through their own caps (single-line fields 560px, notes 48ch). */
    width: 100%;
    display: grid; grid-template-columns: 220px minmax(0, 1fr);
    grid-template-areas: "head head" "nav body";
    column-gap: 24px; align-items: start; align-content: start; min-width: 0;
  }
  .settings-layout > .topbar,
  .settings-panel > .topbar { grid-area: head; position: static; }
  /* The cards scroll past the rail, so the rail stays in reach. The header
     scrolls away with them. On a phone neither is sticky (below): the page
     header never is (guidelines 8.10), and a sticky rail would need an opaque
     backdrop, which the rail's own edge fade (ui-topbar.js data-fade) would
     cut holes into at both ends. */
  .settings-nav {
    grid-area: nav;
    position: sticky; top: 0; align-self: start;
    display: flex; flex-direction: column; gap: 2px;
    /* 20px + an item's own 12px puts the labels on the page title's 32px
       line, off the sidebar's edge. */
    padding: 22px 0 40px 20px; min-width: 0;
  }
  .settings-nav-item {
    position: relative;
    display: flex; align-items: center; min-height: 36px; padding: 0 12px;
    border-radius: var(--r-md);
    font-size: 13px; font-weight: 450; color: var(--ink-2);
    text-decoration: none; white-space: nowrap;
  }
  .settings-nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
  .settings-nav-item[aria-current="page"] {
    background: var(--raised); color: var(--ink); font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  }
  .settings-nav-item[aria-current="page"]::before {
    content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
    width: 2px; border-radius: var(--r-full); background: var(--accent);
  }
  /* max-width: none -- a wrapped screen's own .content-narrow (billing's
     loading and error states) must not shrink the body mid-load either. */
  .settings-body,
  .settings-panel > .content {
    grid-area: body; margin-inline: 0; max-width: none;
    display: grid; gap: 20px; align-content: start; min-width: 0;
    padding: 22px var(--page-pad) 56px 0;
  }
  /* display: contents has no box of its own: the view's topbar and content
     become direct grid items of .settings-layout. It stays in the document so
     a view that re-renders into its root (billing's retry) keeps working. */
  .settings-panel { display: contents; }

  @media (max-width: 960px) {
    .settings-layout {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "head" "nav" "body";
      column-gap: 0;
    }
    .settings-layout > .topbar,
    .settings-panel > .topbar { position: static; }
    .settings-nav {
      position: static; flex-direction: row; gap: 6px;
      padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none;
    }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav-item {
      flex: none; min-height: 40px;
      border: 1px solid var(--line); background: var(--surface-2);
    }
    .settings-nav-item[aria-current="page"] {
      border-color: var(--accent); color: var(--accent);
    }
    .settings-nav-item[aria-current="page"]::before { display: none; }
    .settings-body,
    .settings-panel > .content { padding: 16px 16px 48px; }
  }
  @media (max-width: 640px) {
    .settings-layout {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "head" "nav" "body";
      column-gap: 0;
    }
    /* mobile-headers: neither the header nor the section rail stays on screen.
       A partition page used to keep them both: a sticky 68px header plus the
       48px rail took 116px of a 812px screen away from the form for its whole
       length, and the guide says a phone header scrolls away. The rail goes
       with it, because a sticky strip needs an opaque backdrop and the 28px
       edge fade would punch holes in it (see the note above). Header 53px,
       rail 48px, both scroll; nothing is resident. */
    .settings-layout > .topbar,
    .settings-panel > .topbar { position: static; }
    /* A horizontal strip that scrolls on its own: the page never scrolls
       sideways. mobile-header: ui-topbar.js adds the edge fades, and the
       buttons grow to a 40px touch target. */
    .settings-nav {
      position: static; flex-direction: row; gap: 6px;
      padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none;
    }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav-item {
      flex: none; min-height: 40px;
      border: 1px solid var(--line); background: var(--surface-2);
    }
    .settings-nav-item[aria-current="page"] {
      border-color: var(--accent); color: var(--accent);
    }
    .settings-nav-item[aria-current="page"]::before { display: none; }
    .settings-body,
    .settings-panel > .content { padding: 16px 16px 48px; }
  }

  /* === Wave 2C: CRM & Settings Mobile === */
  /* --- CRM Common --- */
.crm-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
  .crm-nav { position: sticky; top: 12px; display: grid; gap: 16px; }
  .crm-nav-group { display: grid; gap: 2px; }
  .crm-nav-title { font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 0 9px 4px; }
  .crm-nav-item {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    padding: 6px 9px; border: 0; border-radius: var(--r-sm); background: none;
    font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer;
  }
  .crm-nav-item:hover { background: var(--surface-3); color: var(--ink); }
  .crm-nav-item[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .crm-nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crm-nav-count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
  .crm-nav-item[aria-pressed="true"] .crm-nav-count { color: inherit; }
  /* One explicit track: an implicit auto column would be sized by the widest
     child's max-content, and the filter bar's sideways-scrolling strip on a
     phone is wider than the screen -- the column would then push the page (and
     the filter sheet button) off the side instead of letting the strip scroll. */
  .crm-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
  .crm-main > * { min-width: 0; }
  .crm-toolbar { display: flex; align-items: flex-start; gap: 10px 12px; flex-wrap: wrap; }
  .crm-search { flex: 0 1 260px; min-width: 180px; margin-left: auto; }
  /* Filter bar: scope, the stage (or lead status) chips with live counts,
     quick filters and the rarer facets as compact selects. It replaced a
     220px left rail whose groups held two to five items each. */
  .crm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 520px; min-width: 0; }
  .crm-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
  .crm-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
    border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surface);
    font: inherit; font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .crm-chip:hover { border-color: var(--line-strong); color: var(--ink); }
  .crm-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .crm-chip[aria-pressed="true"] .crm-nav-count { color: inherit; }
  .crm-chip i { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
  .crm-chip i.b-ok { background: var(--ok); }
  .crm-chip i.b-warn { background: var(--warn); }
  .crm-chip i.b-bad { background: var(--bad); }
  .crm-chip i.b-info { background: var(--info); }
  .crm-chip i.b-violet { background: var(--violet); }
  .crm-chip i.b-neutral { background: var(--ink-3); }
  .crm-scope button { display: inline-flex; align-items: center; gap: 5px; }
  .crm-scope .crm-nav-count { font-size: 11px; }
  .crm-sep { width: 1px; height: 18px; background: var(--line-strong); }
  .crm-pick-select { width: auto; min-height: 28px; height: 28px; padding-top: 0; padding-bottom: 0; font-size: 12px; border-radius: var(--r-full); }
  .crm-pick-select[data-active] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
  /* The chosen conditions of the filter sheet, above the list. Only a phone
     shows the row (ui-filter-sheet.js hides the host when nothing is selected). */
  .crm-filter-chips { display: none; }
  /* mobile-crm: ui-filter-sheet.js holds the follow-up status and tag selects in
     one host so a phone can move them into the sheet. The order property keeps
     the wide bar in its original sequence -- follow-up status, the quick
     filters, then tag -- because the host sits where the first of the three
     used to be. */
  .crm-filters > .crm-quick { order: 1; }
  .crm-filters > .filter-controls > .crm-tag-pick { order: 2; }
  .crm-filters > .crm-clear { order: 3; }
  /* The width that keeps columns readable applies above phone width; on a
     phone the rows become cards (ui-table.js and the stylesheet). */
  @media (min-width: 641px) {
  .crm-table { min-width: 860px; }
  }
  .crm-table td { vertical-align: middle; }
  .crm-name { font-weight: 550; }
  .crm-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
  .crm-tag {
    display: inline-flex; align-items: center; gap: 5px; max-width: 14ch;
    padding: 1px 7px; border-radius: var(--r-full); font-size: 11px;
    border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface);
  }
  .crm-tag i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
  .crm-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
  .crm-swatch {
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .crm-swatch[aria-pressed="true"] { border-color: var(--ink); }
  .crm-picks { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; }
  .crm-pick { display: flex; align-items: center; gap: 8px; padding: 5px 4px; font-size: 13px; cursor: pointer; }
  .crm-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
  .crm-timeline li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .crm-timeline li:last-child { border-bottom: 0; }
  .crm-tl-icon {
    width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    background: var(--surface-3); color: var(--ink-2);
  }
  .crm-tl-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
  .crm-tl-meta strong { color: var(--ink); font-weight: 600; font-size: 13px; }
  .crm-tl-mail { display: inline-block; margin-top: 2px; }
  .crm-tl-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; margin-top: 2px; }
  .crm-dl { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
  .crm-dl dt { color: var(--ink-3); font-size: 12px; }
  .crm-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  .crm-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
  .crm-pool-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  @media (max-width: 960px) {
    .crm-search { flex-basis: 100%; margin-left: 0; }
    .crm-sep { display: none; }
    .crm-layout { grid-template-columns: minmax(0, 1fr); }
    .crm-nav { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
    .crm-nav-group { display: flex; gap: 4px; align-items: center; flex: none; }
    .crm-nav-title { display: none; }
    .crm-nav-item { width: auto; white-space: nowrap; border: 1px solid var(--line); }
  }
  /* mobile-crm: the CRM list filter bar on a phone is two lines: the search
     box, then one sideways-scrolling strip of scope + stage/status chips +
     quick filters, with the filter sheet button at its right end. The
     follow-up status and tag selects are inside that sheet here
     (ui-filter-sheet.js), and the chosen ones come back as removable chips
     above the list. The bar was five wrapped rows before: the scope tabs, five
     stage chips over two lines, the two quick chips, a select, and the
     clear-filters button. */
  @media (max-width: 640px) {
    .crm-toolbar { align-items: center; gap: 8px; }
    .crm-toolbar > .crm-search { order: -1; flex: 1 1 100%; max-width: none; margin-left: 0; }
    .crm-filters {
      flex: 1 1 0; min-width: 0; flex-wrap: nowrap; align-items: center; gap: 6px;
      overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    }
    .crm-filters::-webkit-scrollbar { display: none; }
    /* The groups themselves never wrap; the strip scrolls instead. */
    .crm-filters > * { flex: none; }
    .crm-chips, .crm-scope { flex-wrap: nowrap; }
    /* A filter pill is pressed, so it grows to a tappable height (the filter
       chips of ui-filter-sheet.js are 32px on a phone). */
    .crm-chip { min-height: 36px; }
    .crm-filter-chips { display: block; }
    /* These rules are not in a layer, so they would beat the sheet's own
       utilities-layer row (44px, 16px so iOS does not zoom). Lift the two
       compact pill selects back to the sheet's size while they are in it. */
    .filter-sheet .crm-pick-select {
      width: 100%; max-width: none; height: 44px; min-height: 44px; padding: 0 10px;
      font-size: 16px; border-radius: var(--r-sm);
    }
    /* mobile-spec: the timeline meta line is body text, not a label; it takes
       the 12px phone floor (guidelines 3.2). */
    .crm-tl-meta { font-size: 12px; }
  }

  /* --- CRM Tasks --- */
.task-groups { display: grid; gap: 14px; }
  .task-list { list-style: none; margin: 0; padding: 0; display: grid; }
  .task-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start;
    padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .task-row:last-child { border-bottom: 0; }
  .task-row.is-compact { padding: 8px 0; }
  .task-check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong);
    background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
  .task-check:hover { border-color: var(--ok); color: var(--ok); }
  .task-row.is-done .task-check { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
  .task-row.is-done .task-title { text-decoration: line-through; color: var(--ink-3); }
  .task-title { font-weight: 550; overflow-wrap: anywhere; }
  .task-title-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 550; color: var(--ink);
    text-align: left; cursor: pointer; overflow-wrap: anywhere; }
  .task-title-btn:hover { color: var(--accent); }
  .task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
  /* No box of its own: its children are the meta line's flex items, so the wide
     card keeps the due date, the record link and the owner in that order. On a
     phone it becomes one row (the phone block at the end of this sheet). */
  .task-when { display: contents; }
  .task-meta .is-late { color: var(--bad); font-weight: 600; }
  .task-meta .is-today { color: var(--warn); font-weight: 600; }
  .task-link { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--accent); cursor: pointer; }
  .task-link:hover { text-decoration: underline; }
  @media (pointer: coarse) {
    .task-title-btn, .task-link { min-height: 40px; }
  }
  .task-notes { font-size: 13px; color: var(--ink-2); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .task-actions { display: inline-flex; gap: 2px; }
  .task-group-head { display: flex; align-items: center; gap: 8px; }
  .task-count { font-variant-numeric: tabular-nums; }
  .task-quick { display: flex; gap: 6px; flex-wrap: wrap; }
  .task-digest { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
  details.task-done > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
  details.task-done > summary::-webkit-details-marker { display: none; }
  /* mobile-crm: the task card on a phone. The finish circle keeps its 28px look
     but gets a 44px target around it (guidelines 8.10: a check box on a phone is
     44px), and the due date and the owner share the first meta line instead of
     the record link pushing the owner onto the next one. */
  @media (max-width: 640px) {
    .task-check { position: relative; }
    .task-check::after { content: ""; position: absolute; inset: -8px; }
    /* A little more room for the meta line: the two 40px buttons on the right
       leave about 180px, which fits a due date and a name side by side. */
    .task-row { gap: 8px; padding: 10px 12px; }
    .task-meta { gap: 4px 6px; }
    .task-when {
      display: flex; flex-wrap: wrap; flex: 0 1 auto; min-width: 0;
      align-items: baseline; gap: 4px 6px;
    }
    .task-due { flex: none; }
    /* The record link keeps its own line under the due date and the owner. */
    .task-link { order: 2; flex: 1 1 100%; min-width: 0; text-align: left; }
    .task-who {
      order: 1; flex: 0 1 auto; min-width: 0;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
  }

  /* --- CRM Analytics --- */
.an-toolbar { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
  .an-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .an-range .input { width: auto; }
  .an-range[hidden] { display: none; }
  .an-campaign { width: auto; max-width: 220px; }
  .an-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
  /* The single column is spelled out: an implicit (auto) track grows to the
     widest child's min-content, so the usage table widened the card -- and
     the page -- on a phone instead of scrolling inside its .table-wrap. */
  .an-card { padding: 16px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .an-card h2 { font-size: 16px; margin: 0; }
  .an-card .an-sub { font-size: 12px; color: var(--ink-3); }
  /* The charts are drawn on a 720-unit canvas and scale with their card. In a
     narrower card that scaling took the 11-13px labels under the 10.5px floor,
     so the chart never shrinks below its canvas: it scrolls inside its own box. */
  .an-scroll { overflow-x: auto; min-width: 0; }
  .an-svg { width: 100%; height: auto; display: block; overflow: visible; }
  @media (min-width: 641px) {
    .an-svg { min-width: 720px; }
  }
  @media (max-width: 640px) {
    .an-scroll { overflow-x: visible; }
    .an-svg { min-width: 0; }
    .an-svg text { font-size: 12px; }
  }
  .an-svg text { font-family: var(--sans); fill: var(--ink-2); font-size: 12px; }
  .an-svg .an-muted { fill: var(--ink-3); font-size: 11px; }
  .an-svg .an-count { fill: var(--ink); font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
  .an-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
  .an-legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; margin-right: 6px; vertical-align: middle; }
  .an-legend i.is-dash { border-top-style: dashed; }
  .an-hits { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: relative; }
  .an-chips { display: flex; flex-wrap: wrap; gap: 4px; }
  .an-chip { font-size: 12px; padding: 1px 7px; border-radius: var(--r-full); border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
  .an-note { font-size: 12px; color: var(--ink-3); line-height: 1.6; }
  @media (min-width: 1081px) {
    .an-grid.is-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  }

  /* --- CRM Strategy Common --- */
.st-tier-nav { display: grid; gap: 8px; }
  .st-tier {
    display: grid; gap: 2px; width: 100%; text-align: left; cursor: pointer;
    padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface); color: var(--ink);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .st-tier:hover { border-color: var(--line-strong); }
  .st-tier[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
  .st-tier-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .st-tier-name { font-size: 13px; font-weight: 600; }
  .st-tier-count { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
  .st-tier-sub { font-size: 12px; color: var(--ink-3); }
  /* mobile-spec: the tier card's subtitle is read on a phone (3.2, phone floor). */
  @media (max-width: 640px) { .st-tier-sub { font-size: 12px; } }
  .st-head { display: grid; gap: 10px; padding: 16px 18px; }
  .st-head h2 { margin: 0; font-size: 16px; }
  .st-stats { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
  .st-stats strong { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
  .st-section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; font-size: 13px; font-weight: 600; }
  .st-rule-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
  .st-rule-row:first-child { border-top: 0; }
  .st-rule-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .st-rule-name { font-weight: 550; font-size: 13px; overflow-wrap: anywhere; }
  .st-rule-desc { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
  .st-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
  .st-chip { padding: 1px 7px; border-radius: var(--r-full); font-size: 11px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); }
  .st-switch { position: relative; display: inline-block; width: 32px; height: 19px; flex: none; cursor: pointer; }
  .st-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
  .st-track { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--line-strong); transition: background var(--dur) var(--ease); pointer-events: none; }
  .st-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--raised); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-1); }
  .st-switch input:checked + .st-track { background: var(--accent); }
  .st-switch input:checked + .st-track::after { transform: translateX(13px); }
  .st-switch input:focus-visible + .st-track { outline: 2px solid var(--accent); outline-offset: 2px; }
  .st-switch input:disabled + .st-track { opacity: .55; }
  .st-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
  .st-tpl { display: grid; gap: 8px; padding: 14px 16px; align-content: start; }
  .st-tpl h3 { margin: 0; font-size: 14px; }
  .st-flow { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
  .st-flow b { color: var(--ink-3); font-weight: 600; margin-right: 6px; }
  .st-form { display: grid; gap: 16px; }
  .st-block { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
  .st-block-title { font-size: 12px; font-weight: 600; color: var(--ink-3); }
  .st-checks { display: flex; gap: 6px 14px; flex-wrap: wrap; }
  .st-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
  .st-action { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); }
  .st-action-head { display: flex; gap: 8px; align-items: center; }
  .st-action-head .select { flex: 1; min-width: 0; }
  .st-preview { display: grid; gap: 8px; }
  .st-preview ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
  .st-preview li { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; }
  .st-notice { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); align-items: start; }
  .st-notice:first-child { border-top: 0; }
  .st-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--accent); }
  .st-notice.is-read .st-dot { background: transparent; }
  .st-notice.is-read { color: var(--ink-3); }
  .st-note { font-size: 12px; color: var(--ink-3); }
  @media (max-width: 960px) {
    .st-tier-nav { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  }

  /* --- CRM Goals --- */
.goal-toolbar { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
  .goal-period { display: inline-flex; align-items: center; gap: 6px; }
  .goal-period-label { min-width: 9ch; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
  .goal-batch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
  .goal-batch .select, .goal-batch .input { width: auto; }
  .goal-wrap { overflow-x: auto; }
  .goal-table { min-width: 760px; }
  .goal-table td { vertical-align: top; }
  .goal-table th.goal-col { text-align: left; min-width: 130px; }
  .goal-team td { background: var(--surface-2); }
  .goal-who { display: grid; gap: 2px; }
  .goal-who small { color: var(--ink-3); font-size: 12px; }
  .goal-cell { display: grid; gap: 6px; min-width: 124px; }
  .goal-input { width: 100px; text-align: right; font-variant-numeric: tabular-nums; }
  .goal-input.is-dirty { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
  .goal-actual { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; gap: 8px; }
  .goal-rate { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: right; }
  .goal-bar { height: 6px; }
  .goal-foot { font-size: 12px; color: var(--ink-3); }

  @media (max-width: 960px) {
    .crm-nav.st-tier-nav {
      display: flex; flex-direction: row; flex-wrap: nowrap; gap: 8px;
      overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
      padding-bottom: 6px;
    }
    .crm-nav.st-tier-nav::-webkit-scrollbar { display: none; }
    .crm-nav.st-tier-nav .st-tier {
      flex: 0 0 auto; width: auto; min-width: 140px;
    }
  }
  @media (max-width: 640px) {
    .st-rule-row {
      flex-wrap: wrap; gap: 8px 12px;
    }
    .st-rule-row .st-switch {
      margin-left: auto;
    }
    .st-switch {
      min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
    }
    .st-switch .st-track {
      top: 50%; transform: translateY(-50%);
    }
  }


  @media (max-width: 640px) {
    .bulk-bar {
      position: sticky;
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px) + 8px);
      z-index: 40;
      box-shadow: var(--shadow-2);
    }
  }


  .drawer-section-nav {
    display: flex; gap: 6px; padding: 0 0 10px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
  }
  .drawer-section-nav::-webkit-scrollbar { display: none; }
  .crm-tags .row-tight {
    display: inline-flex; align-items: center; gap: 2px;
  }
  .crm-tags .btn-icon {
    width: 22px; height: 22px; min-height: 22px; padding: 0; border-radius: var(--r-full);
  }
  @media (max-width: 640px), (pointer: coarse) {
    .crm-tags .btn-icon {
      width: 28px; height: 28px; min-height: 28px;
    }
  }


  @media (max-width: 640px) {
    .task-row {
      grid-template-columns: 28px minmax(0, 1fr) auto;
    }
    .task-row .task-title-btn {
      width: 100%;
    }
    .task-meta {
      display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    }
    .task-when {
      display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; width: 100%;
    }
  }


  @media (max-width: 640px) {
    .conn-row {
      grid-template-columns: 1fr; gap: 4px; padding: 8px 12px;
    }
    .conn-row .label { font-size: 12px; }
    .tx-step > .btn { width: 100%; margin-top: 6px; }
    .tx-log-head-controls {
      display: flex; flex-wrap: wrap; gap: 8px; width: 100%;
    }
    .tx-log-head-controls .segmented {
      overflow-x: auto; max-width: 100%; flex-wrap: nowrap; scrollbar-width: none;
    }
    .tx-code-segmented {
      overflow-x: auto; max-width: 100%; flex-wrap: nowrap; scrollbar-width: none;
    }
  }

  
  .crm-drawer-tabs { display: none; }
  @media (max-width: 640px) {
    .crm-drawer-tabs {
      display: flex; width: 100%; margin-bottom: 8px; position: sticky; top: -20px; z-index: 2;
      background: var(--surface); padding-bottom: 4px;
    }
    .crm-drawer-tabs button { flex: 1; text-align: center; }
  }

  
  .booking-week-row {
    display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line);
  }
  .booking-week-row:last-child { border-bottom: 0; }
  .booking-week-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
  }
  .booking-win-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%;
  }
  .booking-win-row .input {
    flex: 1 1 90px; min-width: 0;
  }
  .booking-ov-row {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; padding: 4px 0; border-bottom: 1px solid var(--line);
  }
  .booking-ov-row:last-child { border-bottom: 0; }
  .booking-ov-row .input[type="date"] {
    flex: 1 1 130px; min-width: 0;
  }
  .booking-ov-row .input[type="time"] {
    flex: 1 1 80px; min-width: 0;
  }
  details.booking-advanced {
    border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; background: var(--surface);
  }
  details.booking-advanced summary {
    cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink); list-style: none; display: flex; align-items: center; justify-content: space-between;
  }
  details.booking-advanced summary::-webkit-details-marker { display: none; }
  details.booking-advanced[open] summary {
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
  }

  
  @media (max-width: 640px) {
    .settings-members li.spread {
      flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line);
    }
    .settings-members li.spread:last-child { border-bottom: 0; }
    .settings-members li.spread > span:last-child {
      width: 100%; justify-content: flex-end;
    }
    .settings-members li.spread > span:first-child {
      display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
    }
    #export-data .card-body > .row {
      width: 100%;
    }
    #export-data .card-body > .row .btn {
      width: 100%;
    }
  }

  
  details.bill-collapse {
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  }
  details.bill-collapse summary {
    cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 14px; color: var(--ink); list-style: none;
    display: flex; align-items: center; justify-content: space-between;
  }
  details.bill-collapse summary::-webkit-details-marker { display: none; }
  details.bill-collapse[open] summary {
    border-bottom: 1px solid var(--line);
  }
  details.bill-collapse .card-body {
    padding: 16px;
  }

  
  .dlv-trend-readout {
    min-height: 20px; font-size: 12px; color: var(--ink); font-weight: 550;
    padding: 4px 8px; border-radius: var(--r-sm); background: var(--surface-2);
  }
  .dlv-trend-readout:empty { display: none; }
  @media (max-width: 640px) {
    .dlv-axis-label { font-size: 12px; }
    .dlv-line-label { font-size: 12px; }
    .dlv-bar-val { font-size: 12px; }
    .dlv-trend-readout { display: block; width: 100%; text-align: center; }
  }

  
  .health-drawer-tabs { display: none; }
  @media (max-width: 640px) {
    .health-drawer-tabs {
      display: flex; width: 100%; margin-bottom: 8px; position: sticky; top: -20px; z-index: 2;
      background: var(--surface); padding-bottom: 4px;
    }
    .health-drawer-tabs button { flex: 1; text-align: center; }
  }

  
  @media (max-width: 640px) {
    .sending-card-single {
      display: none;
    }
  }

  
  .an-readout {
    min-height: 20px; font-size: 12px; color: var(--ink); font-weight: 550;
    padding: 4px 8px; border-radius: var(--r-sm); background: var(--surface-2); margin-top: 6px;
  }
  .an-readout:empty { display: none; }

  /* === End Wave 2C === */

  /* ---------------------------------------------------- views/crm-goals.js -- */
  .goal-empty { padding: 10px 14px; }

  /* -------------------------------------------------------- views/audit.js -- */
  .audit-when { white-space: nowrap; }
  .audit-kv { display: inline-block; margin-right: 10px; max-width: 28ch; }
}

/* ============================== email editor (drag and drop) (2026-11, wave 5) == */
/* views/email-editor/*.js. The editor is a full-screen <dialog>: three panes
   (blocks, canvas, properties) do not fit a drawer, and the hash router's paths
   are a frozen contract, so it is not a page either. The canvas draws the
   email's own colours inline (they are content); everything around it uses the
   tokens. */
@layer components {
  dialog.ee-dialog {
    width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
    height: 100dvh; max-height: 100dvh;
    margin: 0; padding: 0; border: 0; overflow: hidden;
    background: var(--canvas); color: var(--ink);
  }
  dialog.ee-dialog[open] { display: flex; flex-direction: column; }
  dialog.ee-dialog::backdrop { background: var(--scrim); }
  .ee-loading { padding: 24px; }
  .ee-top {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none;
    padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface);
  }
  .ee-titles { display: grid; grid-template-columns: minmax(140px, 220px) minmax(180px, 320px); gap: 8px; }
  .ee-title-input { height: 32px; }
  .ee-status { white-space: nowrap; }
  /* mobile-designer: the phone gathers undo/redo and the view switch into one
     second header row. Above 640px the wrapper is display: contents, so the
     header lays out exactly as it did with the buttons loose. */
  .ee-tools { display: contents; }
  /* mobile-designer: the phone keeps a dot in the status's slot (and hides the
     sentence); above 640px both the dot and the ⋯ button are not shown. */
  .ee-status-dot { display: none; }
  .ee-more { display: none; }
  /* The phone's toolbar under the canvas, the add sheet and the properties
     sheet; none of it exists on a wide screen. */
  .ee-dock { display: none; }
  .ee-empty-phone { display: none; }
  .ee-side-inner { display: contents; }
  .ee-flip-x svg { transform: scaleX(-1); }
  .ee-flip svg { transform: rotate(180deg); }
  .ee-hint-narrow { display: none; padding: 4px 12px; background: var(--surface-2); }
  .ee-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 208px minmax(0, 1fr) 328px; }

  /* ---- blocks palette ---- */
  .ee-palette {
    overflow-y: auto; padding: 12px; display: grid; gap: 10px; align-content: start;
    border-right: 1px solid var(--line); background: var(--canvas);
  }
  .ee-pal-title { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--ink-3); }
  .ee-pal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .ee-pal-item {
    display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
    color: var(--ink-2); font-size: 12px; cursor: grab; user-select: none;
    transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  @media (min-width: 641px) and (pointer: fine) {
    .ee-pal-item { touch-action: none; }
  }
  .ee-pal-item:hover { border-color: var(--accent); color: var(--ink); }
  .ee-pal-item:active { cursor: grabbing; }
  .ee-layout-glyph { display: flex; gap: 2px; width: 100%; height: 16px; }
  .ee-layout-glyph i { background: var(--surface-4); border-radius: 2px; }
  .ee-pal-help { line-height: 1.55; }

  /* ---- canvas ---- */
  .ee-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  /* The canvas well: --surface-2 with a 20px hairline dot grid. The mail's own
     colour is painted on .ee-board, above it. */
  .ee-canvas {
    flex: 1; overflow: auto; min-height: 0;
    background-color: var(--surface-2);
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 20px 20px;
  }
  .ee-canvas[hidden], .ee-preview[hidden], .ee-side [hidden] { display: none; }
  .ee-banner-host:empty { display: none; }
  .ee-banner { margin: 10px 12px 0; align-items: center; }
  .ee-board { min-height: 100%; padding: 24px 16px 64px; }
  .ee-sheet {
    position: relative; margin: 0 auto; border-radius: var(--r-xs); min-height: 120px;
    box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-2);
  }
  .ee-sheet.is-drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
  .ee-row { position: relative; }
  .ee-row:hover { outline: 1px dashed var(--line-strong); outline-offset: -1px; }
  .ee-row.is-selected { outline: 1px solid var(--accent); outline-offset: -1px; }
  .ee-cols { display: flex; gap: 0; }
  .ee-col { min-width: 0; display: flex; flex-direction: column; }
  .ee-col.is-drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
  .ee-col-empty {
    display: grid; place-items: center; min-height: 56px; margin: 4px;
    border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
    color: var(--ink-3); font-size: 12px;
  }
  .ee-block { position: relative; cursor: pointer; padding: 2px 6px; }
  .ee-block:hover { outline: 1px dashed var(--accent); outline-offset: -1px; }
  .ee-block.is-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
  .ee-bar, .ee-row-bar {
    display: flex; align-items: center; gap: 2px; padding: 2px;
    background: var(--overlay); border: 1px solid var(--line-strong);
    border-radius: var(--r-sm); box-shadow: var(--shadow-2);
  }
  .ee-bar { position: absolute; top: 4px; right: 4px; z-index: 2; }
  .ee-row-bar { position: absolute; top: 0; left: 0; z-index: 2; display: none; }
  .ee-row:hover > .ee-row-bar, .ee-row.is-selected > .ee-row-bar, .ee-row:focus-within > .ee-row-bar { display: flex; }
  .ee-bar-btn {
    display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
    border: 0; border-radius: var(--r-xs); background: transparent; color: var(--ink-2); cursor: pointer;
  }
  .ee-bar-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
  .ee-bar-btn:disabled { opacity: 0.4; cursor: default; }
  .ee-handle { cursor: grab; touch-action: none; }
  .ee-row-label { border: 0; background: transparent; color: var(--ink-3); font-size: 11px; padding: 0 6px; cursor: pointer; }
  .ee-row-label[aria-pressed="true"] { color: var(--accent); font-weight: 600; }
  .ee-empty {
    display: grid; justify-items: center; gap: 6px; padding: 56px 16px; text-align: center; color: var(--ink-3);
  }
  .ee-placeholder { opacity: 0.55; }
  .ee-b-heading { margin: 0; line-height: 1.3; font-weight: 700; padding: 4px 0; }
  .ee-b-text { line-height: 1.6; padding: 2px 0; }
  .ee-b-text p { margin: 0 0 12px; }
  .ee-b-text a { color: var(--ee-link); text-decoration: underline; }
  .ee-b-text ul, .ee-b-text ol { margin: 0 0 12px; padding-left: 24px; }
  .ee-b-image-wrap { padding: 2px 0; }
  .ee-b-image { display: inline-block; max-width: 100%; height: auto; vertical-align: top; }
  .ee-b-image-empty {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 90px;
    border: 1px dashed var(--line-strong); border-radius: var(--r-sm); color: var(--ink-3); font-size: 12px;
  }
  .ee-b-button-wrap { padding: 6px 0; }
  .ee-b-button { display: inline-block; padding: 12px 28px; font-weight: 700; line-height: 1.2; }
  .ee-b-button.is-full { display: block; text-align: center; }
  .ee-b-divider-wrap { padding: 8px 0; }
  .ee-b-divider { margin: 0 auto; border-top-style: solid; }
  .ee-b-spacer { display: grid; place-items: center; font-size: 11px; color: var(--ink-3); background: var(--surface-2); opacity: 0.6; }
  .ee-b-social { display: flex; gap: 12px; padding: 6px 0; }
  .ee-b-html { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--surface-2); border-radius: var(--r-sm); color: var(--ink-3); font-size: 12px; overflow: hidden; }
  .ee-b-html code { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ee-b-footer { font-size: 12px; line-height: 1.6; padding: 6px 0; }

  /* ---- drag and drop ---- */
  .ee-ghost {
    position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none;
    padding: 6px 10px; background: var(--overlay); color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-2); font-size: 12px; font-weight: 550;
  }
  .ee-drop-line { position: absolute; z-index: 3; height: 3px; border-radius: var(--r-full); background: var(--accent); pointer-events: none; }
  body.ee-dragging { user-select: none; cursor: grabbing; }

  /* ---- preview ---- */
  .ee-preview { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .ee-preview-meta { padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); min-height: 36px; }
  /* mobile-designer: where the phone puts the 桌面/手机 switch while previewing
     (editor.js lends the same node to this bar). Empty and hidden above 640px,
     where the switch stays in the header's tool row. */
  .ee-preview-device { display: none; }
  .ee-preview-wrap {
    flex: 1; display: flex; justify-content: center; padding: 16px; overflow: auto; min-height: 0;
    background-color: var(--surface-2);
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 20px 20px;
  }
  .ee-preview-frame {
    width: min(var(--ee-preview-w, 640px), 100%); min-height: 480px; height: 100%;
    border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
    box-shadow: var(--shadow-2);
    transition: width 0.24s var(--ease), border-radius 0.24s var(--ease), box-shadow 0.24s var(--ease);
  }
  /* The phone preview: a plain obsidian bezel, nothing glowing. */
  .ee-preview-wrap[data-device="mobile"] .ee-preview-frame {
    border-radius: var(--r-xl);
    box-shadow: 0 0 0 8px var(--solid), var(--shadow-3);
  }

  /* ---- properties panel ---- */
  .ee-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--surface); }
  .ee-side-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); flex: none; background: var(--surface-2); }
  .ee-tab {
    flex: 1; padding: 6px 4px; border: 0; border-radius: var(--r-sm); background: transparent;
    color: var(--ink-3); font-size: 13px; cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .ee-tab:hover { background: var(--surface-3); color: var(--ink); }
  .ee-tab[aria-pressed="true"] { background: var(--raised); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
  .ee-side-body { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
  .ee-props-title { font-size: 14px; }
  /* mobile-designer: block → row settings; the phone shows it, the wide panel
     does not (the row's own bar is right there on a wide screen). */
  .ee-row-link { display: none; }
  .ee-section { display: grid; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .ee-section:last-child { padding-bottom: 0; border-bottom: 0; }
  .ee-section > h3 { font-size: 12px; font-weight: 600; color: var(--ink-3); }
  /* mobile-designer: the phone's 邮件信息 (name + subject) lives in the
     properties panel. Declared after `.ee-section` so the hiding wins; above
     640px the same fields are in the header. */
  .ee-meta-section { display: none; }
  .ee-range { display: flex; align-items: center; gap: 8px; }
  .ee-range input[type="range"] { flex: 1; min-width: 0; }
  .ee-num { width: 76px; }
  .ee-color { display: flex; align-items: center; gap: 8px; }
  .ee-color input[type="color"] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
  .ee-hex { width: 98px; font-family: var(--mono); }
  .ee-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
  .ee-swatch {
    width: 22px; height: 22px; padding: 0; border-radius: var(--r-full);
    border: 1px solid var(--line-strong); cursor: pointer;
    transition: border-color var(--dur) var(--ease);
  }
  .ee-swatch:hover { border-color: var(--ink-3); }
  .ee-check { display: flex; align-items: flex-start; gap: 8px; }
  .ee-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .ee-social-item { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
  .ee-social-item .hint { grid-column: 1 / -1; }
  .ee-rich { border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
  .ee-rich-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
  .ee-rich-link, .ee-rich-colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px; border-bottom: 1px solid var(--line); }
  .ee-rich-link[hidden], .ee-rich-colors[hidden] { display: none; }
  .ee-rich-link .input { flex: 1; min-width: 120px; }
  .ee-rich-body { min-height: 104px; padding: 10px; font-size: 13px; line-height: 1.55; }
  .ee-rich-body p { margin: 0 0 8px; }
  .ee-issues, .ee-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
  .ee-versions li { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); }
  .ee-versions .grow { min-width: 0; }

  /* ---- gallery ---- */
  dialog.ee-gallery-modal { max-width: min(1000px, calc(100vw - 32px)); }
  .ee-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 14px; }
  .ee-card {
    display: grid; gap: 6px; align-content: start; padding: 10px; text-align: left;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
    color: var(--ink); cursor: pointer;
    transition: border-color var(--dur) var(--ease);
  }
  .ee-card:hover { border-color: var(--accent); }
  .ee-card-name { font-weight: 600; font-size: 13px; }
  .ee-card-thumb { position: relative; height: 176px; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
  .ee-card-blank { display: grid; place-items: center; color: var(--ink-3); }
  .ee-thumb-frame { position: absolute; left: 0; top: 0; width: 600px; height: 660px; border: 0; transform: scale(var(--ee-thumb-scale, 0.3)); transform-origin: 0 0; pointer-events: none; }
  .skel-fill { height: 100%; border-radius: 0; }

  /* tablet & phone: single canvas, dock below, palette and properties in bottom sheets. */
  @media (max-width: 960px) {
    .ee-hint-narrow { display: none; }
    .ee-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    .ee-palette { display: none; }
    .ee-side { display: none; }
    .ee-meta-section { display: grid; }
    .ee-empty-wide { display: none; }
    .ee-empty-phone { display: block; }
    .ee-dialog .ee-block > .ee-bar, .ee-dialog .ee-row > .ee-row-bar { display: none; }

    /* -- the dock under the canvas -- */
    .ee-dock {
      display: flex; flex-direction: column; gap: 8px; flex: none;
      padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
      padding-left: calc(12px + env(safe-area-inset-left, 0px));
      padding-right: calc(12px + env(safe-area-inset-right, 0px));
      border-top: 1px solid var(--line); background: var(--surface);
    }
    .ee-dock[hidden] { display: none; }
    .ee-actions { display: flex; align-items: center; gap: 4px; }
    .ee-actions-props { flex: 1 1 auto; justify-content: center; }
    .ee-actions .ee-bar-btn { width: 40px; height: 40px; flex: none; }
    .ee-dock-row { display: flex; gap: 8px; }
    .ee-add { flex: 1 1 auto; }
    .ee-canvas { touch-action: pan-y; }
    .ee-more { display: inline-flex; }
    .ee-more-actions { display: grid; gap: 6px; }
    .ee-more-action {
      display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px;
      padding: 0 12px; text-align: left; cursor: pointer;
      border: 1px solid var(--line); border-radius: var(--r-sm);
      background: var(--surface); color: var(--ink); font-size: 13px;
    }
    .ee-more-action:hover { background: var(--surface-3); }
    .ee-more-action.is-danger { color: var(--bad); }
    .ee-preview-device {
      display: flex; justify-content: center; flex: none;
      padding: 8px 12px 0; background: var(--surface);
    }
    .ee-preview-device[hidden] { display: none; }

    /* -- the add sheet -- */
    .ee-pal-grid-sheet { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .ee-pal-grid-sheet .ee-pal-item { min-height: 64px; padding: 8px 4px; font-size: 13px; }
    .ee-add-sheet .ee-pal-help { line-height: 1.55; }

    /* -- the properties sheet: the same nodes as the third pane -- */
    .ee-dialog .ui-sheet:has(.ee-side-inner) .ui-sheet-panel {
      max-height: 70vh; max-height: 70dvh;
    }
    .ee-side-inner.is-in-sheet { display: flex; flex-direction: column; min-height: 0; }
    .ee-side-inner.is-in-sheet .ee-side-tabs {
      position: sticky; top: 0; z-index: 2; padding: 4px 0 8px;
      background: var(--overlay); border-bottom: 1px solid var(--line);
    }
    .ee-side-inner.is-in-sheet .ee-tab { min-height: 40px; }
    .ee-row-link { display: inline-flex; align-self: start; }
    .ee-side-inner.is-in-sheet .ee-side-body { overflow: visible; padding: 14px 4px 0; }
    .ee-titles { grid-template-columns: minmax(0, 1fr); }
  }

  /* mobile-designer: the designer on a phone (guidelines 8.10, 手机与触屏).
     One pane (the canvas), a two-row header, and every secondary surface in a
     bottom sheet. The in-block and in-row bars are replaced by one bar under
     the canvas, so nothing floats over the mail or overlaps. None of this
     applies above 640px. */
  @media (max-width: 640px) {
    /* -- header: name + status dot + save, then one tools row -- */
    .ee-top {
      display: grid; grid-template-columns: 40px minmax(0, 1fr) 16px auto;
      grid-template-rows: auto auto; align-items: center; gap: 6px 8px; padding: 6px 10px;
      /* mobile-ios: landscape notch on a side; the × and 保存 stay reachable. */
      padding-left: calc(10px + env(safe-area-inset-left, 0px));
      padding-right: calc(10px + env(safe-area-inset-right, 0px));
    }
    .ee-top > .grow { display: none; }
    .ee-top > .ee-close { grid-area: 1 / 1; }
    .ee-top > .ee-titles { grid-area: 1 / 2; }
    .ee-top > .ee-status-dot { grid-area: 1 / 3; }
    .ee-top > .ee-save { grid-area: 1 / 4; }
    .ee-top > .ee-tools { grid-area: 2 / 1 / 3 / 5; }
    .ee-top > .ee-status {
      position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
      overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
    }
    .ee-titles { grid-template-columns: minmax(0, 1fr); gap: 0; min-width: 0; }
    .ee-titles .ee-subject { display: none; }
    .ee-title-input { width: 100%; min-width: 0; height: 40px; }
    .ee-status-dot { display: grid; place-items: center; width: 16px; height: 16px; }
    .ee-status-dot::before { content: ""; width: 8px; height: 8px; border-radius: var(--r-full); background: var(--line-strong); }
    .ee-status-dot[data-state="saved"]::before { background: var(--ok); }
    .ee-status-dot[data-state="dirty"]::before { background: var(--warn); }
    .ee-status-dot[data-state="error"]::before { background: var(--bad); }
    .ee-save { min-height: 40px; }
    .ee-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
    .ee-tools .segmented { flex-wrap: nowrap; }
    .ee-tools .btn-icon { flex: none; width: 40px; min-height: 40px; }
    .ee-more { display: inline-flex; }
    .ee-hint-narrow { display: none; }

    /* -- canvas contents on mobile -- */
    .ee-canvas .ee-cols { flex-direction: column; }
    .ee-swatch { width: 36px; height: 36px; }
    .ee-social-item { grid-template-columns: minmax(0, 1fr); }
    .ee-board { padding: 16px 12px 24px; }
    .ee-empty { padding: 40px 16px; }

    /* -- gallery: one column, the render scaled to the card -- */
    dialog.ee-gallery-modal { max-width: 100vw; }
    .ee-gallery { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .ee-card-thumb { height: 200px; }
  }
}
/* ============================================ shared inbox (inbox-collab.js) == */
@layer components {
  /* Conversation state chips: where a conversation stands, and the note label.
     Quiet like the campaign tag; colour only for "waiting" and "closed". */
  .collab-chip {
    display: inline-flex; align-items: center; gap: 4px; flex: none;
    padding: 0 8px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--ink-2);
    font-size: 11px; line-height: 18px; white-space: nowrap;
  }
  .collab-chip.is-pending { background: var(--warn-soft); color: var(--warn); }
  .collab-chip.is-closed { background: var(--ok-soft); color: var(--ok); }
  .collab-chip.is-snoozed { background: var(--accent-soft); color: var(--accent-strong); }
  .collab-chip.is-note { background: var(--warn-soft); color: var(--warn); }
  .collab-row-badges { display: inline-flex; align-items: center; gap: 4px; flex: none; }
  .collab-owner {
    display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: var(--r-full);
    background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 600;
  }
  .collab-views { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .collab-views .folder-link { text-align: left; }

  /* The panel above a conversation: status, owner, who else is here, the note
     form and the activity log. */
  .collab-panel {
    display: grid; gap: 10px; padding: 12px 16px;
    border-bottom: 1px solid var(--line); background: var(--surface-2);
  }
  .collab-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 36px; }
  .collab-row .btn-sm { min-height: 28px; }
  .collab-snooze, .collab-assign .input, .collab-mention { width: auto; font-size: 12px; padding-top: 3px; padding-bottom: 3px; }
  .collab-assign { display: flex; align-items: center; gap: 8px; }
  .collab-presence { display: flex; gap: 8px; flex-wrap: wrap; }
  .collab-presence[hidden] { display: none; }
  .collab-viewer {
    padding: 2px 10px; border-radius: var(--r-full); font-size: 12px;
    background: var(--accent-soft); color: var(--accent-strong);
  }
  .collab-viewer.is-replying { background: var(--warn-soft); color: var(--warn); }
  .collab-note-form { display: grid; gap: 6px; }
  /* Folded, the note form is one quiet line; it opens on a click (and stays
     open while a draft is in it), so the mail is what a reader sees first. */
  .collab-note-toggle {
    display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 0 10px;
    border: 1px dashed var(--line-strong); border-radius: var(--r-md);
    background: var(--surface);
    color: var(--ink-2); font-size: 13px; text-align: left; cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .collab-note-toggle:hover {
    color: var(--ink); border-style: solid; border-color: var(--accent);
  }
  .collab-note-text { width: 100%; resize: vertical; font: inherit; line-height: 1.45; background: var(--warn-soft); }
  .collab-activity summary { cursor: pointer; color: var(--ink-3); }
  .collab-activity-list { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }
  .collab-bulk { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 4px; }
  .collab-report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .collab-stat { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
  .collab-stat-value { font-size: 24px; font-weight: 600; color: var(--ink); }

  /* An internal note in the message timeline: tinted and labelled so it can
     never be mistaken for mail that was sent. */
  .thread-note {
    margin: 8px 0; padding: 10px 14px 10px 12px; border-radius: var(--r-sm);
    border: 1px solid var(--warn-edge); border-left: 3px solid var(--warn);
    background: color-mix(in oklab, var(--warn-soft) 72%, var(--surface));
  }
  .thread-note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
  .thread-note-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
  .collab-mention-tag { color: var(--accent-strong); font-weight: 600; }

  /* Canned responses: the composer button, the "/" popover and the manager. */
  .canned-anchor { position: relative; display: inline-block; }
  .canned-pop {
    position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 20; width: min(320px, 90vw);
    /* .card caps itself at 100% of its parent, and the parent here is the
       small anchor it hangs from: measure against the viewport instead. */
    max-width: calc(100vw - 24px);
    padding: 6px; display: grid; gap: 4px; box-shadow: var(--shadow-3);
  }
  .editor .canned-pop, .editor ~ .canned-pop { bottom: auto; top: 100%; }
  .canned-list { display: grid; gap: 2px; max-height: 240px; overflow-y: auto; }
  .canned-option {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0;
    border-radius: var(--r-xs); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  }
  .canned-option[aria-selected="true"], .canned-option:hover { background: var(--accent-soft); }
  .canned-name { flex: 1 1 auto; min-width: 0; }
  .canned-empty { padding: 6px 8px; }
  .canned-vars { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .canned-var code { font-family: var(--mono); }
  .canned-manage { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
  .canned-form { margin-top: 8px; }
  .canned-form textarea { width: 100%; font: inherit; }

  /* The bell in the page header (views/inbox-bell.js). */
  .bell { position: relative; margin-left: auto; }
  .bell-btn { position: relative; }
  .bell-badge {
    position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: var(--r-full); background: var(--bad); color: var(--solid-ink);
    font-size: 11px; line-height: 16px; text-align: center;
  }
  .bell-badge[hidden] { display: none; }
  .bell-pop {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: min(360px, 92vw);
    /* Same as .canned-pop: the bell button is 30px wide, and .card's
       max-width: 100% squeezed the panel into a scrolling 30px strip. */
    max-width: calc(100vw - 24px);
    max-height: 70vh; overflow-y: auto; padding: 8px; box-shadow: var(--shadow-3);
  }
  .bell-pop[hidden] { display: none; }
  .bell-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; }
  .bell-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  .bell-item {
    display: grid; gap: 1px; padding: 8px; border-radius: var(--r-xs); color: inherit; text-decoration: none;
  }
  .bell-item:hover, .bell-item:focus-visible { background: var(--surface-3); }
  .bell-item[data-unread="1"] { border-left: 3px solid var(--accent); }
  .bell-item-main { font-weight: 500; }
  .bell-empty { padding: 8px; }
  .bell-prefs { display: grid; gap: 4px; padding: 8px 4px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
  .bell-prefs .check { display: flex; align-items: center; gap: 6px; }
}
@layer components {
  /* ----------------------------------- views/journey-builder.js (jf-, jr-) -- */
  /* The canvas is a vertical flow: every step is a card, every edge a short
     line with a "+" that inserts a step into it, and a branching step lays its
     two branches side by side. All colours are tokens. */
  .jf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
  .jf-canvas-wrap { display: grid; gap: 12px; min-width: 0; }
  /* The canvas is a drafting board: the warm shell base with a 20px hairline
     dot grid and a resting inset, no spotlight. "safe center": a wide fork
     centres when it fits and scrolls from its left edge when it does not,
     instead of being clipped on both sides. */
  .jf-flow {
    display: flex; flex-direction: column; align-items: safe center; gap: 0; padding: 20px 12px 28px; overflow-x: auto;
    background-color: var(--canvas);
    background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
    background-size: 20px 20px;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-inset);
  }
  /* max-content, not fit-content: a flex item is clamped to the container's width
     and a wide fork would then overflow its own box on both sides. */
  .jf-flow > .jf-col { width: max-content; }
  /* The trigger: a white capsule. Status is a small mark, never a wash:
     draft = dashed edge and a neutral icon, running = ok icon, paused = warn
     icon; the connectors below carry the same hue (see .jf-link). */
  .jf-start {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; border-radius: var(--r-full);
    background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600;
    border: 1px solid var(--line-strong); box-shadow: var(--shadow-1);
  }
  .jf-start .icon {
    display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-full);
    background: var(--surface-3); color: var(--ink-2);
  }
  .jf-flow[data-status="draft"] .jf-start { border-style: dashed; }
  .jf-flow[data-status="active"] .jf-start { border-color: color-mix(in oklab, var(--ok) 32%, var(--line-strong)); }
  .jf-flow[data-status="active"] .jf-start .icon { background: var(--ok-soft); color: var(--ok); }
  .jf-flow[data-status="paused"] .jf-start { border-color: color-mix(in oklab, var(--warn) 34%, var(--line-strong)); }
  .jf-flow[data-status="paused"] .jf-start .icon { background: var(--warn-soft); color: var(--warn); }
  .jf-col { display: grid; justify-items: center; align-content: start; min-width: 240px; }
  .jf-chain { display: grid; justify-items: center; }
  .jf-fork { display: flex; align-items: flex-start; justify-content: center; gap: 20px; position: relative; padding-top: 12px; }
  .jf-fork::before {
    content: ""; position: absolute; top: 0; left: 25%; right: 25%; border-top: 1px solid var(--line-strong);
  }
  .jf-branch {
    font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--r-full); padding: 2px 10px; margin-bottom: 2px;
  }
  /* Connectors are 1px hairlines; a running or paused journey tints them. */
  .jf-link { position: relative; display: grid; place-items: center; width: 100%; height: 30px; }
  .jf-link::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
    width: 1px; transform: translateX(-0.5px); background: var(--line-strong);
  }
  .jf-flow[data-status="active"] .jf-link::before { background: color-mix(in oklab, var(--accent) 55%, var(--line-strong)); }
  .jf-flow[data-status="paused"] .jf-link::before { background: color-mix(in oklab, var(--warn) 45%, var(--line-strong)); }
  .jf-plus {
    position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
    border-radius: var(--r-full); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-3); cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }
  .jf-plus:hover, .jf-plus:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--surface); }
  /* A step card: white, hairline, and a 2px semantic strip along the top edge
     (accent by default, violet for a branching step, red for a step with an
     issue). The card clips so the strip follows its corners; the button fills
     the card, so the focus ring is drawn just inside it. */
  .jf-node {
    position: relative; overflow: hidden; width: 276px; max-width: 100%;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  .jf-node::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent); opacity: 0.55;
    transition: opacity var(--dur) var(--ease);
  }
  .jf-node:hover:not(.is-exit) { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
  .jf-node:hover::before, .jf-node.is-selected::before { opacity: 1; }
  .jf-node.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
  .jf-node:has(+ .jf-fork)::before { background: var(--violet); }
  .jf-node:has(+ .jf-fork) .jf-node-main .icon { background: var(--violet-soft); color: var(--violet); }
  .jf-node.has-issue { border-color: var(--bad); }
  .jf-node.has-issue::before { background: var(--bad); opacity: 1; }
  .jf-node.has-issue .jf-node-main .icon { background: var(--bad-soft); color: var(--bad); }
  /* The end node: a dashed capsule, no strip. */
  .jf-node.is-exit {
    width: auto; min-width: 124px; border-radius: var(--r-full); border-style: dashed; border-color: var(--line-strong);
    background: var(--surface); box-shadow: none;
  }
  .jf-node.is-exit::before { display: none; }
  .jf-node.is-exit:hover { border-color: var(--ink-3); }
  .jf-node-main {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; background: none;
    font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: var(--r-lg);
  }
  .jf-node-main:focus-visible { outline-offset: -2px; }
  .jf-node-main .icon {
    display: grid; place-items: center; flex: none; width: 30px; height: 30px; margin-top: 0;
    border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-2);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  .jf-node.is-exit .jf-node-main { justify-content: center; padding: 6px 14px 6px 10px; gap: 7px; }
  .jf-node.is-exit .jf-node-main .icon {
    width: 22px; height: 22px; border-radius: var(--r-full); background: var(--surface-3); color: var(--ink-3); box-shadow: none;
  }
  .jf-node-text { display: grid; gap: 3px; min-width: 0; }
  .jf-node-text strong { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
  .jf-node-text .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .jf-issue { color: var(--bad); }
  /* The step's numbers: a quiet band, each figure a white hairline chip. */
  .jf-stats {
    display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 7px 11px; border-top: 1px solid var(--line);
    background: var(--surface-2); font-size: 11px; color: var(--ink-3);
  }
  .jf-stats > span {
    display: inline-flex; align-items: center; padding: 1px 6px; border-radius: var(--r-xs);
    background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-variant-numeric: tabular-nums;
  }
  .jf-dangling {
    max-width: 240px; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
    background: var(--surface);
    font-size: 12px; color: var(--ink-3); text-align: center;
  }
  .jf-dangling.has-issue { border-color: var(--bad); color: var(--bad); }
  .jf-panel { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; border-color: var(--line); }
  .jf-panel .card-head .icon {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line);
  }
  .jf-issues ul { margin: 4px 0 0; padding-left: 18px; }
  .jf-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 8px; }
  .jf-pick {
    display: flex; align-items: flex-start; justify-content: flex-start; gap: 10px; height: auto; padding: 10px 12px; text-align: left;
    border-radius: var(--r-md); border-color: var(--line); background: var(--surface);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .jf-pick:hover { border-color: var(--accent); background: var(--surface-2); }
  .jf-pick .icon {
    display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line);
  }
  .jf-pick-text { display: grid; gap: 2px; min-width: 0; white-space: normal; }
  .jf-pick-text strong { font-size: 13px; color: var(--ink); }
  .jf-settings { max-width: 640px; }
  .jf-goal {
    padding: 12px 14px; border-left: 2px solid var(--accent); border-radius: 0 var(--r-md) var(--r-md) 0;
    background: var(--surface-2);
  }
  .jr-rule { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
  /* Desktop sizes; the phone block below puts the 640px values back. */
  @media (min-width: 641px) {
    .jf-flow { padding: 28px 20px 44px; }
    .jf-link { height: 36px; }
  }
  .link-btn {
    padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
    text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
  }
  .link-btn:hover, .link-btn:focus-visible { color: var(--accent); text-decoration-color: var(--accent); }
  .cd-journey { display: grid; gap: 6px; box-shadow: none; border-radius: var(--r-lg); }
  @media (max-width: 1180px) {
    .jf-layout { grid-template-columns: minmax(0, 1fr); }
    .jf-panel { position: static; max-height: none; }
  }
  @media (max-width: 640px) {
    /* mobile-journey: the flow scrolls sideways on a phone (two branch columns
       are wider than the screen), so it takes a finger pan and shows a fade only
       on the side that still has content. The "+" between steps gets a 44px
       target (inset -8 on a 28px circle) and the gap between cards grows with
       it, so a thumb aiming at the "+" does not land on a step. */
    .jf-flow { touch-action: pan-x pan-y; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
    .jf-flow[data-fade="end"] {
      -webkit-mask-image: linear-gradient(90deg, var(--ink) 0, var(--ink) calc(100% - 28px), transparent 100%);
      mask-image: linear-gradient(90deg, var(--ink) 0, var(--ink) calc(100% - 28px), transparent 100%);
    }
    .jf-flow[data-fade="start"] {
      -webkit-mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px);
      mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px);
    }
    .jf-flow[data-fade="both"] {
      -webkit-mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px, var(--ink) calc(100% - 28px), transparent 100%);
      mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px, var(--ink) calc(100% - 28px), transparent 100%);
    }
    .jf-fork { gap: 10px; }
    .jf-col { min-width: 200px; }
    .jf-node { width: 220px; }
    .jf-node-main { min-height: 44px; }
    /* Read on a phone, so the branch label and the step's numbers take the
       3.2 floor of 12px (they stay 11/11.5 on a wider screen). */
    .jf-branch { font-size: 12px; }
    .jf-stats { font-size: 12px; }
    .jf-dangling { font-size: 12px; }
    .jf-link { height: 44px; }
    .jf-plus { width: 28px; height: 28px; }
    .jf-plus::after { content: ""; position: absolute; inset: -8px; border-radius: var(--r-full); }
  }
  /* mobile-journey: the step editor and the header "⋯" menu are bottom sheets
     (js/ui-pop.js openSheet). The step sheet has a fixed 75dvh cap so its top
     edge does not move while the form paints, and its footer stays above the
     home indicator. The picker is built before it opens and uses one full-width
     row per step, so nothing reflows under a finger mid-tap. */
  .ui-sheet.jf-node-sheet > .ui-sheet-panel { max-height: 75vh; max-height: 75dvh; }
  .ui-sheet.jf-node-sheet .ui-sheet-body { padding: 0 16px 12px; }
  .jf-node-form { display: grid; gap: 12px; align-content: start; }
  .jf-sheet-foot {
    position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px;
    margin-top: 4px; padding: 10px 0 2px; border-top: 1px solid var(--line); background: var(--overlay);
  }
  .jf-sheet-foot .btn { flex: 1 1 0; min-height: 44px; justify-content: center; }
  .jf-sheet-danger { color: var(--bad); }
  .jf-sheet-danger:hover:not(:disabled) { color: var(--bad); background: var(--bad-soft); }
  .ui-sheet.jf-picker-sheet .jf-picker { grid-template-columns: 1fr; gap: 6px; padding-bottom: 4px; }
  .ui-sheet.jf-picker-sheet .jf-pick { min-height: 44px; }
}

/* === Wave 2B: Core Views Mobile === */
@layer components {
  /* Forms detail & preferences */
  .form-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .campaign-tabs { display: contents; }
  .campaign-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

  @media (min-width: 961px) {
    .editor-view-toggle { display: none; }
  }

  @media (max-width: 960px) {
    /* Forms builder */
    .form-builder-grid { grid-template-columns: minmax(0, 1fr); }
    /* Content template editor drawer switch */
    .editor-view-toggle { margin-bottom: 12px; }
    /* Journey builder tablet */
    .jf-layout { grid-template-columns: minmax(0, 1fr); }
    .jf-panel { display: none; }
  }

  @media (max-width: 640px) {
    /* Forms */
    .form-pref-row { flex-wrap: wrap; gap: 8px; }
    .form-pref-row .grow { flex: 1 1 100%; min-width: 0; }

    /* Audience & Potential floating bulk bar above tabbar-lift */
    .bulk-bar {
      position: fixed; left: 50%; right: auto; transform: translateX(-50%);
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px) + 12px);
      z-index: 40; width: calc(100vw - 24px); max-width: 480px; flex-wrap: wrap;
      box-shadow: var(--shadow-2); border-radius: var(--r-md); background: var(--surface);
    }
    .blacklist-search { flex: 1 1 180px; min-width: 0; }

    /* Contact drawer tags and inner card border */
    .chip-btn .btn-icon { width: 18px; min-height: 18px; height: 18px; padding: 0; }
    .cd-journey.card { border: 0; padding-left: 0; padding-right: 0; background: transparent; }

    /* Campaigns */
    .campaign-toolbar .segmented {
      flex: 1 1 100%; min-width: 0; max-width: none;
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      scrollbar-width: none;
    }
    .campaign-toolbar .segmented::-webkit-scrollbar { display: none; }
    .campaign-toolbar .segmented button { flex: none; }
    .campaign-head-actions { width: 100%; }
    .campaign-delivery-head { flex-wrap: wrap; gap: 8px; }
    .campaign-delivery-head .segmented {
      flex: 1 1 100%; min-width: 0; flex-wrap: nowrap; overflow-x: auto;
      overscroll-behavior-x: contain; scrollbar-width: none;
    }
    .campaign-delivery-head .segmented::-webkit-scrollbar { display: none; }
    .campaign-delivery-head .segmented button { flex: none; }

    /* Campaign New */
    .cn-variant { grid-template-columns: 28px minmax(0, 1fr) 68px 30px; }
    .cn-variant > :nth-child(1) { grid-area: 1 / 1; }
    .cn-variant > :nth-child(2) { grid-area: 1 / 2; }
    .cn-variant > :nth-child(3) { grid-area: 2 / 2 / 3 / 5; }
    .cn-variant > :nth-child(4) { grid-area: 1 / 3; }
    .cn-variant > :nth-child(5) { grid-area: 1 / 4; }
    .cn-from { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    .cn-from .input { flex: 1 1 120px; min-width: 0; }
    .cn-from .dim { flex: none; }
    .cn-from .select { flex: 1 1 140px; min-width: 0; }

    .cn-progress {
      display: flex; align-items: center; gap: 6px; overflow-x: auto;
      overscroll-behavior-x: contain; scrollbar-width: none;
      position: sticky; top: 0; z-index: 2;
      padding: 8px 0; border-bottom: 1px solid var(--line); background: var(--surface);
    }
    .cn-progress::-webkit-scrollbar { display: none; }
    .cn-progress-item {
      display: inline-flex; align-items: center; gap: 5px; flex: none;
      padding: 3px 8px; border-radius: var(--r-full); border: 1px solid var(--line);
      background: var(--surface); color: var(--ink-2); font-size: 12px; cursor: pointer;
      transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
    }
    .cn-progress-item.is-active {
      border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600;
    }
    .cn-progress-num {
      display: inline-grid; place-items: center; width: 16px; height: 16px;
      border-radius: var(--r-full); background: var(--surface-3); font-size: 12px; font-weight: 600;
    }
    .cn-progress-item.is-active .cn-progress-num { background: var(--accent); color: var(--canvas); }

    /* Content library */
    .lib-category { max-width: none; width: 100%; min-width: 0; }

    /* Journey people tab */
    .jf-people-toolbar { flex-wrap: wrap; gap: 8px; }
    .jf-people-filters { flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
    .jf-people-filters .input { flex: 1 1 100%; }
    .jf-people-segmented {
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      scrollbar-width: none; max-width: 100%;
    }
    .jf-people-segmented::-webkit-scrollbar { display: none; }
    .jf-people-segmented button { flex: none; }

    /* Store dashboard KPI balancing */
    .grid:has(> .stat) > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  }

  @media (max-width: 480px) {
    .blacklist-search { flex-basis: 100%; }
  }
}

/* Installable app (docs/DEPLOYMENT.md section 58): the "new version" banner. */
@layer components {
  .sw-update {
    position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; gap: 12px;
    width: max-content; max-width: calc(100vw - 32px);
    padding: 10px 12px 10px 16px; border-radius: var(--r-md);
    background: var(--overlay); border: 1px solid var(--line); box-shadow: var(--shadow-2);
    font-size: 13px;
  }
}

/* Phone pass (section 58): comfortable tap targets on touch screens, and room
   for the home indicator when the app runs installed (standalone). */
@layer components {
  @media (max-width: 640px) and (pointer: coarse) {
    /* Size floors only: the layout of a card, a row or a chip is not changed
       here (mobile-touch). The 40px button floor lives in the utilities layer
       above, because a component-layer min-height loses to the utilities rule
       that already sets `.btn` to 40px. */
    .check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
    .check input[type="checkbox"], .check input[type="radio"] { width: 20px; height: 20px; }
    /* Whatever row a tick or a radio owns, the whole label is the target. */
    label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { min-height: 44px; }
    /* Text-styled buttons and standalone links get a 36px target (8.10): the
       names in the contacts table, the overview's next-step link, and the
       small "← 设置" / "前往… →" links. */
    .link-btn, .ov-link, .ov-more, a.small { display: inline-flex; align-items: center; min-height: 36px; }
    .lang-switch button { min-height: 40px; }
    /* Icon buttons that are 24–26px by design (a star, a row's delete, a
       copy glyph) keep their size on screen and grow an invisible tap area to
       40px, so the density of the list does not change. `.msg-row-del` and
       `.msg-check` are already absolutely positioned (they are the containing
       block), so only the static ones need `position: relative`. */
    .copy-btn, .msg-star, .msg-row-star > button { position: relative; }
    .copy-btn::after, .msg-star::after, .msg-row-del::after, .msg-check::after,
    .msg-row-star > button::after {
      content: ""; position: absolute; inset: -8px;
    }
  }
  @media (display-mode: standalone) {
    body { padding-bottom: env(safe-area-inset-bottom, 0px); }
    /* mobile-keyboard: on a phone the home indicator is reserved once, by the
       bottom-most element of the page, and never twice. With the tab bar, the
       bar's own height already includes the inset and `.main` gives up the
       same total; on a page without one (the journey canvas, the new-campaign
       form with its sticky action bar, the sign-in screen) the page runs to
       the bottom of the display and its own last bar or bottom padding keeps
       clear of the indicator. Padding the body as well made the document
       34px taller than the shell, so an installed app scrolled into a strip
       of empty canvas below every tab-bar-less page. */
    @media (max-width: 640px) {
      body { padding-bottom: 0; }
    }
  }
}

/* Smart send time (docs/DEPLOYMENT.md section 62): the hourly column chart. */
@layer components {
  .sto-hist { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-top: 4px; }
  .sto-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; height: 100%; }
  .sto-bar-wrap { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line-strong); }
  .sto-bar { display: block; width: 100%; background: var(--accent); border-radius: var(--r-xs) var(--r-xs) 0 0; }
  .sto-lab { height: 16px; font-size: 11px; color: var(--ink-3); text-align: center; overflow: visible; white-space: nowrap; }
}

/* ======================================== form controls (js/ui-select.js) == */
/* The system draws a <select>'s open list, checkboxes, radios and switches in
   its own colours, which ignore the design tokens. Everything below is
   drawn from the tokens instead. Keep this block identical in
   internal/api/web/app/styles.css and internal/api/web/ops/assets/ops.css. */
@layer components {
  .select[aria-expanded="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
  }

  /* The listbox ui-select.js shows in place of the system menu. It lives in
     the top layer ([popover]) so it sits above an open modal dialog; the UA's
     popover box (inset 0, auto margins, padding, border) is reset here. */
  .ui-listbox-pop {
    position: fixed; inset: auto; margin: 0; padding: 0;
    display: flex; flex-direction: column; width: max-content;
    color: var(--ink); background: var(--overlay);
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    overflow: hidden; z-index: 1000;
    font-size: 13px;
    animation: ui-listbox-in 0.12s var(--ease);
  }
  .ui-listbox-pop[data-side="top"] { animation-name: ui-listbox-in-up; }
  @keyframes ui-listbox-in { from { opacity: 0; transform: translateY(-4px); } }
  @keyframes ui-listbox-in-up { from { opacity: 0; transform: translateY(4px); } }
  .ui-listbox-searchbar { padding: 6px; border-bottom: 1px solid var(--line); flex: none; }
  .ui-listbox-search {
    width: 100%; min-height: 30px; padding: 5px 9px;
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-input); border-radius: var(--r-sm);
    outline: none;
  }
  .ui-listbox-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
  .ui-listbox {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 4px; outline: none;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .ui-option {
    display: flex; align-items: center; gap: 6px;
    min-height: 32px; padding: 5px 10px 5px 6px;
    border-radius: var(--r-sm); cursor: pointer; user-select: none;
    color: var(--ink-2); line-height: 1.35;
  }
  .ui-option.is-active { background: var(--surface-3); color: var(--ink); }
  .ui-option[aria-selected="true"] { color: var(--ink); font-weight: 550; }
  .ui-option[aria-disabled="true"] { color: var(--ink-3); cursor: default; opacity: 0.6; }
  .ui-option-check { flex: none; display: grid; place-items: center; width: 16px; height: 16px; color: var(--accent); visibility: hidden; }
  .ui-option[aria-selected="true"] .ui-option-check { visibility: visible; }
  .ui-option-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ui-optgroup {
    padding: 8px 10px 4px 28px; font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em; color: var(--ink-3);
  }
  .ui-optgroup:first-child { padding-top: 4px; }
  .ui-listbox-empty { padding: 10px 12px; color: var(--ink-3); }

  /* Checkboxes and radios. Sizes set elsewhere (16px in tables, 20px on touch
     screens) still apply: this only replaces the drawing. */
  input[type="checkbox"], input[type="radio"] {
    appearance: none; -webkit-appearance: none;
    flex: none; display: inline-block; vertical-align: -3px;
    width: 16px; height: 16px; margin: 0;
    background: var(--surface) no-repeat center / 100% 100%;
    border: 1px solid var(--line-input); border-radius: var(--r-xs);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), background-position var(--dur) var(--ease);
  }
  input[type="radio"] { border-radius: 50%; }
  input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--accent); }
  input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate, input[type="radio"]:checked {
    background-color: var(--accent); border-color: var(--accent);
  }
  input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.6 8.4l2.9 2.9 5.9-6.6' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  input[type="checkbox"]:indeterminate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  }
  input[type="radio"]:checked { background-image: radial-gradient(circle, var(--surface) 0 3px, transparent 3.5px); }
  input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
  }
  input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }

  /* A checkbox with role="switch" is drawn as a toggle. */
  input[type="checkbox"][role="switch"] {
    width: 32px; height: 18px; border-radius: var(--r-full);
    background: radial-gradient(circle, var(--raised) 0 6px, transparent 6.5px) no-repeat left 1px center / 14px 14px,
                var(--surface-4);
    border-color: var(--line-input);
  }
  input[type="checkbox"][role="switch"]:checked {
    background: radial-gradient(circle, var(--surface) 0 6px, transparent 6.5px) no-repeat right 1px center / 14px 14px,
                var(--accent);
    border-color: var(--accent);
  }
}

/* ============ pickers, tooltips and native parts (js/ui-date.js and friends) == */
/* What the operating system used to draw -- the date and colour pickers, the
   datalist dropdown, tooltips, file buttons, spinners, sliders, scrollbars,
   the search field's clear button, autofill tint and <details> markers -- is
   drawn from the tokens here. Keep this block identical in
   internal/api/web/app/styles.css and internal/api/web/ops/assets/ops.css. */
@layer components {
  /* ---- the floating panels share the listbox's box ---- */
  .ui-date-pop, .ui-color-pop {
    position: fixed; inset: auto; margin: 0; padding: 10px;
    color: var(--ink); background: var(--overlay);
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    overflow: auto; z-index: 1000; font-size: 13px;
    animation: ui-listbox-in 0.12s var(--ease);
  }
  .ui-date-pop[data-side="top"], .ui-color-pop[data-side="top"] { animation-name: ui-listbox-in-up; }
  .ui-option-note { margin-left: auto; padding-left: 12px; color: var(--ink-3); font-size: 12px; white-space: nowrap; }

  /* ---- date and time ---- */
  .ui-date-body { display: flex; gap: 10px; align-items: stretch; }
  .ui-cal { width: 252px; flex: none; }
  .ui-cal-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
  .ui-cal-title { flex: 1 1 auto; text-align: center; font-weight: 600; color: var(--ink); }
  .ui-date-nav {
    display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3); cursor: pointer;
  }
  .ui-date-nav:hover { background: var(--surface-3); color: var(--ink); }
  .ui-cal-grid { display: grid; gap: 2px; }
  .ui-cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .ui-cal-wd { padding: 4px 0; text-align: center; font-size: 11px; color: var(--ink-3); }
  .ui-cal-day, .ui-cal-month, .ui-time-opt {
    width: 100%; border: 0; border-radius: var(--r-sm); background: transparent;
    color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
  }
  .ui-cal-day { height: 32px; }
  .ui-cal-day.is-out { color: var(--ink-3); }
  .ui-cal-day:hover, .ui-cal-month:hover, .ui-time-opt:hover { background: var(--surface-3); }
  .ui-cal-day.is-today, .ui-cal-month.is-today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-strong); font-weight: 600; }
  .ui-cal-day[aria-pressed="true"], .ui-cal-month[aria-pressed="true"], .ui-time-opt[aria-selected="true"] {
    background: var(--accent); color: var(--surface); font-weight: 600; box-shadow: none;
  }
  .ui-cal-day:disabled, .ui-cal-month:disabled, .ui-time-opt:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
  .ui-cal-day:focus-visible, .ui-cal-month:focus-visible, .ui-time-opt:focus-visible, .ui-date-nav:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 1px;
  }
  .ui-cal-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .ui-cal-month { height: 40px; }
  .ui-time-col { display: flex; flex-direction: column; min-height: 0; }
  .ui-date-datetime-local .ui-time-col { width: 76px; padding-left: 10px; border-left: 1px solid var(--line); }
  .ui-date-time .ui-time-col { width: 132px; }
  .ui-time {
    display: grid; gap: 1px; align-content: start;
    height: 100%; max-height: 268px; overflow-y: auto; overscroll-behavior: contain;
  }
  .ui-date-datetime-local .ui-time { max-height: none; height: 0; flex: 1 1 auto; }
  .ui-date-time .ui-time { max-height: 240px; }
  .ui-time-opt { min-height: 30px; }
  .ui-date-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .ui-date-foot .grow { flex: 1 1 auto; }

  /* The field itself: the system calendar/clock button is replaced by a quiet
     icon, and the whole field opens the themed picker. */
  input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] {
    padding-right: 30px;
    background-repeat: no-repeat; background-position: right 9px center; background-size: 15px 15px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a616f' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='2.5' y='3.5' width='11' height='10' rx='2'/%3E%3Cpath d='M2.5 6.5h11M5.5 2v3M10.5 2v3'/%3E%3C/svg%3E");
    cursor: pointer;
  }
  input[type="time"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a616f' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3Cpath d='M8 5v3l2 1.5'/%3E%3C/svg%3E");
  }
  :is(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"])::-webkit-calendar-picker-indicator {
    display: none;
  }
  :is(input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"])[aria-expanded="true"] {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
  }

  /* ---- colour ---- */
  input[type="color"] {
    appearance: none; -webkit-appearance: none; flex: none;
    width: 34px; height: 34px; min-height: 0; padding: 3px;
    background: var(--surface); border: 1px solid var(--line-input); border-radius: var(--r-sm);
    cursor: pointer;
  }
  input[type="color"].input { width: 64px; }
  input[type="color"]:hover { border-color: var(--accent); }
  input[type="color"][aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
  input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
  input[type="color"]::-webkit-color-swatch { border: 0; border-radius: var(--r-xs); }
  input[type="color"]::-moz-color-swatch { border: 0; border-radius: var(--r-xs); }
  .ui-color-pop { width: 236px; display: grid; gap: 10px; }
  .ui-color-area {
    position: relative; height: 140px; border-radius: var(--r-sm); cursor: crosshair; touch-action: none;
    background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue));
  }
  .ui-color-hue {
    position: relative; height: 12px; margin: 0 7px; border-radius: var(--r-full); cursor: pointer; touch-action: none;
    background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  }
  .ui-color-area:focus-visible, .ui-color-hue:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .ui-color-thumb {
    position: absolute; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid #fff; box-shadow: 0 0 0 1px oklch(0 0 0 / 0.35), var(--shadow-1);
    background: var(--picked); transform: translate(-50%, -50%); pointer-events: none;
  }
  .ui-color-hue .ui-color-thumb { top: 50%; background: var(--hue); }
  .ui-color-row { display: flex; align-items: center; gap: 8px; }
  .ui-color-preview { flex: none; width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--picked); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .ui-color-hex { flex: 1 1 auto; min-height: 30px; padding: 4px 8px; font-family: var(--mono); font-size: 13px; }
  .ui-color-presets { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .ui-color-swatch {
    aspect-ratio: 1; padding: 0; border: 0; border-radius: var(--r-sm); cursor: pointer;
    background: var(--swatch); box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .ui-color-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--overlay), 0 0 0 4px var(--accent); }
  .ui-color-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* ---- tooltip ---- */
  .ui-tooltip {
    position: fixed; inset: auto; margin: 0; padding: 5px 8px;
    max-width: min(300px, calc(100vw - 16px)); overflow: hidden;
    color: var(--solid-ink); background: var(--solid);
    border: 0; border-radius: var(--r-sm); box-shadow: var(--shadow-2);
    font-size: 12px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere;
    pointer-events: none; z-index: 1100;
    animation: ui-tooltip-in 0.1s var(--ease);
  }
  @keyframes ui-tooltip-in { from { opacity: 0; } }

  /* ---- number, file, range, search ---- */
  input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
  input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  input[type="file"] { max-width: 100%; font: inherit; font-size: 13px; color: var(--ink-3); }
  input[type="file"]::file-selector-button {
    margin-right: 10px; min-height: 32px; padding: 6px 12px;
    font: inherit; font-size: 13px; font-weight: 500; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    box-shadow: var(--shadow-1); cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  input[type="file"]::file-selector-button:hover { background: var(--surface-3); }
  input[type="range"] {
    appearance: none; -webkit-appearance: none; height: 18px; background: transparent; cursor: pointer;
    accent-color: var(--accent);
  }
  input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-full); background: var(--surface-4); }
  input[type="range"]::-moz-range-track { height: 4px; border-radius: var(--r-full); background: var(--surface-4); }
  input[type="range"]::-moz-range-progress { height: 4px; border-radius: var(--r-full); background: var(--accent); }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1);
  }
  input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-1);
  }
  input[type="range"]:focus-visible { outline: none; }
  input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-ring); }
  input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--accent-ring); }
  input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none; width: 14px; height: 14px; margin-left: 6px; cursor: pointer;
    background: no-repeat center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a616f' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4.5 4.5l7 7M11.5 4.5l-7 7'/%3E%3C/svg%3E");
    opacity: 0.8;
  }
  input[type="search"]::-webkit-search-cancel-button:hover { opacity: 1; }

  /* ---- <details> ---- */
  details > summary { cursor: pointer; list-style: none; }
  details > summary::-webkit-details-marker { display: none; }
  details:not(.editor-menu) > summary::before {
    content: ""; display: inline-block; flex: none;
    width: 6px; height: 6px; margin: 0 8px 2px 1px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg); transition: transform var(--dur) var(--ease); opacity: 0.7;
  }
  details[open]:not(.editor-menu) > summary::before { transform: rotate(45deg); margin-bottom: 4px; }

  /* ---- autofill keeps the theme instead of the browser's yellow or blue ---- */
  :is(input, textarea, select):-webkit-autofill {
    -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
    box-shadow: 0 0 0 1000px var(--surface) inset, var(--shadow-1);
    transition: background-color 600000s 0s;
  }
  :is(input, textarea, select):-webkit-autofill:focus {
    box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 3px var(--accent-ring);
  }
}

/* Scrollbars everywhere follow the theme, not just the workspace's. */
@layer base {
  :root { scrollbar-color: var(--line-strong) transparent; accent-color: var(--accent); }
  :where(*) { scrollbar-width: thin; }
}

/* ===== phone layout: header, dialogs, banners ===== */
@layer components {
  @media (max-width: 640px) {
    /* --- page header: compact, scrolls away with the page --------------- */
    /* mobile-header: the first row is one 40px line -- the menu button's
       height -- and the title's line box is that same 40px, so the menu, the
       title and the bell share one centre line. mobile-headers: the subtitle
       no longer draws a line under it (below), so a header without actions or
       tabs is 53px and one with an action row is 101px. */
    .topbar {
      position: static; padding: 10px 16px 8px; gap: 6px 8px;
      align-items: flex-start;
      backdrop-filter: none; background: var(--surface);
    }
    .topbar .grow { flex: 1 1 55%; min-width: 0; }
    .topbar > .grow {
      display: flex; flex-direction: column;
      min-height: 40px;
    }
    .topbar > .menu-btn { align-self: flex-start; margin-left: -10px; }
    .topbar > .bell { align-self: flex-start; }
    .topbar h1 {
      font-size: 18px; line-height: 40px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* mobile-polish: an inline badge in the title (a journey's 草稿, a read-only
       tag) used to inherit the title's 40px line box and grew into a 46px
       circle. It keeps its own line height and sits on the title's baseline, so
       the title's 40px line stays as it is. */
    .topbar h1 .badge,
    .topbar h1 .status-dot {
      line-height: 1.2; height: auto; vertical-align: middle;
    }
    /* Most views put an h1 inside .grow; a few make the h1 itself the grow
       cell (总览, 客户). That one keeps its own box, so a long title still ends
       in an ellipsis, and centres its single line on the menu button. */
    .topbar > h1.grow { display: block; min-height: 40px; line-height: 40px; }
    .topbar p, .topbar .sub {
      margin-top: 0; font-size: 12px; line-height: 1.3;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* mobile-headers: the subtitle stops drawing a line of its own. It was
       already a single ellipsised line, and a long sentence lost its meaning in
       it; the line was 16px of every phone header. The sentence stays in the
       DOM -- only visually hidden, the sr-only pattern -- so a screen reader
       still reads it after the title. Pages that carry a crumb drop from 135px
       to 101px with this, and every other page 16px. */
    .topbar .grow > p {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
    }
    /* mobile-headers: a detail page's crumb becomes the way back and shares the
       first row with the menu button and the title instead of taking a line
       above them: [☰] ‹ 活动 · 活动详情 [🔔]. Only the parent label survives;
       the chevron before it is the desktop's own, turned round by
       row-reverse, and 详情 / 新建活动 is dropped (views no longer add a second
       back button either: campaigns.js lends its 活动 button here). */
    .topbar .crumb { margin-bottom: 0; }
    .topbar > .grow:has(> .crumb) {
      display: grid; grid-template-columns: auto minmax(0, 1fr);
      column-gap: 4px; align-content: start;
    }
    /* Everything but the crumb keeps the full second column, so a header that
       puts a second line under the title still spans the width instead of
       squeezing into the crumb's column. */
    .topbar > .grow:has(> .crumb) > *:not(.crumb) { grid-column: 2; }
    .topbar > .grow > .crumb {
      grid-column: 1; grid-row: 1; align-self: center;
      flex-direction: row-reverse; justify-content: flex-end; gap: 0;
    }
    .topbar > .grow > .crumb > svg { transform: rotate(180deg); opacity: 0.7; }
    .topbar > .grow > .crumb > span { display: none; }
    .topbar > .grow > .crumb a {
      display: flex; align-items: center; min-width: 40px; min-height: 40px;
      padding: 0 8px 0 4px;
      color: var(--ink-2); font-size: 13px; font-weight: 500;
    }
    .topbar .menu-btn { min-width: 40px; min-height: 40px; }
    body.has-tabbar .topbar .menu-btn { display: none; }
    /* mobile-header: a header with exactly one action (新建活动, 新建旅程 …)
       keeps it on the title row while the title still fits; two or more
       actions scroll on their own row below. No max-width: the item's own
       width decides whether the row breaks, so a long label wraps instead of
       being cut inside the scroll row. */
    .topbar:has(> .topbar-actions > .btn:only-child) > .topbar-actions {
      order: 3; flex: 0 1 auto; margin-left: auto;
    }
    .topbar-actions {
      order: 5; flex: 0 0 100%; flex-wrap: nowrap; gap: 8px;
      overflow-x: auto; padding: 2px 0; scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
    }
    .topbar-actions::-webkit-scrollbar { display: none; }
    .topbar-actions > * { flex: none; white-space: nowrap; }
    .topbar .section-tabs, .topbar .tabs, .settings-nav {
      flex-wrap: nowrap; overflow-x: auto; margin: 0 0 -8px; scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
    }
    .topbar .section-tabs::-webkit-scrollbar, .settings-nav::-webkit-scrollbar { display: none; }
    .topbar .section-tabs .tab, .topbar .tabs .tab, .settings-nav-item {
      flex: none; white-space: nowrap;
      display: inline-flex; align-items: center; min-height: 40px;
    }
    .settings-nav {
      gap: 2px; border-bottom: 1px solid var(--line);
      padding: 0 16px; margin: 0;
    }
    .settings-nav-item {
      border: 0; border-radius: 0; background: none;
      border-bottom: 2px solid transparent; margin-bottom: -1px;
      padding: 9px 12px; font-size: 13px; font-weight: 500; color: var(--ink-3);
    }
    .settings-nav-item:hover { background: none; color: var(--ink); }
    .settings-nav-item[aria-current="page"] {
      border: 0; border-radius: 0; background: none;
      border-bottom: 2px solid var(--ink); color: var(--ink); font-weight: 550;
    }
    /* mobile-header: a horizontal strip shows a fade only on the side that
       still has content; ui-topbar.js sets data-fade from the scroll position,
       so a strip that has been scrolled to the end loses its right fade. */
    :is(.topbar-actions, .topbar .section-tabs, .topbar .tabs, .settings-nav)[data-fade="start"] {
      -webkit-mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px);
      mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px);
    }
    :is(.topbar-actions, .topbar .section-tabs, .topbar .tabs, .settings-nav)[data-fade="end"] {
      -webkit-mask-image: linear-gradient(90deg, var(--ink) calc(100% - 28px), transparent 100%);
      mask-image: linear-gradient(90deg, var(--ink) calc(100% - 28px), transparent 100%);
    }
    :is(.topbar-actions, .topbar .section-tabs, .topbar .tabs, .settings-nav)[data-fade="both"] {
      -webkit-mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px, var(--ink) calc(100% - 28px), transparent 100%);
      mask-image: linear-gradient(90deg, transparent 0, var(--ink) 28px, var(--ink) calc(100% - 28px), transparent 100%);
    }
    .bell { flex: none; }
    .jf-panel { top: 8px; }

    /* --- modal -> bottom sheet ------------------------------------------ */
    dialog.modal {
      width: 100%; max-width: 100%; margin: auto 0 0 0;
      max-height: 92vh; max-height: 92dvh;
      border-radius: var(--r-xl) var(--r-xl) 0 0;
      animation: sheet-in 0.26s var(--ease);
    }
    dialog.modal[open] { display: flex; flex-direction: column; }
    dialog.modal[data-closing] { animation: sheet-out 0.18s var(--ease) forwards; }
    dialog.modal > .card {
      display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto;
      max-height: 92vh; max-height: 92dvh;
      border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0;
      /* mobile-ios: in landscape the notch covers a side of the screen; the
         card keeps its full-width background and insets its contents. */
      padding-left: env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
    }
    dialog.modal .card-head { flex: none; border-radius: var(--r-xl) var(--r-xl) 0 0; }
    /* mobile-sheet: the head is also the pull-to-close handle (ui.js wires the
       gesture). touch-action keeps the browser from panning the page instead of
       following the finger, and the title is not selectable while it moves. */
    dialog.modal > .card > .card-head {
      touch-action: none;
      -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    }
    dialog.modal > .card > .card-body:not(.modal-actions) {
      flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto;
      overscroll-behavior: contain;
    }
    dialog.modal .modal-actions {
      flex: none; background: var(--surface); border-top: 1px solid var(--line);
      padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
    /* mobile-keyboard: with the keyboard up the dialog is fitted above it
       (js/ui-pop.js fitSheetToKeyboard, wired once in js/ui.js) and the home
       indicator sits behind the keys, so the safe-area padding would push the
       actions into the scroll area for no reason. */
    dialog.modal[data-kb] .modal-actions { padding-bottom: 10px; }
    @keyframes sheet-in { from { transform: translateY(100%) } }
    @keyframes sheet-out { to { transform: translateY(100%) } }

    /* --- drawer: safe areas, pinned head/foot --------------------------- */
    dialog.drawer { border-left: 0; }
    .drawer-head {
      padding-top: calc(14px + env(safe-area-inset-top, 0px));
      padding-left: calc(16px + env(safe-area-inset-left, 0px));
      padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }
    .drawer-body {
      min-height: 0; overscroll-behavior: contain;
      padding-left: calc(16px + env(safe-area-inset-left, 0px));
      padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }
    .drawer-foot {
      padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
      padding-left: calc(16px + env(safe-area-inset-left, 0px));
      padding-right: calc(16px + env(safe-area-inset-right, 0px));
    }

    /* --- command palette: full width at the top -------------------------- */
    dialog.cmdk {
      width: 100%; max-width: 100%; margin: 0;
      border-radius: 0 0 var(--r-lg) var(--r-lg); border-top: 0;
      max-height: 85vh; max-height: 85dvh;
      padding-top: env(safe-area-inset-top, 0px);
      /* mobile-ios: a full-width overlay at the top; landscape's notch is on a
         side, so the search field and the rows are inset there. */
      padding-left: env(safe-area-inset-left, 0px);
      padding-right: env(safe-area-inset-right, 0px);
    }
    dialog.cmdk[open] { display: flex; flex-direction: column; }
    .cmdk-list {
      flex: 1 1 auto; min-height: 0;
      max-height: calc(85vh - 120px); max-height: calc(85dvh - 120px);
    }

    /* --- toasts and the update banner above the home indicator ----------- */
    /* mobile-shell: and above the phone tab bar, which owns the bottom edge. */
    .toasts {
      width: calc(100vw - 16px); width: calc(100dvw - 16px);
      bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--tabbar-lift, 0px));
    }
    .sw-update {
      width: calc(100vw - 16px); max-width: calc(100vw - 16px);
      bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--tabbar-lift, 0px));
      justify-content: space-between; font-size: 13px;
    }

    /* --- banners above the header: compact ------------------------------- */
    .verify-banner, .announce {
      flex-wrap: nowrap; gap: 8px; padding: 6px 16px; font-size: 13px; line-height: 1.4;
    }
    .verify-banner .grow, .announce .grow { flex: 1 1 0; min-width: 0; }
    /* One row: the notice shrinks and ellipsises, the action is a text link,
       the close button keeps a 44px target. */
    .plan-banner {
      flex-wrap: wrap; gap: 8px; padding: 6px 16px; font-size: 13px; line-height: 1.4; padding-right: 4px;
    }
    .plan-banner .grow { flex: 1 1 0; min-width: 0; }
    .plan-banner .btn:not(.btn-icon) { min-height: 44px; padding: 0 8px; font-size: 13px; font-weight: 600; }
    .plan-banner .btn-icon, .plan-banner .btn-sm.btn-icon { width: 44px; min-height: 44px; flex: none; }
    .verify-banner .btn, .announce .btn {
      flex: none; white-space: nowrap; min-height: 28px; padding: 3px 10px; font-size: 12px;
    }
    .announce-body { margin-top: 0; }

    /* --- vh -> dvh for phone max-heights --------------------------------- */
    .side-switch .side-switch-menu { max-height: 60vh; max-height: 60dvh; }
    .editor-body { max-height: 60vh; max-height: 60dvh; }
    .editor-split .editor-body { max-height: 52vh; max-height: 52dvh; }
    .preview-shell { height: min(70vh, 620px); height: min(70dvh, 620px); }
    .compose.is-inline .editor-body { max-height: 18vh; max-height: 18dvh; }
    .assist-settings { max-height: min(62vh, 620px); max-height: min(62dvh, 620px); }
    .bell-pop { max-height: 70vh; max-height: 70dvh; }
    .jf-panel { max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); }
  }
}

/* ===== tables become cards on phones (js/ui-table.js, js/ui-row-menu.js) ===== */
/* In the utilities layer on purpose: a cell carries utility classes of its own
   (.small, .dim, .num, .truncate) and a row action sits in a .row-end, and a
   layer beats specificity -- these phone rules have to win over them. */
@layer utilities {
  @media (max-width: 640px) {
    .table-wrap:has(> table.data:not([data-mobile="scroll"])),
    .rp-table-wrap:has(> table.data:not([data-mobile="scroll"])) { overflow: visible; }
    /* mobile-cards: a list row is a compact item, not a card with one labelled
       line per column. The heading and its status badge share the first line,
       a cell with nothing in it is dropped (ui-table.js marks it data-empty),
       the remaining values are inline "label: value" pairs that share a line,
       and the row keeps one primary action with the rest behind "⋯"
       (ui-row-menu.js, which reads --ui-mobile-cards below to know these rules
       are in force instead of assuming them). Desktop keeps the table. */
    table.data:not([data-mobile="scroll"]) {
      display: block; min-width: 0; width: 100%;
      --ui-mobile-cards: 1;
    }
    table.data:not([data-mobile="scroll"]) thead {
      position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
      overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    }
    table.data:not([data-mobile="scroll"]) tbody { display: block; }
    table.data:not([data-mobile="scroll"]) tbody tr {
      display: flex; flex-wrap: wrap; align-items: flex-start;
      column-gap: 12px; row-gap: 6px; position: relative;
      padding: 12px 14px; margin-bottom: 10px;
      border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
      box-shadow: var(--shadow-1);
    }
    table.data:not([data-mobile="scroll"]) tbody tr:hover { background: var(--surface); }
    table.data:not([data-mobile="scroll"]) tbody tr.is-selected,
    table.data:not([data-mobile="scroll"]) tbody tr.is-selected:hover {
      background: var(--accent-soft); border-color: var(--accent-edge);
    }
    table.data:not([data-mobile="scroll"]) tbody tr:last-child { margin-bottom: 0; }
    /* An empty state or a skeleton drawn across the whole table is not a card. */
    table.data:not([data-mobile="scroll"]) tbody tr:has(> td[data-cell="span"]) {
      padding: 0; border: 0; background: transparent; box-shadow: none;
    }
    table.data:not([data-mobile="scroll"]) tbody tr td {
      display: inline-flex; align-items: baseline; gap: 4px;
      order: 10; flex: 1 1 calc(50% - 6px); min-width: 130px; max-width: 100%;
      padding: 0; height: auto; border: 0; text-align: left;
      font-size: 13px; line-height: 1.45;
      overflow-wrap: anywhere; white-space: normal;
    }
    /* "label: value": the label a step smaller and dimmer, so a line of these
       reads as facts, not as a form. */
    table.data:not([data-mobile="scroll"]) td[data-label]::before {
      content: attr(data-label) ":";
      flex: none; color: var(--ink-3); font-size: 12px; font-weight: 400;
    }
    table.data:not([data-mobile="scroll"]) td[data-empty] { display: none; }
    table.data:not([data-mobile="scroll"]) td[data-cell="select"] {
      order: 0; flex: none; display: flex; align-items: center; margin: -6px 4px -6px -6px;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="select"]::before { content: none; }
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] {
      display: block; order: 1; flex: 1 1 50%;
      min-width: 0; padding: 0; text-align: left;
      font-size: 14px; font-weight: 600; line-height: 1.35;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="title"]::before { content: none; }
    /* mobile-polish: a contact's card title cell stacks the name, the email,
       the company and up to two address marks -- four or five block lines, each
       about 17px. The email and the company fit on one line ("email · company",
       both truncating), so only the name and the marks keep a line of their
       own. Scoped to a title cell that holds a .contact-email, so no other
       table's heading changes. */
    table.data:not([data-mobile="scroll"]) td[data-cell="title"]:has(> .contact-email) {
      display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] > .contact-name { flex: 1 1 100%; }
    /* flex-basis 0 on the email: with wrap on, two auto-basis lines whose
       contents do not fit would each take a row; a zero basis lets the email
       share the company's line and truncate instead. */
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] > .contact-email { flex: 1 1 0; min-width: 0; }
    /* The company is the secondary field: it may take up to 45% of the line
       and the rest goes to the address (which keeps its full text when it
       fits). */
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] > .contact-email + .small.dim {
      flex: 0 1 auto; min-width: 0; max-width: 45%;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] > .contact-email + .small.dim::before {
      content: "· "; color: var(--ink-3);
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="title"] > .contact-check { flex: 1 1 100%; }
    table.data:not([data-mobile="scroll"]) td[data-cell="badge"] {
      order: 2; flex: none; display: inline-flex; flex-wrap: wrap;
      align-items: center; justify-content: flex-end; gap: 2px 6px;
      margin-left: auto; max-width: 50%; text-align: right;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="badge"]::before { content: none; }
    /* The checkbox keeps its 16px look but gets a 40px target (WCAG 2.5.8). */
    table.data:not([data-mobile="scroll"]) .cell-check-hit {
      display: grid; place-items: center; width: 40px; height: 40px; cursor: pointer;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] {
      order: 20; flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center;
      gap: 6px; margin-top: 2px; padding-top: 6px;
      border-top: 1px solid var(--line); text-align: left;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"]::before { content: none; }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] > .row {
      flex: 1 1 auto; min-width: 0; gap: 6px; justify-content: flex-start;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] [data-menu-hidden] { display: none; }
    /* The "⋯" used to be a faint gray glyph; at the primary action's weight it
       gets that action's tone plus a quiet fill and the hairline, so the two
       read as one pair of row actions. */
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] .cell-more {
      flex: none; width: 40px; height: 40px; margin-left: auto; padding: 0;
      justify-content: center; color: var(--ink);
      background: var(--surface-2); border-color: var(--line);
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] .cell-more:hover,
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"] .cell-more:active { background: var(--surface-3); }
    /* mobile-polish: with one primary action and the "⋯", the pair no longer
       gets a row of its own with a separator above it (that was ~50px on a
       167px contact card). ui-row-menu.js marks that shape with
       data-compact-actions, and the cell moves to the card's bottom right, on
       the same line as the last fact. A cell without that mark -- a row whose
       actions the view drew itself, so nothing is folded into a sheet -- keeps
       the full-width row. */
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"][data-compact-actions] {
      order: 30; flex: 0 0 auto; margin-top: 0; padding-top: 0;
      border-top: 0; align-self: flex-end; margin-left: auto; max-width: 100%;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"][data-compact-actions] > .row {
      flex: 0 1 auto; min-width: 0; gap: 4px; flex-wrap: wrap; justify-content: flex-end;
    }
    /* In the compact pair the buttons are card-sized (>= 36px, 8.10), not the
       stand-alone 40px: the pair rides on the facts line, so its height is the
       card's, not a row's. */
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"][data-compact-actions] > .row > .btn {
      min-height: 36px;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="actions"][data-compact-actions] .cell-more {
      width: 36px; height: 36px; min-height: 36px;
    }
    table.data:not([data-mobile="scroll"]) td[data-cell="span"] {
      display: block; order: 5; flex: 1 1 100%; text-align: left;
    }
    table.data:not([data-mobile="scroll"]) td.span { display: block; text-align: left; }
    /* The "⋯" sheet (ui-row-menu.js): one full-width row per action. */
    .cell-actions { display: flex; flex-direction: column; gap: 2px; }
    .cell-act {
      display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px;
      padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent;
      color: var(--ink); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
    }
    .cell-act:hover { background: var(--surface-2); }
    .cell-act:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
    .cell-act[data-tone="bad"] { color: var(--bad); }
    .cell-act[data-tone="bad"]:hover { background: var(--bad-soft); }
    .cell-act svg { flex: none; }
    .cell-act:disabled { opacity: 0.5; cursor: not-allowed; }
    .cell-act-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
    /* A domain's group header is a heading, not a card. */
    table.data:not([data-mobile="scroll"]) tbody tr.mb-group {
      display: block; padding: 0; margin: 14px 0 8px; border: 0;
      border-radius: var(--r-sm); background: var(--surface-2); box-shadow: none;
    }
    table.data:not([data-mobile="scroll"]) tbody tr.mb-group > th {
      display: block; width: 100%; padding: 4px 8px; border: 0; background: transparent;
    }
    table.data:not([data-mobile="scroll"]) tbody tr.mb-empty { border: 0; box-shadow: none; background: transparent; }
    /* The mailbox list's desktop "⋯"; on a phone ui-row-menu.js draws its own. */
    table.data .btn.mb-more { display: none; }
    table.data[data-mobile="scroll"] :is(th, td):first-child {
      position: sticky; left: 0; background: var(--surface);
    }
    table.data[data-mobile="scroll"] th:first-child { background: var(--surface-2); z-index: 2; }
    table.data[data-mobile="scroll"] td:first-child { z-index: 1; }
  }
}

/* mobile-polish: toasts over an open sheet.
   A bottom sheet or a full-screen drawer covers the bottom of the phone, which
   is exactly where the toast strip sits: a refusal raised from inside 新建模板
   appeared through the sheet's scrim, half transparent and on top of the
   panel's own words. ui.js now hosts the strip in the open dialog (the
   .is-in-overlay class), and the strip moves to the top of the screen, where
   the sheet's pinned actions cannot sit under it. The toast surface is the
   opaque --overlay token in that position, and over a sheet it takes the
   elevated shadow so it lifts off the scrim. */
@layer utilities {
  @media (max-width: 640px) {
    html:has(dialog[open]) .toasts,
    html:has(.ui-sheet) .toasts,
    .toasts.is-in-overlay {
      top: calc(8px + env(safe-area-inset-top, 0px)); bottom: auto;
    }
    /* --overlay is an opaque token (2.6): the strip never shows the sheet
       through it. Over a sheet the toast takes the elevated shadow so it lifts
       off the scrim under it. */
    .toasts .toast { background: var(--overlay); border-radius: var(--r-lg); }
    .toasts.is-in-overlay .toast { box-shadow: var(--shadow-3); }
  }
}

/* ===== phone density: one card layer, two-up stats, compact empties ===== */
@layer components {
  /* mobile-density: a 375px phone leaves ~310px of content inside a card that
     is itself inside a card. These rules drop the wrapper card when its content
     is already cards, fold the KPI tiles into two columns, and let an empty
     state sit on the page instead of in a box. Everything is inside a
     max-width query: the desktop layout is unchanged. */
  @media (max-width: 640px) {
    /* --- a card whose content is cards again: keep the title, drop the box.
       The table below it is already turned into row cards by the block above,
       so the card around it only adds a second border and dead margin. --- */
    /* Scoped to .main: a dialog or drawer card is appended to <body> and must
       stay opaque over the page behind it. */
    .main .card:has(> .table-wrap > table.data:not([data-mobile="scroll"])):not(:has(form, .field, .lib-drop, .grid)),
    .main .card:has(> div > .table-wrap > table.data:not([data-mobile="scroll"])):not(:has(form, .field, .lib-drop, .grid)),
    .main .card:has(> .card-body > .card) {
      border: 0; border-radius: 0; background: transparent;
    }
    .main .card:has(> .card-body > .table-wrap > table.data:not([data-mobile="scroll"])):not(:has(form, .field, .lib-drop, .grid)) > .card-body,
    .main .card:has(> .card-body > .card) > .card-body { padding: 0; }
    /* With the box gone the title starts where the row cards start (the page's
       16px margin), not 16px inside a box that is no longer drawn. */
    .main .card:has(> .table-wrap > table.data:not([data-mobile="scroll"])):not(:has(form, .field, .lib-drop, .grid)) > .card-head,
    .main .card:has(> div > .table-wrap > table.data:not([data-mobile="scroll"])):not(:has(form, .field, .lib-drop, .grid)) > .card-head,
    .main .card:has(> .card-body > .card) > .card-head,
    .main .card:has(> .empty) > .card-head,
    .main .card:has(> .card-body > .empty) > .card-head { padding-left: 0; padding-right: 0; }

    /* The sending-domain summary row card and the detail card under it say the
       same thing. The detail card is the fuller one, so the row is hidden while
       it is open (sending.js sets .is-open); the other rows stay as switchers. */
    /* [data-domain-id] is there to outrank the row-card rule above, which is
       more specific than a plain `.is-open`. */
    .sending-domains tbody tr.is-open[data-domain-id] { display: none; }

    /* --- KPI tiles: two per row, so four metrics fit one screen instead of
       one and a half. The number keeps the 23px step and the label the 11.5px
       one; a change note that does not fit is ellipsised rather than wrapped. */
    .grid:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .grid:has(> .stat) > .stat {
      padding: 14px; gap: 3px; min-height: 82px; align-content: start;
      border-radius: var(--r-lg); box-shadow: var(--shadow-1);
    }
    /* A stat tile built as card > card-body (migration result) keeps one
       padding, not two. A note that sits in the same grid spans both columns. */
    .grid:has(> .stat) > .stat > .card-body { padding: 0; }
    .grid:has(> .stat) > :not(.stat) { grid-column: 1 / -1; }
    .stat .label { font-size: 12px; line-height: 1.25; }
    .stat .value { font-size: 24px; line-height: 1.2; }
    .stat .delta { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    /* Campaign detail: the five-tile strip already folds into two columns by
       its own container query; just take the desktop padding out of it. */
    .metric-strip .stat { padding: 12px 14px; }

    /* --- overview: phone sizes. */
    .ov-hello { font-size: 24px; }
    .ov-metric-value { font-size: 28px; }

    /* --- empty states: the message, not the box. The icon block, title, note
       and action stay; the wrapper card's border and background go, and the
       action is a full-width 44px target. */
    .main .card:has(> .empty),
    .main .card:has(> .card-body > .empty) { border: 0; border-radius: 0; background: transparent; }
    .main .card:has(> .card-body > .empty) > .card-body { padding: 0; }
    .empty { padding: 28px 16px; gap: 8px; }
    .empty .icon { width: 36px; height: 36px; }
    .empty > .btn { width: 100%; max-width: 320px; min-height: 44px; }
    .empty .row .btn { min-height: 44px; }
  }

  /* The narrowest phones: same two columns, less padding so the 23px value
     still fits. 480px is the existing small breakpoint; the intent is ≤360px. */
  @media (max-width: 480px) {
    .grid:has(> .stat) > .stat { padding: 10px; }
    .empty { padding: 24px 12px; }
  }
}

/* ===== touch polish: field text size, tap feedback ===== */
@layer utilities {
  /* iOS Safari zooms the page when a field under 16px is focused. This lives in
     the utilities layer, not components: `.select` and `.textarea` (13px) are
     class rules, and inside one layer they beat a bare `select` / `textarea`
     selector, which left those two at 13px on phones while `.input` got 16px.
     A later layer wins whatever the specificity. */
  @media (max-width: 640px), (pointer: coarse) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]), select, textarea, .ui-listbox-search, .ui-color-hex { font-size: 16px; }
  }
  /* mobile-ios: a contenteditable under 16px makes iOS Safari zoom the page the
     moment the caret enters it, exactly like an input -- the composer's body
     editor (.editor-body, 13px) is the one that matters. Scoped to a phone
     width: on a touch laptop the editor keeps its desktop size. */
  @media (max-width: 640px) {
    [contenteditable="true"] { font-size: 16px; }
  }
}
@layer components {
  @media (pointer: coarse) {
    a, button, [role=button], [role=tab], [role=option], [role=menuitem], [role=switch], .side-link, summary, label {
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    .btn:not(:disabled):not(.btn-danger):active, .side-link:active, .tab:active, .link-btn:active { background: var(--surface-3); }
    .btn-primary:active { background: var(--primary-hover); }
    button, .btn, .side-link, .tab { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  }
  @media (max-width: 640px), (pointer: coarse) {
    .side-switch-btn { width: 40px; height: 40px; min-height: 40px; }
    .side-switch .side-tenant { padding-right: 48px; }
    .side-menu-item { min-height: 40px; }
    .side-menu { max-height: min(60dvh, 320px); overflow-y: auto; }
  }
}
@layer base {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { overscroll-behavior-y: none; }
}

/* ===== mobile sheets (js/ui-pop.js openSheet) ===== */
@layer components {
  html.ui-sheet-open { overflow: hidden; }
  /* mobile-ios: below 961px the page scrolls inside .main, not <html>, so
     locking <html> alone leaves the page behind an open sheet, dialog or
     full-screen drawer free to scroll (a touch drag chains into it). The
     scroll position of .main is kept while overflow is hidden. */
  @media (max-width: 960px) {
    html.ui-sheet-open .main,
    html:has(dialog.modal[open]) .main,
    html:has(dialog.drawer[open]) .main { overflow: hidden; }
  }
  .ui-sheet {
    position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
    margin: 0; padding: 0; border: 0; overflow: hidden;
    display: flex; flex-direction: column; justify-content: flex-end;
    background: var(--scrim); color: var(--ink); z-index: 1000;
    animation: ui-sheet-fade var(--dur) var(--ease);
  }
  .ui-sheet-panel {
    display: flex; flex-direction: column; width: 100%;
    max-height: 85vh; max-height: 85dvh;
    padding-bottom: env(safe-area-inset-bottom);
    /* mobile-ios: on a phone held sideways the notch covers a side edge; the
       panel keeps its full-width background and insets what sits in it. Both
       insets are 0 in portrait, so nothing moves there. */
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    background: var(--overlay); color: var(--ink);
    border-top: 1px solid var(--line-strong);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-3); outline: none; font-size: 14px;
    animation: ui-sheet-up var(--dur) var(--ease);
  }
  @keyframes ui-sheet-up { from { transform: translateY(100%); } }
  @keyframes ui-sheet-fade { from { opacity: 0; } }
  /* mobile-keyboard: `[data-kb]` is set by fitSheetToKeyboard while the phone
     keyboard is up (js/ui-pop.js, js/ui.js). The home indicator is behind the
     keyboard then, so the 34px it reserves at the bottom of the panel is dead
     space between the last row and the keys. */
  .ui-sheet[data-kb] .ui-sheet-panel { padding-bottom: 8px; }
  .ui-sheet-grip { flex: none; width: 36px; height: 4px; margin: 8px auto 0; border-radius: var(--r-full); background: var(--line-strong); position: relative; touch-action: none; }
  /* mobile-sheet: the visible grip is 4px tall; ::after stretches its hit area
     to ~32px so a thumb can start the pull-to-close gesture on it too (the
     head is the main handle). */
  .ui-sheet-grip::after { content: ""; position: absolute; inset: -14px -60px; }
  .ui-sheet-head { flex: none; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 6px 0 16px; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .ui-sheet-title { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ui-sheet-close {
    flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: var(--r-full); background: transparent; color: var(--ink-3); cursor: pointer;
  }
  .ui-sheet-close:hover { color: var(--ink); }
  .ui-sheet-close:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .ui-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 12px; }
  /* The picker's own box (popover chrome) is dropped inside a sheet. */
  .is-in-sheet.ui-listbox-pop, .is-in-sheet.ui-date-pop, .is-in-sheet.ui-color-pop, .is-in-sheet.bell-pop {
    position: relative; width: auto; min-width: 0; max-width: none; margin: 0; padding: 0;
    border: 0; border-radius: 0; box-shadow: none; background: transparent;
    animation: none; overflow: visible;
  }
  .is-in-sheet.bell-pop .bell-head strong { display: none; }
  .is-in-sheet.bell-pop .bell-head { justify-content: flex-end; padding-top: 0; }
  .is-in-sheet.ui-listbox-pop { max-height: calc(85vh - 96px); max-height: calc(85dvh - 96px); overflow: hidden; }
  .is-in-sheet .ui-listbox-searchbar { padding: 4px 0 8px; border-bottom: 0; }
  .is-in-sheet .ui-listbox-search { min-height: 44px; font-size: 16px; }
  .is-in-sheet .ui-option { min-height: 44px; padding: 8px 10px 8px 6px; font-size: 16px; }
  .is-in-sheet.ui-date-pop, .is-in-sheet.ui-color-pop { max-width: 420px; margin: 0 auto; }
  .is-in-sheet .ui-cal-day { height: 40px; }
  .is-in-sheet .ui-cal-month { height: 44px; }
  .is-in-sheet .ui-date-nav { min-width: 40px; min-height: 40px; }
  .is-in-sheet .ui-time-opt { min-height: 44px; }
  .is-in-sheet.ui-date-time .ui-time-col { width: 100%; }
  .is-in-sheet.ui-date-time .ui-time { max-height: 40vh; max-height: 40dvh; }
  .is-in-sheet.ui-date-datetime-local .ui-date-body { flex-direction: column; }
  .is-in-sheet.ui-date-datetime-local .ui-cal { width: 100%; max-width: 340px; margin: 0 auto; }
  .is-in-sheet.ui-date-datetime-local .ui-time-col { width: 100%; max-height: 132px; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
  .is-in-sheet.ui-date-datetime-local .ui-time { height: auto; max-height: 120px; }
  .is-in-sheet .ui-date-foot .btn { min-height: 40px; }
  .is-in-sheet .ui-color-area { height: 180px; }
  .is-in-sheet .ui-color-hue { height: 20px; }
  .is-in-sheet .ui-color-hex { min-height: 44px; font-size: 16px; }
  /* Suggestions stay anchored under the field on a phone; only the rows grow. */
  .ui-suggest-pop.is-touch .ui-option { min-height: 44px; font-size: 16px; }
  @media (prefers-reduced-motion: reduce) {
    .ui-sheet, .ui-sheet-panel { animation: none; }
  }
}

/* ===== page header action row (js/ui-topbar.js) ===== */
/* ui-topbar.js gathers a header's loose buttons into .topbar-actions[data-auto].
   Wider than a phone the wrapper is display: contents, so the desktop header is
   laid out exactly as before; on a phone the phone-layout block above makes
   .topbar-actions one scrollable row, and the order here puts the title row
   (menu, title, bell) first, then the actions, then the section tabs. */
@layer components {
  @media (max-width: 640px) {
    /* A card cell is a flex row; its content must be allowed to shrink, or a
       long name pushes the card past the screen instead of truncating. */
    table.data:not([data-mobile="scroll"]) td > * { min-width: 0; max-width: 100%; }
  }
  @media (max-width: 640px) and (pointer: coarse) {
    /* mobile-touch: a link inside a card (a tenant or customer name) gets a
       36px target, and two links side by side keep 8px apart so a thumb does
       not hit the wrong one. The card's own structure is untouched. */
    table.data:not([data-mobile="scroll"]) td a:not(.btn) {
      display: inline-flex; align-items: center; min-height: 36px;
    }
    table.data:not([data-mobile="scroll"]) td a:not(.btn) + a:not(.btn) { margin-left: 8px; }
  }
  @media (min-width: 641px) {
    .topbar-actions[data-auto] { display: contents; }
  }
  @media (max-width: 640px) {
    .topbar { flex-wrap: wrap; }
    .topbar > .menu-btn { order: 0; }
    .topbar > .grow { order: 1; }
    .topbar > .bell, .topbar > .btn-icon:not(.menu-btn) { order: 2; }
    .topbar > .topbar-actions { order: 5; display: flex; }
    .topbar > .section-tabs, .topbar > .tabs { order: 6; flex: 0 0 100%; }
    /* The email-verification banner keeps its heading, the "sent to" line and
       the resend button; the explanation sentence is dropped on a phone. */
    .verify-banner .grow > .dim { display: none; }
  }
}

/* ====================== static styles taken out of view scripts (2026-11) == */
@layer components {
  .brand-logo-img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
  .input-narrow { width: 7rem; }
  .kv-label { width: 8em; }
  .day-label { width: 3.5em; }
  .logo-preview {
    max-height: 48px; max-width: 160px; padding: 4px;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  }
  .approval-preview {
    width: 100%; height: 320px;
    border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  }
  .signup-bars { display: flex; gap: 2px; align-items: flex-end; height: 60px; }
  .signup-bar { flex: 1 1 0; min-width: 2px; background: var(--accent); border-radius: calc(var(--r-xs) / 2); }
}
@layer utilities {
  .pre-wrap { white-space: pre-wrap; }
  .break-all { word-break: break-all; }
  .logo-box { gap: 12px; }
}

/* ===== mobile integration fixes ===== */
/* These sit in the utilities layer because `.stack-sm` / `.grid` (utilities)
   would otherwise beat the component-layer rules that fold the card. */
@layer utilities {
  @media (max-width: 640px) {
    /* Empty placeholder rows (banner slots) still cost a 16px grid gap each. */
    .content > :empty { display: none; }
    /* The open domain's summary row card: the table-card rules live in this layer
       now, so the density rule that hides it has to as well. */
    .sending-domains tbody tr.is-open[data-domain-id] { display: none; }
  }
}

/* ===== mobile-inbox: the inbox list, reader and composer on a phone ===== */
/* The list is a dense mail list, not a card of cards: the tick box belongs to
   selection mode, the star keeps a column of its own, and the reader puts its
   actions in a bar at the bottom instead of four rows under the subject. The
   rules live in the utilities layer because `.stack-sm` / `.row` / `.small`
   (utilities) would otherwise beat a component-layer rule of the same shape. */
@layer utilities {
  /* Hidden until a phone shows them. */
  .inbox-select-btn,
  .inbox-read-more,
  .inbox-side-toggle,
  .inbox-actionbar,
  .compose-tools,
  .compose-options-btn { display: none; }

  @media (max-width: 640px) {
    /* --- the page, not a card inside the page (guidelines 8.10) --------- */
    .inbox-content { padding-left: 16px; padding-right: 16px; }
    .inbox { border: 0; border-radius: 0; background: transparent; min-height: 0; }
    .inbox > * { background: transparent; }

    /* --- list head: one 40px row ---------------------------------------- */
    .inbox-list-head {
      gap: 4px; padding: 2px 0 4px; border-bottom: 0;
    }
    .inbox-list-head .grow { font-size: 16px; }
    .inbox-head-count { font-size: 12px; }
    .inbox-select-btn { display: inline-flex; }
    /* The 10.5px filter pills were 36px; the phone floor is 40 (guidelines 8.10). */
    .inbox-filter { min-height: 40px; }

    /* --- search: one row, then one scrolling row of chips --------------- */
    .inbox-search { gap: 6px; padding: 2px 0 6px; border-bottom: 0; }
    .inbox-search-input { min-height: 40px; }
    .inbox-search-flags {
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      scrollbar-width: none;
    }
    .inbox-search-flags::-webkit-scrollbar { display: none; }
    .inbox-search-flags > * { flex: none; }
    .inbox-search-meta { padding-bottom: 6px; }

    /* --- the rows: 头像 | 发件人+时间 / 主题 / 摘要, ≤ 76px ------------ */
    .inbox-rows { max-height: none; }
    .msg-row { gap: 9px; padding: 7px 10px 8px; }
    /* mobile-ios: a long press on a row is the selection gesture (inbox.js
       bindLongPress). Without these iOS raises its callout, magnifier and text
       selection on top of it. The row only -- the reader's body keeps its own
       selection so a message can still be copied. */
    .msg-row {
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      user-select: none;
    }
    .msg-row .avatar { width: 30px; height: 30px; margin-top: 0; font-size: 12px; }
    /* Three lines inside 76px: the row's own leading, not the body's 1.55. */
    .msg-main { gap: 1px; line-height: 1.4; }
    .msg-top { gap: 6px; }
    .msg-from { font-size: 13px; }
    .msg-subject { font-size: 13px; }
    .msg-preview { font-size: 13px; }
    /* The star keeps a right-hand column of its own: 40px of tap area, the
       icon unchanged (guidelines 8.10), vertically centred on the row. */
    .msg-row-wrap .msg-row { padding-right: 44px; }
    .msg-row-star {
      position: absolute; right: 2px; top: 50%; margin-top: -20px;
      width: 40px; height: 40px; transform: none;
    }
    /* 40px is the floor already, so the coarse-pointer -8px halo would only
       steal taps from the subject underneath. */
    .msg-row-star::after, .msg-row-wrap .msg-check::after { content: none; }
    /* The tick box only exists in 选择 mode; without it the row uses the full
       width (the 34px indent was what pushed the star onto its own line). */
    .msg-row-wrap .msg-check { display: none; }
    .msg-row-wrap.has-check .msg-row { padding-left: 12px; }
    .msg-row-wrap.has-check .msg-row[data-unread]::after { left: 3px; }
    .inbox[data-select-mode] .msg-row-wrap .msg-check {
      display: inline-flex; left: 0; top: 0; bottom: 0; width: 40px; height: auto;
    }
    .inbox[data-select-mode] .msg-row-wrap.has-check .msg-row { padding-left: 48px; }
    .inbox[data-select-mode] .msg-row-wrap.has-check .msg-row[data-unread]::after { left: 41px; }
    .inbox:not([data-select-mode]) .inbox-bulk { display: none; }

    /* The bulk strip: one scrolling action row, no second line of note. */
    .inbox-bulk:not(.is-active) { gap: 4px 8px; padding: 6px 0 8px; border-bottom: 0; background: transparent; }
    /* With rows ticked, the capsule floats above the tab bar (and the home
       indicator) instead of sitting in the list's flow. */
    .inbox-bulk.is-active {
      position: fixed; left: 50%; right: auto; transform: translateX(-50%);
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px) + 12px);
      z-index: 40; width: calc(100vw - 24px); max-width: 480px; flex-wrap: wrap;
      padding: 6px 8px;
    }
    .inbox-bulk.is-active .inbox-bulk-actions { justify-content: flex-start; flex: 1 1 100%; min-width: 0; }
    /* Line 1: the count with ⋯ and ✕ at its end; then the actions and the
       team's buttons, each one scrolling line. */
    .inbox-bulk-end { order: 0; margin-left: auto; }
    .inbox-bulk.is-active .inbox-bulk-actions, .inbox-bulk.is-active .collab-bulk { order: 1; }
    .inbox-bulk.is-active .collab-bulk {
      flex: 1 1 100%; min-width: 0; margin-left: 0;
      flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    }
    .inbox-list-body:has(.inbox-bulk.is-active) .inbox-rows { padding-bottom: 120px; }
    .inbox-bulk-actions {
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      gap: 4px; padding-bottom: 2px; scrollbar-width: none;
    }
    .inbox-bulk-actions::-webkit-scrollbar { display: none; }
    .inbox-bulk-actions > * { flex: none; }
    .inbox-bulk-note { display: none; }
    .inbox-pager { padding: 8px 0; border-top: 0; }

    /* --- reader: back + subject + ⋯ on one line ------------------------- */
    .inbox-read { padding-bottom: 68px; }
    .inbox-read-head {
      position: sticky; top: 0; z-index: 3; background: var(--surface);
      display: grid; column-gap: 2px; row-gap: 6px;
      padding: 4px 0 6px; border-bottom: 0;
      grid-template-columns: 40px minmax(0, 1fr);
    }
    .inbox-read-head > * { grid-column: 1 / -1; }
    .inbox-read-head > .inbox-back { grid-column: 1; grid-row: 1; justify-self: start; }
    .inbox-read-head > .msg-title {
      grid-column: 2; grid-row: 1; align-self: center;
      font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .inbox-read-head > .inbox-read-more { display: none; }
    .inbox-read-head > .inbox-head-actions { display: none; }
    /* The facts under the sender are one line each, ellipsised rather than
       wrapped: three lines of "收件人：…" is what pushed the body down. */
    .inbox-read-head .small.dim,
    .inbox-read-lead .small.dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .inbox-read-lead { padding: 0; }
    .inbox-side-toggle {
      display: flex; align-items: center; gap: 6px; width: 100%; min-height: 40px;
      padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
      background: var(--surface-2); color: var(--ink-2); font-size: 13px; text-align: left;
      cursor: pointer;
    }
    .inbox-side-toggle .inbox-side-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .inbox-side-toggle svg { flex: none; color: var(--ink-3); }
    .inbox-side-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
    .inbox-read .thread { padding: 10px 0 16px; gap: 10px; }
    .inbox-read .mail-text { padding: 14px 0; }
    .inbox-read .image-bar { padding: 7px 0; }
    .inbox-read .attach-list { gap: 6px; }

    /* --- the fixed action bar, above the tab bar ------------------------ */
    .inbox-actionbar {
      display: flex; align-items: stretch;
      position: fixed; left: 0; right: 0;
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px));
      z-index: 40; padding: 4px 6px;
      /* mobile-ios: landscape puts the notch on a side; the bar's first and
         last buttons stay out of it. */
      padding-left: calc(6px + env(safe-area-inset-left, 0px));
      padding-right: calc(6px + env(safe-area-inset-right, 0px));
      background: var(--overlay);
      border-top: 1px solid var(--line); box-shadow: var(--shadow-2);
    }
    .inbox-act {
      flex: 1 1 0; min-width: 0; display: grid; justify-items: center; align-content: center;
      gap: 2px; min-height: 48px; padding: 4px 2px; border: 0; border-radius: var(--r-sm);
      background: transparent; color: var(--ink-2); font-size: 12px; cursor: pointer;
    }
    .inbox-act:active { background: var(--surface-3); }
    .inbox-act:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
    .inbox-act.is-primary { color: var(--accent-strong); }
    .inbox-act-label { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .inbox-act-more { flex: 0 0 56px; }

    /* --- compose / reply: a full-screen sheet --------------------------- */
    .compose, .compose.is-inline {
      position: fixed; inset: 0; z-index: 80;
      display: flex; flex-direction: column; gap: 0;
      /* mobile-ios: vh first (iOS < 15.4 has no dvh, and an invalid var()
         fallback would drop the whole height). --compose-h and --compose-top
         come from visualViewport in js/views/inbox.js. */
      top: var(--compose-top, 0px);
      height: var(--compose-h, 100vh); max-height: var(--compose-h, 100vh);
      height: var(--compose-h, 100dvh); max-height: var(--compose-h, 100dvh);
      /* mobile-ios: the notch sits on the left or right in landscape; the
         composer's own rows are inset so no button hides under it. */
      padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
      border: 0; border-radius: 0; background: var(--surface);
      overflow-y: auto; overscroll-behavior: contain;
    }
    /* Nothing shrinks: a tall message body scrolls the sheet instead of
       squeezing the editor. The send row is pushed to the bottom when the
       content is short and pinned there (sticky) when it scrolls. */
    .compose > *, .compose.is-inline > * { flex: none; }
    .inbox-read:has(.compose) { overflow: visible; }
    .compose > .row:first-child,
    .compose.is-inline > .row:first-child {
      position: sticky; top: 0; z-index: 2;
      padding: calc(6px + env(safe-area-inset-top, 0px)) 14px 6px;
      background: var(--surface); border-bottom: 1px solid var(--line);
    }
    .compose > .row:first-child h2 { font-size: 16px; }
    .compose > .small, .compose.is-inline > .small { padding: 6px 14px 0; font-size: 12px; }
    .compose .field, .compose.is-inline > .field { padding: 8px 14px 0; }
    .compose .editor { border-radius: var(--r-md); }
    .compose .editor-body, .compose.is-inline .editor-body {
      flex: 1 1 0; min-height: 160px; max-height: none;
    }
    /* The formatting toolbar: one row that scrolls sideways, 40px targets. */
    .compose .editor-bar {
      flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
      scrollbar-width: none; padding: 5px;
    }
    .compose .editor-bar::-webkit-scrollbar { display: none; }
    .compose .editor-btn { flex: none; width: 40px; height: 40px; }
    .compose .editor-select { flex: none; height: 40px; font-size: 16px; }
    .compose .editor-sep { flex: none; }
    .compose .editor-bar > .grow { flex: none; }
    /* Signature / tracking / reminder live in the 选项 sheet on a phone. */
    .compose-options { display: none; }
    .compose-tools { display: flex; justify-content: space-between; gap: 8px; padding: 6px 14px 0; }
    /* Cc/Bcc open from the 抄送/密送 button beside 选项 (js/views/inbox.js). */
    .compose .field.compose-optional { display: none; }
    .compose[data-cc-open] .field.compose-optional { display: grid; }
    .compose-options-btn { display: inline-flex; }
    .compose-options-sheet { display: grid; gap: 12px; }
    .compose-options-sheet .compose-options { display: flex; }
    .compose-options-sheet .compose-option,
    .compose-options-sheet .compose-track { flex-wrap: wrap; }
    .compose > .hint, .compose.is-inline > .hint {
      padding: 6px 14px 0; font-size: 12px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .compose > .row:last-child, .compose.is-inline > .row:last-child {
      position: sticky; bottom: 0; z-index: 2; margin-top: auto;
      display: flex; flex-wrap: nowrap; justify-content: stretch; gap: 6px;
      padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
      border-top: 1px solid var(--line); background: var(--surface);
    }
    .compose > .row:last-child > .btn,
    .compose.is-inline > .row:last-child > .btn,
    .compose > .row:last-child > .canned-anchor,
    .compose.is-inline > .row:last-child > .canned-anchor { flex: 1 1 0; min-width: 0; justify-content: center; font-size: 13px; }
    .compose > .row:last-child > .canned-anchor > .btn,
    .compose.is-inline > .row:last-child > .canned-anchor > .btn { width: 100%; min-width: 0; justify-content: center; font-size: 13px; }
    .compose > .row:last-child > .btn-primary,
    .compose.is-inline > .row:last-child > .btn-primary { flex: 1.4 1 0; }
  }
}

/* === Wave 2A: Inbox & Mail Mobile === */
@layer components {
  /* 1. HTML Mail iframe & zero vertical double scroll traps */
  .mail-frame,
  .inbox-read .mail-frame {
    min-height: 0;
  }

  /* 2. Floating Compose FAB (<=640px) */
  .inbox-fab {
    display: none;
  }
  @media (max-width: 640px) {
    .inbox[data-pane="list"] .inbox-fab {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      position: fixed;
      right: 16px;
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px) + 16px);
      z-index: 40;
      min-width: 48px;
      height: 48px;
      padding: 0 16px;
      gap: 8px;
      border: 0;
      border-radius: 999px;
      background: var(--accent);
      color: var(--accent-ink);
      box-shadow: var(--shadow-2);
      font-size: 14px;
      font-weight: 550;
      cursor: pointer;
    }
    .inbox[data-pane="list"] .inbox-fab:active {
      transform: scale(0.96);
    }
  }

  /* 3. Mobile list header, search bar, active mailbox subtitle & sheet */
  .inbox-mobile-only {
    display: none;
  }
  .inbox-scope-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 0 4px;
    cursor: pointer;
    border-radius: var(--r-sm);
  }
  .inbox-scope-btn:hover,
  .inbox-scope-btn:focus-visible {
    background: var(--surface-3);
  }
  .inbox-head-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    padding: 0 4px;
  }
  .inbox-head-title-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    max-width: 100%;
  }
  .inbox-head-sub {
    font-size: 12px;
    color: var(--ink-3);
    line-height: 1.2;
    max-width: 100%;
  }
  .inbox-scope-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex: none;
  }
  .inbox-scope-caret {
    color: var(--ink-3);
    flex: none;
    display: inline-flex;
    align-items: center;
  }
  .inbox-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
  }

  @media (max-width: 640px) {
    .inbox-mobile-only {
      display: inline-flex;
    }
    .inbox-desktop-only {
      display: none;
    }
    .inbox-list-head {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 4px 0 6px;
    }
    .inbox-head-sheet {
      display: flex;
      flex-direction: column;
      gap: 4px;
      padding: 4px 0;
    }
    .inbox-head-sheet-item {
      display: flex;
      align-items: center;
      gap: 10px;
      min-height: 44px;
      padding: 8px 12px;
      border: 0;
      border-radius: var(--r-sm);
      background: transparent;
      color: var(--ink);
      font-size: 14px;
      text-align: left;
      cursor: pointer;
      width: 100%;
    }
    .inbox-head-sheet-item:hover,
    .inbox-head-sheet-item:focus-visible {
      background: var(--surface-3);
    }
    .inbox-head-sheet-item[data-tone="bad"] {
      color: var(--bad);
    }
    .inbox-head-sheet-item[data-tone="bad"]:hover {
      background: var(--bad-soft);
    }
    .inbox-viewbar {
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 4px 0 8px;
    }
    .inbox-viewbar > .inbox-search-flags {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: nowrap;
      overflow-x: auto;
      scrollbar-width: none;
    }
  }

  /* 4. Immersive Reading View & History Stack (<=640px) */
  .inbox-read-subject {
    display: none;
  }
  @media (max-width: 640px) {
    body.inbox-reading .tabbar,
    body.inbox-reading .topbar {
      display: none;
    }
    body.inbox-reading .inbox-actionbar {
      bottom: 0;
      padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }
    .inbox-read-subject {
      display: block;
      margin: 8px 0 12px;
      font-size: 18px;
      font-weight: 600;
      line-height: 1.35;
      color: var(--ink);
      word-break: break-word;
    }
  }

  /* 5. Message Rows & Swipe Quick Actions (<=640px) */
  @media (max-width: 640px) {
    .msg-row-wrap {
      overflow: hidden;
      position: relative;
    }
    .msg-row {
      transform: translateX(var(--swipe-x, 0px));
      transition: transform 0.15s ease-out;
      will-change: transform;
    }
    .msg-row.is-swiping {
      transition: none;
    }
    .msg-foot {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
      min-width: 0;
      width: 100%;
    }
    .msg-foot > .msg-preview {
      width: 100%;
      white-space: normal;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      line-height: 1.4;
      font-size: 13px;
    }
    .msg-foot > .msg-tags {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 4px;
      max-width: 100%;
    }
    .msg-foot > .msg-tags:empty {
      display: none;
    }
  }

  /* 6. Compose View, Canned Replies, Collab & Reply Assist */
  .compose-orig {
    padding: 8px 14px 4px;
    border-bottom: 1px solid var(--line);
  }
  .compose-orig-sum {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
  }
  .compose-orig-body {
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .compose-orig-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
  }
  .compose-orig-content {
    max-height: 120px;
    overflow-y: auto;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.4;
  }
  @media (max-width: 640px) {
    .assist-settings {
      max-height: none;
      overflow-y: visible;
      padding-right: 0;
    }
  }

  /* 7. Tablet (641px–960px) polish */
  @media (min-width: 641px) and (max-width: 960px) {
    .inbox-read-head {
      top: 57px;
    }
  }
  @media (max-width: 960px) {
    .inbox-bulk.is-active {
      position: fixed;
      left: 50%;
      right: auto;
      transform: translateX(-50%);
      bottom: calc(var(--tabbar-lift, 0px) + env(safe-area-inset-bottom, 0px) + 12px);
      z-index: 40;
      width: calc(100vw - 24px);
      max-width: 480px;
      flex-wrap: wrap;
      padding: 6px 8px;
    }
  }

  /* 8. Mailboxes, Rules, Setup & Aliases Mobile Polish */
  .mb-date-field {
    flex: 1 1 200px;
  }
  .mb-sig {
    flex-wrap: wrap;
  }
  @media (max-width: 640px) {
    .filter-cond-row,
    .filter-act-row {
      flex-wrap: wrap;
      gap: 6px;
    }
    .alias-adder {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      align-items: center;
    }
    .alias-adder > input,
    .alias-adder > select {
      flex: 1 1 140px;
      min-width: 0;
    }
    .alias-adder > button {
      flex: 0 0 100%;
    }
    .setup-clients.segmented {
      flex-wrap: nowrap;
      overflow-x: auto;
      overscroll-behavior-x: contain;
      scrollbar-width: none;
      max-width: 100%;
      padding: 2px;
    }
    .setup-clients.segmented::-webkit-scrollbar {
      display: none;
    }
    .setup-clients.segmented > * {
      flex: none;
      white-space: nowrap;
    }
    .conn-row {
      grid-template-columns: minmax(0, 1fr) auto;
      row-gap: 2px;
    }
    .conn-row .label {
      grid-column: 1 / -1;
    }
  }
  @media (max-width: 480px) {
    .conn-row {
      grid-template-columns: 1fr;
      row-gap: 4px;
    }
    .conn-row .btn,
    .conn-row button {
      justify-self: start;
    }
  }
}

/* mobile-editor: on a phone the formatting toolbar is one scrolling row, so the
   colour palettes open in a bottom sheet instead of a popover it would clip
   (js/editor.js colorMenu). */
@layer utilities {
  @media (max-width: 640px) {
    .editor-swatches {
      display: grid; grid-template-columns: repeat(6, 40px); gap: 10px;
      justify-content: start; padding: 4px 0 8px;
    }
    .editor-swatches .editor-swatch { width: 40px; height: 40px; }
  }
}

/* mobile-quota: mobile-headers hides every page subtitle on a phone, which was
   right for a sentence but wrong for the few subtitles that carry live data --
   the campaign send budget, the contact/list counts and a journey's trigger,
   live version and save state. Those pages write the same value to one compact
   line at the top of the content (the header copy is what a screen reader
   reads, so the phone line is aria-hidden). Spacing and type match the phone
   content margin (16px); the quota pages raise it to --warn from 80% used and
   --bad once it is used up, the same levels as the usage card (.usage-warm /
   .usage-hot). */
@layer components {
  .topbar-sub-mobile { display: none; }
  @media (max-width: 640px) {
    .topbar-sub-mobile:not(:empty) {
      display: block;
      padding: 8px 16px 0;
      font-size: 12px; line-height: 1.4;
      color: var(--ink-3);
      overflow-wrap: anywhere;
    }
  }

  @media (max-width: 640px) {
    .inbox-scope-static {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      min-width: 0;
      padding: 0 4px;
    }
    .inbox-search:not(.is-expanded) { display: none; }
    .inbox-search.is-expanded { display: grid; }
    .inbox-search[hidden] { display: none; }
  }
}
