/* Matrix site typography (Anna, 2026-11-16, 「Matrix UI 优化」).

   The one source of truth for type on every Matrix page: font stacks, the size
   tiers, weights and line heights, and which tier each kind of text uses. Loaded
   LAST in index.html and by the signed-out pages, so a component sheet never needs
   its own font-size: use a token below, or let the role rule here decide.

   Tiers (px / line height). Same-level text uses the same tier everywhere:
     micro    11 / 16  counts and tiny badges only (never a label you must read)
     caption  12 / 18  hints, meta, chips and tags, table headers, small buttons
     control  13 / 20  buttons, tabs, menus, tree and list rows, inputs, table cells,
                       navigation — the default size of the product UI
     body     14 / 22  prose and settings rows
     section  16 / 24  section and dialog titles
     heading  18 / 26  panel headings (新任务)
     figure   20 / 28  big numbers on stat cards
     title    22 / 30  the page title
   Weights: 400 regular, 500 medium (controls), 600 semibold (titles, the selected
   tab, figures, emphasis); 700 only for the brand mark.

   Font stack for Chinese, English and mixed lines: the platform Latin face first,
   then the platform CJK face, so Latin letters and digits never take the CJK
   face's wide forms and Chinese never falls back to a serif.

   Why `:is(html, #mx-type)`: the component sheets this layer replaces carry
   selectors up to three classes deep (`.task-page--spa .task-workspace-panel >
   header .mx-btn`). An id inside :is() lifts every rule here above them without
   !important; `#mx-type` matches nothing, `html` is what actually matches. */

:root {
  --mx-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei",
    "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --mx-font-mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono",
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", monospace;

  --mx-text-micro: 11px;   --mx-lh-micro: 16px;
  --mx-text-caption: 12px; --mx-lh-caption: 18px;
  --mx-text-control: 13px; --mx-lh-control: 20px;
  --mx-text-body: 14px;    --mx-lh-body: 22px;
  --mx-text-section: 16px; --mx-lh-section: 24px;
  --mx-text-heading: 18px; --mx-lh-heading: 26px;
  --mx-text-figure: 20px;  --mx-lh-figure: 28px;
  --mx-text-title: 22px;   --mx-lh-title: 30px;

  --mx-weight-regular: 400;
  --mx-weight-medium: 500;
  --mx-weight-semibold: 600;
  --mx-weight-bold: 700;

  /* The older per-sheet names resolve to the same faces. */
  --font: var(--mx-font-sans);
  --sans: var(--mx-font-sans);
  --font-mono: var(--mx-font-mono);
}
/* tokens.css / components.css declare --mx-sans / --mx-mono on .mx-next. */
:is(html, #mx-type) .mx-next { --mx-sans: var(--mx-font-sans); --mx-mono: var(--mx-font-mono); }
:is(html, #mx-type) :is(#agent-chat-mount, .assistant-side-dock, .ca-root) { --font: var(--mx-font-sans); }

/* ---- Base ------------------------------------------------------------------ */
:is(html, #mx-type) body { font-family: var(--mx-font-sans); }
:is(html, #mx-type) .mx-next {
  font-family: var(--mx-font-sans);
  font-size: var(--mx-text-control);
  line-height: var(--mx-lh-control);
}
:is(html, #mx-type) body :is(button, input, select, textarea, summary):not(.mx-mono) { font-family: var(--mx-font-sans); }
:is(html, #mx-type) body :is(code, kbd, pre, samp, .mx-mono) { font-family: var(--mx-font-mono); }

/* ---- Page, section and panel titles ------------------------------------------ */
:is(html, #mx-type) body :is(.mx-page h1, .mx-auth__title, .page h1) {
  font-size: var(--mx-text-title); line-height: var(--mx-lh-title); font-weight: var(--mx-weight-semibold);
}
/* A page's own heading under the page title (Settings › 设备与 Hand) and the
   创建区's 新任务: heading tier (one class more than the section rule below). */
:is(html, #mx-type) body :is(.mx-create-area__title, .mx-page h2.settings-main__title) {
  font-size: var(--mx-text-heading); line-height: var(--mx-lh-heading); font-weight: var(--mx-weight-semibold);
}
:is(html, #mx-type) body :is(.mx-page h2, .billing-page h2, .dash-page h2, .mx-modal h2, .mx-modal h3, [role="dialog"] h2, [role="dialog"] h3, .mx-dialog h2, .mx-dialog h3) {
  font-size: var(--mx-text-section); line-height: var(--mx-lh-section); font-weight: var(--mx-weight-semibold);
  letter-spacing: 0; text-transform: none;
}
:is(html, #mx-type) body :is(.mx-page h3, .mx-panel h3, .mx-card h3) {
  font-size: var(--mx-text-body); line-height: var(--mx-lh-body); font-weight: var(--mx-weight-semibold);
}
:is(html, #mx-type) body :is(.mx-page h4, .mx-panel h4, .task-detail h4, .task-canvas-layer h4) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-semibold);
}
/* The Task header's title is a list-level title: one tier above its controls. */
:is(html, #mx-type) body .task-detail__head :is(.task-detail__title, .task-detail__title h2, h2) {
  font-size: var(--mx-text-body); line-height: var(--mx-lh-body); font-weight: var(--mx-weight-semibold);
}
/* Small uppercase eyebrows read as captions, not as titles. */
:is(html, #mx-type) body :is(.mx-eyebrow, .task-tree__eyebrow) {
  font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); font-weight: var(--mx-weight-semibold);
}

/* ---- Controls: buttons, tabs, menus ------------------------------------------- */
/* Standard buttons: control tier. */
:is(html, #mx-type) body :is(.mx-btn, .vl-btn, .send-btn, .stop-btn, .input-btn, .task-settings-popover button, .btn) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-medium);
}
/* Compact buttons (small buttons, toolbar and panel-header buttons): caption tier. */
/* Keep id selectors out of shared :is() lists: :is() takes the specificity of its
   most specific argument, which would lift every other argument with it. */
:is(html, #mx-type) body :is(.mx-btn--small, .vl-btn--sm, .mx-btn.mx-btn--small, .runtime-btn, .ca-btn, .mx-task-tools__btn,
  .mx-room-decision__btn, .t2-archived .mx-btn) {
  font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); font-weight: var(--mx-weight-medium);
}
/* The sign-in card's one main action and its inputs read at the body tier. */
:is(html, #mx-type) body :is(.mx-auth__primary) { font-size: var(--mx-text-body); line-height: var(--mx-lh-body); font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body :is(.mx-auth__textlink) { font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-semibold); }
/* A disclosure's summary reads at the control tier; its weight stays its own (a
   summary can hold a whole row: a name and its meta). */
:is(html, #mx-type) body :is(.mx-next, .mx-modal) details > summary {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control);
}
:is(html, #mx-type) body :is([role="tab"], .mx-tab, .mx-segment button, .assistant-scope-tab, .task-canvas-switch__tab,
  .task-result-tab, .pool-provider-tabs button, .pool-brand-tabs button, .task-files-work__tabs button, .task-tree__tab) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-medium);
  letter-spacing: 0; text-transform: none;
}
:is(html, #mx-type) body :is([role="tab"][aria-selected="true"], .mx-tab.active, .mx-segment button.active,
  .assistant-scope-tab.active, .task-canvas-switch__tab.is-selected, .task-tree__tab.is-active) { font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body :is([role="menuitem"], [role="menu"] button, .mx-menu button, .mx-menu a, .runtime-menu-panel button,
  .task-settings-popover [role="menuitem"], .matrix-pet-menu button) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-regular);
}
/* Top bar and settings navigation. */
:is(html, #mx-type) body :is(.mx-topbar__nav a, .mx-topbar nav a, .mx-topbar nav button, .settings-nav a, .settings-nav button) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-medium);
}
:is(html, #mx-type) body .mx-topbar .mx-version {
  font-size: var(--mx-text-micro); line-height: var(--mx-lh-micro); font-weight: var(--mx-weight-medium);
}

/* ---- Inputs ----------------------------------------------------------------- */
:is(html, #mx-type) body :is(.mx-next, .mx-modal, .mx-menu, .mx-auth, .chat-panel) :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control);
}
:is(html, #mx-type) body .mx-auth :is(input, .mx-auth__input) { font-size: var(--mx-text-body); line-height: var(--mx-lh-body); }
:is(html, #mx-type) body :is(label, .mx-check, .mx-auth__label, .mx-pick__k) { font-size: var(--mx-text-control); line-height: var(--mx-lh-control); }

/* ---- Lists: the Task tree, the device tree, rows ------------------------------- */
:is(html, #mx-type) body :is(.t2-task, .t2-task .title, .t2-line-toggle, .t2-line-toggle b, .task-ptree__project .t2-linehead b,
  .task-tree__addline, .t2-archived-toggle, .task-device-tab__name, .task-workspace__body strong,
  .task-files-tree__link, .task-locations__open, .rs-tree__leaf, .rs-tree__leaf .task-device-tab__name, .rg-name) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control);
}
:is(html, #mx-type) body :is(.task-ptree__project .t2-linehead b, .task-device-tab__name, .task-workspace__body strong, .rg-name) { font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body :is(.t2-task, .t2-task .title, .task-tree__addline, .t2-archived-toggle, .task-files-tree__link) { font-weight: var(--mx-weight-regular); }
/* 「已归档（n）」 and 「恢复」: the same scale as the rows they sit in. */
:is(html, #mx-type) body .t2-archived-toggle { color: var(--mx-dim, #9198a1); }
:is(html, #mx-type) body :is(.t2-linehead small, .task-device-tab__state, .task-workspace__body small,
  .task-tree__legend, .rs-tree__leaf .task-device-tab__state, .task-device-tab__flag) {
  font-size: var(--mx-text-micro); line-height: var(--mx-lh-micro);
}
:is(html, #mx-type) body :is(.set-row__title) { font-size: var(--mx-text-body); line-height: var(--mx-lh-body); font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body :is(.set-kv__k) { font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); }

/* ---- Tables -------------------------------------------------------------------- */
:is(html, #mx-type) body :is(.mx-next, .mx-modal) th { font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body :is(.mx-next, .mx-modal) td { font-size: var(--mx-text-control); line-height: var(--mx-lh-control); }

/* ---- Hints, meta, chips and tags ---------------------------------------------- */
:is(html, #mx-type) body :is(.mx-hint, .mx-help, .mx-callout p, .mx-auth__hint, .runtime-team, .runtime-node-counts,
  .assistant-recipient, .task-detail__info, .runtime-viewing) {
  font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption);
}
:is(html, #mx-type) body :is(.mx-tag, .mx-src, .mx-chip, .task-chip, .task-canvas-chip, .task-canvas-kind, .task-result-state,
  .task-row__mode, .task-row__state) {
  font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); font-weight: var(--mx-weight-medium); letter-spacing: 0;
}
:is(html, #mx-type) body :is(.mx-empty) { font-size: var(--mx-text-body); line-height: var(--mx-lh-body); }
:is(html, #mx-type) body :is(.task-ptree__empty, .task-tree .mx-empty) { font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); }

/* ---- Figures ------------------------------------------------------------------- */
/* Stat cards: one figure size and weight on every page. */
:is(html, #mx-type) body :is(.billing-stat__value, .mx-stat strong, .rg-stat b, .pool-health b, .dash-stat strong) {
  font-size: var(--mx-text-figure); line-height: var(--mx-lh-figure); font-weight: var(--mx-weight-semibold);
}
/* Values inside key/value lists: one tier above their labels. */
:is(html, #mx-type) body :is(.dash-kv strong, .company-summary b) {
  font-size: var(--mx-text-section); line-height: var(--mx-lh-section); font-weight: var(--mx-weight-semibold);
}
/* Card and panel labels (详情, a card's name line). */
:is(html, #mx-type) body :is(.mx-panel__head, .task-result-details__head b) {
  font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-semibold);
}
/* The language switch and the account chip in the top bar. */
:is(html, #mx-type) body .mx-topbar :is([data-locale], .mx-account__name) { font-size: var(--mx-text-caption); font-weight: var(--mx-weight-semibold); }

/* ---- Assistant panel (the accepted docked panel, option B) ---------------------- */
:is(html, #mx-type) body :is(.ai-header-title) { font-size: var(--mx-text-control); line-height: var(--mx-lh-control); font-weight: var(--mx-weight-semibold); }
:is(html, #mx-type) body #agent-chat-mount :is(.mx-room-strip button, .mx-room-strip select, .mx-room-strip summary, .mx-task-tools__btn, .ai-header-controls .ca-btn) {
  font-size: var(--mx-text-caption); line-height: var(--mx-lh-caption); font-weight: var(--mx-weight-medium);
}
:is(html, #mx-type) body #agent-chat-mount :is(.chat-msg, .msg-body, .mx-room-msg__body) { font-size: var(--mx-text-control); line-height: var(--mx-lh-control); }
